); } if ($boolLocked && $saleModulePermissions >= 'W') { $aMenu[] = array( "TEXT" => GetMessage("SOE_TO_UNLOCK"), "LINK" => "/bitrix/admin/sale_order_new.php?ID=".$ID."&unlock=Y&lang=".LANGUAGE_ID.GetFilterParams("filter_"), ); } $link = urlencode(DeleteParam(array("mode"))); $link = urlencode($APPLICATION->GetCurPage())."?mode=settings".($link <> "" ? "&".$link: ""); $bUserCanViewOrder = CSaleOrder::CanUserViewOrder($ID, $arUserGroups, $intUserID); $bUserCanEditOrder = CSaleOrder::CanUserUpdateOrder($ID, $arUserGroups, $LID); $bUserCanDeleteOrder = CSaleOrder::CanUserDeleteOrder($ID, $arUserGroups, $intUserID); $bUserCanCancelOrder = CSaleOrder::CanUserCancelOrder($ID, $arUserGroups, $intUserID); $bUserCanDeductOrder = CSaleOrder::CanUserChangeOrderFlag($ID, "PERM_DEDUCTION", $arUserGroups); $bUserCanMarkOrder = CSaleOrder::CanUserMarkOrder($ID, $arUserGroups, $intUserID); $bUserCanPayOrder = CSaleOrder::CanUserChangeOrderFlag($ID, "P", $arUserGroups); $bUserCanDeliverOrder = CSaleOrder::CanUserChangeOrderFlag($ID, "D", $arUserGroups); if ($bUserCanViewOrder && $ID > 0) { $aMenu[] = array( "TEXT" => GetMessage("NEWO_DETAIL"), "TITLE"=>GetMessage("NEWO_DETAIL_TITLE"), "LINK" => "/bitrix/admin/sale_order_detail.php?ID=".$ID."&lang=".LANGUAGE_ID.GetFilterParams("filter_") ); }
$errorMessage = ""; $bVarsFromForm = false; $PARTIAL_SUBMIT = $PARTIAL_SUBMIT == "Y" ? "Y" : "N"; if ($PARTIAL_SUBMIT == "Y") { $bVarsFromForm = true; $arInd = array(); $ids = array(); $allIDs = array(); $arIDs = explode(",", trim($_POST["BASKET_IDS"])); foreach ($arIDs as $v) { $ids[] = $v; $allIDs[] = $v; } } $bUserCanViewOrder = CSaleOrder::CanUserViewOrder($ID, $GLOBALS["USER"]->GetUserGroupArray(), $GLOBALS["USER"]->GetID()); $bUserCanEditOrder = CSaleOrder::CanUserUpdateOrder($ID, $GLOBALS["USER"]->GetUserGroupArray()); $bUserCanCancelOrder = CSaleOrder::CanUserCancelOrder($ID, $GLOBALS["USER"]->GetUserGroupArray(), $GLOBALS["USER"]->GetID()); $bUserCanPayOrder = CSaleOrder::CanUserChangeOrderFlag($ID, "P", $GLOBALS["USER"]->GetUserGroupArray()); $bUserCanDeliverOrder = CSaleOrder::CanUserChangeOrderFlag($ID, "D", $GLOBALS["USER"]->GetUserGroupArray()); $bUserCanDeleteOrder = CSaleOrder::CanUserDeleteOrder($ID, $GLOBALS["USER"]->GetUserGroupArray(), $GLOBALS["USER"]->GetID()); $simpleForm = COption::GetOptionString("sale", "lock_catalog", "Y"); $bSimpleForm = $simpleForm == "Y" ? True : False; if ($action == "update" && $saleModulePermissions >= "U" && $_SERVER["REQUEST_METHOD"] == "POST" && check_bitrix_sessid() && $bUserCanEditOrder && $PARTIAL_SUBMIT != "Y" && empty($dontsave)) { // ***************************************************************** // ***** Preparing *********************************************** // ***************************************************************** $bTrabsactionStarted = False; // Order params $currentDate = Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANG))); $dbOrderTmp = CSaleOrder::GetList(array(), array("ID" => $ID)); //GetByID($ID);
if (($arOrder['LOCK_STATUS'] == "red" && $saleModulePermissions >= "W") || $arOrder['LOCK_STATUS'] == "yellow") { $arActions[] = array( "ICON" => "unlock", "TEXT" => GetMessage("IBEL_A_UNLOCK"), "TITLE" => GetMessage("IBLOCK_UNLOCK_ALT"), "ACTION" => $lAdmin->ActionDoGroup($arOrder["ID"], "unlock", '') ); $arActions[] = array("SEPARATOR" => true); } $arActions[] = array("ICON"=>"view", "TEXT"=>GetMessage("SALE_DETAIL_DESCR"), "ACTION"=>$lAdmin->ActionRedirect("sale_order_detail.php?ID=".$f_ID."&lang=".LANGUAGE_ID.GetFilterParams("filter_")), "DEFAULT"=>true); $arActions[] = array("ICON"=>"print", "TEXT"=>GetMessage("SALE_PRINT_DESCR"), "ACTION"=>$lAdmin->ActionRedirect("sale_order_print.php?ID=".$f_ID."&lang=".LANGUAGE_ID.GetFilterParams("filter_"))); if ($arOrder['LOCK_STATUS'] != "red") { if (CSaleOrder::CanUserUpdateOrder($f_ID, $arUserGroups)) $arActions[] = array("ICON"=>"edit", "TEXT"=>GetMessage("SALE_OEDIT_DESCR"), "ACTION"=>$lAdmin->ActionRedirect("sale_order_new.php?ID=".$f_ID."&lang=".LANGUAGE_ID.GetFilterParams("filter_"))); if ($saleModulePermissions == "W" || $f_PAYED != "Y" && CSaleOrder::CanUserDeleteOrder($f_ID, $arUserGroups, $intUserID)) { $arActions[] = array("SEPARATOR" => true); $arActions[] = array("ICON"=>"delete", "TEXT"=>GetMessage("SALE_DELETE_DESCR"), "ACTION"=>"if(confirm('".GetMessage('SALE_CONFIRM_DEL_MESSAGE')."')) ".$lAdmin->ActionDoGroup($f_ID, "delete")); } } $row->AddActions($arActions); } $arFooterArray = array( array( "title" => GetMessage('SOAN_FILTERED1').":",
public static function execHandlerAction($orderId, $actionId) { global $DB, $USER; $arResult = array(); $arOrder = CSaleOrder::GetById($orderId); $handlerActions = CSaleDeliveryHandler::getActionsList($arOrder["DELIVERY_ID"]); if (!array_key_exists($actionId, $handlerActions)) { $arResult = array("RESULT" => "ERROR", "TEXT" => GetMessage("SALE_DHLP_HANDLER_HAS_NO_ACTION")); } $dt = new \Bitrix\Main\Type\DateTime(); $depList = \Bitrix\Sale\Internals\OrderDeliveryReqTable::getList(array('filter' => array('=ORDER_ID' => $orderId))); $dep = $depList->fetch(); if ($dep && !is_null($dep["DATE_REQUEST"])) { $arResult = array("RESULT" => "ERROR", "TEXT" => GetMessage("SALE_DHLP_HANDLER_REQUEST_ALREADY_SENT")); } if (empty($arResult)) { $arUserGroups = $USER->GetUserGroupArray(); $arOrder["ITEMS"] = array(); $dbItemsList = CSaleBasket::GetList(array("SET_PARENT_ID" => "DESC", "TYPE" => "DESC", "NAME" => "ASC"), array("ORDER_ID" => $orderId)); while ($arItem = $dbItemsList->GetNext()) { $arItem["DIMENSIONS"] = unserialize($arItem["~DIMENSIONS"]); unset($arItem["~DIMENSIONS"]); $arOrder["ITEMS"][] = $arItem; } $arResult = CSaleDeliveryHandler::executeAction($arOrder["DELIVERY_ID"], $actionId, $arOrder); if ($actionId == "REQUEST_SELF" && isset($arResult["TRACKING_NUMBER"])) { $bUserCanEditOrder = CSaleOrder::CanUserUpdateOrder($orderId, $arUserGroups); if ($bUserCanEditOrder) { if ($dep) { \Bitrix\Sale\Internals\OrderDeliveryReqTable::update($dep["ID"], array("DATE_REQUEST" => $dt)); } else { \Bitrix\Sale\Internals\OrderDeliveryReqTable::add(array("ORDER_ID" => $orderId, "DATE_REQUEST" => $dt)); } $fields = array(); if (isset($arResult["TRACKING_NUMBER"])) { $fields["TRACKING_NUMBER"] = $arResult["TRACKING_NUMBER"]; } if (isset($arResult["DELIVERY_DOC_NUM"])) { $fields["DELIVERY_DOC_NUM"] = $arResult["DELIVERY_DOC_NUM"]; $fields["DELIVERY_DOC_DATE"] = Date($DB->DateFormatToPHP(CLang::GetDateFormat("SHORT", $arOrder["LID"]))); } CSaleOrder::Update($orderId, $fields); } } CSaleOrderChange::AddRecord($orderId, "ORDER_DELIVERY_REQUEST_SENT", $arResult); } return $arResult; }
} else { foreach ($arOrderProps as $key => $value) { $row->AddField("PROP_" . $key, ""); } foreach ($arOrderPropsCode as $key => $value) { $row->AddField("PROP_" . $key, ""); } } $arActions = array(); if ($arOrder['LOCK_STATUS'] == "red" && $saleModulePermissions >= "W" || $arOrder['LOCK_STATUS'] == "yellow") { $arActions[] = array("ICON" => "unlock", "TEXT" => GetMessage("IBEL_A_UNLOCK"), "TITLE" => GetMessage("IBLOCK_UNLOCK_ALT"), "ACTION" => $lAdmin->ActionDoGroup($arOrder["ID"], "unlock", '')); $arActions[] = array("SEPARATOR" => true); } $arActions[] = array("ICON" => "view", "TEXT" => GetMessage("SALE_DETAIL_DESCR"), "ACTION" => $lAdmin->ActionRedirect("sale_order_detail.php?ID=" . $f_ID . "&lang=" . LANGUAGE_ID . GetFilterParams("filter_")), "DEFAULT" => true); $arActions[] = array("ICON" => "print", "TEXT" => GetMessage("SALE_PRINT_DESCR"), "ACTION" => $lAdmin->ActionRedirect("sale_order_print.php?ID=" . $f_ID . "&lang=" . LANGUAGE_ID . GetFilterParams("filter_"))); if (CSaleOrder::CanUserUpdateOrder($f_ID, $GLOBALS["USER"]->GetUserGroupArray())) { $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage("SALE_OEDIT_DESCR"), "ACTION" => $lAdmin->ActionRedirect("sale_order_new.php?ID=" . $f_ID . "&lang=" . LANGUAGE_ID . GetFilterParams("filter_"))); } if ($saleModulePermissions == "W" || $f_PAYED != "Y" && CSaleOrder::CanUserDeleteOrder($f_ID, $GLOBALS["USER"]->GetUserGroupArray(), $GLOBALS["USER"]->GetID())) { $arActions[] = array("SEPARATOR" => true); $arActions[] = array("ICON" => "delete", "TEXT" => GetMessage("SALE_DELETE_DESCR"), "ACTION" => "if(confirm('" . GetMessage('SALE_CONFIRM_DEL_MESSAGE') . "')) " . $lAdmin->ActionDoGroup($f_ID, "delete")); } $row->AddActions($arActions); } $arFooterArray = array(array("title" => GetMessage('SOAN_FILTERED1') . ":", "value" => $dbOrderList->SelectedRowsCount())); if ($saleModulePermissions == "W") { $dbOrderList = CSaleOrder::GetList(array("CURRENCY" => "ASC"), $arFilterTmp, array("CURRENCY", "SUM" => "PRICE"), false, array("CURRENCY", "SUM" => "PRICE")); while ($arOrderList = $dbOrderList->Fetch()) { $arFooterArray[] = array("title" => GetMessage("SOAN_ITOG") . " " . $arOrderList["CURRENCY"] . ":", "value" => htmlspecialcharsex(SaleFormatCurrency($arOrderList["PRICE"], $arOrderList["CURRENCY"]))); } } elseif ($saleModulePermissions < "W" && COption::GetOptionString("sale", "show_order_sum", "N") == "Y") {
} $row->AddField("DELIVERY_DOC_DATE", $fieldValue); } $row->AddViewField('BASKET_DISCOUNT_COUPON', ' '); $row->AddViewField('BASKET_DISCOUNT_NAME', ' '); $row->AddViewField("SOURCE_NAME", '<span style="white-space:nowrap;">' . htmlspecialcharsbx($arOrder["SOURCE_NAME"]) . '</span>'); $arActions = array(); if ($arOrder['LOCK_STATUS'] == "red" && $saleModulePermissions >= "W" || $arOrder['LOCK_STATUS'] == "yellow") { $arActions[] = array("ICON" => "unlock", "TEXT" => Loc::getMessage("IBEL_A_UNLOCK"), "TITLE" => Loc::getMessage("IBLOCK_UNLOCK_ALT"), "ACTION" => $lAdmin->ActionDoGroup($arOrder["ID"], "unlock", '')); $arActions[] = array("SEPARATOR" => true); } $arActions[] = array("ICON" => "view", "TEXT" => Loc::getMessage("SALE_DETAIL_DESCR"), "ACTION" => $lAdmin->ActionRedirect("sale_order_view.php?ID=" . $orderId . "&lang=" . LANGUAGE_ID . GetFilterParams("filter_")), "DEFAULT" => true); $arActions[] = array("ICON" => "copy", "TEXT" => Loc::getMessage("SOA_ORDER_COPY"), "ACTION" => $lAdmin->ActionRedirect("sale_order_create.php?ID=" . $orderId . "&lang=" . LANGUAGE_ID . "&" . 'SITE_ID=' . $arOrder['LID'] . '&' . bitrix_sessid_get() . GetFilterParams("filter_"))); $arActions[] = array("ICON" => "print", "TEXT" => Loc::getMessage("SALE_PRINT_DESCR"), "ACTION" => $lAdmin->ActionRedirect("sale_order_print.php?ID=" . $orderId . "&lang=" . LANGUAGE_ID . GetFilterParams("filter_"))); if ($arOrder['LOCK_STATUS'] != "red") { if (CSaleOrder::CanUserUpdateOrder($orderId, $arUserGroups)) { $arActions[] = array("ICON" => "edit", "TEXT" => Loc::getMessage("SALE_OEDIT_DESCR"), "ACTION" => $lAdmin->ActionRedirect("sale_order_edit.php?ID=" . $orderId . "&lang=" . LANGUAGE_ID . GetFilterParams("filter_"))); } if ($saleModulePermissions == "W" || $arOrder["PAYED"] != "Y" && CSaleOrder::CanUserDeleteOrder($orderId, $arUserGroups, $intUserID)) { $arActions[] = array("SEPARATOR" => true); $arActions[] = array("ICON" => "delete", "TEXT" => Loc::getMessage("SALE_DELETE_DESCR"), "ACTION" => "if(confirm('" . Loc::getMessage('SALE_CONFIRM_DEL_MESSAGE') . "')) " . $lAdmin->ActionDoGroup($orderId, "delete", GetFilterParams("filter_", false))); } } $row->AddActions($arActions); } } if (!empty($rowsList)) { if (in_array('BASKET_DISCOUNT_NAME', $arVisibleColumns)) { $discountList = array(); $discountsIterator = Sale\Internals\OrderRulesTable::getList(array('select' => array('ORDER_ID', 'DISCOUNT_NAME' => 'ORDER_DISCOUNT.NAME', 'DISCOUNT_ID' => 'ORDER_DISCOUNT.ID'), 'filter' => array('@ORDER_ID' => array_keys($rowsList)), 'order' => array('ORDER_ID' => 'ASC', 'ID' => 'ASC'))); while ($discount = $discountsIterator->fetch()) {