当前位置: 首页>>代码示例>>PHP>>正文


PHP CSaleLocation::UpdateRegion方法代码示例

本文整理汇总了PHP中CSaleLocation::UpdateRegion方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleLocation::UpdateRegion方法的具体用法?PHP CSaleLocation::UpdateRegion怎么用?PHP CSaleLocation::UpdateRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSaleLocation的用法示例。


在下文中一共展示了CSaleLocation::UpdateRegion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Update


//.........这里部分代码省略.........
  * @return int <p>Возвращается код измененного местоположения или <i>false</i> у
  * случае ошибки.</p> <a name="examples"></a>
  *
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * $arFields = array(
  *    "SORT" =&gt; 100,
  *    "COUNTRY_ID" =&gt; 8,
  *    "WITHOUT_CITY" =&gt; "N"
  * );
  * 
  * $arCity = array(
  *    "NAME" =&gt; "Kaliningrad",
  *    "SHORT_NAME" =&gt; "Kaliningrad",
  *    "ru" =&gt; array(
  *       "LID" =&gt; "ru",
  *       "NAME" =&gt; "Калининград",
  *       "SHORT_NAME" =&gt; "Калининград"
  *       ),
  *    "en" =&gt; array(
  *       "LID" =&gt; "en",
  *       "NAME" =&gt; "Kaliningrad",
  *       "SHORT_NAME" =&gt; "Kaliningrad"
  *       )
  * );
  * 
  * $arFields["CITY"] = $arCity;
  * 
  * if (!CSaleLocation::Update(6, $arFields))
  *    echo "Ошибка изменения местоположения";
  * ?&gt;
  * </pre>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalelocation/csalelocation__update.a6601f1c.php
  * @author Bitrix
  */
 public static function Update($ID, $arFields)
 {
     global $DB;
     if (!CSaleLocation::CheckFields("UPDATE", $arFields)) {
         return false;
     }
     if (!($arLocRes = CSaleLocation::GetByID($ID, LANGUAGE_ID))) {
         return false;
     }
     if ((!is_set($arFields, "COUNTRY_ID") || IntVal($arFields["COUNTRY_ID"]) <= 0) && $arFields["COUNTRY_ID"] != "") {
         $arFields["COUNTRY_ID"] = CSaleLocation::AddCountry($arFields["COUNTRY"]);
         if (IntVal($arFields["COUNTRY_ID"]) <= 0) {
             return false;
         }
         unset($arFields["CITY_ID"]);
         unset($arFields["REGION_ID"]);
         CSaleLocation::AddLocation($arFields);
     } elseif ($arFields["CHANGE_COUNTRY"] == "Y" || $arFields["COUNTRY_ID"] == "") {
         CSaleLocation::UpdateCountry($arFields["COUNTRY_ID"], $arFields["COUNTRY"]);
     }
     //city
     if ($arFields["WITHOUT_CITY"] != "Y") {
         if (IntVal($arLocRes["CITY_ID"]) > 0) {
             CSaleLocation::UpdateCity(IntVal($arLocRes["CITY_ID"]), $arFields["CITY"]);
         } else {
             $arFields["CITY_ID"] = CSaleLocation::AddCity($arFields["CITY"]);
             if (IntVal($arFields["CITY_ID"]) <= 0) {
                 return false;
             }
         }
     } else {
         CSaleLocation::DeleteCity($arLocRes["CITY_ID"]);
         $arFields["CITY_ID"] = false;
     }
     //region
     if (IntVal($arFields["REGION_ID"]) > 0) {
         CSaleLocation::UpdateRegion(IntVal($arLocRes["REGION_ID"]), $arFields["REGION"]);
     } elseif ($arFields["REGION_ID"] == 0 && $arFields["REGION_ID"] != '') {
         $db_res = CSaleLocation::GetRegionList(array("ID" => "DESC"), array("NAME" => $arFields["REGION"][LANGUAGE_ID]["NAME"]));
         $arRegion = $db_res->Fetch();
         if (count($arRegion) > 1) {
             $arFields["REGION_ID"] = $arRegion["ID"];
         } else {
             $arFields["REGION_ID"] = CSaleLocation::AddRegion($arFields["REGION"]);
             if (IntVal($arFields["REGION_ID"]) <= 0) {
                 return false;
             }
             $arFieldsTmp = $arFields;
             unset($arFieldsTmp["CITY_ID"]);
             CSaleLocation::AddLocation($arFieldsTmp);
         }
     } elseif ($arFields["REGION_ID"] == '') {
         //CSaleLocation::DeleteRegion($arLocRes["REGION_ID"]);
         $arFields["REGION_ID"] = 0;
     } else {
         unset($arFields["REGION_ID"]);
     }
     CSaleLocation::UpdateLocation($ID, $arFields);
     return $ID;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:location.php

示例2: Update

	function Update($ID, $arFields)
	{
		global $DB;

		if (!CSaleLocation::CheckFields("UPDATE", $arFields)) return false;

		if (!($arLocRes = CSaleLocation::GetByID($ID, LANGUAGE_ID))) return false;

		if(self::isLocationProMigrated())
		{
			try
			{
				// only partial support: name update functionality

				if(($arFields["CHANGE_COUNTRY"]=="Y" || intval($arFields["COUNTRY_ID"])) && is_array($arFields["COUNTRY"]))
					CSaleLocation::UpdateCountry($arFields["COUNTRY_ID"], $arFields["COUNTRY"]);

				if(intval($arFields["REGION_ID"]) && is_array($arFields["REGION"]))
					CSaleLocation::UpdateRegion($arFields["REGION_ID"], $arFields["REGION"]);

				if(intval($arFields["CITY_ID"]) && is_array($arFields["CITY"]))
					CSaleLocation::UpdateCity($arFields["CITY_ID"], $arFields["CITY"]);
			}
			catch(Exception $e)
			{
				return false;
			}
		}
		else
		{
			if ((!is_set($arFields, "COUNTRY_ID") || IntVal($arFields["COUNTRY_ID"])<=0) && $arFields["COUNTRY_ID"] != "")
			{
				$arFields["COUNTRY_ID"] = CSaleLocation::AddCountry($arFields["COUNTRY"]);
				if (IntVal($arFields["COUNTRY_ID"])<=0) return false;

				UnSet($arFields["CITY_ID"]);
				UnSet($arFields["REGION_ID"]);
				CSaleLocation::AddLocation($arFields);
			}
			elseif ($arFields["CHANGE_COUNTRY"]=="Y" || $arFields["COUNTRY_ID"] == "")
			{
				CSaleLocation::UpdateCountry($arFields["COUNTRY_ID"], $arFields["COUNTRY"]);
			}

			//city
			if ($arFields["WITHOUT_CITY"]!="Y")
			{
				if (IntVal($arLocRes["CITY_ID"])>0)
				{
					CSaleLocation::UpdateCity(IntVal($arLocRes["CITY_ID"]), $arFields["CITY"]);
				}
				else
				{
					$arFields["CITY_ID"] = CSaleLocation::AddCity($arFields["CITY"]);
					if (IntVal($arFields["CITY_ID"])<=0) return false;
				}
			}
			else
			{
				CSaleLocation::DeleteCity($arLocRes["CITY_ID"]);
				$arFields["CITY_ID"] = false;
			}

			//region
			if (IntVal($arFields["REGION_ID"])>0)
			{
				CSaleLocation::UpdateRegion(IntVal($arLocRes["REGION_ID"]), $arFields["REGION"]);
			}
			elseif ($arFields["REGION_ID"] == 0 && $arFields["REGION_ID"] != '')
			{
				$db_res = CSaleLocation::GetRegionList(array("ID" => "DESC"), array("NAME" => $arFields["REGION"][LANGUAGE_ID]["NAME"]));
				$arRegion = $db_res->Fetch();

				if (count($arRegion) > 1)
					$arFields["REGION_ID"] = $arRegion["ID"];
				else
				{
					$arFields["REGION_ID"] = CSaleLocation::AddRegion($arFields["REGION"]);
					if (IntVal($arFields["REGION_ID"])<=0)
						return false;

					$arFieldsTmp = $arFields;
					UnSet($arFieldsTmp["CITY_ID"]);
					CSaleLocation::AddLocation($arFieldsTmp);
				}
			}
			elseif ($arFields["REGION_ID"] == '')
			{
				//CSaleLocation::DeleteRegion($arLocRes["REGION_ID"]);
				$arFields["REGION_ID"] = 0;
			}
			else
			{
				UnSet($arFields["REGION_ID"]);
			}

			CSaleLocation::UpdateLocation($ID, $arFields);

			return $ID;
		}
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:1C_Bitrix_info_site,代码行数:101,代码来源:location.php


注:本文中的CSaleLocation::UpdateRegion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。