@@ 301-324 (lines=24) @@ | ||
298 | * |
|
299 | * @return int |
|
300 | */ |
|
301 | public function getCustomersCountWhatMakeCarts(AclHelper $aclHelper, \DateTime $from = null, \DateTime $to = null) |
|
302 | { |
|
303 | $qb = $this->createQueryBuilder('c'); |
|
304 | ||
305 | try { |
|
306 | $qb |
|
307 | ->select('COUNT(DISTINCT c.customer) + SUM(CASE WHEN c.isGuest = true THEN 1 ELSE 0 END)'); |
|
308 | if ($from) { |
|
309 | $qb |
|
310 | ->andWhere('c.createdAt > :from') |
|
311 | ->setParameter('from', $from); |
|
312 | } |
|
313 | if ($to) { |
|
314 | $qb |
|
315 | ->andWhere('c.createdAt < :to') |
|
316 | ->setParameter('to', $to); |
|
317 | } |
|
318 | $this->applyActiveChannelLimitation($qb); |
|
319 | ||
320 | return (int)$aclHelper->apply($qb)->getSingleScalarResult(); |
|
321 | } catch (NoResultException $ex) { |
|
322 | return 0; |
|
323 | } |
|
324 | } |
|
325 | ||
326 | /** |
|
327 | * @param string $alias |
@@ 274-296 (lines=23) @@ | ||
271 | * |
|
272 | * @return int |
|
273 | */ |
|
274 | public function getUniqueBuyersCount(AclHelper $aclHelper, \DateTime $from = null, \DateTime $to = null) |
|
275 | { |
|
276 | $qb = $this->createQueryBuilder('o'); |
|
277 | ||
278 | try { |
|
279 | $qb->select('COUNT(DISTINCT o.customer) + SUM(CASE WHEN o.isGuest = true THEN 1 ELSE 0 END)'); |
|
280 | if ($from) { |
|
281 | $qb |
|
282 | ->andWhere('o.createdAt > :from') |
|
283 | ->setParameter('from', $from); |
|
284 | } |
|
285 | if ($to) { |
|
286 | $qb |
|
287 | ->andWhere('o.createdAt > :to') |
|
288 | ->setParameter('to', $to); |
|
289 | } |
|
290 | $this->applyActiveChannelLimitation($qb); |
|
291 | ||
292 | return (int) $aclHelper->apply($qb)->getSingleScalarResult(); |
|
293 | } catch (NoResultException $ex) { |
|
294 | return 0; |
|
295 | } |
|
296 | } |
|
297 | ||
298 | /** |
|
299 | * @param $alias |
@@ 496-513 (lines=18) @@ | ||
493 | * |
|
494 | * @return double |
|
495 | */ |
|
496 | public function getWeightedPipelineAmount(AclHelper $aclHelper, DateTime $start = null, DateTime $end = null) |
|
497 | { |
|
498 | $qb = $this->createQueryBuilder('o'); |
|
499 | ||
500 | $qb->select('SUM(o.budgetAmount * o.probability)'); |
|
501 | if ($start) { |
|
502 | $qb |
|
503 | ->andWhere('o.createdAt > :start') |
|
504 | ->setParameter('start', $start); |
|
505 | } |
|
506 | if ($end) { |
|
507 | $qb |
|
508 | ->andWhere('o.createdAt < :end') |
|
509 | ->setParameter('end', $end); |
|
510 | } |
|
511 | ||
512 | return $aclHelper->apply($qb)->getSingleScalarResult(); |
|
513 | } |
|
514 | ||
515 | /** |
|
516 | * @param AclHelper $aclHelper |