@@ 422-453 (lines=32) @@ | ||
419 | * |
|
420 | * @return double |
|
421 | */ |
|
422 | public function getTotalServicePipelineAmount( |
|
423 | AclHelper $aclHelper, |
|
424 | DateTime $start = null, |
|
425 | DateTime $end = null, |
|
426 | $owners = [] |
|
427 | ) { |
|
428 | $qb = $this->createQueryBuilder('o'); |
|
429 | ||
430 | $qb |
|
431 | ->select('SUM(o.budgetAmount)') |
|
432 | ->andWhere('o.closeDate IS NULL') |
|
433 | ->andWhere('o.status = :status') |
|
434 | ->andWhere('o.probability != 0') |
|
435 | ->andWhere('o.probability != 1') |
|
436 | ->setParameter('status', self::OPPORTUNITY_STATE_IN_PROGRESS_CODE); |
|
437 | if ($start) { |
|
438 | $qb |
|
439 | ->andWhere('o.createdAt > :start') |
|
440 | ->setParameter('start', $start); |
|
441 | } |
|
442 | if ($end) { |
|
443 | $qb |
|
444 | ->andWhere('o.createdAt < :end') |
|
445 | ->setParameter('end', $end); |
|
446 | } |
|
447 | ||
448 | if ($owners) { |
|
449 | QueryUtils::applyOptimizedIn($qb, 'o.owner', $owners); |
|
450 | } |
|
451 | ||
452 | return $aclHelper->apply($qb)->getSingleScalarResult(); |
|
453 | } |
|
454 | ||
455 | /** |
|
456 | * @param AclHelper $aclHelper |
|
@@ 523-553 (lines=31) @@ | ||
520 | * |
|
521 | * @return double |
|
522 | */ |
|
523 | public function getOpenWeightedPipelineAmount( |
|
524 | AclHelper $aclHelper, |
|
525 | DateTime $start = null, |
|
526 | DateTime $end = null, |
|
527 | $owners = [] |
|
528 | ) { |
|
529 | $qb = $this->createQueryBuilder('o'); |
|
530 | ||
531 | $qb |
|
532 | ->select('SUM(o.budgetAmount * o.probability)') |
|
533 | ->andWhere('o.status = :status') |
|
534 | ->andWhere('o.probability != 0') |
|
535 | ->andWhere('o.probability != 1') |
|
536 | ->setParameter('status', self::OPPORTUNITY_STATE_IN_PROGRESS_CODE); |
|
537 | if ($start) { |
|
538 | $qb |
|
539 | ->andWhere('o.createdAt > :start') |
|
540 | ->setParameter('start', $start); |
|
541 | } |
|
542 | if ($end) { |
|
543 | $qb |
|
544 | ->andWhere('o.createdAt < :end') |
|
545 | ->setParameter('end', $end); |
|
546 | } |
|
547 | ||
548 | if ($owners) { |
|
549 | QueryUtils::applyOptimizedIn($qb, 'o.owner', $owners); |
|
550 | } |
|
551 | ||
552 | return $aclHelper->apply($qb)->getSingleScalarResult(); |
|
553 | } |
|
554 | } |
|
555 |