本文整理匯總了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);
}