Пример #1
0
    $fields["CURRENCY"] = COption::GetOptionString("sale", "default_currency", "RUB");
    $fields["RIGHTS"] = "YYY";
    //Admin Manager Client
    if ($fields["CLASS_NAME"] == '\\Bitrix\\Sale\\Delivery\\Services\\Group') {
        $fields["ACTIVE"] = "Y";
    }
}
$serviceConfig = array();
$canHasProfiles = false;
$showRestrictions = true;
$showExtraServices = false;
$parentService = null;
$showFieldsList = \Bitrix\Sale\Delivery\Services\Table::getMap();
/* saving or updating Extra service & restrictions */
if ($ID > 0 && ($_SERVER['REQUEST_METHOD'] != "POST" || $isItSavingProcess)) {
    $dbRes = \Bitrix\Sale\Delivery\Services\Table::getById($ID);
    if (!($fields = $dbRes->fetch())) {
        $strError .= str_replace("#ID#", $ID, Loc::getMessage("SALE_DSE_ERROR_ID")) . "<br>";
    }
}
/* If action is copying */
if ($_REQUEST["action"] == "copy") {
    $ID = 0;
    unset($fields["ID"]);
} elseif ($_REQUEST["action"] == "profile_delete") {
    $idProf = isset($_REQUEST["ID_PROF"]) ? intval($_REQUEST["ID_PROF"]) : 0;
    if ($idProf > 0) {
        $res = \Bitrix\Sale\Delivery\Services\Table::delete($idProf);
        if (!$res->isSuccess()) {
            $strError .= implode("<br>\n", $res->getErrorMessages()) . "<br>";
        }
Пример #2
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     global $USER_FIELD_MANAGER, $DB, $APPLICATION;
     if (is_set($arFields, "SITE_ID") && strlen($arFields["SITE_ID"]) > 0) {
         $arFields["LID"] = $arFields["SITE_ID"];
     }
     if ((is_set($arFields, "LID") || $ACTION == "ADD") && strlen($arFields["LID"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_SITE"), "EMPTY_SITE_ID");
         return false;
     }
     if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION == "ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_PERS_TYPE"), "EMPTY_PERSON_TYPE_ID");
         return false;
     }
     if ((is_set($arFields, "USER_ID") || $ACTION == "ADD") && IntVal($arFields["USER_ID"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_USER_ID"), "EMPTY_USER_ID");
         return false;
     }
     if (is_set($arFields, "PAYED") && $arFields["PAYED"] != "Y") {
         $arFields["PAYED"] = "N";
     }
     if (is_set($arFields, "CANCELED") && $arFields["CANCELED"] != "Y") {
         $arFields["CANCELED"] = "N";
     }
     if (is_set($arFields, "STATUS_ID") && strlen($arFields["STATUS_ID"]) <= 0) {
         $arFields["STATUS_ID"] = "N";
     }
     if (is_set($arFields, "ALLOW_DELIVERY") && $arFields["ALLOW_DELIVERY"] != "Y") {
         $arFields["ALLOW_DELIVERY"] = "N";
     }
     if (is_set($arFields, "EXTERNAL_ORDER") && $arFields["EXTERNAL_ORDER"] != "Y") {
         $arFields["EXTERNAL_ORDER"] = "N";
     }
     if (is_set($arFields, "PRICE") || $ACTION == "ADD") {
         $arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
         $arFields["PRICE"] = DoubleVal($arFields["PRICE"]);
     }
     if (is_set($arFields, "PRICE_DELIVERY") || $ACTION == "ADD") {
         $arFields["PRICE_DELIVERY"] = str_replace(",", ".", $arFields["PRICE_DELIVERY"]);
         $arFields["PRICE_DELIVERY"] = DoubleVal($arFields["PRICE_DELIVERY"]);
     }
     if (is_set($arFields, "SUM_PAID") || $ACTION == "ADD") {
         $arFields["SUM_PAID"] = str_replace(",", ".", $arFields["SUM_PAID"]);
         $arFields["SUM_PAID"] = DoubleVal($arFields["SUM_PAID"]);
     }
     if (is_set($arFields, "DISCOUNT_VALUE") || $ACTION == "ADD") {
         $arFields["DISCOUNT_VALUE"] = str_replace(",", ".", $arFields["DISCOUNT_VALUE"]);
         $arFields["DISCOUNT_VALUE"] = DoubleVal($arFields["DISCOUNT_VALUE"]);
     }
     if (is_set($arFields, "TAX_VALUE") || $ACTION == "ADD") {
         $arFields["TAX_VALUE"] = str_replace(",", ".", $arFields["TAX_VALUE"]);
         $arFields["TAX_VALUE"] = DoubleVal($arFields["TAX_VALUE"]);
     }
     if (!is_set($arFields, "LOCKED_BY") && (!is_set($arFields, "UPDATED_1C") || is_set($arFields, "UPDATED_1C") && $arFields["UPDATED_1C"] != "Y")) {
         $arFields["UPDATED_1C"] = "N";
         $arFields["~VERSION"] = "VERSION+0+1";
     }
     if ((is_set($arFields, "CURRENCY") || $ACTION == "ADD") && strlen($arFields["CURRENCY"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_CURRENCY"), "EMPTY_CURRENCY");
         return false;
     }
     if (is_set($arFields, "CURRENCY")) {
         if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], Loc::getMessage("SKGO_WRONG_CURRENCY")), "ERROR_NO_CURRENCY");
             return false;
         }
     }
     if (is_set($arFields, "LID")) {
         $dbSite = CSite::GetByID($arFields["LID"]);
         if (!$dbSite->Fetch()) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["LID"], Loc::getMessage("SKGO_WRONG_SITE")), "ERROR_NO_SITE");
             return false;
         }
     }
     if (is_set($arFields, "USER_ID")) {
         $dbUser = CUser::GetByID($arFields["USER_ID"]);
         if (!$dbUser->Fetch()) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["USER_ID"], Loc::getMessage("SKGO_WRONG_USER")), "ERROR_NO_USER_ID");
             return false;
         }
     }
     if (is_set($arFields, "PERSON_TYPE_ID")) {
         if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], Loc::getMessage("SKGO_WRONG_PERSON_TYPE")), "ERROR_NO_PERSON_TYPE");
             return false;
         }
     }
     if (is_set($arFields, "PAY_SYSTEM_ID") && IntVal($arFields["PAY_SYSTEM_ID"]) > 0) {
         if (!($arPaySystem = CSalePaySystem::GetByID(IntVal($arFields["PAY_SYSTEM_ID"])))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["PAY_SYSTEM_ID"], Loc::getMessage("SKGO_WRONG_PS")), "ERROR_NO_PAY_SYSTEM");
             return false;
         }
     }
     if (is_set($arFields, "DELIVERY_ID") && IntVal($arFields["DELIVERY_ID"]) > 0) {
         if (!($delivery = \Bitrix\Sale\Delivery\Services\Table::getById($arFields["DELIVERY_ID"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], Loc::getMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
             return false;
         }
     }
     if (is_set($arFields, "STATUS_ID")) {
         if (!($arStatus = CSaleStatus::GetByID($arFields["STATUS_ID"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["STATUS_ID"], Loc::getMessage("SKGO_WRONG_STATUS")), "ERROR_NO_STATUS_ID");
             return false;
         }
     }
     if (is_set($arFields, "ACCOUNT_NUMBER") && $ACTION == "UPDATE") {
         if (strlen($arFields["ACCOUNT_NUMBER"]) <= 0) {
             $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_ACCOUNT_NUMBER"), "EMPTY_ACCOUNT_NUMBER");
             return false;
         } else {
             $dbres = $DB->Query("SELECT ID, ACCOUNT_NUMBER FROM b_sale_order WHERE ACCOUNT_NUMBER = '" . $DB->ForSql($arFields["ACCOUNT_NUMBER"]) . "'", true);
             if ($arRes = $dbres->GetNext()) {
                 if (is_array($arRes) && $arRes["ID"] != $ID) {
                     $APPLICATION->ThrowException(Loc::getMessage("SKGO_EXISTING_ACCOUNT_NUMBER"), "EXISTING_ACCOUNT_NUMBER");
                     return false;
                 }
             }
         }
     }
     if ($ACTION == "ADD") {
         $arFields["VERSION"] = 1;
     }
     if (!$USER_FIELD_MANAGER->CheckFields("ORDER", $ID, $arFields)) {
         return false;
     }
     return True;
 }
Пример #3
0
        $row->AddField("NAME", '<a href="' . $actUrl . '" class="adm-list-table-icon-link">' . '<span class="adm-submenu-item-link-icon adm-list-table-icon sale_section_icon"></span>' . '<span class="adm-list-table-link">' . $f_NAME . '</span>' . '</a>');
    } else {
        $actUrl = "sale_delivery_service_edit.php?lang=" . LANG . "&PARENT_ID=" . $f_PARENT_ID . "&ID=" . $f_ID . "&back_url=" . $backUrl;
        $row =& $lAdmin->AddRow($f_ID, $service, $actUrl, GetMessage("SALE_SALE_EDIT_DESCR"));
        $row->AddField("NAME", '<a href="' . $actUrl . '" class="adm-list-table-icon-link">' . '<span class="adm-list-table-link">' . $f_NAME . '</span>' . '</a>');
    }
    $row->AddField("ID", $f_ID);
    $logoHtml = intval($f_LOGOTIP) > 0 ? CFile::ShowImage(CFile::GetFileArray($f_LOGOTIP), 150, 150, "border=0", "", false) : "";
    $row->AddField("LOGOTIP", $logoHtml);
    $row->AddField("DESCRIPTION", $f_DESCRIPTION);
    $row->AddField("SORT", $f_SORT);
    $row->AddField("ACTIVE", $f_ACTIVE == "Y" ? Loc::getMessage("SALE_SDL_YES") : Loc::getMessage("SALE_SDL_NO"));
    $row->AddField("CLASS_NAME", (is_callable($f_CLASS_NAME . "::getClassTitle") ? $f_CLASS_NAME::getClassTitle() : "") . " [" . $f_CLASS_NAME . "]");
    $groupNameHtml = "";
    if ($f_PARENT_ID > 0) {
        $res = \Bitrix\Sale\Delivery\Services\Table::getById($f_PARENT_ID);
        if ($group = $res->fetch()) {
            $groupNameHtml = '<a href="sale_delivery_service_edit.php?lang=' . LANG . '&PARENT_ID=' . $group["PARENT_ID"] . '&ID=' . $group["ID"] . "&back_url=" . $backUrl . '">' . htmlspecialcharsbx($group["NAME"]) . '</a>';
        }
    }
    $row->AddField("GROUP_NAME", $groupNameHtml);
    $arActions = array();
    $arActions[] = array("ICON" => "copy", "TEXT" => Loc::getMessage("SALE_SDL_COPY_DESCR"), "ACTION" => 'BX.Sale.Delivery.showGroupsDialog("sale_delivery_service_edit.php?lang=' . LANG . '&ID=' . $f_ID . '&action=copy","' . $f_PARENT_ID . "&back_url=" . $backUrl . '");', "DEFAULT" => true);
    $arActions[] = array("ICON" => "edit", "TEXT" => Loc::getMessage("SALE_SDL_EDIT_DESCR"), "ACTION" => $lAdmin->ActionRedirect("sale_delivery_service_edit.php?lang=" . LANG . "&PARENT_ID=" . $f_PARENT_ID . "&ID=" . $f_ID . "&back_url=" . $backUrl), "DEFAULT" => true);
    if ($saleModulePermissions >= "W") {
        $arActions[] = array("SEPARATOR" => true);
        $arActions[] = array("ICON" => "delete", "TEXT" => Loc::getMessage("SALE_SDL_DELETE_DESCR"), "ACTION" => "if(confirm('" . Loc::getMessage('SALE_SDL_CONFIRM_DEL_MESSAGE') . "')) " . $lAdmin->ActionDoGroup($f_ID, "delete", "PARENT_ID=" . $f_PARENT_ID));
    }
    $row->AddActions($arActions);
}
$lAdmin->AddFooter(array(array("title" => Loc::getMessage("MAIN_ADMIN_LIST_SELECTED"), "value" => $dbResultList->SelectedRowsCount()), array("counter" => true, "title" => Loc::getMessage("MAIN_ADMIN_LIST_CHECKED"), "value" => "0")));