/** * <p>Метод удаляет статус заказа с кодом ID. Если в базе есть заказы, находящиеся в этом статусе, то этот статус удалить нельзя. Метод динамичный.</p> * * * @param string $ID Код статуса заказа. </htm * * @return bool <p>Возвращается <i>true</i> в случае успешного удаления и <i>false</i> - в * противном случае.</p> <br><br> * * @static * @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalestatus/csalestatus__delete.11104aab.php * @author Bitrix */ public static function Delete($statusId) { if (!$statusId) { return false; } global $DB, $APPLICATION; $statusId = $DB->ForSql($statusId, 2); if (OrderTable::getList(array('filter' => array('=STATUS_ID' => $statusId), 'limit' => 1))->fetch()) { $APPLICATION->ThrowException(Loc::getMessage("SKGS_ERROR_DELETE"), "ERROR_DELETE_STATUS_TO_ORDER"); return false; } foreach (GetModuleEvents("sale", "OnBeforeStatusDelete", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($statusId)) === false) { return false; } } foreach (GetModuleEvents("sale", "OnStatusDelete", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($statusId)); } StatusLangTable::deleteByStatus($statusId); StatusGroupTaskTable::deleteByStatus($statusId); return StatusTable::delete($statusId)->isSuccess(); }
if ($result->isSuccess()) { if ($isNew) { CSaleStatus::CreateMailTemplate($statusId); } } if ($_POST['save']) { LocalRedirect('sale_status.php?lang=' . LANGUAGE_ID . GetFilterParams('filter_', false)); } else { LocalRedirect("sale_status_edit.php?ID=" . $statusId . "&lang=" . LANGUAGE_ID . GetFilterParams("filter_", false)); } } } else { if ($statusId) { if ($row = StatusTable::getList(array('select' => array('*'), 'filter' => array('=ID' => $statusId), 'limit' => 1))->fetch()) { $status = $row; $result = StatusLangTable::getList(array('select' => array('*'), 'filter' => array('=STATUS_ID' => $statusId))); while ($row = $result->fetch()) { $translations[$row['LID']] = $row; } $result = StatusGroupTaskTable::getList(array('select' => array('*'), 'filter' => array('=STATUS_ID' => $statusId))); while ($row = $result->fetch()) { $groupTasks[$row['GROUP_ID']] = $row; } } else { $status['ID'] = $statusId; $statusId = null; } } } // V I E W ///////////////////////////////////////////////////////////////////////////////////////////////////////////// if ($statusId) {
/** * @return array Order's statuses & flags. */ public static function getBitrixStatuses($siteId) { $result = array("CANCELED" => Loc::getMessage("SALE_EBAY_HLP_FLAG_CANCELED"), "ALLOW_DELIVERY" => Loc::getMessage("SALE_EBAY_HLP_FLAG_DELIVERY"), "PAYED" => Loc::getMessage("SALE_EBAY_HLP_FLAG_PAYED"), "DEDUCTED" => Loc::getMessage("SALE_EBAY_HLP_FLAG_DEDUCTED")); if (strlen($siteId) <= 0) { throw new ArgumentNullException("siteId"); } $dbRes = SiteTable::getList(array('filter' => array('LID' => $siteId), 'select' => array("LANGUAGE_ID"))); if ($site = $dbRes->fetch()) { $langId = $site["LANGUAGE_ID"]; } else { throw new SystemException("Site with id: \"" . $siteId . "\" not found!"); } $dbRes = StatusLangTable::getList(array('filter' => array('LID' => $langId, 'STATUS.TYPE' => 'O'), 'order' => array("STATUS.SORT" => "ASC", "NAME" => "ASC"), 'select' => array("ID" => "STATUS.ID", "NAME"))); while ($row = $dbRes->fetch()) { $result[$row['ID']] = Loc::getMessage("SALE_EBAY_HLP_STATUS") . " " . $row['NAME'] . ' [' . $row['ID'] . ']'; } return $result; }
static function install(array $data) { if (!($statusId = $data['ID']) || !is_string($statusId)) { throw new SystemException('invalid status ID', 0, __FILE__, __LINE__); } if ($languages = $data['LANG']) { unset($data['LANG']); if (!is_array($languages)) { throw new SystemException('invalid status LANG', 0, __FILE__, __LINE__); } } $data['TYPE'] = static::TYPE; // install status if it is not installed if (!StatusTable::getById($statusId)->fetch()) { StatusTable::add($data); } // install status languages if they are not installed if ($languages) { $installedLanguages = array(); $result = StatusLangTable::getList(array('select' => array('LID'), 'filter' => array('=STATUS_ID' => $statusId))); while ($row = $result->fetch()) { $installedLanguages[$row['LID']] = true; } foreach ($languages as $language) { if (!is_array($language)) { throw new SystemException('invalid status language', 0, __FILE__, __LINE__); } if (!$installedLanguages[$language['LID']]) { $language['STATUS_ID'] = $statusId; StatusLangTable::add($language); } } } }