@@ 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 |
@@ 447-470 (lines=24) @@ | ||
444 | * |
|
445 | * @return double |
|
446 | */ |
|
447 | public function getTotalServicePipelineAmountInProgress( |
|
448 | AclHelper $aclHelper, |
|
449 | \DateTime $start = null, |
|
450 | \DateTime $end = null |
|
451 | ) { |
|
452 | $qb = $this->createQueryBuilder('o'); |
|
453 | ||
454 | $qb |
|
455 | ->select('SUM(o.budgetAmount)') |
|
456 | ->andWhere('o.status = :status') |
|
457 | ->setParameter('status', self::OPPORTUNITY_STATE_IN_PROGRESS_CODE); |
|
458 | if ($start) { |
|
459 | $qb |
|
460 | ->andWhere('o.createdAt > :start') |
|
461 | ->setParameter('start', $start); |
|
462 | } |
|
463 | if ($end) { |
|
464 | $qb |
|
465 | ->andWhere('o.createdAt < :end') |
|
466 | ->setParameter('end', $end); |
|
467 | } |
|
468 | ||
469 | return $aclHelper->apply($qb)->getSingleScalarResult(); |
|
470 | } |
|
471 | ||
472 | /** |
|
473 | * @param AclHelper $aclHelper |
|
@@ 479-496 (lines=18) @@ | ||
476 | * |
|
477 | * @return double |
|
478 | */ |
|
479 | public function getWeightedPipelineAmount(AclHelper $aclHelper, \DateTime $start = null, \DateTime $end = null) |
|
480 | { |
|
481 | $qb = $this->createQueryBuilder('o'); |
|
482 | ||
483 | $qb->select('SUM(o.budgetAmount * o.probability)'); |
|
484 | if ($start) { |
|
485 | $qb |
|
486 | ->andWhere('o.createdAt > :start') |
|
487 | ->setParameter('start', $start); |
|
488 | } |
|
489 | if ($end) { |
|
490 | $qb |
|
491 | ->andWhere('o.createdAt < :end') |
|
492 | ->setParameter('end', $end); |
|
493 | } |
|
494 | ||
495 | return $aclHelper->apply($qb)->getSingleScalarResult(); |
|
496 | } |
|
497 | ||
498 | /** |
|
499 | * @param AclHelper $aclHelper |