public static function GetAll() { if (!CModule::IncludeModule('catalog')) { return false; } $VATS = isset(self::$VATS) ? self::$VATS : null; if (!$VATS) { $VATS = array(); $dbResultList = CCatalogVat::GetList(array('C_SORT' => 'ASC')); while ($arVat = $dbResultList->Fetch()) { $VATS[$arVat['ID']] = $arVat; } self::$VATS = $VATS; } return $VATS; }
public static function Update($ID, $arFields) { global $DB; $ID = intval($ID); if (0 >= $ID) { return false; } if (!CCatalogVat::CheckFields('UPDATE', $arFields, $ID)) { return false; } $strUpdate = $DB->PrepareUpdate("b_catalog_vat", $arFields); if (!empty($strUpdate)) { $strSql = "UPDATE b_catalog_vat SET " . $strUpdate . " WHERE ID = " . $ID; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } return $ID; }
public static function createVatZero() { \Bitrix\Main\Config\Option::set('crm', 'check_vat_zero', '0', ''); if (!Loader::includeModule('catalog')) { return; } $siteID = ''; $languageID = ''; $dbSites = \CSite::GetList($by = 'sort', $order = 'desc', array('DEFAULT' => 'Y', 'ACTIVE' => 'Y')); $defaultSite = is_object($dbSites) ? $dbSites->Fetch() : null; if (is_array($defaultSite)) { $siteID = $defaultSite['LID']; $languageID = $defaultSite['LANGUAGE_ID']; } if ($siteID === '') { $siteID = 's1'; } if ($languageID === '') { $languageID = 'ru'; } \Bitrix\Main\Config\Option::set('crm', 'check_vat_zero', '-1', ''); if ($languageID == 'ru') { \Bitrix\Main\Config\Option::set('crm', 'check_vat_zero', '-2', ''); $resVats = \CCatalogVat::GetListEx(array(), array('RATE' => 0), false, false, array('ID')); if (!($vatInfo = $resVats->Fetch())) { \Bitrix\Main\Config\Option::set('crm', 'check_vat_zero', '-3', ''); $fields = array('ACTIVE' => 'Y', 'SORT' => '100', 'NAME' => Loc::getMessage('CRM_VAT_ZERO', null, $languageID), 'RATE' => '0.0'); $vatID = \CCatalogVat::Add($fields); if ($vatID) { $vatID = (int) $vatID; } else { $vatID = -4; } \Bitrix\Main\Config\Option::set('crm', 'check_vat_zero', $vatID, ''); } } }
function Set($arFields) { global $DB; global $APPLICATION; $ACTION = empty($arFields['ID']) ? 'INSERT' : 'UPDATE'; if (CCatalogVat::CheckFields($ACTION, $arFields)) { //echo '<pre>'; print_r($arFields); echo '</pre>'; $ID = 0; if ($ACTION == 'UPDATE') { $ID = intval($arFields['ID']); } else { if (array_key_exists('ID', $arFields)) { unset($arFields['ID']); } } foreach ($arFields as $key => $value) { $arFields[$key] = "'" . $DB->ForSql($arFields[$key]) . "'"; } if ($ACTION == 'INSERT') { $res = $DB->Insert('b_catalog_vat', $arFields, $err_mess . __LINE__); $ID = $res; } else { unset($arFields['ID']); $res = $DB->Update('b_catalog_vat', $arFields, "WHERE ID=" . $ID, $err_mess . __LINE__); } if ($res) { return $ID; } else { //$GLOBALS['APPLICATION']->ThrowException(GetMessage('CVAT_ERROR_SET')); $APPLICATION->ThrowException(GetMessage('CVAT_ERROR_SET')); return false; } } else { return false; } }
function CatalogGetVATArray($arFilter = array(), $bInsertEmptyLine = false) { $bInsertEmptyLine = $bInsertEmptyLine === true; if (!is_array($arFilter)) { $arFilter = array(); } $arFilter['ACTIVE'] = 'Y'; $dbResult = CCatalogVat::GetListEx(array(), $arFilter, false, false, array('ID', 'NAME')); $arReference = array(); if ($bInsertEmptyLine) { $arList = array('REFERENCE' => array(0 => Loc::getMessage('CAT_VAT_REF_NOT_SELECTED')), 'REFERENCE_ID' => array(0 => '')); } else { $arList = array('REFERENCE' => array(), 'REFERENCE_ID' => array()); } $bEmpty = true; while ($arRes = $dbResult->Fetch()) { $bEmpty = false; $arList['REFERENCE'][] = $arRes['NAME']; $arList['REFERENCE_ID'][] = $arRes['ID']; } if ($bEmpty && !$bInsertEmptyLine) { return false; } else { return $arList; } }
if(!($dbVat->Fetch())) { $arF = array("ACTIVE" => "Y", "SORT" => "100", "NAME" => GetMessage("WIZ_VAT_1"), "RATE" => 0); CCatalogVat::Add($arF); } $dbVat = CCatalogVat::GetListEx( array(), array('RATE' => GetMessage("WIZ_VAT_2_VALUE")), false, false, array('ID', 'RATE') ); if(!($dbVat->Fetch())) { $arF = array("ACTIVE" => "Y", "SORT" => "200", "NAME" => GetMessage("WIZ_VAT_2"), "RATE" => GetMessage("WIZ_VAT_2_VALUE")); CCatalogVat::Add($arF); } $dbResultList = CCatalogGroup::GetList(array(), array("CODE" => "BASE")); if($arRes = $dbResultList->Fetch()) { $arFields = Array(); foreach($arLanguages as $langID) { WizardServices::IncludeServiceLang("step1.php", $langID); $arFields["USER_LANG"][$langID] = GetMessage("WIZ_PRICE_NAME"); } $arFields["BASE"] = "Y"; if ($wizard->GetVar("installPriceBASE") == "Y") { $db_res = CCatalogGroup::GetGroupsList(array("CATALOG_GROUP_ID"=>'1', "BUY"=>"Y")); if ($ar_res = $db_res->Fetch())
/** * <p>Метод добавляет новую ставку НДС или обновляет существующую в зависимости от передаваемых данных в массиве <i>arFields</i>. Метод динамичный.</p> <p></p> <div class="note"> <b>Примечание:</b> метод устарел, вместо него рекомендуется использоваться <a href="http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogvat/add.php">CCatalogVat::Add</a> и <a href="http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogvat/update.php">CCatalogVat::Update</a> соответственно.</div> * * * @param array $arFields Ассоциативный массив параметров ставки НДС. Допустимые ключи: <ul> * <li>ID - код ставки НДС (задается только для существующей ставки);</li> * <li>ACTIVE - активность ставки НДС ('Y' - активна, 'N' - неактивна);</li> <li>C_SORT * - индекс сортировки;</li> <li>NAME - название ставки НДС;</li> <li>RATE - * величина ставки НДС.</li> </ul> * * @return mixed <p>Метод возвращает <i>ID</i> созданной или измененной ставки НДС, * либо <i>false</i> в случае ошибки.</p> <br><br> * * @static * @link http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogvat/set.php * @author Bitrix * @deprecated deprecated since catalog 12.5.6 -> CCatalogVat::Add() */ public static function Set($arFields) { if (isset($arFields['ID']) && intval($arFields['ID']) > 0) { return CCatalogVat::Update($arFields['ID'], $arFields); } else { return CCatalogVat::Add($arFields); } }
break; case "activate": case "deactivate": $arFields = array("ID" => $ID, "ACTIVE" => $_REQUEST['action'] == "activate" ? "Y" : "N"); if (!CCatalogVat::Set($arFields)) { if ($ex = $APPLICATION->GetException()) { $lAdmin->AddGroupError($ex->GetString(), $ID); } else { $lAdmin->AddGroupError(str_replace("#ID#", $ID, GetMessage("ERROR_UPDATE_VAT")), $ID); } } break; } } } $dbResultList = CCatalogVat::GetList(array($by => $order), $arFilter); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("CVAT_NAV"))); $lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "id", "default" => true), array("id" => "C_SORT", "content" => GetMessage("CVAT_SORT"), "sort" => "c_sort", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("CVAT_ACTIVE"), "sort" => "active", "default" => true), array("id" => "NAME", "content" => GetMessage("CVAT_NAME"), "sort" => "name", "default" => true), array("id" => "RATE", "content" => GetMessage("CVAT_RATE"), "sort" => "rate", "default" => true))); $arVisibleColumns = $lAdmin->GetVisibleHeaderColumns(); while ($arVAT = $dbResultList->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arVAT); $row->AddField("ID", $f_ID); if ($bReadOnly) { $row->AddViewField("ACTIVE", $f_ACTIVE); $row->AddViewField("NAME", $f_NAME); $row->AddViewField("C_SORT", $f_C_SORT); } else { $row->AddCheckField("ACTIVE"); $row->AddInputField("NAME", array("size" => "30"));
if($lang == "ru") CCurrencyLang::Update($arCur["CURRENCY"], $lang, Array("DECIMALS" => 0)); elseif($arCur["CURRENCY"] == "EUR") CCurrencyLang::Update($arCur["CURRENCY"], $lang, Array("DECIMALS" => 2, "FORMAT_STRING" => "€#")); } } WizardServices::IncludeServiceLang("step1.php", $lang); CModule::IncludeModule("catalog"); $dbVat = CCatalogVat::GetList(array(), Array("SITE_ID" => WIZARD_SITE_ID)); if(!($dbVat->Fetch())) { $arF = Array ("ACTIVE" => "Y", "SORT" => "100", "NAME" => GetMessage("WIZ_VAT_1"), "RATE" => 0); CCatalogVat::Set($arF); $arF = Array ("ACTIVE" => "Y", "SORT" => "200", "NAME" => GetMessage("WIZ_VAT_2"), "RATE" => GetMessage("WIZ_VAT_2_VALUE")); CCatalogVat::Set($arF); } $dbResultList = CCatalogGroup::GetList(Array(), Array("CODE" => "BASE")); if($arRes = $dbResultList->Fetch()) { $arFields = Array(); foreach($arLanguages as $langID) { WizardServices::IncludeServiceLang("step1.php", $langID); $arFields["USER_LANG"][$langID] = GetMessage("WIZ_PRICE_NAME"); } $arFields["BASE"] = "Y"; if($wizard->GetVar("installPriceBASE") == "Y"){ $db_res = CCatalogGroup::GetGroupsList(array("CATALOG_GROUP_ID"=>'1', "BUY"=>"Y")); if ($ar_res = $db_res->Fetch()) {
/** * <p>Метод добавляет новую ставку НДС или обновляет существующую в зависимости от передаваемых данных в массиве <i>arFields</i>.</p> <p><b>Примечание:</b> метод устарел, вместо него рекомендуется использоваться <a href="http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogvat/add.php">CCatalogVat::Add</a> и <a href="http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogvat/update.php">CCatalogVat::Update</a> соответственно.</p> * * * * * @param array $arFields Ассоциативный массив параметров ставки НДС. Допустимые ключи: <ul> * <li>ID - код ставки НДС (задается только для существующей ставки);</li> * <li>ACTIVE - активность ставки НДС ('Y' - активна, 'N' - неактивна);</li> <li>C_SORT * - индекс сортировки;</li> <li>NAME - название ставки НДС;</li> <li>RATE - * величина ставки НДС.</li> </ul> * * * * @return mixed <p>Метод возвращает <i>ID</i> созданной или измененной ставки НДС, * либо <i>false</i> в случае ошибки.</p><br><br> * * @static * @link http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogvat/set.php * @author Bitrix */ public static function Set($arFields) { if (array_key_exists('ID', $arFields) && 0 < intval($arFields['ID'])) { return CCatalogVat::Update($arFields['ID'], $arFields); } else { return CCatalogVat::Add($arFields); } }
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/catalog/prolog.php"; if (!($USER->CanDoOperation('catalog_read') || $USER->CanDoOperation('catalog_vat'))) { $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); } CModule::IncludeModule("catalog"); $bReadOnly = !$USER->CanDoOperation('catalog_vat'); IncludeModuleLangFile(__FILE__); ClearVars(); $errorMessage = ""; $bVarsFromForm = false; $ID = intval($ID); if ('POST' == $_SERVER['REQUEST_METHOD'] && strlen($Update) > 0 && !$bReadOnly && check_bitrix_sessid()) { $DB->StartTransaction(); $arFields = array("ACTIVE" => 'Y' == $ACTIVE ? "Y" : "N", "C_SORT" => intval($C_SORT), "NAME" => $NAME, "RATE" => $RATE); if (0 < $ID) { $res = CCatalogVat::Update($ID, $arFields); } else { $ID = CCatalogVAT::Add($arFields); $res = 0 < $ID; } if ($res) { $DB->Commit(); if (strlen($apply) <= 0) { LocalRedirect("/bitrix/admin/cat_vat_admin.php?lang=" . LANGUAGE_ID . "&" . GetFilterParams("filter_", false)); } else { LocalRedirect("/bitrix/admin/cat_vat_edit.php?lang=" . LANGUAGE_ID . "&ID=" . $ID . "&" . GetFilterParams("filter_", false)); } } else { if ($ex = $APPLICATION->GetException()) { $errorMessage .= $ex->GetString(); } else {
public static function GetVatRateInfos() { if (self::$VAT_RATES !== null) { return self::$VAT_RATES; } if (!CModule::IncludeModule('catalog')) { return array(); } self::$VAT_RATES = array(); $dbResult = CCatalogVat::GetListEx(array('C_SORT' => 'ASC'), array('ACTIVE' => 'Y'), false, false, array('ID', 'NAME', 'RATE')); if (is_object($dbResult)) { while ($fields = $dbResult->Fetch()) { $ID = intval($fields['ID']); self::$VAT_RATES[] = array('ID' => $ID, 'NAME' => isset($fields['NAME']) ? $fields['NAME'] : "[{$ID}]", 'VALUE' => isset($fields['RATE']) ? round(doubleval($fields['RATE']), 2) : 0.0); } } return self::$VAT_RATES; }
public static function Add($arFields) { if (!CModule::IncludeModule('catalog')) { return false; } self::$LAST_ERROR = ''; global $DB; $tableName = CCrmCatalog::TABLE_NAME; if (!self::CheckFields('ADD', $arFields, 0)) { return false; } $DB->Add($tableName, $arFields, array(), '', false, 'File: ' . __FILE__ . '<br/>Line: ' . __LINE__); if (strlen($DB->db_Error) > 0) { self::RegisterError($DB->db_Error); return false; } // -------------- register in catalog module --------------> $catalogId = $arFields['ID']; $arFields = array('IBLOCK_ID' => $catalogId, 'CATALOG' => 'Y'); // get default vat $defCatVatId = 0; $dbVat = CCatalogVat::GetList(array('SORT' => 'ASC')); if ($arVat = $dbVat->Fetch()) { $defCatVatId = $arVat['ID']; unset($arVat); } unset($dbVat); $defCatVatId = intval($defCatVatId); if ($defCatVatId > 0) { $arFields['VAT_ID'] = $defCatVatId; } // add crm iblock to catalog $CCatalog = new CCatalog(); $dbRes = $CCatalog->GetList(array(), array('ID' => $catalogId), false, false, array('ID')); if (!$dbRes->Fetch()) { if ($CCatalog->Add($arFields)) { COption::SetOptionString('catalog', 'save_product_without_price', 'Y'); COption::SetOptionString('catalog', 'default_can_buy_zero', 'Y'); } else { self::RegisterError(GetMessage('CRM_ERR_REGISTER_CATALOG')); return false; } } // <------------- register in catalog module -------------- return true; }
} else { $lAdmin->AddGroupError(str_replace("#ID#", $ID, GetMessage("ERROR_UPDATE_VAT")), $ID); } } break; } } } $lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "ID", "default" => true), array("id" => "C_SORT", "content" => GetMessage("CVAT_SORT"), "sort" => "C_SORT", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("CVAT_ACTIVE"), "sort" => "ACTIVE", "default" => true), array("id" => "NAME", "content" => GetMessage("CVAT_NAME"), "sort" => "NAME", "default" => true), array("id" => "RATE", "content" => GetMessage("CVAT_RATE"), "sort" => "RATE", "default" => true))); $arSelectFields = $lAdmin->GetVisibleHeaderColumns(); if (!in_array('ID', $arSelectFields)) { $arSelectFields[] = 'ID'; } $arSelectFields = array_values($arSelectFields); $arNavParams = isset($_REQUEST["mode"]) && 'excel' == $_REQUEST["mode"] ? false : array("nPageSize" => CAdminResult::GetNavSize($sTableID)); $dbResultList = CCatalogVat::GetListEx(array($by => $order), $arFilter, false, $arNavParams, $arSelectFields); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("CVAT_NAV"))); while ($arVAT = $dbResultList->Fetch()) { $arVAT['ID'] = (int) $arVAT['ID']; $row =& $lAdmin->AddRow($arVAT['ID'], $arVAT); $row->AddField("ID", $arVAT['ID']); if ($bReadOnly) { $row->AddCheckField("ACTIVE", false); $row->AddInputField("NAME", false); $row->AddViewField("C_SORT", false); } else { $row->AddCheckField("ACTIVE"); $row->AddInputField("NAME", array("size" => 30)); $row->AddInputField("C_SORT", array("size" => 5));
} if ($shopLocalization == "ru") { $dbVat = CCatalogVat::GetListEx(array(), array('RATE' => 0), false, false, array('ID')); if (!$dbVat->Fetch()) { $arF = array("ACTIVE" => "Y", "SORT" => "100", "NAME" => Loc::getMessage("CRM_VAT_1"), "RATE" => '0'); CCatalogVat::Add($arF); } $dbVat = CCatalogVat::GetListEx(array(), array('RATE' => 18), false, false, array('ID')); if (!$dbVat->Fetch()) { $arF = array("ACTIVE" => "Y", "SORT" => "200", "NAME" => Loc::getMessage("CRM_VAT_2"), "RATE" => '18'); CCatalogVat::Add($arF); } } // get default vat $defCatVatId = 0; $dbVat = CCatalogVat::GetListEx(array('SORT' => 'ASC'), array(), false, array('nPageTop' => 1)); if ($arVat = $dbVat->Fetch()) { $defCatVatId = $arVat['ID']; } unset($arVat, $dbVat); $defCatVatId = (int) $defCatVatId; // create base price $basePriceId = 0; $basePrice = array(); $dbRes = CCatalogGroup::GetListEx(array(), array("BASE" => "Y"), false, false, array('ID')); if (!($basePrice = $dbRes->Fetch())) { $catalogGroupLangFiles = array(); foreach ($arActiveLangs as &$language) { $catalogGroupLangFiles[$language] = Loc::loadLanguageFile(__FILE__, $language); } $arFields = array();
} else { $errorMsg = GetMessage('CRM_VAT_ADD_UNKNOWN_ERROR'); } } } if (strlen($errorMsg) <= 0) { LocalRedirect(isset($_POST['apply']) ? CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_VAT_EDIT'], array('vat_id' => $vatID)) : CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_VAT_LIST'], array('vat_id' => $vatID))); } else { ShowError($errorMsg); $arVat = $fields; } } elseif ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['delete'])) { $vatID = isset($arParams['VAT_ID']) ? intval($arParams['VAT_ID']) : 0; $arVat = $vatID > 0 ? CCrmVat::GetByID($vatID) : null; if ($arVat) { if (!CCatalogVat::Delete($vatID)) { ShowError(GetMessage('CRM_VAT_DELETE_UNKNOWN_ERROR')); } } LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_VAT_LIST'], array())); } } $arResult['FIELDS'] = array(); if (strlen($arParams['VAT_ID']) > 0) { $arResult['FIELDS']['tab_1'][] = array('id' => 'ID', 'name' => GetMessage('CRM_VAT_FIELD_ID'), 'value' => $vatID, 'type' => 'label'); } $arResult['FIELDS']['tab_1'][] = array('id' => 'NAME', 'name' => GetMessage('CRM_VAT_FIELD_NAME'), 'value' => htmlspecialcharsbx($arVat['NAME']), 'type' => 'text'); $arResult['FIELDS']['tab_1'][] = array('id' => 'RATE', 'name' => GetMessage('CRM_VAT_FIELD_RATE'), 'value' => floatval($arVat['RATE']), 'type' => 'text'); $arResult['FIELDS']['tab_1'][] = array('id' => 'ACTIVE', 'name' => GetMessage('CRM_VAT_FIELD_ACTIVE'), 'value' => $arVat['ACTIVE'] == 'Y', 'type' => 'checkbox'); $arResult['FIELDS']['tab_1'][] = array('id' => 'C_SORT', 'name' => GetMessage('CRM_VAT_FIELD_C_SORT'), 'value' => intval($arVat['C_SORT']), 'type' => 'text'); $this->IncludeComponentTemplate();
public static function GetControls($strControlID = false) { $arVatList = array(); $arFilter = array(); $rsVats = CCatalogVat::GetListEx(array(), $arFilter, false, false, array('ID', 'NAME')); while ($arVat = $rsVats->Fetch()) { $arVatList[$arVat['ID']] = $arVat['NAME']; } unset($arVat, $rsVats); $arControlList = array( 'CondIBElement' => array( 'ID' => 'CondIBElement', 'PARENT' => true, 'FIELD' => 'ID', 'FIELD_TYPE' => 'int', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_ELEMENT_ID_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_ELEMENT_ID_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)), 'JS_VALUE' => array( 'type' => 'popup', 'popup_url' => '/bitrix/admin/iblock_element_search.php', 'popup_params' => array( 'lang' => LANGUAGE_ID, 'discount' => 'Y' ), 'param_id' => 'n', 'show_value' => 'Y' ), 'PHP_VALUE' => array( 'VALIDATE' => 'element' ) ), 'CondIBIBlock' => array( 'ID' => 'CondIBIBlock', 'PARENT' => true, 'FIELD' => 'IBLOCK_ID', 'FIELD_TYPE' => 'int', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_IBLOCK_ID_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_IBLOCK_ID_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)), 'JS_VALUE' => array( 'type' => 'popup', 'popup_url' => '/bitrix/admin/cat_iblock_search.php', 'popup_params' => array( 'lang' => LANGUAGE_ID, 'discount' => 'Y' ), 'param_id' => 'n', 'show_value' => 'Y' ), 'PHP_VALUE' => array( 'VALIDATE' => 'iblock' ) ), 'CondIBSection' => array( 'ID' => 'CondIBSection', 'PARENT' => false, 'FIELD' => 'SECTION_ID', 'FIELD_TYPE' => 'int', 'MULTIPLE' => 'Y', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_SECTION_ID_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_SECTION_ID_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)), 'JS_VALUE' => array( 'type' => 'popup', 'popup_url' => '/bitrix/admin/cat_section_search.php', 'popup_params' => array( 'lang' => LANGUAGE_ID, 'discount' => 'Y' ), 'param_id' => 'n', 'show_value' => 'Y' ), 'PHP_VALUE' => array( 'VALIDATE' => 'section' ) ), 'CondIBCode' => array( 'ID' => 'CondIBCode', 'PARENT' => true, 'FIELD' => 'CODE', 'FIELD_TYPE' => 'string', 'FIELD_LENGTH' => 255, 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_CODE_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_CODE_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)), 'JS_VALUE' => array( 'type' => 'input' ), 'PHP_VALUE' => '' ), 'CondIBXmlID' => array( 'ID' => 'CondIBXmlID', 'PARENT' => true, 'FIELD' => 'XML_ID', 'FIELD_TYPE' => 'string', 'FIELD_LENGTH' => 255, 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_XML_ID_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_XML_ID_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)), 'JS_VALUE' => array( 'type' => 'input' ), 'PHP_VALUE' => '' ), 'CondIBName' => array( 'ID' => 'CondIBName', 'PARENT' => true, 'FIELD' => 'NAME', 'FIELD_TYPE' => 'string', 'FIELD_LENGTH' => 255, 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_NAME_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_NAME_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)), 'JS_VALUE' => array( 'type' => 'input' ), 'PHP_VALUE' => '' ), 'CondIBActive' => array( 'ID' => 'CondIBActive', 'PARENT' => true, 'FIELD' => 'ACTIVE', 'FIELD_TYPE' => 'char', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_ACTIVE_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_ACTIVE_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)), 'JS_VALUE' => array( 'type' => 'select', 'values' => array( 'Y' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_ACTIVE_VALUE_YES'), 'N' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_ACTIVE_VALUE_NO') ) ), 'PHP_VALUE' => array( 'VALIDATE' => 'list' ) ), 'CondIBDateActiveFrom' => array( 'ID' => 'CondIBDateActiveFrom', 'PARENT' => true, 'FIELD' => 'DATE_ACTIVE_FROM', 'FIELD_TYPE' => 'datetime', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_ACTIVE_FROM_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_ACTIVE_FROM_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)), 'JS_VALUE' => array( 'type' => 'datetime', 'format' => 'datetime' ), 'PHP_VALUE' => '' ), 'CondIBDateActiveTo' => array( 'ID' => 'CondIBDateActiveTo', 'PARENT' => true, 'FIELD' => 'DATE_ACTIVE_TO', 'FIELD_TYPE' => 'datetime', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_ACTIVE_TO_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_ACTIVE_TO_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)), 'JS_VALUE' => array( 'type' => 'datetime', 'format' => 'datetime' ), 'PHP_VALUE' => '' ), 'CondIBSort' => array( 'ID' => 'CondIBSort', 'PARENT' => true, 'FIELD' => 'SORT', 'FIELD_TYPE' => 'int', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_SORT_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_SORT_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)), 'JS_VALUE' => array( 'type' => 'input' ), 'PHP_VALUE' => '' ), 'CondIBPreviewText' => array( 'ID' => 'CondIBPreviewText', 'PARENT' => true, 'FIELD' => 'PREVIEW_TEXT', 'FIELD_TYPE' => 'text', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_PREVIEW_TEXT_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_PREVIEW_TEXT_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)), 'JS_VALUE' => array( 'type' => 'input' ), 'PHP_VALUE' => '' ), 'CondIBDetailText' => array( 'ID' => 'CondIBDetailText', 'PARENT' => true, 'FIELD' => 'DETAIL_TEXT', 'FIELD_TYPE' => 'text', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DETAIL_TEXT_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DETAIL_TEXT_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)), 'JS_VALUE' => array( 'type' => 'input' ), 'PHP_VALUE' => '' ), 'CondIBDateCreate' => array( 'ID' => 'CondIBDateCreate', 'PARENT' => true, 'FIELD' => 'DATE_CREATE', 'FIELD_TYPE' => 'datetime', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_CREATE_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_CREATE_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)), 'JS_VALUE' => array( 'type' => 'datetime', 'format' => 'datetime' ), 'PHP_VALUE' => '' ), 'CondIBCreatedBy' => array( 'ID' => 'CondIBCreatedBy', 'PARENT' => true, 'FIELD' => 'CREATED_BY', 'FIELD_TYPE' => 'int', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_CREATED_BY_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_CREATED_BY_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)), 'JS_VALUE' => array( 'type' => 'input' ), 'PHP_VALUE' => array( 'VALIDATE' => 'user' ) ), 'CondIBTimestampX' => array( 'ID' => 'CondIBTimestampX', 'PARENT' => true, 'FIELD' => 'TIMESTAMP_X', 'FIELD_TYPE' => 'datetime', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_TIMESTAMP_X_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_TIMESTAMP_X_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)), 'JS_VALUE' => array( 'type' => 'datetime', 'format' => 'datetime' ), 'PHP_VALUE' => '' ), 'CondIBModifiedBy' => array( 'ID' => 'CondIBModifiedBy', 'PARENT' => true, 'FIELD' => 'MODIFIED_BY', 'FIELD_TYPE' => 'int', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_MODIFIED_BY_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_MODIFIED_BY_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)), 'JS_VALUE' => array( 'type' => 'input' ), 'PHP_VALUE' => array( 'VALIDATE' => 'user' ) ), 'CondIBTags' => array( 'ID' => 'CondIBTags', 'PARENT' => true, 'FIELD' => 'TAGS', 'FIELD_TYPE' => 'string', 'FIELD_LENGTH' => 255, 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_TAGS_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_TAGS_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)), 'JS_VALUE' => array( 'type' => 'input' ), 'PHP_VALUE' => '' ), 'CondCatQuantity' => array( 'ID' => 'CondCatQuantity', 'PARENT' => false, 'FIELD' => 'CATALOG_QUANTITY', 'FIELD_TYPE' => 'double', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_QUANTITY_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_QUANTITY_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)), 'JS_VALUE' => array( 'type' => 'input' ) ), 'CondCatWeight' => array( 'ID' => 'CondCatWeight', 'PARENT' => false, 'FIELD' => 'CATALOG_WEIGHT', 'FIELD_TYPE' => 'double', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_WEIGHT_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_WEIGHT_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)), 'JS_VALUE' => array( 'type' => 'input' ), 'PHP_VALUE' => '' ), 'CondCatVatID' => array( 'ID' => 'CondCatVatID', 'PARENT' => false, 'FIELD' => 'CATALOG_VAT_ID', 'FIELD_TYPE' => 'int', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_ID_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_ID_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)), 'JS_VALUE' => array( 'type' => 'select', 'values' => $arVatList ), 'PHP_VALUE' => array( 'VALIDATE' => 'list' ) ), 'CondCatVatIncluded' => array( 'ID' => 'CondCatVatIncluded', 'PARENT' => false, 'FIELD' => 'CATALOG_VAT_INCLUDED', 'FIELD_TYPE' => 'char', 'MULTIPLE' => 'N', 'GROUP' => 'N', 'LABEL' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_INCLUDED_LABEL'), 'PREFIX' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_INCLUDED_PREFIX'), 'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)), 'JS_VALUE' => array( 'type' => 'select', 'values' => array( 'Y' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_INCLUDED_VALUE_YES'), 'N' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_INCLUDED_VALUE_NO') ) ), 'PHP_VALUE' => array( 'VALIDATE' => 'list' ) ) ); if ($strControlID === false) { return $arControlList; } elseif (isset($arControlList[$strControlID])) { return $arControlList[$strControlID]; } else { return false; } }
function CheckTax($title, $rate) { $tax_name = $title." ".$rate."%"; if(!array_key_exists($tax_name, $this->arTaxCache)) { $rsVat = CCatalogVat::GetList( array('CSORT' => 'ASC'), array( "NAME" => $tax_name, "NAME_EXACT_MATCH" => "Y", "RATE" => $rate, ), array("ID") ); if($arVat = $rsVat->Fetch()) $this->arTaxCache[$tax_name] = $arVat["ID"]; else $this->arTaxCache[$tax_name] = CCatalogVat::Set(array( "ACTIVE" => "Y", "NAME" => $tax_name, "RATE" => $rate, )); } return $this->arTaxCache[$tax_name]; }
function CheckTax($title, $rate) { $tax_name = $title . " " . $rate . "%"; if (!array_key_exists($tax_name, $this->arTaxCache)) { $rsVat = CCatalogVat::GetListEx(array(), array("=NAME" => $tax_name, "RATE" => $rate), false, false, array("ID")); if ($arVat = $rsVat->Fetch()) { $this->arTaxCache[$tax_name] = $arVat["ID"]; } else { $this->arTaxCache[$tax_name] = CCatalogVat::Add(array("ACTIVE" => "Y", "NAME" => $tax_name, "RATE" => $rate)); } } return $this->arTaxCache[$tax_name]; }
public static function delete($params) { if (!CModule::IncludeModule('catalog')) { throw new RestException('The Commercial Catalog module is not installed.'); } global $DB, $USER; $CrmPerms = new CCrmPerms($USER->GetID()); if (!$CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE')) { throw new RestException('Access denied.'); } $ID = CCrmInvoiceRestUtil::getParamScalar($params, 'id', 0); if ($ID <= 0) { throw new RestException('Invalid identifier.'); } $DB->StartTransaction(); $catalogVat = new CCatalogVat(); $bDeleted = $catalogVat->Delete($ID); if ($bDeleted) { $DB->Commit(); } else { $DB->Rollback(); throw new RestException('Error on deleting VAT rate.'); } return $bDeleted; }