|
|
|
|
|
|
|
|
$query->select('count(e.id)'); |
|
|
$query->select('count(e.id)'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isset($params['select'])) { |
|
|
|
|
|
$query->select( $params['select']); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (isset($params['dateStart']) || isset($params['dateEnd'])) { |
|
|
if (isset($params['dateStart']) || isset($params['dateEnd'])) { |
|
|
$params['dateField'] = isset($params['dateField']) ? $params['dateField'] : 'validationDate'; |
|
|
$params['dateField'] = isset($params['dateField']) ? $params['dateField'] : 'validationDate'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$query->andWhere('e.deliveryAddress = :address OR e.invoiceAddress = :address')->setParameter('address', $params['address']); |
|
|
$query->andWhere('e.deliveryAddress = :address OR e.invoiceAddress = :address')->setParameter('address', $params['address']); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(isset($params['weekDeliveryTruck'])) { |
|
|
|
|
|
$query->andWhere('e.weekDeliveryTruck = :weekDeliveryTruck')->setParameter('weekDeliveryTruck', $params['weekDeliveryTruck']); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(isset($params['deliveryDate'])) { |
|
|
|
|
|
$query->andWhere('e.deliveryDate >= :deliveryDateStart'); |
|
|
|
|
|
$query->andWhere('e.deliveryDate < :deliveryDateEnd'); |
|
|
|
|
|
$query->setParameter('deliveryDateStart', $params['deliveryDate']->format('Y-m-d 00:00:00')); |
|
|
|
|
|
$query->setParameter('deliveryDateEnd', $params['deliveryDate']->modify('+1 day')->format('Y-m-d 00:00:00')); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (isset($params['mergeComplementaryOrderShops'])) { |
|
|
if (isset($params['mergeComplementaryOrderShops'])) { |
|
|
$query->andWhere('e.mainOrderShop IS NULL'); |
|
|
$query->andWhere('e.mainOrderShop IS NULL'); |
|
|
$query->leftJoin('e.complementaryOrderShops', 'complementaryOrderShops'); |
|
|
$query->leftJoin('e.complementaryOrderShops', 'complementaryOrderShops'); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($params['groupBy'])) { |
|
|
|
|
|
$query->groupBy( $params['groupBy']); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (isset($params['count']) && $params['count']) { |
|
|
if (isset($params['count']) && $params['count']) { |
|
|
return $query->getQuery()->getSingleScalarResult(); |
|
|
return $query->getQuery()->getSingleScalarResult(); |
|
|
} else { |
|
|
} else { |