function AddLocation($arFields) { global $DB; if (!CSaleLocation::LocationCheckFields("ADD", $arFields)) { return false; } if (self::isLocationProMigrated()) { return parent::RebindLocationTriplet($arFields); } // make IX_B_SALE_LOC_CODE feel happy $arFields['CODE'] = 'randstr' . rand(999, 99999); foreach (GetModuleEvents('sale', 'OnBeforeLocationAdd', true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($arFields)) === false) { return false; } } $arInsert = $DB->PrepareInsert("b_sale_location", $arFields); $strSql = "INSERT INTO b_sale_location(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")"; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $ID = IntVal($DB->LastID()); // make IX_B_SALE_LOC_CODE feel happy Location\LocationTable::update($ID, array('CODE' => $ID)); foreach (GetModuleEvents('sale', 'OnLocationAdd', true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $arFields)); } return $ID; }