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


PHP CSaleLocation::getTypes方法代码示例

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


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

示例1: saveSelectedTypes

 /**
  * A very important function. Here we decide what locations we need to take, 
  * making a descision based on $_REQUEST from sales zone selector.
  * 
  * Then we normalize the selection and store to database.
  * 
  * Also this function is used in data migrator.
  */
 public static function saveSelectedTypes($typeList, $siteId)
 {
     $types = \CSaleLocation::getTypes();
     $locations = array(Location\Connector::DB_LOCATION_FLAG => array(), Location\Connector::DB_GROUP_FLAG => array());
     if (is_array($typeList['COUNTRY']) && !empty($typeList['COUNTRY'])) {
         $typeList['COUNTRY'] = array_flip($typeList['COUNTRY']);
     }
     if (is_array($typeList['REGION']) && !empty($typeList['REGION'])) {
         $typeList['REGION'] = array_flip($typeList['REGION']);
     }
     if (is_array($typeList['CITY']) && !empty($typeList['CITY'])) {
         $typeList['CITY'] = array_flip($typeList['CITY']);
     }
     $allCountries = isset($typeList['COUNTRY']['']);
     $allRegions = isset($typeList['REGION']['']);
     $allCities = isset($typeList['CITY']['']);
     // no countries
     $noCountry = isset($typeList['COUNTRY']['NULL']);
     $noRegion = isset($typeList['REGION']['NULL']);
     // make up list of ids
     $res = Location\LocationTable::getList(array('select' => array('ID', 'COUNTRY_ID', 'REGION_ID', 'CITY_ID', 'TYPE_ID'), 'filter' => array()));
     while ($item = $res->fetch()) {
         $id = $item['ID'];
         $countryId = intval($item['COUNTRY_ID']);
         $regionId = intval($item['REGION_ID']);
         $cityId = intval($item['CITY_ID']);
         $typeId = intval($item['TYPE_ID']);
         $take = false;
         $countryTaken = false;
         $regionTaken = false;
         if ($typeId == $types['COUNTRY']) {
             if ($allCountries || isset($typeList['COUNTRY'][$countryId])) {
                 $take = true;
                 $countryTaken = true;
             }
         }
         if ($typeId == $types['REGION']) {
             if ($allRegions && $countryTaken || isset($typeList['REGION'][$regionId]) || $noCountry && !$countryId) {
                 $take = true;
                 $regionTaken = true;
             }
         }
         if ($typeId == $types['CITY']) {
             if ($allCities && $regionTaken || isset($typeList['REGION'][$regionId]) || $noRegion && !$regionId) {
                 $take = true;
             }
         }
         if (isset($typeList['CITY'][$cityId]) && $typeId == $types['CITY']) {
             // this is a city and it is in list - take it
             $take = true;
         }
         if ($take) {
             $locations[Location\Connector::DB_LOCATION_FLAG][$id] = true;
         }
     }
     // normalize
     $class = self::CONN_ENTITY_NAME . 'Table';
     $locations[Location\Connector::DB_LOCATION_FLAG] = array_keys($locations[Location\Connector::DB_LOCATION_FLAG]);
     $locations[Location\Connector::DB_LOCATION_FLAG] = $class::normalizeLocationList($locations[Location\Connector::DB_LOCATION_FLAG]);
     // store to database
     $class::resetMultipleForOwner(strlen($siteId) ? $siteId : $class::ALL_SITES, $locations);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:70,代码来源:saleszone.php


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