Example #1
0
function __cat_setVAT($arVAT)
{
    $arCurrentVAT = array();
    $dbRes = CCatalogVAT::GetList();
    while ($arRes = $dbRes->Fetch()) {
        $arCurrentVAT[floatval($arRes['RATE'])] = $arRes;
    }
    foreach ($arVAT as $arFields) {
        if (isset($arCurrentVAT[floatval($arFields['RATE'])])) {
            continue;
        }
        // errors're goin by forest
        CCatalogVAT::Set($arFields);
    }
}
        } else {
            $errorMessage .= (0 < $ID ? str_replace('#ID#', $ID, GetMessage('CVAT_ERR_UPDATE')) : GetMessage('CVAT_ERR_ADD')) . "<br>";
        }
        $bVarsFromForm = true;
        $DB->Rollback();
    }
}
if ($ID > 0) {
    $APPLICATION->SetTitle(str_replace("#ID#", $ID, GetMessage("CVAT_TITLE_UPDATE")));
} else {
    $APPLICATION->SetTitle(GetMessage("CVAT_TITLE_ADD"));
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$str_ACTIVE = "Y";
if ($ID > 0) {
    $dbResult = CCatalogVAT::GetByID($ID);
    if (!$dbResult->ExtractFields("str_")) {
        $ID = 0;
    }
}
if ($bVarsFromForm) {
    $DB->InitTableVarsForEdit("b_catalog_vat", "", "str_");
}
?>

<?php 
$aMenu = array(array("TEXT" => GetMessage("CVAT_LIST"), "ICON" => "btn_list", "LINK" => "/bitrix/admin/cat_vat_admin.php?lang=" . LANG . "&" . GetFilterParams("filter_", false)));
if ($ID > 0 && !$bReadOnly) {
    $aMenu[] = array("SEPARATOR" => "Y");
    $aMenu[] = array("TEXT" => GetMessage("CVAT_NEW"), "ICON" => "btn_new", "LINK" => "/bitrix/admin/cat_vat_edit.php?lang=" . LANG . "&" . GetFilterParams("filter_", false));
    $aMenu[] = array("TEXT" => GetMessage("CVAT_DELETE"), "ICON" => "btn_delete", "LINK" => "javascript:if(confirm('" . GetMessage("CVAT_DELETE_CONFIRM") . "')) window.location='/bitrix/admin/cat_vat_admin.php?action=delete&ID[]=" . $ID . "&lang=" . LANG . "&" . bitrix_sessid_get() . "#tb';", "WARNING" => "Y");