Пример #1
0
 /**
  * @param WidgetOptionBag $widgetOptions
  * @param                 $providerAlias
  * @param                 $getterName
  * @param                 $dataType
  * @param bool            $lessIsBetter
  * @param bool            $lastWeek
  * @return array
  */
 public function getBigNumberValues(WidgetOptionBag $widgetOptions, $providerAlias, $getterName, $dataType, $lessIsBetter = false, $lastWeek = false)
 {
     $getter = $this->getGetter($providerAlias, $getterName);
     $lessIsBetter = (bool) $lessIsBetter;
     $dateRange = $lastWeek ? $this->dateHelper->getLastWeekPeriod() : $widgetOptions->get('dateRange');
     $value = call_user_func($getter, $dateRange);
     $previousInterval = $widgetOptions->get('usePreviousInterval', []);
     $previousData = [];
     if (count($previousInterval)) {
         if ($lastWeek) {
             $previousInterval = $this->dateHelper->getLastWeekPeriod(-1);
         }
         $previousData['value'] = call_user_func($getter, $previousInterval);
         $previousData['dateRange'] = $previousInterval;
         $previousData['lessIsBetter'] = $lessIsBetter;
     }
     return $this->bigNumberFormatter->formatResult($value, $dataType, $previousData);
 }
Пример #2
0
 /**
  * @param array $dateRange
  * @return int
  */
 public function getCustomerConversionValues($dateRange)
 {
     $result = 0;
     list($start, $end) = $this->dateHelper->getPeriod($dateRange, 'OroCRMMagentoBundle:Customer', 'createdAt');
     $customers = $this->doctrine->getRepository('OroCRMMagentoBundle:Customer')->getNewCustomersNumberWhoMadeOrderByPeriod($start, $end, $this->aclHelper);
     $visits = $this->doctrine->getRepository('OroCRMChannelBundle:Channel')->getVisitsCountByPeriodForChannelType($start, $end, $this->aclHelper, ChannelType::TYPE);
     if ($visits !== 0) {
         $result = $customers / $visits;
     }
     return $result;
 }
Пример #3
0
 /**
  * @param array $dateRange
  *
  * @return double
  */
 public function getOpenWeightedPipelineAmount($dateRange)
 {
     list($start, $end) = $this->dateHelper->getPeriod($dateRange, 'OroCRMSalesBundle:Opportunity', 'createdAt');
     return $this->doctrine->getRepository('OroCRMSalesBundle:Opportunity')->getOpenWeightedPipelineAmount($this->aclHelper, $start, $end);
 }