case "buyer": echo Admin\Blocks\OrderBuyer::getView($saleOrder); break; case "delivery": $shipments = $saleOrder->getShipmentCollection(); $index = 0; /** @var \Bitrix\Sale\Shipment $shipment*/ foreach ($shipments as $shipment) { if (!$shipment->isSystem()) { echo Admin\Blocks\OrderShipment::getView($shipment, $index++); } } echo Admin\Blocks\OrderShipment::createNewShipmentButton(); break; case "financeinfo": echo Admin\Blocks\OrderFinanceInfo::getView($saleOrder, false); break; case "payment": $payments = $saleOrder->getPaymentCollection(); $index = 0; foreach ($payments as $payment) { echo Admin\Blocks\OrderPayment::getView($payment, $index++); } echo Admin\Blocks\OrderPayment::createButtonAddPayment('view'); break; case "additional": echo Admin\Blocks\OrderAdditional::getView($saleOrder, $formId . "_form"); break; case "basket": echo $orderBasket->getView(); echo '<div style="display: none;">' . $orderBasket->settingsDialog->getHtml() . '</div>';
protected function updatePaymentStatusAction() { global $USER; if (!isset($this->request['orderId']) || intval($this->request['orderId']) <= 0) { throw new ArgumentNullException("orderId"); } if (!isset($this->request['paymentId']) || intval($this->request['paymentId']) <= 0) { throw new ArgumentNullException("paymentId"); } $fields = array(); $orderStatusId = ''; /** @var \Bitrix\Sale\Order $order */ $order = \Bitrix\Sale\Order::load($this->request['orderId']); /** @var \Bitrix\Sale\Payment $payment */ $payment = $order->getPaymentCollection()->getItemById($this->request['paymentId']); if ($this->request['method'] == 'save') { if ($payment->getField('IS_RETURN') == 'Y') { $res = $payment->setReturn('N'); if (!$res->isSuccess()) { $this->addResultError(join("\n", $res->getErrorMessages())); } } else { $res = $payment->setPaid('Y'); if (!$res->isSuccess()) { $this->addResultError(join("\n", $res->getErrorMessages())); } } foreach ($this->request['data'] as $key => $value) { $newKey = substr($key, 0, strripos($key, '_')); if (strpos($newKey, 'PAY_VOUCHER') !== false) { $fields[$newKey] = $value; } if ($newKey == 'ORDER_STATUS_ID') { $orderStatusId = $value; } } $fields['PAY_VOUCHER_DATE'] = new \Bitrix\Main\Type\Date($fields['PAY_VOUCHER_DATE']); } else { foreach ($this->request['data'] as $key => $value) { $newKey = substr($key, 0, strripos($key, '_')); if (strpos($newKey, 'PAY_RETURN') !== false) { $fields[$newKey] = $value; } } if (isset($fields['PAY_RETURN_OPERATION_ID']) && $fields['PAY_RETURN_OPERATION_ID'] == 'RETURN') { $res = $payment->setReturn('Y'); if (!$res->isSuccess()) { $this->addResultError(join("\n", $res->getErrorMessages())); } unset($fields['PAY_RETURN_OPERATION_ID']); } else { $res = $payment->setPaid('N'); if (!$res->isSuccess()) { $this->addResultError(join("\n", $res->getErrorMessages())); } } $fields['PAY_RETURN_DATE'] = new \Bitrix\Main\Type\Date($fields['PAY_RETURN_DATE']); } $saveResult = $payment->setFields($fields); if ($saveResult->isSuccess()) { if (!empty($orderStatusId)) { if ($USER && $USER->isAuthorized()) { $statusesList = Sale\OrderStatus::getAllowedUserStatuses($USER->getID(), $order->getField('STATUS_ID')); } else { $statusesList = Sale\OrderStatus::getAllStatuses(); } if ($order->getField('STATUS_ID') != $orderStatusId && array_key_exists($orderStatusId, $statusesList)) { $res = $order->setField('STATUS_ID', $orderStatusId); if (!$res->isSuccess()) { $this->addResultError(join("\n", $res->getErrorMessages())); return; } } } $result = $order->save(); if ($result->isSuccess()) { $preparedData = \Bitrix\Sale\Helpers\Admin\Blocks\OrderFinanceInfo::prepareData($order); $preparedData["PAYMENT_PAID_" . $payment->getId()] = $payment->isPaid() ? "Y" : "N"; $this->addResultData("RESULT", $preparedData); } else { $this->addResultError(join("\n", $result->getErrorMessages())); } } else { $this->addResultError(join("\n", $saveResult->getErrorMessages())); } }
case "payment": $payments = $order->getPaymentCollection(); if (count($payments) == 0) { $order->getPaymentCollection()->createItem(); } $index = 0; foreach ($payments as $payment) { echo Blocks\OrderPayment::getEdit($payment, ++$index, $_POST['PAYMENT'][$index]); } echo Blocks\OrderPayment::createButtonAddPayment('edit'); break; case 'relprops': echo Blocks\OrderBuyer::getPropsEdit($order); break; case "financeinfo": echo Blocks\OrderFinanceInfo::getView($order); break; case "additional": echo Blocks\OrderAdditional::getEdit($order, $formId . "_form", 'ORDER'); break; case "statusorder": echo Blocks\OrderStatus::getEditSimple($USER->GetID(), 'STATUS_ID', \Bitrix\Sale\OrderStatus::getInitialStatus()); break; } $tabControl->DraggableBlockEnd(); } ?> </div> </td></tr> <?php $tabControl->EndTab();
$message = ""; foreach ($result->getErrors() as $error) { $message .= $error->getMessage() . "<br>\n"; } CAdminMessage::ShowMessage(array("TYPE" => "ERROR", "MESSAGE" => $message, "HTML" => true)); } $formId = "sale_order_edit"; $basketPrefix = "sale_order_basket"; $orderBasket = new Blocks\OrderBasket($order, "BX.Sale.Admin.OrderBasketObj", $basketPrefix); echo OrderEdit::getScripts($order, $formId); echo Blocks\OrderInfo::getScripts(); echo Blocks\OrderBuyer::getScripts(); echo Blocks\OrderPayment::getScripts(); echo Blocks\OrderAdditional::getScripts(); echo Blocks\OrderStatus::getScripts($order, $USER->GetID()); echo Blocks\OrderFinanceInfo::getScripts(); echo Blocks\OrderShipment::getScripts(); echo $orderBasket->getScripts(); // navigation echo OrderEdit::getFastNavigationHtml($fastNavItems); // yellow block with brief echo Blocks\OrderInfo::getView($order, $orderBasket); // Problem block if ($order->getField("MARKED") == "Y") { echo OrderEdit::getProblemBlockHtml($order->getField("REASON_MARKED")); } $aTabs = array(array("DIV" => "tab_order", "TAB" => Loc::getMessage("SALE_TAB_ORDER"), "SHOW_WRAP" => "N", "IS_DRAGGABLE" => "Y"), array("DIV" => "tab_analysis", "TAB" => Loc::getMessage("SALE_TAB_ANALYSIS"), "TITLE" => Loc::getMessage("SALE_TAB_ANALYSIS"))); ?> <form method="POST" action="<?php echo $APPLICATION->GetCurPage() . "?lang=" . LANGUAGE_ID . "&ID=" . $ID . "&" . $urlForm . GetFilterParams("filter_", false); ?>
<?php echo bitrix_sessid_post(); $paymentCount = 1; ?> <tr> <td> <div style="position: relative; vertical-align: top"> <?php $tabControl->DraggableBlocksStart(); ?> <?php foreach ($blocksOrder as $blockCode) { $tabControl->DraggableBlockBegin(GetMessage("SALE_BLOCK_TITLE_" . toUpper($blockCode)), $blockCode); switch ($blockCode) { case "financeinfo": echo \Bitrix\Sale\Helpers\Admin\Blocks\OrderFinanceInfo::getView($saleOrder, $new); break; case "payment": $index = 1; echo \Bitrix\Sale\Helpers\Admin\Blocks\OrderPayment::getEdit($payment, $index, $_POST['PAYMENT'][$index]); break; case "buyer": echo \Bitrix\Sale\Helpers\Admin\Blocks\OrderBuyer::getView($saleOrder); break; case "additional": echo \Bitrix\Sale\Helpers\Admin\Blocks\OrderAdditional::getEdit($payment, $tableId . "_form", 'PAYMENT[1]'); break; case "statusorder": echo \Bitrix\Sale\Helpers\Admin\Blocks\OrderStatus::getEditSimple($USER->GetID(), 'PAYMENT[1][ORDER_STATUS_ID]', $saleOrder->getField('STATUS_ID')); break; }