Beispiel #1
0
 /**
  * Function formats delivery system info in arResult
  * @return void
  */
 protected function formatResultDeliverySystem()
 {
     $arResult =& $this->arResult;
     foreach ($arResult['SHIPMENT'] as &$shipment) {
         if (!empty($shipment["DELIVERY_ID"])) {
             $shipment["DELIVERY"]["NAME"] = htmlspecialcharsEx($shipment["DELIVERY"]["NAME"]);
         }
         $res = \Bitrix\Sale\Delivery\ExtraServices\Table::getList(array('filter' => array("=DELIVERY_ID" => $shipment['DELIVERY_ID'], "=CLASS_NAME" => '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store', "=CODE" => 'BITRIX_STORE_PICKUP')));
         $store = $res->fetch();
         if ($store) {
             $dbRes = \Bitrix\Sale\Internals\ShipmentExtraServiceTable::getList(array('filter' => array('=SHIPMENT_ID' => $shipment['ID'], '=EXTRA_SERVICE_ID' => $store['ID'])));
             if ($row = $dbRes->fetch()) {
                 $shipment['STORE_ID'] = $row["VALUE"];
             }
         }
     }
     unset($shipment);
     if (!empty($arResult["DELIVERY"])) {
         if (!empty($arResult['DELIVERY_STORE_LIST'])) {
             $arResult["DELIVERY"]['STORE_LIST'] = $arResult['DELIVERY_STORE_LIST'];
             unset($arResult['DELIVERY_STORE_LIST']);
         }
     }
 }
                }
            } else {
                $strError .= Loc::getMessage("SALE_ESDE_ERROR_ID") . '.<br>\\n';
            }
            if (strlen($strError) <= 0) {
                if (strlen($_POST["apply"]) > 0) {
                    LocalRedirect($APPLICATION->GetCurPageParam("ID=" . $ID, array('ID')));
                } elseif (strlen($_POST["save"]) > 0) {
                    LocalRedirect(isset($_REQUEST["back_url"]) ? $_REQUEST["back_url"] : "sale_delivery_service_edit.php?lang=" . LANG . "&ID=" . $fields["DELIVERY_ID"]);
                }
            }
        }
    }
}
if ($ID > 0) {
    $res = ExtraServices\Table::getById($ID);
    $fields = $res->fetch();
}
if (isset($fields["DELIVERY_ID"])) {
    $DELIVERY_ID = $fields["DELIVERY_ID"];
} elseif (isset($_REQUEST["DELIVERY_ID"])) {
    $DELIVERY_ID = $_REQUEST["DELIVERY_ID"];
} else {
    $DELIVERY_ID = 0;
}
$DELIVERY_ID = intval($DELIVERY_ID);
if ($DELIVERY_ID <= 0) {
    $strError .= Loc::getMessage("SALE_ESDE_ERROR_ID");
}
$currencyLang = "";
$deliveryService = null;
             if (!$res->isSuccess()) {
                 $strError .= Loc::getMessage("SALE_DSE_ERROR_ADD_DELIVERY") . "<br>" . implode("<br>", $res->getErrorMessages());
             } else {
                 $ID = $res->getId();
                 Services\Manager::onAfterAdd($ID, $fields);
             }
         }
         if ($ID > 0) {
             //stores
             unset($res);
             if (isset($_POST["STORES_SHOW"]) && $_POST["STORES_SHOW"] == "Y" && isset($_POST["STORES"]["PARAMS"]["STORES"])) {
                 $res = ExtraServices\Manager::saveStores($ID, Bitrix\Sale\Delivery\ExtraServices\Store::getStoresIdsFromParams($_POST["STORES"]["PARAMS"]));
             } else {
                 $storesFields = ExtraServices\Manager::getStoresFields($ID);
                 if (!empty($storesFields)) {
                     $res = Delivery\ExtraServices\Table::delete($storesFields["ID"]);
                 }
             }
             if ($res && !$res->isSuccess()) {
                 $strError .= implode("<br>\n", $res->getErrorMessages());
             }
         }
     }
 }
 if (strlen($strError) <= 0) {
     if (strlen($_POST["apply"]) > 0) {
         $paramsToKill = array("ID");
         if (!empty($_REQUEST["RESET_TARIF_SETTINGS"])) {
             $paramsToKill[] = "RESET_TARIF_SETTINGS";
         }
         $redirectUrl = $APPLICATION->GetCurPageParam("ID=" . $ID, $paramsToKill);
Beispiel #4
0
 protected static function getByDeliveryId($deliveryId)
 {
     static $hitCache = array();
     if (isset($hitCache[$deliveryId])) {
         return $hitCache[$deliveryId];
     }
     $result = array();
     $dbRes = Table::getList(array("order" => array("SORT" => "ASC", "NAME" => "ASC"), "filter" => array("=DELIVERY_ID" => $deliveryId, "=ACTIVE" => "Y", "=CLASS_NAME" => self::getClassesList()), "select" => array("*", "CURRENCY" => "DELIVERY_SERVICE.CURRENCY")));
     while ($row = $dbRes->fetch()) {
         $result[$row["ID"]] = $row;
     }
     $hitCache[$deliveryId] = $result;
     return $result;
 }
$ID = intval($_GET['ID']);
$strError = "";
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "delete_extra_service" && isset($_REQUEST["ES_ID"])) {
    if (intval($_REQUEST["ES_ID"] > 0)) {
        $res = ExtraServices\Table::delete(intval($_REQUEST["ES_ID"]));
        if (!$res->isSuccess()) {
            $strError .= Loc::getMessage("SALE_ESDE_ERROR_DELETE") . ' ' . implode("<br>\n", $res->getErrorMessages());
        }
    } else {
        $strError .= Loc::getMessage("SALE_ESDE_ERROR_ID");
    }
}
$tableId = 'table_delivery_extra_service';
$oSort = new \CAdminSorting($tableId);
$lAdmin = new \CAdminList($tableId, $oSort);
$res = \Bitrix\Sale\Delivery\ExtraServices\Table::getList(array('filter' => array('DELIVERY_ID' => $ID, '=CLASS_NAME' => ExtraServices\Manager::getClassesList()), 'select' => array('ID', 'CODE', 'NAME', 'DESCRIPTION', 'CLASS_NAME', 'RIGHTS', 'ACTIVE', 'SORT'), 'order' => array('SORT' => 'ASC', 'ID' => 'DESC')));
$data = $res->fetchAll();
$dbRes = new \CDBResult();
$dbRes->InitFromArray($data);
$dbRecords = new \CAdminResult($dbRes, $tableId);
$dbRecords->NavStart();
$lAdmin->NavText($dbRecords->GetNavPrint(Loc::getMessage('SALE_ESDL_LIST')));
$header = array(array('id' => 'ID', 'content' => Loc::getMessage('SALE_ESDL_COL_ID'), "sort" => "", 'default' => true), array('id' => 'CODE', 'content' => Loc::getMessage('SALE_ESDL_COL_CODE'), "sort" => "", 'default' => false), array('id' => 'NAME', 'content' => Loc::getMessage('SALE_ESDL_COL_NAME'), "sort" => "", 'default' => true), array('id' => 'SORT', 'content' => Loc::getMessage('SALE_ESDL_COL_SORT'), "sort" => "", 'default' => true), array('id' => 'RIGHTS', 'content' => Loc::getMessage('SALE_ESDL_COL_RIGHTS'), "sort" => "", 'default' => false), array('id' => 'ACTIVE', 'content' => Loc::getMessage('SALE_ESDL_COL_ACTIVE'), "sort" => "", 'default' => true), array('id' => 'CLASS_NAME', 'content' => Loc::getMessage('SALE_ESDL_COL_CLASS_NAME'), "sort" => "", 'default' => true), array('id' => 'DESCRIPTION', 'content' => Loc::getMessage('SALE_ESDL_COL_DESCRIPTION'), "sort" => "", 'default' => true));
$lAdmin->AddHeaders($header);
while ($record = $dbRecords->Fetch()) {
    $link = 'sale_delivery_eservice_edit.php?ID=' . $record['ID'] . '&lang=' . LANGUAGE_ID . '&' . $tabControl->ActiveTabParam() . '&back_url=' . urlencode($APPLICATION->GetCurPageParam());
    $row =& $lAdmin->AddRow($record['ID'], $record, $link, '');
    $row->AddField('ID', '<a href="' . $link . '">' . $record['ID'] . '</a>');
    $row->AddField('CODE', $record['CODE']);
    $row->AddField('NAME', $record['NAME']);
    $row->AddField('SORT', $record['SORT']);