本文整理汇总了PHP中CSaleLocation::RegionCheckFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleLocation::RegionCheckFields方法的具体用法?PHP CSaleLocation::RegionCheckFields怎么用?PHP CSaleLocation::RegionCheckFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleLocation
的用法示例。
在下文中一共展示了CSaleLocation::RegionCheckFields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UpdateRegion
/**
* The function modifies the parameters of the region
*
* @param int $ID region code
* @param array $arFields array with parameters region
* @return int $ID code region
*/
public static function UpdateRegion($ID, $arFields)
{
global $DB;
$ID = intval($ID);
if ($ID <= 0 || !CSaleLocation::RegionCheckFields("UPDATE", $arFields)) {
return false;
}
foreach (GetModuleEvents("sale", "OnBeforeRegionUpdate", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) {
return false;
}
}
$strUpdate = $DB->PrepareUpdate("b_sale_location_region", $arFields);
$strSql = "UPDATE b_sale_location_region SET " . $strUpdate . " WHERE ID = " . $ID . "";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$db_lang = CLangAdmin::GetList($b = "sort", $o = "asc", array("ACTIVE" => "Y"));
while ($arLang = $db_lang->Fetch()) {
if ($arCntLang = CSaleLocation::GetRegionLangByID($ID, $arLang["LID"])) {
$strUpdate = $DB->PrepareUpdate("b_sale_location_region_lang", $arFields[$arLang["LID"]]);
//print_r($arFields);die();
$strSql = "UPDATE b_sale_location_region_lang SET " . $strUpdate . " WHERE ID = " . $arCntLang["ID"] . "";
} else {
$arInsert = $DB->PrepareInsert("b_sale_location_region_lang", $arFields[$arLang["LID"]]);
$strSql = "INSERT INTO b_sale_location_region_lang(REGION_ID, " . $arInsert[0] . ") " . "VALUES(" . $ID . ", " . $arInsert[1] . ")";
}
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
foreach (GetModuleEvents("sale", "OnRegionUpdate", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
return $ID;
}
示例2: AddRegion
public static function AddRegion($arFields)
{
global $DB;
if (!CSaleLocation::RegionCheckFields("ADD", $arFields)) {
return false;
}
if (self::isLocationProMigrated()) {
return self::AddLocationUnattached('REGION', $arFields);
}
foreach (GetModuleEvents('sale', 'OnBeforeRegionAdd', true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($arFields)) === false) {
return false;
}
}
$arInsert = $DB->PrepareInsert("b_sale_location_region", $arFields);
$strSql = "INSERT INTO b_sale_location_region(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$ID = IntVal($DB->LastID());
$b = "sort";
$o = "asc";
$db_lang = CLangAdmin::GetList($b, $o, array("ACTIVE" => "Y"));
while ($arLang = $db_lang->Fetch()) {
if ($arFields[$arLang["LID"]]) {
$arInsert = $DB->PrepareInsert("b_sale_location_region_lang", $arFields[$arLang["LID"]]);
$strSql = "INSERT INTO b_sale_location_region_lang(REGION_ID, " . $arInsert[0] . ") " . "VALUES(" . $ID . ", " . $arInsert[1] . ")";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
}
foreach (GetModuleEvents('sale', 'OnRegionAdd', true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
return $ID;
}
示例3: UpdateRegion
public static function UpdateRegion($ID, $arFields)
{
global $DB;
$ID = intval($ID);
if ($ID <= 0 || !CSaleLocation::RegionCheckFields("UPDATE", $arFields)) {
return false;
}
foreach (GetModuleEvents("sale", "OnBeforeRegionUpdate", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) {
return false;
}
}
if (self::isLocationProMigrated()) {
try {
$locId = self::getLocationIdByRegionId($ID);
if (!$locId) {
return false;
}
$res = Location\LocationTable::update($locId, self::refineFieldsForSaveCRC($item['ID'], $arFields), array('REBALANCE' => false));
if ($res->isSuccess()) {
return $ID;
}
return false;
} catch (Exception $e) {
return false;
}
} else {
$strUpdate = $DB->PrepareUpdate("b_sale_location_region", $arFields);
$strSql = "UPDATE b_sale_location_region SET " . $strUpdate . " WHERE ID = " . $ID . "";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$db_lang = CLangAdmin::GetList($b = "sort", $o = "asc", array("ACTIVE" => "Y"));
while ($arLang = $db_lang->Fetch()) {
if ($arCntLang = CSaleLocation::GetRegionLangByID($ID, $arLang["LID"])) {
$strUpdate = $DB->PrepareUpdate("b_sale_location_region_lang", $arFields[$arLang["LID"]]);
$strSql = "UPDATE b_sale_location_region_lang SET " . $strUpdate . " WHERE ID = " . $arCntLang["ID"] . "";
} else {
$arInsert = $DB->PrepareInsert("b_sale_location_region_lang", $arFields[$arLang["LID"]]);
$strSql = "INSERT INTO b_sale_location_region_lang(REGION_ID, " . $arInsert[0] . ") " . "VALUES(" . $ID . ", " . $arInsert[1] . ")";
}
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
}
foreach (GetModuleEvents("sale", "OnRegionUpdate", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
return $ID;
}
示例4: AddRegion
/**
* The function adds a new region
*
* @param array $arFields array with parameters region
* @return int $ID code region
*/
function AddRegion($arFields)
{
global $DB;
if (!CSaleLocation::RegionCheckFields("ADD", $arFields))
return false;
$db_events = GetModuleEvents("sale", "OnBeforeRegionAdd");
while ($arEvent = $db_events->Fetch())
if (ExecuteModuleEventEx($arEvent, array($arFields))===false)
return false;
$arInsert = $DB->PrepareInsert("b_sale_location_region", $arFields);
$strSql =
"INSERT INTO b_sale_location_region(".$arInsert[0].") ".
"VALUES(".$arInsert[1].")";
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
$ID = IntVal($DB->LastID());
$db_lang = CLangAdmin::GetList(($b="sort"), ($o="asc"), array("ACTIVE" => "Y"));
while ($arLang = $db_lang->Fetch())
{
if ($arFields[$arLang["LID"]])
{
$arInsert = $DB->PrepareInsert("b_sale_location_region_lang", $arFields[$arLang["LID"]]);
$strSql =
"INSERT INTO b_sale_location_region_lang(REGION_ID, ".$arInsert[0].") ".
"VALUES(".$ID.", ".$arInsert[1].")";
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
}
}
$events = GetModuleEvents("sale", "OnRegionAdd");
while ($arEvent = $events->Fetch())
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
return $ID;
}