Esempio n. 1
0
 public static function delete($primary)
 {
     $primary = Assert::expectIntegerPositive($primary, '$primary');
     $delResult = parent::delete($primary);
     // delete connected data
     if ($delResult->isSuccess()) {
         Name\TypeTable::deleteMultipleForOwner($primary);
     }
     return $delResult;
 }
Esempio n. 2
0
 public static function delete($primary)
 {
     $primary = Assert::expectIntegerPositive($primary, Loc::getMessage('SALE_LOCATION_TYPE_ENTITY_PRIMARY_FIELD'));
     $delResult = parent::delete($primary);
     // delete connected data
     if ($delResult->isSuccess()) {
         Name\TypeTable::deleteMultipleForOwner($primary);
     }
     return $delResult;
 }
Esempio n. 3
0
 public static function createTypes($types, $existed = false)
 {
     // read existed
     if ($existed === false) {
         $existed = static::getExistedTypes();
     }
     // here we try to add type names for ALL languages
     $langs = Location\Admin\NameHelper::getLanguageList();
     foreach ($types as $line) {
         // for sure
         unset($line['SELECTORLEVEL']);
         unset($line['DEFAULTSELECT']);
         $names = array();
         if (!is_array($line['NAME'])) {
             $line['NAME'] = array();
         }
         if (is_array($langs)) {
             foreach ($langs as $lid => $f) {
                 $names[ToUpper($lid)] = static::getTranslatedName($line['NAME'], $lid);
             }
         }
         if (!isset($existed[$line['CODE']])) {
             $existed[$line['CODE']] = static::createType($line);
         } else {
             // ensure it has all appropriate translations
             // we can not use ::updateMultipleForOwner() here, because user may rename his types manually
             Location\Name\TypeTable::addAbsentForOwner($existed[$line['CODE']], $names);
         }
     }
     return $existed;
 }
Esempio n. 4
0
 public static function createBaseTypes()
 {
     $types = array('COUNTRY' => array('CODE' => 'COUNTRY', 'SORT' => 100, 'DISPLAY_SORT' => 700, 'NAME' => array()), 'REGION' => array('CODE' => 'REGION', 'SORT' => 300, 'DISPLAY_SORT' => 500, 'NAME' => array()), 'CITY' => array('CODE' => 'CITY', 'SORT' => 600, 'DISPLAY_SORT' => 100, 'NAME' => array()));
     $langs = array();
     $res = \Bitrix\Main\Localization\LanguageTable::getList();
     while ($item = $res->Fetch()) {
         $MESS = array();
         @(include $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/lang/' . $item['LID'] . '/lib/location/migration/migrate.php');
         if (!empty($MESS)) {
             $types['COUNTRY']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_COUNTRY'];
             $types['REGION']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_REGION'];
             $types['CITY']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_CITY'];
         }
         $langs[$item['LID']] = true;
     }
     $typeCode2Id = array();
     $res = Location\TypeTable::getList(array('select' => array('ID', 'CODE')));
     while ($item = $res->Fetch()) {
         $typeCode2Id[$item['CODE']] = $item['ID'];
     }
     foreach ($types as $code => &$type) {
         foreach ($langs as $lid => $f) {
             $type['NAME'][$lid] = \Bitrix\Sale\Location\Admin\NameHelper::getTranslatedName($type['NAME'], $lid);
         }
         if (!isset($typeCode2Id[$type['CODE']])) {
             $typeCode2Id[$type['CODE']] = Location\TypeTable::add($type);
         } else {
             // ensure it has all appropriate translations
             // we can not use ::updateMultipleForOwner() here, because user may rename types manually
             Location\Name\TypeTable::addAbsentForOwner($typeCode2Id[$type['CODE']], $type['NAME']);
         }
     }
     return $typeCode2Id;
 }
Esempio n. 5
0
 /**
  * <p>Метод удаляет все местоположения из базы. Метод динамичный.</p> <br><br>
  *
  *
  * @return mixed 
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalelocation/csalelocation__deleteall.1cda6559.php
  * @author Bitrix
  */
 public static function DeleteAll()
 {
     global $DB;
     foreach (GetModuleEvents("sale", "OnBeforeLocationDeleteAll", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent) === false) {
             return false;
         }
     }
     if (self::isLocationProMigrated()) {
         //main
         $DB->Query("DELETE FROM " . Location\LocationTable::getTableName());
         $DB->Query("DELETE FROM " . Location\GroupTable::getTableName());
         $DB->Query("DELETE FROM " . Location\TypeTable::getTableName());
         //names
         $DB->Query("DELETE FROM " . Location\Name\LocationTable::getTableName());
         $DB->Query("DELETE FROM " . Location\Name\GroupTable::getTableName());
         $DB->Query("DELETE FROM " . Location\Name\TypeTable::getTableName());
         //links
         $DB->Query("DELETE FROM " . Location\GroupLocationTable::getTableName());
         $DB->Query("DELETE FROM " . Location\SiteLocationTable::getTableName());
         $DB->Query("DELETE FROM " . Delivery\DeliveryLocationTable::getTableName());
         //other
         $DB->Query("DELETE FROM " . Location\DefaultSiteTable::getTableName());
         $DB->Query("DELETE FROM " . Location\ExternalTable::getTableName());
         $DB->Query("DELETE FROM " . Location\ExternalServiceTable::getTableName());
     }
     $DB->Query("DELETE FROM b_sale_location2location_group");
     $DB->Query("DELETE FROM b_sale_location_group_lang");
     $DB->Query("DELETE FROM b_sale_location_group");
     $DB->Query("DELETE FROM b_sale_delivery2location");
     $DB->Query("DELETE FROM b_sale_location");
     $DB->Query("DELETE FROM b_sale_location_city_lang");
     $DB->Query("DELETE FROM b_sale_location_city");
     $DB->Query("DELETE FROM b_sale_location_country_lang");
     $DB->Query("DELETE FROM b_sale_location_country");
     $DB->Query("DELETE FROM b_sale_location_region_lang");
     $DB->Query("DELETE FROM b_sale_location_region");
     $DB->Query("DELETE FROM b_sale_location_zip");
     foreach (GetModuleEvents("sale", "OnLocationDeleteAll", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent);
     }
 }