@@ 518-540 (lines=23) @@ | ||
515 | * |
|
516 | * @return double |
|
517 | */ |
|
518 | public function getOpenWeightedPipelineAmount( |
|
519 | AclHelper $aclHelper, |
|
520 | \DateTime $start = null, |
|
521 | \DateTime $end = null, |
|
522 | $owners = [] |
|
523 | ) { |
|
524 | $qb = $this->createQueryBuilder('o'); |
|
525 | ||
526 | $qb |
|
527 | ->select('SUM(o.budgetAmount * o.probability)') |
|
528 | ->andWhere('o.status = :status') |
|
529 | ->andWhere('o.probability != 0') |
|
530 | ->andWhere('o.probability != 1') |
|
531 | ->setParameter('status', self::OPPORTUNITY_STATE_IN_PROGRESS_CODE); |
|
532 | ||
533 | $this->setCreationPeriod($qb, $start, $end); |
|
534 | ||
535 | if ($owners) { |
|
536 | QueryUtils::applyOptimizedIn($qb, 'o.owner', $owners); |
|
537 | } |
|
538 | ||
539 | return $aclHelper->apply($qb)->getSingleScalarResult(); |
|
540 | } |
|
541 | ||
542 | /** |
|
543 | * @param AclHelper $aclHelper |
|
@@ 579-597 (lines=19) @@ | ||
576 | * |
|
577 | * @return int |
|
578 | */ |
|
579 | public function getWonOpportunitiesToDateCount( |
|
580 | AclHelper $aclHelper, |
|
581 | \DateTime $start = null, |
|
582 | \DateTime $end = null, |
|
583 | $owners = [] |
|
584 | ) { |
|
585 | $qb = $this->createQueryBuilder('o'); |
|
586 | $qb->select('COUNT(o.id)') |
|
587 | ->andWhere('o.status = :status') |
|
588 | ->setParameter('status', self::OPPORTUNITY_STATUS_CLOSED_WON_CODE); |
|
589 | ||
590 | $this->setClosedPeriod($qb, $start, $end); |
|
591 | ||
592 | if ($owners) { |
|
593 | QueryUtils::applyOptimizedIn($qb, 'o.owner', $owners); |
|
594 | } |
|
595 | ||
596 | return $aclHelper->apply($qb)->getSingleScalarResult(); |
|
597 | } |
|
598 | ||
599 | /** |
|
600 | * @param AclHelper $aclHelper |