예제 #1
0
 /**
  * @param $id
  * @return Main\Entity\DeleteResult
  * @throws Main\ArgumentException
  * @throws Main\ArgumentNullException
  */
 public static function deleteWithItems($id)
 {
     $id = intval($id);
     if ($id <= 0) {
         throw new Main\ArgumentNullException("id");
     }
     $itemsList = ShipmentItemTable::getList(array("filter" => array("ORDER_DELIVERY_ID" => $id), "select" => array("ID")));
     while ($item = $itemsList->fetch()) {
         ShipmentItemTable::deleteWithItems($item["ID"]);
     }
     return ShipmentTable::delete($id);
 }
예제 #2
0
 /**
  * Perform reading main data from database, no cache is used for it
  * @throws Main\SystemException
  * @return void
  */
 protected function obtainDataOrder()
 {
     global $USER;
     $select = array('ID', 'LID', 'PERSON_TYPE_ID', 'PAYED', 'DATE_PAYED', 'EMP_PAYED_ID', 'CANCELED', 'DATE_CANCELED', 'EMP_CANCELED_ID', 'REASON_CANCELED', 'MARKED', 'DATE_MARKED', 'EMP_MARKED_ID', 'REASON_MARKED', 'STATUS_ID', 'DATE_STATUS', 'EMP_STATUS_ID', 'PRICE_DELIVERY', 'PRICE', 'CURRENCY', 'DISCOUNT_VALUE', 'USER_ID', 'DATE_INSERT', 'DATE_INSERT_FORMAT', 'DATE_UPDATE', 'USER_DESCRIPTION', 'ADDITIONAL_INFO', 'COMMENTS', 'TAX_VALUE', 'STAT_GID', 'RECURRING_ID', 'RECOUNT_FLAG', 'ORDER_TOPIC', 'ACCOUNT_NUMBER', 'XML_ID');
     $sort = array("ID" => "ASC");
     $filter = array("USER_ID" => $USER->GetID(), "ACCOUNT_NUMBER" => $this->requestData["ID"]);
     $arOrder = false;
     if ($this->options['USE_ACCOUNT_NUMBER']) {
         $res = \Bitrix\Sale\OrderTable::getList(array('filter' => $filter, 'select' => $select));
         if ($arOrder = $res->fetch()) {
             $this->requestData["ID"] = $arOrder["ID"];
         }
     }
     if (!$arOrder) {
         $filter = array("USER_ID" => $USER->GetID(), "ID" => $this->requestData["ID"]);
         $res = \Bitrix\Sale\OrderTable::getList(array('filter' => $filter, 'select' => $select));
         $arOrder = $res->fetch();
     }
     if (empty($arOrder)) {
         throw new Main\SystemException(str_replace("#ID#", $this->requestData["ID"], Localization\Loc::getMessage("SPOD_NO_ORDER")), self::E_ORDER_NOT_FOUND);
     }
     $arOShipment = array();
     $dbShipment = \Bitrix\Sale\Internals\ShipmentTable::getList(array('select' => array('DELIVERY_NAME', 'DEDUCTED', 'DATE_DEDUCTED', 'EMP_DEDUCTED_ID', 'REASON_UNDO_DEDUCTED', 'SYSTEM', 'ID', 'DELIVERY_ID', 'TRACKING_NUMBER', 'TRACKING_STATUS', 'TRACKING_DESCRIPTION', 'ALLOW_DELIVERY', 'DATE_ALLOW_DELIVERY', 'EMP_ALLOW_DELIVERY_ID', 'RESERVED', 'DELIVERY_DOC_NUM', 'DELIVERY_DOC_DATE'), 'filter' => array('ORDER_ID' => $arOrder['ID'])));
     while ($arShipment = $dbShipment->fetch()) {
         if ($arShipment['SYSTEM'] == 'Y') {
             continue;
         }
         $dbShipmentItem = \Bitrix\Sale\Internals\ShipmentItemTable::getList(array('select' => array('BASKET_ID', 'QUANTITY'), 'filter' => array('ORDER_DELIVERY_ID' => $arShipment['ID'])));
         $shipmentItems = array();
         while ($shipmentItem = $dbShipmentItem->fetch()) {
             $shipmentItem['QUANTITY'] = \Bitrix\Sale\BasketItem::formatQuantity($shipmentItem['QUANTITY']);
             $shipmentItems[$shipmentItem['BASKET_ID']] = $shipmentItem;
         }
         $arShipment['ITEMS'] = $shipmentItems;
         $arShipment['TRACKING_STATUS'] = \Bitrix\Sale\Delivery\Tracking\Manager::getStatusName($arShipment['TRACKING_STATUS']);
         $arOShipment[] = $arShipment;
     }
     $arOrder['SHIPMENT'] = $arOShipment;
     // for compatibility
     if (!empty($this->compatibilityShipmentFields) && is_array($this->compatibilityShipmentFields)) {
         foreach ($this->compatibilityShipmentFields as $shipmentField) {
             if (isset($arOShipment[0][$shipmentField])) {
                 $setFieldValue = $arOShipment[0][$shipmentField];
                 if ($setFieldValue instanceof Main\Type\Date || $setFieldValue instanceof Main\Type\DateTime) {
                     $setFieldValue = $setFieldValue->toString();
                 }
                 $arOrder[$shipmentField] = $setFieldValue;
             }
         }
     }
     //		$arOrder['DELIVERY_ID'] = $arOShipment[0]['DELIVERY_ID'];
     //		$arOrder['TRACKING_NUMBER'] = $arOShipment[0]['TRACKING_NUMBER'];
     $dbPayment = \Bitrix\Sale\Internals\PaymentTable::getList(array('select' => array('PAY_SYSTEM_NAME', 'PAID', 'ID', 'DATE_PAID', 'PAY_SYSTEM_ID', 'SUM', 'PAY_VOUCHER_NUM', 'PAY_VOUCHER_DATE', 'PS_STATUS', 'PS_STATUS_CODE', 'PS_STATUS_DESCRIPTION', 'PS_STATUS_MESSAGE', 'PS_SUM', 'PS_CURRENCY', 'PS_RESPONSE_DATE', 'DATE_PAY_BEFORE', 'DATE_BILL'), 'filter' => array('ORDER_ID' => $arOrder['ID'])));
     $arOPayment = array();
     while ($arPayment = $dbPayment->fetch()) {
         $arPayment['PAY_SYSTEM_NAME'] = htmlspecialcharsbx($arPayment['PAY_SYSTEM_NAME']);
         $arOPayment[] = $arPayment;
     }
     $arOrder['PAYMENT'] = $arOPayment;
     // for compatibility
     //		$arOrder['PAY_SYSTEM_ID'] = $arOPayment[0]['PAY_SYSTEM_ID'];
     //		$arOrder['PAY_VOUCHER_NUM'] = $arOPayment[0]['PAY_VOUCHER_NUM'];
     if (!empty($this->compatibilityPaymentFields) && is_array($this->compatibilityPaymentFields)) {
         foreach ($this->compatibilityPaymentFields as $paymentName => $paymentField) {
             $findPaymentField = $paymentField;
             if (intval($paymentName) !== $paymentName) {
                 $findPaymentField = $paymentName;
             }
             if (isset($arOPayment[0][$findPaymentField])) {
                 $setFieldValue = $arOPayment[0][$findPaymentField];
                 if ($setFieldValue instanceof Main\Type\Date || $setFieldValue instanceof Main\Type\DateTime) {
                     $setFieldValue = $setFieldValue->toString();
                 }
                 $arOrder[$paymentField] = $setFieldValue;
             }
         }
     }
     $this->dbResult = $arOrder;
 }
예제 #3
0
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/prolog.php";
$orderId = intval($_GET['ORDER_ID']);
$bUserCanViewOrder = CSaleOrder::CanUserViewOrder($orderId, $GLOBALS["USER"]->GetUserGroupArray(), $GLOBALS["USER"]->GetID());
$urlParams = '';
$errorMsg = '';
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
if ($_SERVER["REQUEST_METHOD"] == "GET" && $bUserCanViewOrder && check_bitrix_sessid()) {
    $doc = (string) $_GET['doc'];
    if (strlen($doc) == 0) {
        $errorMsg .= GetMessage("SOP_ERROR_REPORT") . '<br>';
    } else {
        if (isset($_GET['SHIPMENT_ID']) && intval($_GET['SHIPMENT_ID']) > 0) {
            $orderId = intval($_GET['ORDER_ID']);
            $shipmentId = intval($_GET['SHIPMENT_ID']);
            $params = array('select' => array('BASKET_ID', 'QUANTITY'), 'filter' => array('DELIVERY.ORDER_ID' => $orderId, 'ORDER_DELIVERY_ID' => $shipmentId));
            $items = \Bitrix\Sale\Internals\ShipmentItemTable::getList($params);
            $quantity = array();
            $basketIds = array();
            while ($item = $items->fetch()) {
                $basketIds[] = $item['BASKET_ID'];
                $quantity[] = $item['QUANTITY'];
            }
            $urlParams .= 'BASKET_IDS=' . urlencode(join(',', $basketIds)) . '&QUANTITIES=' . urlencode(join(',', $quantity));
            LocalRedirect('/bitrix/admin/sale_print.php?PROPS_ENABLE=Y&doc=' . CUtil::JSEscape($doc) . '&ORDER_ID=' . $orderId . '&' . $urlParams . '&SHIPMENT_ID=' . $shipmentId);
        } else {
            $urlParams = "SHOW_ALL=Y";
            LocalRedirect('/bitrix/admin/sale_print.php?PROPS_ENABLE=Y&doc=' . CUtil::JSEscape($doc) . '&ORDER_ID=' . $orderId . '&' . $urlParams);
        }
    }
} else {
    $errorMsg .= GetMessage('SOP_ERROR_ACCESS');
예제 #4
0
 /**
  * @param $id
  * @return array
  * @throws Main\ArgumentException
  * @throws Main\ArgumentNullException
  */
 public static function loadForShipment($id)
 {
     if (intval($id) <= 0) {
         throw new Main\ArgumentNullException("id");
     }
     $items = array();
     $itemDataList = Internals\ShipmentItemTable::getList(array('filter' => array('ORDER_DELIVERY_ID' => $id), 'order' => array('DATE_INSERT' => 'ASC', 'ID' => 'ASC')));
     while ($itemData = $itemDataList->fetch()) {
         $items[] = new static($itemData);
     }
     return $items;
 }
 /**
  * @param array $filter
  * @return \Bitrix\Main\DB\Result
  */
 public static function getList(array $filter = array())
 {
     return Internals\ShipmentItemTable::getList($filter);
 }