public static function onGenerateInitialData(Date $from, Date $to)
 {
     $data = array();
     // 1. Payments
     $result = \CSaleOrder::GetList(array(), array('PAYED' => 'Y', 'CANCELED' => 'N', '>=DATE_PAYED' => $from, '<=DATE_PAYED' => $to), false, false, array('LID', 'DATE_PAYED', 'PRICE', 'CURRENCY'));
     while ($row = $result->Fetch()) {
         $day = new DateTime($row['DATE_PAYED']);
         $sum = Utils::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
         if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
             $counters['sale_payment_add_day'] += 1;
             $counters['sale_payment_sum_add'] += $sum;
         } else {
             $counters = array('sale_payment_add_day' => 1, 'sale_payment_sum_add' => $sum);
         }
     }
     // 2. Orders
     $result = \CSaleOrder::GetList(array(), array('CANCELED' => 'N', '>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY'));
     while ($row = $result->Fetch()) {
         $day = new DateTime($row['DATE_INSERT']);
         $sum = Utils::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
         if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
             $counters['sale_order_add_day'] += 1;
             $counters['sale_order_sum_add'] += $sum;
         } else {
             $counters = array('sale_order_add_day' => 1, 'sale_order_sum_add' => $sum);
         }
     }
     // 3. Cart
     $result = \CSaleBasket::GetList(array(), array('>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY', 'QUANTITY'));
     while ($row = $result->Fetch()) {
         $day = new DateTime($row['DATE_INSERT']);
         $sum = Utils::convertToBaseCurrency($row['PRICE'] * $row['QUANTITY'], $row['CURRENCY']);
         if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
             $counters['sale_cart_add_day'] += 1;
             $counters['sale_cart_sum_add'] += $sum;
         } else {
             $counters = array('sale_cart_add_day' => 1, 'sale_cart_sum_add' => $sum);
         }
     }
     // Result
     unset($counters);
     $result = array();
     foreach ($data as $siteId => $dayCounters) {
         $result[] = array('ATTRIBUTES' => array('conversion_site' => $siteId), 'DAY_COUNTERS' => $dayCounters);
     }
     return $result;
 }
示例#2
0
 /** Add currency value to counter. If counter not exists set counter to value.
  * @param string           $name     - counter name
  * @param int|float|string $value    - numeric value
  * @param string           $currency - currency code (eg: RUB)
  */
 public function addCurrencyCounter($name, $value, $currency)
 {
     $this->addCounter($name, Utils::convertToBaseCurrency($value, $currency));
 }
示例#3
0
文件: calc.php 项目: vim84/b-markt
,
				initialGrosses = <?php 
echo Json::encode($initialGrosses);
?>
,
				funnelData     = <?php 
echo Json::encode($funnelData);
?>
,
				funnel         = new AmCharts.AmFunnelChart();

			funnel.dataProvider       = funnelData;
			funnel.theme              = 'none';
			funnel.labelText          = ' ';
			funnel.balloonText        = '[[title]]: <span style="white-space: nowrap; ">[[value]] <?php 
echo CUtil::JSEscape(Utils::getBaseCurrencyUnit());
?>
</span>';
			funnel.titleField         = 'title';
			funnel.valueField         = 'value';
			funnel.thousandsSeparator = ' ';
			funnel.depth3D            = 160;
			funnel.angle              = 23;
			funnel.outlineAlpha       = 2;
			funnel.outlineColor       = '#FFFFFF';
			funnel.outlineThickness   = 2;
			funnel.marginRight        = 50;
			funnel.marginLeft         = 50;
			funnel.balloon            = {'fixedPosition': true};
			funnel.write('bitrix-conversion-funnel');
示例#4
0
 /** @deprecated */
 public static function getBaseCurrencyUnit()
 {
     return Utils::getBaseCurrencyUnit();
 }