public function GetDiscount($arParams = array(), $getAll = false) { global $DB, $USER; $adminSection = defined('ADMIN_SECTION') && ADMIN_SECTION === true; $arResult = array(); if (!CCatalog::IsUserExists() || !$USER->IsAuthorized() || !self::IsEnabled()) { return $arResult; } foreach (GetModuleEvents("catalog", "OnGetDiscountSave", true) as $arEvent) { $mxResult = ExecuteModuleEventEx($arEvent, $arParams); if ($mxResult !== true) { return $mxResult; } } if (empty($arParams) || !is_array($arParams)) { return $arResult; } $intUserID = 0; $arUserGroups = array(); $strSiteID = false; if (isset($arParams['USER_ID'])) { $intUserID = (int) $arParams['USER_ID']; } if (isset($arParams['USER_GROUPS'])) { $arUserGroups = $arParams['USER_GROUPS']; } if (isset($arParams['SITE_ID'])) { $strSiteID = $arParams['SITE_ID']; } if (self::GetDiscountUserID() > 0) { $intUserID = (int) self::GetDiscountUserID(); $arUserGroups = array(); } if ($intUserID <= 0 && !$adminSection) { $intUserID = (int) $USER->GetID(); $arUserGroups = array(); } if (empty($arUserGroups)) { if (!isset(self::$userGroups[$intUserID])) { self::$userGroups[$intUserID] = $USER->GetUserGroup($intUserID); } $arUserGroups = self::$userGroups[$intUserID]; } if (empty($arUserGroups) || !is_array($arUserGroups) || $intUserID <= 0) { return $arResult; } $key = array_search(2, $arUserGroups); if ($key !== false) { unset($arUserGroups[$key]); } if (empty($arUserGroups)) { return $arResult; } Main\Type\Collection::normalizeArrayValuesByInt($arUserGroups, true); if (empty($arUserGroups)) { return $arResult; } if ($strSiteID === false) { $strSiteID = SITE_ID; } $cacheKey = md5('U' . implode('_', $arUserGroups)); if (!isset(self::$discountFilterCache[$cacheKey])) { self::$discountFilterCache[$cacheKey] = CCatalogDiscountSave::__GetDiscountIDByGroup($arUserGroups); } if (empty(self::$discountFilterCache[$cacheKey])) { return $arResult; } $arCurrentDiscountID = self::$discountFilterCache[$cacheKey]; if (isset($arParams['ID'])) { Main\Type\Collection::normalizeArrayValuesByInt($arUserGroups, true); if (!empty($arParams['ID'])) { $arCurrentDiscountID = array_intersect($arCurrentDiscountID, $arParams['ID']); } } if (!empty($arCurrentDiscountID)) { $getAll = $getAll === true; $intCurrentTime = getmicrotime(); $strDate = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCurrentTime); $arFilter = array('ID' => $arCurrentDiscountID, 'SITE_ID' => $strSiteID, 'TYPE' => self::ENTITY_ID, 'ACTIVE' => 'Y', '+<=ACTIVE_FROM' => $strDate, '+>=ACTIVE_TO' => $strDate); CTimeZone::Disable(); $rsDiscSaves = CCatalogDiscountSave::GetList(array(), $arFilter); CTimeZone::Enable(); while ($arDiscSave = $rsDiscSaves->Fetch()) { $arDiscSave['ACTION_SIZE'] = (int) $arDiscSave['ACTION_SIZE']; $arDiscSave['COUNT_SIZE'] = (int) $arDiscSave['COUNT_SIZE']; $arDiscSave['ACTIVE_FROM_UT'] = false; $arDiscSave['ACTIVE_TO_UT'] = false; $arDiscSave['COUNT_FROM_UT'] = false; $arDiscSave['COUNT_TO_UT'] = false; $arDiscSave['TYPE'] = (int) $arDiscSave['TYPE']; $arDiscSave['MODULE_ID'] = 'catalog'; $strCountPeriod = self::COUNT_TIME_ALL; $strActionPeriod = self::ACTION_TIME_ALL; $arCountPeriodBack = array(); $arActionPeriodBack = array(); $arActionPeriod = array(); $arStartDate = false; $arOldOrderSumm = false; $arOrderSumm = false; $boolPeriodInsert = true; $intCountTime = $intCurrentTime; $arOrderFilter = array('USER_ID' => $intUserID, 'LID' => $arDiscSave['SITE_ID'], 'PAYED' => 'Y', 'CANCELED' => 'N'); $arOldOrderFilter = $arOrderFilter; if (!empty($arDiscSave['ACTIVE_FROM']) || !empty($arDiscSave['ACTIVE_TO'])) { $strActionPeriod = self::ACTION_TIME_INTERVAL; if (!empty($arDiscSave['ACTIVE_FROM'])) { $arDiscSave['ACTIVE_FROM_UT'] = MakeTimeStamp($arDiscSave['ACTIVE_FROM']); } if (!empty($arDiscSave['ACTIVE_TO'])) { $arDiscSave['ACTIVE_TO_UT'] = MakeTimeStamp($arDiscSave['ACTIVE_TO']); } } elseif ($arDiscSave['ACTION_SIZE'] > 0 && in_array($arDiscSave['ACTION_TYPE'], array('D', 'M', 'Y'))) { $strActionPeriod = self::ACTION_TIME_PERIOD; $arActionPeriodBack = CCatalogDiscountSave::__GetTimeStampArray($arDiscSave['ACTION_SIZE'], $arDiscSave['ACTION_TYPE']); $arActionPeriod = CCatalogDiscountSave::__GetTimeStampArray($arDiscSave['ACTION_SIZE'], $arDiscSave['ACTION_TYPE'], true); } if (!empty($arDiscSave['COUNT_FROM']) || !empty($arDiscSave['COUNT_TO'])) { $strCountPeriod = self::COUNT_TIME_INTERVAL; if (!empty($arDiscSave['COUNT_FROM'])) { $arDiscSave['COUNT_FROM_UT'] = MakeTimeStamp($arDiscSave['COUNT_FROM']); } if (!empty($arDiscSave['COUNT_TO'])) { $arDiscSave['COUNT_TO_UT'] = MakeTimeStamp($arDiscSave['COUNT_TO']); if ($arDiscSave['COUNT_TO_UT'] > $intCountTime) { $arDiscSave['COUNT_TO_UT'] = $intCountTime; $arDiscSave['COUNT_TO'] = ConvertTimeStamp($intCountTime, 'FULL'); } } } elseif ($arDiscSave['COUNT_SIZE'] > 0 && in_array($arDiscSave['COUNT_TYPE'], array('D', 'M', 'Y'))) { $strCountPeriod = self::COUNT_TIME_PERIOD; $arCountPeriodBack = CCatalogDiscountSave::__GetTimeStampArray($arDiscSave['COUNT_SIZE'], $arDiscSave['COUNT_TYPE']); } if ($strCountPeriod == self::COUNT_TIME_INTERVAL) { if (false !== $arDiscSave['COUNT_FROM_UT']) { if ($arDiscSave['COUNT_FROM_UT'] > $intCountTime) { continue; } if (false !== $arDiscSave['COUNT_TO_UT'] && $arDiscSave['COUNT_TO_UT'] <= $arDiscSave['COUNT_FROM_UT']) { continue; } if (false !== $arDiscSave['ACTIVE_TO_UT'] && $arDiscSave['COUNT_FROM_UT'] >= $arDiscSave['ACTIVE_TO_UT']) { continue; } } if (false !== $arDiscSave['COUNT_TO_UT']) { if ($strActionPeriod == self::ACTION_TIME_PERIOD && $arDiscSave['COUNT_TO_UT'] < AddToTimeStamp($arActionPeriodBack, $intCountTime)) { continue; } } } if ($strActionPeriod == self::ACTION_TIME_PERIOD) { if ($strCountPeriod == self::COUNT_TIME_PERIOD) { $arStartDate = CCatalogDiscountSave::__GetUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID, 'ACTIVE_FROM' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arActionPeriodBack, $intCountTime)))); if (is_array($arStartDate) && !empty($arStartDate)) { $arOldOrderFilter['<DATE_INSERT'] = $arStartDate['ACTIVE_FROM_FORMAT']; $arOldOrderFilter['>=DATE_INSERT'] = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arCountPeriodBack, MakeTimeStamp($arStartDate['ACTIVE_FROM_FORMAT']))); $arOldOrderSumm = CCatalogDiscountSave::__SaleOrderSumm($arOldOrderFilter, $arDiscSave['CURRENCY']); } } else { $arStartDate = CCatalogDiscountSave::__GetUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID), array('ACTIVE_FROM' => false, 'DELETE' => false)); if (is_array($arStartDate) && !empty($arStartDate)) { $intTimeStart = MakeTimeStamp($arStartDate['ACTIVE_FROM_FORMAT']); $intTimeFinish = MakeTimeStamp($arStartDate['ACTIVE_TO_FORMAT']); if (!($intTimeStart <= $intCountTime && $intTimeFinish >= $intCountTime)) { continue; } else { $boolPeriodInsert = false; } } } } $intTimeStart = false; $intTimeFinish = false; if ($strCountPeriod == self::COUNT_TIME_INTERVAL) { $intTimeStart = !empty($arDiscSave['COUNT_FROM']) ? $arDiscSave['COUNT_FROM'] : false; $intTimeFinish = !empty($arDiscSave['COUNT_TO']) ? $arDiscSave['COUNT_TO'] : false; } elseif ($strCountPeriod == self::COUNT_TIME_PERIOD) { $intTimeStart = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arCountPeriodBack, $intCountTime)); } if ($intTimeStart) { $arOrderFilter['>=DATE_INSERT'] = $intTimeStart; } if ($intTimeFinish) { $arOrderFilter['<DATE_INSERT'] = $intTimeFinish; } $arOrderSumm = CCatalogDiscountSave::__SaleOrderSumm($arOrderFilter, $arDiscSave['CURRENCY']); if (is_array($arOldOrderSumm) && 0 < $arOldOrderSumm['RANGE_SUMM']) { if ($arOrderSumm['RANGE_SUMM'] <= $arOldOrderSumm['RANGE_SUMM']) { $arOrderSumm = $arOldOrderSumm; } else { $arOldOrderSumm = false; } } $rsRanges = CCatalogDiscountSave::GetRangeByDiscount(array('RANGE_FROM' => 'DESC'), array('DISCOUNT_ID' => $arDiscSave['ID'], '<=RANGE_FROM' => $arOrderSumm['RANGE_SUMM']), false, array('nTopCount' => 1)); $arRange = $rsRanges->Fetch(); if (!empty($arRange) || $getAll) { if (!empty($arRange)) { if ($strActionPeriod == self::ACTION_TIME_PERIOD) { if ($strCountPeriod == self::COUNT_TIME_PERIOD) { if (!is_array($arOldOrderSumm)) { CCatalogDiscountSave::__UpdateUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID, 'ACTIVE_FROM' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCountTime), 'ACTIVE_TO' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arActionPeriod, $intCountTime)), 'RANGE_FROM' => -1)); } } else { if ($boolPeriodInsert) { CCatalogDiscountSave::__UpdateUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID, 'ACTIVE_FROM' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCountTime), 'ACTIVE_TO' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arActionPeriod, $intCountTime)), 'RANGE_FROM' => -1), array('SEARCH' => true, 'DELETE' => false)); } } } } unset($arDiscSave['ACTIVE_FROM_UT'], $arDiscSave['ACTIVE_TO_UT'], $arDiscSave['COUNT_FROM_UT'], $arDiscSave['COUNT_TO_UT']); $arOneResult = $arDiscSave; if (!empty($arRange)) { $arOneResult['VALUE'] = $arRange['VALUE']; $arOneResult['VALUE_TYPE'] = $arRange['TYPE']; $arOneResult['RANGE_FROM'] = $arRange['RANGE_FROM']; $arOneResult['MAX_DISCOUNT'] = 0; } else { $arOneResult['VALUE'] = 0; $arOneResult['VALUE_TYPE'] = self::TYPE_PERCENT; $arOneResult['MAX_DISCOUNT'] = 0; $rsRanges = CCatalogDiscountSave::GetRangeByDiscount(array('RANGE_FROM' => 'ASC'), array('DISCOUNT_ID' => $arDiscSave['ID']), false, array('nTopCount' => 1)); $arRange = $rsRanges->Fetch(); $arOneResult['NEXT_RANGE_FROM'] = $arRange['RANGE_FROM']; $arOneResult['NEXT_VALUE'] = $arRange['VALUE']; $arOneResult['NEXT_VALUE_TYPE'] = $arRange['TYPE']; } $arOneResult['SUMM'] = $arOrderSumm['SUMM']; $arOneResult['SUMM_CURRENCY'] = $arOrderSumm['CURRENCY']; $arOneResult['RANGE_SUMM'] = $arOrderSumm['RANGE_SUMM']; $arOneResult['LAST_ORDER_DATE'] = $arOrderSumm['LAST_ORDER_DATE']; $arResult[] = $arOneResult; } } } return $arResult; }
public function GetDiscount($arParams = array()) { global $DB; global $USER; $arResult = array(); if (!(isset($USER) && $USER instanceof CUser && 'CUser' == get_class($USER))) { return $arResult; } if (!$USER->IsAuthorized()) { return $arResult; } if (!self::IsEnabled()) { return $arResult; } foreach (GetModuleEvents("catalog", "OnGetDiscountSave", true) as $arEvent) { $mxResult = ExecuteModuleEventEx($arEvent, $arParams); if (true !== $mxResult) { return $mxResult; } } if (!is_array($arParams) || empty($arParams)) { return $arResult; } $intUserID = 0; $arUserGroups = array(); $strSiteID = false; if (isset($arParams['USER_ID'])) { $intUserID = $arParams['USER_ID']; } if (isset($arParams['USER_GROUPS'])) { $arUserGroups = $arParams['USER_GROUPS']; } if (isset($arParams['SITE_ID'])) { $strSiteID = $arParams['SITE_ID']; } if (0 < self::GetDiscountUserID()) { $intUserID = self::GetDiscountUserID(); $arUserGroups = $USER->GetUserGroup($intUserID); } else { $intUserID = intval($intUserID); if (0 >= $intUserID) { $intUserID = $USER->GetID(); $arUserGroups = $USER->GetUserGroupArray(); } else { if (empty($arUserGroups)) { $arUserGroups = $USER->GetUserGroup($intUserID); } } } if (!is_array($arUserGroups) || empty($arUserGroups) || 0 >= $intUserID) { return $arResult; } $key = array_search(2, $arUserGroups); if (false !== $key) { unset($arUserGroups[$key]); } if (empty($arUserGroups)) { return $arResult; } if ($strSiteID === false) { $strSiteID = SITE_ID; } $arCurrentDiscountID = CCatalogDiscountSave::__GetDiscountIDByGroup($arUserGroups); if (!empty($arCurrentDiscountID)) { $intCurrentTime = getmicrotime(); $arFilter = array("ID" => $arCurrentDiscountID, 'SITE_ID' => $strSiteID, "TYPE" => DISCOUNT_TYPE_SAVE, 'ACTIVE' => 'Y', "+<=ACTIVE_FROM" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCurrentTime), "+>=ACTIVE_TO" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCurrentTime)); $rsDiscSaves = CCatalogDiscountSave::GetList(array(), $arFilter); while ($arDiscSave = $rsDiscSaves->Fetch()) { $arDiscSave['ACTION_SIZE'] = intval($arDiscSave['ACTION_SIZE']); $arDiscSave['COUNT_SIZE'] = intval($arDiscSave['COUNT_SIZE']); $arDiscSave['ACTIVE_FROM_UT'] = false; $arDiscSave['ACTIVE_TO_UT'] = false; $arDiscSave['COUNT_FROM_UT'] = false; $arDiscSave['COUNT_TO_UT'] = false; $strCountPeriod = 'U'; $strActionPeriod = 'U'; $arCountPeriodBack = array(); $arActionPeriodBack = array(); $arActionPeriod = array(); $arStartDate = false; $arOldOrderSumm = false; $arOrderSumm = false; $boolPeriodInsert = true; $intCountTime = $intCurrentTime; $arOrderFilter = array("USER_ID" => $intUserID, "LID" => $arDiscSave['SITE_ID'], "PAYED" => "Y", "CANCELED" => "N"); $arOldOrderFilter = $arOrderFilter; if (!empty($arDiscSave['ACTIVE_FROM']) || !empty($arDiscSave['ACTIVE_TO'])) { $strActionPeriod = 'D'; if (!empty($arDiscSave['ACTIVE_FROM'])) { $arDiscSave['ACTIVE_FROM_UT'] = MakeTimeStamp($arDiscSave['ACTIVE_FROM']); } if (!empty($arDiscSave['ACTIVE_TO'])) { $arDiscSave['ACTIVE_TO_UT'] = MakeTimeStamp($arDiscSave['ACTIVE_TO']); } } elseif (0 < $arDiscSave['ACTION_SIZE'] && in_array($arDiscSave['ACTION_TYPE'], array('D', 'M', 'Y'))) { $strActionPeriod = 'P'; $arActionPeriodBack = CCatalogDiscountSave::__GetTimeStampArray($arDiscSave['ACTION_SIZE'], $arDiscSave['ACTION_TYPE']); $arActionPeriod = CCatalogDiscountSave::__GetTimeStampArray($arDiscSave['ACTION_SIZE'], $arDiscSave['ACTION_TYPE'], true); } if (!empty($arDiscSave['COUNT_FROM']) || !empty($arDiscSave['COUNT_TO'])) { $strCountPeriod = 'D'; if (!empty($arDiscSave['COUNT_FROM'])) { $arDiscSave['COUNT_FROM_UT'] = MakeTimeStamp($arDiscSave['COUNT_FROM']); } if (!empty($arDiscSave['COUNT_TO'])) { $arDiscSave['COUNT_TO_UT'] = MakeTimeStamp($arDiscSave['COUNT_TO']); if ($arDiscSave['COUNT_TO_UT'] > $intCountTime) { $arDiscSave['COUNT_TO_UT'] = $intCountTime; $arDiscSave['COUNT_TO'] = ConvertTimeStamp($intCountTime, 'FULL'); } } } elseif (0 < $arDiscSave['COUNT_SIZE'] && in_array($arDiscSave['COUNT_TYPE'], array('D', 'M', 'Y'))) { $strCountPeriod = 'P'; $arCountPeriodBack = CCatalogDiscountSave::__GetTimeStampArray($arDiscSave['COUNT_SIZE'], $arDiscSave['COUNT_TYPE']); } if ('D' == $strCountPeriod) { if (false !== $arDiscSave['COUNT_FROM_UT']) { if ($arDiscSave['COUNT_FROM_UT'] > $intCountTime) { continue; } if (false !== $arDiscSave['COUNT_TO_UT'] && $arDiscSave['COUNT_TO_UT'] <= $arDiscSave['COUNT_FROM_UT']) { continue; } if (false !== $arDiscSave['ACTIVE_TO_UT'] && $arDiscSave['COUNT_FROM_UT'] >= $arDiscSave['ACTIVE_TO_UT']) { continue; } } if (false !== $arDiscSave['COUNT_TO_UT']) { if ('P' == $strActionPeriod && $arDiscSave['COUNT_TO_UT'] < AddToTimeStamp($arActionPeriodBack, $intCountTime)) { continue; } } } if ('P' == $strActionPeriod) { if ('P' == $strCountPeriod) { $arStartDate = CCatalogDiscountSave::__GetUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID, 'ACTIVE_FROM' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arActionPeriodBack, $intCountTime)))); if (is_array($arStartDate) && !empty($arStartDate)) { $arOldOrderFilter['<DATE_INSERT'] = $arStartDate['ACTIVE_FROM_FORMAT']; $arOldOrderFilter['>=DATE_INSERT'] = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arCountPeriodBack, MakeTimeStamp($arStartDate['ACTIVE_FROM_FORMAT']))); $arOldOrderSumm = CCatalogDiscountSave::__SaleOrderSumm($arOldOrderFilter, $arDiscSave['CURRENCY']); } } else { $arStartDate = CCatalogDiscountSave::__GetUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID), array('ACTIVE_FROM' => false, 'DELETE' => false)); if (is_array($arStartDate) && !empty($arStartDate)) { $intTimeStart = MakeTimeStamp($arStartDate['ACTIVE_FROM_FORMAT']); $intTimeFinish = MakeTimeStamp($arStartDate['ACTIVE_TO_FORMAT']); if (!($intTimeStart <= $intCountTime && $intTimeFinish >= $intCountTime)) { continue; } else { $boolPeriodInsert = false; } } } } $intTimeStart = false; $intTimeFinish = false; if ('D' == $strCountPeriod) { $intTimeStart = !empty($arDiscSave['COUNT_FROM']) ? $arDiscSave['COUNT_FROM'] : false; $intTimeFinish = !empty($arDiscSave['COUNT_TO']) ? $arDiscSave['COUNT_TO'] : false; } elseif ('P' == $strCountPeriod) { $intTimeStart = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arCountPeriodBack, $intCountTime)); } if ($intTimeStart) { $arOrderFilter['>=DATE_INSERT'] = $intTimeStart; } if ($intTimeFinish) { $arOrderFilter['<DATE_INSERT'] = $intTimeFinish; } $arOrderSumm = CCatalogDiscountSave::__SaleOrderSumm($arOrderFilter, $arDiscSave['CURRENCY']); if (is_array($arOldOrderSumm) && 0 < $arOldOrderSumm['RANGE_SUMM']) { if ($arOrderSumm['RANGE_SUMM'] <= $arOldOrderSumm['RANGE_SUMM']) { $arOrderSumm = $arOldOrderSumm; } else { $arOldOrderSumm = false; } } $rsRanges = CCatalogDiscountSave::GetRangeByDiscount(array('RANGE_FROM' => 'desc'), array('DISCOUNT_ID' => $arDiscSave['ID'], '<=RANGE_FROM' => $arOrderSumm['RANGE_SUMM']), false, array('nTopCount' => 1)); if ($arRange = $rsRanges->Fetch()) { if ('P' == $strActionPeriod) { if ('P' == $strCountPeriod) { if (!is_array($arOldOrderSumm)) { CCatalogDiscountSave::__UpdateUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID, 'ACTIVE_FROM' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCountTime), 'ACTIVE_TO' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arActionPeriod, $intCountTime)), 'RANGE_FROM' => -1)); } } else { if ($boolPeriodInsert) { CCatalogDiscountSave::__UpdateUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID, 'ACTIVE_FROM' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCountTime), 'ACTIVE_TO' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arActionPeriod, $intCountTime)), 'RANGE_FROM' => -1), array('SEARCH' => true, 'DELETE' => false)); } } } unset($arDiscSave['ACTIVE_FROM_UT']); unset($arDiscSave['ACTIVE_TO_UT']); unset($arDiscSave['COUNT_FROM_UT']); unset($arDiscSave['COUNT_TO_UT']); $arOneResult = array(); $arOneResult = $arDiscSave; $arOneResult['VALUE'] = $arRange['VALUE']; $arOneResult['VALUE_TYPE'] = $arRange['TYPE']; $arOneResult['RANGE_FROM'] = $arRange['RANGE_FROM']; $arOneResult['SUMM'] = $arOrderSumm['SUMM']; $arOneResult['SUMM_CURRENCY'] = $arOrderSumm['CURRENCY']; $arOneResult['RANGE_SUMM'] = $arOrderSumm['RANGE_SUMM']; $arOneResult['LAST_ORDER_DATE'] = $arOrderSumm['LAST_ORDER_DATE']; $arResult[] = $arOneResult; } } } return $arResult; }