static function delete($id) { global $DB; $id = intval($id); if ($id > 0) { $dbDocument = CCatalogDocs::getList(array(), array("CONTRACTOR_ID" => $id)); if ($arDocument = $dbDocument->Fetch()) { $GLOBALS["APPLICATION"]->ThrowException(Loc::getMessage("CC_CONTRACTOR_HAVE_DOCS")); return false; } return $DB->Query("DELETE FROM b_catalog_contractor WHERE ID = " . $id . " ", true); } return false; }
/** * @param $idDocument * @param int $userId * @return array|bool|string */ public static function cancellationDocument($idDocument, $userId = 0) { global $DB; $result = ''; $id = intval($idDocument); $dbDocType = CCatalogDocs::getList(array(), array("ID" => $id)); if ($arDocType = $dbDocType->Fetch()) { if ($arDocType["STATUS"] !== "Y") { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("CAT_DOC_ERROR_CANCEL_STATUS")); return false; } $documentClass = self::$types[$arDocType["DOC_TYPE"]]; $arFields = array("ID" => $id); $result = $documentClass::cancellationDocument($arFields); if ($result !== false) { $arDocFields = array("STATUS" => "N", "DATE_STATUS" => $DB->GetNowFunction()); if (intval($userId) > 0) { $arDocFields["STATUS_BY"] = intval($userId); } if (!self::Update($id, $arDocFields)) { return false; } } } return $result; }
public static function OnBeforeIBlockElementDelete($productID) { global $APPLICATION; $productID = (int) $productID; if ($productID > 0) { $dbStoreDocs = CCatalogDocs::getList(array(), array("PRODUCTS_ELEMENT_ID" => $productID, "STATUS" => "Y"), false, false, array('ID')); if ($arStoreDocs = $dbStoreDocs->fetch()) { $APPLICATION->ThrowException(GetMessage("CAT_DOC_ERROR_ELEMENT_IN_DOCUMENT")); return false; } } return true; }
if(!$requiredFields || $_REQUEST["dontsave"]) { LocalRedirect("/bitrix/admin/cat_store_document_list.php?lang=".LANGUAGE_ID."&".GetFilterParams("filter_", false)); } $sTableID = "b_catalog_store_docs_".$docType; $oSort = new CAdminSorting($sTableID, "ID", "asc"); $lAdmin = new CAdminList($sTableID, $oSort); $isDocumentConduct = false; if($ID > 0 || isset($_REQUEST["AJAX_MODE"])) { if($ID > 0) { $dbDocument = CCatalogDocs::getList(array(), array("ID" => $ID), false, false, array("DOC_TYPE", "SITE_ID", "CONTRACTOR_ID", "CURRENCY", "TOTAL", "STATUS")); if($arDocument = $dbDocument->Fetch()) { $isDocumentConduct = ($arDocument["STATUS"] == 'Y') ? true : false; $arAllDocumentElement = array(); foreach($arDocument as $key => $value) { $arResult[$key] = $value; } $arResult["DATE_DOCUMENT"] = 'now'; $arResult["CREATED_BY"] = $arResult["MODIFIED_BY"] = $USER->GetID(); $bReadOnly = ($arDocument["STATUS"] == 'Y') ? true : $bReadOnly; } } if (isset($_REQUEST["AJAX_MODE"])) {
$arUserList = array(); $strNameFormat = CSite::GetNameFormat(true); $arRows = array(); $by = ($_REQUEST["by"]) ? $_REQUEST["by"] : 'ID'; $order = ($_REQUEST["order"]) ? $_REQUEST["order"] : 'desc'; if(array_key_exists("mode", $_REQUEST) && $_REQUEST["mode"] == "excel") $arNavParams = false; else $arNavParams = array("nPageSize"=>CAdminResult::GetNavSize($sTableID)); $dbResultList = CCatalogDocs::getList( array($by => $order), $arFilter, false, $arNavParams, $arSelectFields ); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("group_admin_nav"))); while($arRes = $dbResultList->Fetch()) { $arRes['ID'] = (int)$arRes['ID']; if($arSelectFieldsMap['CREATED_BY']) { $arRes['CREATED_BY'] = (int)$arRes['CREATED_BY']; if($arRes['CREATED_BY'] > 0) $arUserID[$arRes['CREATED_BY']] = true;