@@ 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 |
@@ 305-328 (lines=24) @@ | ||
302 | * |
|
303 | * @return int |
|
304 | */ |
|
305 | public function getCustomersCountWhatMakeCarts(AclHelper $aclHelper, \DateTime $from = null, \DateTime $to = null) |
|
306 | { |
|
307 | $qb = $this->createQueryBuilder('c'); |
|
308 | ||
309 | try { |
|
310 | $qb |
|
311 | ->select('COUNT(DISTINCT c.customer) + SUM(CASE WHEN c.isGuest = true THEN 1 ELSE 0 END)'); |
|
312 | if ($from) { |
|
313 | $qb |
|
314 | ->andWhere('c.createdAt > :from') |
|
315 | ->setParameter('from', $from); |
|
316 | } |
|
317 | if ($to) { |
|
318 | $qb |
|
319 | ->andWhere('c.createdAt < :to') |
|
320 | ->setParameter('to', $to); |
|
321 | } |
|
322 | $this->applyActiveChannelLimitation($qb); |
|
323 | ||
324 | return (int)$aclHelper->apply($qb)->getSingleScalarResult(); |
|
325 | } catch (NoResultException $ex) { |
|
326 | return 0; |
|
327 | } |
|
328 | } |
|
329 | ||
330 | /** |
|
331 | * @param string $alias |
@@ 489-506 (lines=18) @@ | ||
486 | * |
|
487 | * @return double |
|
488 | */ |
|
489 | public function getWeightedPipelineAmount(AclHelper $aclHelper, \DateTime $start = null, \DateTime $end = null) |
|
490 | { |
|
491 | $qb = $this->createQueryBuilder('o'); |
|
492 | ||
493 | $qb->select('SUM(o.budgetAmount * o.probability)'); |
|
494 | if ($start) { |
|
495 | $qb |
|
496 | ->andWhere('o.createdAt > :start') |
|
497 | ->setParameter('start', $start); |
|
498 | } |
|
499 | if ($end) { |
|
500 | $qb |
|
501 | ->andWhere('o.createdAt < :end') |
|
502 | ->setParameter('end', $end); |
|
503 | } |
|
504 | ||
505 | return $aclHelper->apply($qb)->getSingleScalarResult(); |
|
506 | } |
|
507 | ||
508 | /** |
|
509 | * @param AclHelper $aclHelper |