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; }
$strUseStoreControlBeforeSubmit = (string)Option::get('catalog', 'default_use_store_control'); $strUseStoreControl = (isset($_POST['use_store_control']) && (string)$_POST['use_store_control'] === 'Y' ? 'Y' : 'N'); if ($strUseStoreControlBeforeSubmit != $strUseStoreControl) { if ($strUseStoreControl == 'Y') { $countStores = (int)CCatalogStore::GetList(array(), array("ACTIVE" => 'Y'), array()); if ($countStores <= 0) { $arStoreFields = array("TITLE" => Loc::getMessage("CAT_STORE_NAME"), "ADDRESS" => " "); $newStoreId = CCatalogStore::Add($arStoreFields); if ($newStoreId) { CCatalogDocs::synchronizeStockQuantity($newStoreId); } else { $strWarning .= Loc::getMessage("CAT_STORE_ACTIVE_ERROR"); $strUseStoreControl = 'N'; } } else { $strWarning .= Loc::getMessage("CAT_STORE_SYNCHRONIZE_WARNING"); } } elseif($strUseStoreControl == 'N') { $strWarning .= Loc::getMessage("CAT_STORE_DEACTIVATE_NOTICE");
/** * @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;
$docId = CCatalogDocs::add($arGeneral); } $res = CIBlockElement::GetByID(intval($data[0])); if ($ar_res = $res->GetNext()) { $stock = intval($data[1]); $z++; $arAdditional = array("AMOUNT" => $stock, "ELEMENT_ID" => $ar_res["ID"], "PURCHASING_PRICE" => floatval($data[2]), "STORE_TO" => $_REQUEST["STORE_TO"] ? intval($_REQUEST["STORE_TO"]) : 1, "ENTRY_ID" => $z, "DOC_ID" => $docId); $total += $arAdditional["PURCHASING_PRICE"] * $stock; $docElementId = CCatalogStoreDocsElement::add($arAdditional); } else { $notice .= GetMessage("ELCORSO_WAREHOUSECSVIMPORT_ELEMENT") . $data[0] . ' ' . GetMessage("ELCORSO_WAREHOUSECSVIMPORT_NE_NAYDEN") . "\r\n"; } } } //CCatalogDocs::conductDocument($docId, $USER->GetID()); CCatalogDocs::update($docId, array("TOTAL" => $total)); LocalRedirect("/bitrix/admin/warehouse_import_admin.php?ID=" . $ID . "&mess=import&docId=" . $docId . "&z=" . $z . "&lang=" . LANG); fclose($handle); } } // else // { // $message = new CAdminMessage(GetMessage("ELCORSO_WAREHOUSECSVIMPORT_PUSTOY_FAYL")); // } } else { $message = new CAdminMessage(GetMessage("ELCORSO_WAREHOUSECSVIMPORT_NE_ZAGRUJEN_FAYL")); } } $APPLICATION->SetTitle(GetMessage("ELCORSO_WAREHOUSE_IMPORT_edit")); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; $aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("ELCORSO_WAREHOUSECSVIMPORT_REDAKTIROVANIE_IMPOR"), "ICON" => "main_user_edit", "TITLE" => GetMessage("ELCORSO_WAREHOUSECSVIMPORT_REDAKTIROVANIE_IMPOR")));
CCatalogStoreDocsBarcode::add(array("BARCODE" => $barCode, "DOC_ELEMENT_ID" => $docElementId)); } } } } if ($_REQUEST["save_and_conduct"]) { LocalRedirect("/bitrix/admin/cat_store_document_edit.php?lang=" . LANG . "&ID=" . $docId . "&action=conduct&sessid=" . $_REQUEST["sessid"] . "&" . GetFilterParams("filter_", false)); } } if ($docId) { LocalRedirect("/bitrix/admin/cat_store_document_list.php?lang=" . LANG . "&" . GetFilterParams("filter_", false)); } } if ($ID > 0) { $arSelect = array("ID", "SITE_ID", "DOC_TYPE", "CONTRACTOR_ID", "DATE_DOCUMENT", "CURRENCY", "STATUS"); $dbResult = CCatalogDocs::GetList(array(), array('ID' => $ID), false, false, $arSelect); if (!$dbResult->ExtractFields("str_")) { $ID = 0; } else { $docType = $str_DOC_TYPE; $bReadOnly = $str_STATUS == 'Y' ? true : $bReadOnly; } } $requiredFields = CCatalogStoreControlUtil::getFields($docType); if (!$requiredFields) { LocalRedirect("/bitrix/admin/cat_store_document_list.php?lang=" . LANG . "&" . GetFilterParams("filter_", false)); } $TAB_TITLE = GetMessage("CAT_DOC_{$docType}"); if ($ID > 0) { if ($bReadOnly) { $APPLICATION->SetTitle(str_replace("#ID#", $ID, GetMessage("CAT_DOC_TITLE_VIEW")) . ". " . $TAB_TITLE . ".");