Beispiel #1
0
 /**
  * @param array $arOrder
  * @param array $arFilter
  * @param bool $arGroupBy
  * @param bool $arNavStartParams
  * @param array $arSelectFields
  * @return \CDBResult
  * @throws \Bitrix\Main\ArgumentException
  * @deprecated
  */
 public static function GetList($arOrder = array("SORT" => "ASC", "NAME" => "ASC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array('*'))
 {
     if (empty($arSelectFields)) {
         $arSelectFields = array('*');
     }
     $params = array('order' => $arOrder, 'filter' => self::convertFilterOldToNew($arFilter), 'group' => self::convertGroupOldToNew($arGroupBy), 'select' => self::convertSelectOldToNew($arSelectFields));
     $services = array();
     $params['filter']['=CLASS_NAME'] = '\\Bitrix\\Sale\\Delivery\\Services\\Configurable';
     $dbRes = \Bitrix\Sale\Delivery\Services\Table::getList($params);
     if (isset($arFilter["WEIGHT"]) && DoubleVal($arFilter["WEIGHT"]) > 0) {
         if (!isset($arFilter["WEIGHT_FROM"]) || floatval($arFilter["WEIGHT"]) > floatval($arFilter["WEIGHT_FROM"])) {
             $arFilter["+<=WEIGHT_FROM"] = $arFilter["WEIGHT"];
         }
         if (!isset($arFilter["WEIGHT_TO"]) || floatval($arFilter["WEIGHT"]) < floatval($arFilter["WEIGHT_TO"])) {
             $arFilter["+>=WEIGHT_TO"] = $arFilter["WEIGHT"];
         }
     }
     if (isset($arFilter["ORDER_PRICE"]) && IntVal($arFilter["ORDER_PRICE"]) > 0) {
         if (!isset($arFilter["ORDER_PRICE_FROM"]) || floatval($arFilter["ORDER_PRICE"]) > floatval($arFilter["ORDER_PRICE_FROM"])) {
             $arFilter["+<=ORDER_PRICE_FROM"] = $arFilter["ORDER_PRICE"];
         }
         if (!isset($arFilter["ORDER_PRICE_TO"]) || floatval($arFilter["ORDER_PRICE"]) < floatval($arFilter["ORDER_PRICE_TO"])) {
             $arFilter["+>=ORDER_PRICE_TO"] = $arFilter["ORDER_PRICE"];
         }
     }
     while ($service = $dbRes->fetch()) {
         $dbRstrRes = \Bitrix\Sale\Delivery\Restrictions\Table::getList(array('filter' => array("=DELIVERY_ID" => $service["ID"])));
         while ($restr = $dbRstrRes->fetch()) {
             if (!self::checkRestrictionFilter($restr, $arFilter)) {
                 continue 2;
             }
             $service = self::getSelectedRestrictionField($service, $restr, $arSelectFields);
         }
         $selectAsterisk = in_array('*', $arSelectFields);
         $mofifiedFields = array("LID", "WEIGHT_FROM", "WEIGHT_TO", "ORDER_PRICE_FROM", "ORDER_PRICE_TO", "ORDER_CURRENCY");
         foreach ($mofifiedFields as $field) {
             if (($selectAsterisk || in_array($field, $arSelectFields)) && !array_key_exists($field, $service)) {
                 $service[$field] = "";
             }
         }
         if ($selectAsterisk || in_array("PERIOD_FROM", $arSelectFields)) {
             $service["PERIOD_FROM"] = $service["CONFIG"]["MAIN"]["PERIOD"]["FROM"];
         }
         if ($selectAsterisk || in_array("PERIOD_TO", $arSelectFields)) {
             $service["PERIOD_TO"] = $service["CONFIG"]["MAIN"]["PERIOD"]["TO"];
         }
         if ($selectAsterisk || in_array("PERIOD_TYPE", $arSelectFields)) {
             $service["PERIOD_TYPE"] = $service["CONFIG"]["MAIN"]["PERIOD"]["TYPE"];
         }
         if ($selectAsterisk || in_array("PRICE", $arSelectFields)) {
             $service["CLASS_NAME"] = '\\Bitrix\\Sale\\Delivery\\Services\\Configurable';
             $tmpSrv = \Bitrix\Sale\Delivery\Services\Manager::createServiceObject($service);
             $res = $tmpSrv->calculate();
             $service["PRICE"] = $res->getPrice();
         }
         if ($selectAsterisk || in_array("STORE", $arSelectFields)) {
             $stores = \Bitrix\Sale\Delivery\ExtraServices\Manager::getStoresList($service["ID"]);
             $service["STORE"] = count($stores) > 0 ? serialize($stores) : "";
         }
         if (intval($service["CODE"]) > 0) {
             $service["ID"] = $service["CODE"];
         }
         unset($service["CODE"], $service["CLASS_NAME"], $service["CONFIG"], $service["PARENT_ID"]);
         $services[] = $service;
     }
     $result = new \CDBResult();
     $result->InitFromArray($services);
     return $result;
 }
/* if we have only one class - let's fix it */
if (empty($fields["CLASS_NAME"]) && count($classNamesList) == 1) {
    $fields["CLASS_NAME"] = current($classNamesList);
}
$isGroup = $fields["CLASS_NAME"] == '\\Bitrix\\Sale\\Delivery\\Services\\Group';
$service = null;
if (isset($fields["CLASS_NAME"]) && strlen($fields["CLASS_NAME"]) > 0) {
    /* We must convert handler config from post as it was taken from database */
    if ($isItSavingProcess && strlen($strError) > 0) {
        try {
            $service = Services\Manager::createServiceObject($fields);
            $fields = $service->prepareFieldsForSaving($fields);
        } catch (\Bitrix\Main\SystemException $e) {
        }
    }
    $service = Services\Manager::createServiceObject($fields);
    $fields = $service->prepareFieldsForUsing($fields);
    if ($service) {
        $serviceConfig = $service->getConfig();
        $showRestrictions = $service->whetherAdminRestrictionsShow();
        $showExtraServices = $service->whetherAdminExtraServicesShow();
        $showFieldsList = $service->getAdminFieldsList();
        $canHasProfiles = $service->canHasProfiles() && $ID > 0;
    }
}
$serviceCurrency = $fields["CURRENCY"];
if (\Bitrix\Main\Loader::includeModule('currency')) {
    $currencyList = Currency\CurrencyManager::getCurrencyList();
    if (isset($currencyList[$fields["CURRENCY"]])) {
        $serviceCurrency = $currencyList[$fields["CURRENCY"]];
    }