Exemple #1
0
 public static function AddLocationZIP($location, $ZIP, $bSync = false)
 {
     if (self::isLocationProMigrated()) {
         try {
             if ($bSync) {
                 $res = Location\ExternalTable::getList(array('filter' => array('=SERVICE.CODE' => self::ZIP_EXT_SERVICE_CODE, '=XML_ID' => $ZIP, '=LOCATION_ID' => $location), 'select' => array('ID'), 'limit' => 1))->fetch();
                 if ($res) {
                     if (!Location\ExternalTable::update($res['ID'], array('LOCATION_ID' => $location, 'XML_ID' => $ZIP))->isSuccess()) {
                         $bSync = false;
                     }
                 }
             }
             if (!$bSync) {
                 $zipId = self::getZipId();
                 if ($zipId) {
                     Location\ExternalTable::add(array('LOCATION_ID' => $location, 'XML_ID' => $ZIP, 'SERVICE_ID' => $zipId));
                 }
             }
         } catch (Exception $e) {
             return new DB\ArrayResult(array());
         }
     } else {
         global $DB;
         $arInsert = array("LOCATION_ID" => intval($location), "ZIP" => intval($ZIP));
         if ($bSync) {
             $cnt = $DB->Update('b_sale_location_zip', $arInsert, "WHERE LOCATION_ID='" . $arInsert["LOCATION_ID"] . "' AND ZIP='" . $arInsert["ZIP"] . "'");
             if ($cnt <= 0) {
                 $bSync = false;
             }
         }
         if (!$bSync) {
             $DB->Insert('b_sale_location_zip', $arInsert);
         }
         return;
     }
 }