@@ 506-526 (lines=21) @@ | ||
503 | * |
|
504 | * @return double |
|
505 | */ |
|
506 | public function getOpenWeightedPipelineAmount( |
|
507 | AclHelper $aclHelper, |
|
508 | \DateTime $start = null, |
|
509 | \DateTime $end = null, |
|
510 | $owners = [] |
|
511 | ) { |
|
512 | $qb = $this->createQueryBuilder('o'); |
|
513 | ||
514 | $qb |
|
515 | ->select('SUM(o.budgetAmount * o.probability)') |
|
516 | ->andWhere('o.status = :status') |
|
517 | ->setParameter('status', self::OPPORTUNITY_STATE_IN_PROGRESS_CODE); |
|
518 | ||
519 | $this->setCreationPeriod($qb, $start, $end); |
|
520 | ||
521 | if ($owners) { |
|
522 | QueryUtils::applyOptimizedIn($qb, 'o.owner', $owners); |
|
523 | } |
|
524 | ||
525 | return $aclHelper->apply($qb)->getSingleScalarResult(); |
|
526 | } |
|
527 | ||
528 | /** |
|
529 | * @param AclHelper $aclHelper |
|
@@ 563-581 (lines=19) @@ | ||
560 | * |
|
561 | * @return int |
|
562 | */ |
|
563 | public function getWonOpportunitiesToDateCount( |
|
564 | AclHelper $aclHelper, |
|
565 | \DateTime $start = null, |
|
566 | \DateTime $end = null, |
|
567 | $owners = [] |
|
568 | ) { |
|
569 | $qb = $this->createQueryBuilder('o'); |
|
570 | $qb->select('COUNT(o.id)') |
|
571 | ->andWhere('o.status = :status') |
|
572 | ->setParameter('status', self::OPPORTUNITY_STATUS_CLOSED_WON_CODE); |
|
573 | ||
574 | $this->setClosedPeriod($qb, $start, $end); |
|
575 | ||
576 | if ($owners) { |
|
577 | QueryUtils::applyOptimizedIn($qb, 'o.owner', $owners); |
|
578 | } |
|
579 | ||
580 | return $aclHelper->apply($qb)->getSingleScalarResult(); |
|
581 | } |
|
582 | ||
583 | /** |
|
584 | * @param AclHelper $aclHelper |
|
@@ 591-609 (lines=19) @@ | ||
588 | * |
|
589 | * @return double |
|
590 | */ |
|
591 | public function getWonOpportunitiesToDateAmount( |
|
592 | AclHelper $aclHelper, |
|
593 | \DateTime $start = null, |
|
594 | \DateTime $end = null, |
|
595 | $owners = [] |
|
596 | ) { |
|
597 | $qb = $this->createQueryBuilder('o'); |
|
598 | $qb->select('SUM(o.closeRevenue)') |
|
599 | ->andWhere('o.status = :status') |
|
600 | ->setParameter('status', self::OPPORTUNITY_STATUS_CLOSED_WON_CODE); |
|
601 | ||
602 | $this->setClosedPeriod($qb, $start, $end); |
|
603 | ||
604 | if ($owners) { |
|
605 | QueryUtils::applyOptimizedIn($qb, 'o.owner', $owners); |
|
606 | } |
|
607 | ||
608 | return $aclHelper->apply($qb)->getSingleScalarResult(); |
|
609 | } |
|
610 | ||
611 | /** |
|
612 | * @param QueryBuilder $qb |