Example #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);
 }
Example #2
0
 static function getForShipment($shipment, $codeName, $order = null)
 {
     static $cache = array();
     if (is_numeric($shipment)) {
         $shipment = ($v = $cache[$shipment]) ? $v : ShipmentTable::getById($shipment)->fetch();
     } elseif ($shipment instanceof Shipment) {
         if (($collection = $shipment->getCollection()) && ($o = $collection->getOrder())) {
             $order = $o;
         }
         $shipment = $shipment->getFieldValues();
     }
     if (is_array($shipment)) {
         $cache[$shipment['ID']] = $shipment;
         return self::get($codeName, $order ? $order : $shipment['ORDER_ID'], null, $shipment);
     } else {
         return null;
     }
 }
Example #3
0
 /**
  * @return Entity\AddResult|Entity\UpdateResult
  * @throws Main\ArgumentOutOfRangeException
  * @throws Main\ObjectNotFoundException
  * @throws \Exception
  */
 public function save()
 {
     $id = $this->getId();
     $fields = $this->fields->getValues();
     if ($id > 0) {
         $fields = $this->fields->getChangedValues();
         if (!empty($fields) && is_array($fields)) {
             //				$fields['DATE_UPDATE'] = new Main\Type\DateTime();
             $r = Internals\ShipmentTable::update($id, $fields);
             if (!$r->isSuccess()) {
                 return $r;
             }
         }
         $result = new Entity\UpdateResult();
         if (!empty($fields['TRACKING_NUMBER'])) {
             $oldEntityValues = $this->fields->getOriginalValues();
             /** @var Main\Event $event */
             $event = new Main\Event('sale', EventActions::EVENT_ON_SHIPMENT_TRACKING_NUMBER_CHANGE, array('ENTITY' => $this, 'VALUES' => $oldEntityValues));
             $event->send();
         }
     } else {
         $fields['ORDER_ID'] = $this->getParentOrderId();
         $fields['DATE_INSERT'] = new Main\Type\DateTime();
         $fields['SYSTEM'] = $fields['SYSTEM'] ? 'Y' : 'N';
         $r = Internals\ShipmentTable::add($fields);
         if (!$r->isSuccess()) {
             return $r;
         }
         $id = $r->getId();
         $this->setFieldNoDemand('ID', $id);
         $result = new Entity\AddResult();
         /** @var ShipmentItemCollection $shipmentItemCollection */
         if (!($shipmentItemCollection = $this->getShipmentItemCollection())) {
             throw new Main\ObjectNotFoundException('Entity "ShipmentItemCollection" not found');
         }
         /** @var Shipment $shipment */
         if (!($shipment = $shipmentItemCollection->getShipment())) {
             throw new Main\ObjectNotFoundException('Entity "Shipment" not found');
         }
         /** @var ShipmentCollection $shipmentCollection */
         if (!($shipmentCollection = $shipment->getCollection())) {
             throw new Main\ObjectNotFoundException('Entity "ShipmentCollection" not found');
         }
         /** @var Order $order */
         if (!($order = $shipmentCollection->getOrder())) {
             throw new Main\ObjectNotFoundException('Entity "Order" not found');
         }
         if ($order->getId() > 0 && !$this->isSystem()) {
             OrderHistory::addAction('SHIPMENT', $order->getId(), 'SHIPMENT_ADDED', $id, $this);
         }
     }
     if ($result->isSuccess() && !$this->isSystem()) {
         $this->saveExtraServices();
         $this->saveStoreId();
     }
     /** @var ShipmentItemCollection $shipmentItemCollection */
     if (!($shipmentItemCollection = $this->getShipmentItemCollection())) {
         throw new Main\ObjectNotFoundException('Entity "ShipmentItemCollection" not found');
     }
     $r = $shipmentItemCollection->save();
     if (!$r->isSuccess()) {
         $result->addErrors($r->getErrors());
     }
     if ($result->isSuccess()) {
         /** @var Shipment $shipment */
         if (!($shipment = $shipmentItemCollection->getShipment())) {
             throw new Main\ObjectNotFoundException('Entity "Shipment" not found');
         }
         /** @var ShipmentCollection $shipmentCollection */
         if (!($shipmentCollection = $shipment->getCollection())) {
             throw new Main\ObjectNotFoundException('Entity "ShipmentCollection" not found');
         }
         /** @var Order $order */
         if (!($order = $shipmentCollection->getOrder())) {
             throw new Main\ObjectNotFoundException('Entity "Order" not found');
         }
         if (!$this->isSystem()) {
             OrderHistory::collectEntityFields('SHIPMENT', $order->getId(), $id);
         }
     }
     return $result;
 }
Example #4
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;
 }
 function InitParamArrays($arOrder, $orderID = 0, $psParams = "", $relatedData = array(), $payment = array())
 {
     if (!is_array($relatedData)) {
         $relatedData = array();
     }
     $GLOBALS["SALE_INPUT_PARAMS"] = array();
     $GLOBALS["SALE_CORRESPONDENCE"] = array();
     if (!is_array($arOrder) || count($arOrder) <= 0 || !array_key_exists("ID", $arOrder)) {
         $arOrder = array();
         $orderID = IntVal($orderID);
         if ($orderID > 0) {
             $arOrderTmp = CSaleOrder::GetByID($orderID);
         }
         if (!empty($arOrderTmp)) {
             foreach ($arOrderTmp as $k => $v) {
                 $arOrder["~" . $k] = $v;
                 $arOrder[$k] = htmlspecialcharsbx($v);
             }
         }
     } else {
         if ($orderID == 0 && $arOrder['ID'] > 0) {
             $orderID = $arOrder['ID'];
         }
     }
     if (empty($payment) && $orderID > 0) {
         $payment = \Bitrix\Sale\Internals\PaymentTable::getRow(array('select' => array('*'), 'filter' => array('ORDER_ID' => $orderID, '!PAY_SYSTEM_ID' => \Bitrix\Sale\PaySystem\Manager::getInnerPaySystemId())));
     }
     if (count($arOrder) > 0) {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"] = $arOrder;
     }
     if (!empty($payment)) {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PAYMENT_ID"] = $payment['ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~PAYMENT_ID"] = $payment['ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"] = $payment['SUM'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~SHOULD_PAY"] = $payment['SUM'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PAYED"] = $payment['PAID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~PAYED"] = $payment['PAID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PAY_SYSTEM_ID"] = $payment['PAY_SYSTEM_ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~PAY_SYSTEM_ID"] = $payment['PAY_SYSTEM_ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["ORDER_PAYMENT_ID"] = $payment['ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~ORDER_PAYMENT_ID"] = $payment['ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["PAYMENT"] = $payment;
     } else {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"] = DoubleVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PRICE"]) - DoubleVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SUM_PAID"]);
     }
     $arDateInsert = explode(" ", $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT"]);
     if (is_array($arDateInsert) && count($arDateInsert) > 0) {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT_DATE"] = $arDateInsert[0];
     } else {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT_DATE"] = $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT"];
     }
     if (!empty($payment)) {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_BILL_DATE"] = ConvertTimeStamp(MakeTimeStamp($payment["DATE_BILL"]), 'SHORT');
     }
     $userID = IntVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["USER_ID"]);
     if ($userID > 0) {
         $dbUser = CUser::GetByID($userID);
         if ($arUser = $dbUser->GetNext()) {
             $GLOBALS["SALE_INPUT_PARAMS"]["USER"] = $arUser;
         }
     }
     $arCurOrderProps = array();
     if (isset($relatedData["PROPERTIES"]) && is_array($relatedData["PROPERTIES"])) {
         $properties = $relatedData["PROPERTIES"];
         foreach ($properties as $key => $value) {
             $arCurOrderProps["~" . $key] = $value;
             $arCurOrderProps[$key] = htmlspecialcharsEx($value);
         }
     } else {
         $dbOrderPropVals = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["ID"]), false, false, array("ID", "CODE", "VALUE", "ORDER_PROPS_ID", "PROP_TYPE"));
         while ($arOrderPropVals = $dbOrderPropVals->Fetch()) {
             $arCurOrderPropsTmp = CSaleOrderProps::GetRealValue($arOrderPropVals["ORDER_PROPS_ID"], $arOrderPropVals["CODE"], $arOrderPropVals["PROP_TYPE"], $arOrderPropVals["VALUE"], LANGUAGE_ID);
             foreach ($arCurOrderPropsTmp as $key => $value) {
                 $arCurOrderProps["~" . $key] = $value;
                 $arCurOrderProps[$key] = htmlspecialcharsEx($value);
             }
         }
     }
     if (count($arCurOrderProps) > 0) {
         $GLOBALS["SALE_INPUT_PARAMS"]["PROPERTY"] = $arCurOrderProps;
     }
     $shipment = \Bitrix\Sale\Internals\ShipmentTable::getRow(array('select' => array('DELIVERY_ID'), 'filter' => array('ORDER_ID' => $orderID, 'SYSTEM' => 'N')));
     if ($shipment) {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DELIVERY_ID"] = $shipment['DELIVERY_ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~DELIVERY_ID"] = $shipment['DELIVERY_ID'];
     }
     $paySystemId = '';
     if ($payment && $payment['PAY_SYSTEM_ID'] > 0) {
         $paySystemId = $payment['PAY_SYSTEM_ID'];
     } elseif (isset($arOrder['PAY_SYSTEM_ID']) && $arOrder['PAY_SYSTEM_ID'] > 0) {
         $paySystemId = $arOrder['PAY_SYSTEM_ID'];
     } else {
         $psParams = unserialize($psParams);
         if (isset($psParams['BX_PAY_SYSTEM_ID'])) {
             $paySystemId = $psParams['BX_PAY_SYSTEM_ID']['VALUE'];
         }
     }
     if ($paySystemId !== '') {
         if (!isset($arOrder['PERSON_TYPE_ID']) || $arOrder['PERSON_TYPE_ID'] <= 0) {
             // for crm quote compatibility
             $personTypes = CSalePaySystem::getPaySystemPersonTypeIds($paySystemId);
             $personTypeId = array_shift($personTypes);
         } else {
             $personTypeId = $arOrder['PERSON_TYPE_ID'];
         }
         $params = CSalePaySystemAction::getParamsByConsumer('PAYSYSTEM_' . $paySystemId, $personTypeId);
         foreach ($params as $key => $value) {
             $params[$key]['~VALUE'] = htmlspecialcharsbx($value['VALUE']);
         }
         $GLOBALS["SALE_CORRESPONDENCE"] = $params;
     }
     if ($payment['COMPANY_ID'] > 0) {
         if (!array_key_exists('COMPANY', $GLOBALS["SALE_INPUT_PARAMS"])) {
             $GLOBALS["SALE_INPUT_PARAMS"]["COMPANY"] = array();
         }
         global $USER_FIELD_MANAGER;
         $userFieldsList = $USER_FIELD_MANAGER->GetUserFields(\Bitrix\Sale\Internals\CompanyTable::getUfId(), null, LANGUAGE_ID);
         foreach ($userFieldsList as $key => $userField) {
             $value = $USER_FIELD_MANAGER->GetUserFieldValue(\Bitrix\Sale\Internals\CompanyTable::getUfId(), $key, $payment['COMPANY_ID']);
             $GLOBALS["SALE_INPUT_PARAMS"]["COMPANY"][$key] = $value;
             $GLOBALS["SALE_INPUT_PARAMS"]["COMPANY"]["~" . $key] = $value;
         }
         $companyFieldList = \Bitrix\Sale\Internals\CompanyTable::getRowById($payment['COMPANY_ID']);
         foreach ($companyFieldList as $key => $value) {
             $GLOBALS["SALE_INPUT_PARAMS"]["COMPANY"][$key] = $value;
             $GLOBALS["SALE_INPUT_PARAMS"]["COMPANY"]["~" . $key] = $value;
         }
     }
     // fields with no interface
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_STREET']["TYPE"] = 'PROPERTY';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_STREET']["VALUE"] = 'LOCATION_STREET';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_STREET']["~VALUE"] = 'LOCATION_STREET';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_VILLAGE']["TYPE"] = 'PROPERTY';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_VILLAGE']["VALUE"] = 'LOCATION_VILLAGE';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_VILLAGE']["~VALUE"] = 'LOCATION_VILLAGE';
     $GLOBALS["SALE_CORRESPONDENCE"]['ORDER_PAYMENT_ID']["TYPE"] = 'ORDER';
     $GLOBALS["SALE_CORRESPONDENCE"]['ORDER_PAYMENT_ID']["VALUE"] = 'PAYMENT_ID';
     $GLOBALS["SALE_CORRESPONDENCE"]['ORDER_PAYMENT_ID']["~VALUE"] = 'PAYMENT_ID';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYED']["TYPE"] = 'ORDER';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYED']["VALUE"] = 'PAYED';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYED']["~VALUE"] = 'PAYED';
     if (isset($relatedData["BASKET_ITEMS"]) && is_array($relatedData["BASKET_ITEMS"])) {
         $GLOBALS["SALE_INPUT_PARAMS"]["BASKET_ITEMS"] = $relatedData["BASKET_ITEMS"];
     }
     if (isset($relatedData["TAX_LIST"]) && is_array($relatedData["TAX_LIST"])) {
         $GLOBALS["SALE_INPUT_PARAMS"]["TAX_LIST"] = $relatedData["TAX_LIST"];
     }
     if (isset($relatedData["REQUISITE"]) && is_array($relatedData["REQUISITE"])) {
         $GLOBALS["SALE_INPUT_PARAMS"]["REQUISITE"] = $relatedData["REQUISITE"];
         self::$relatedData['REQUISITE'] = array('GET_INSTANCE_VALUE' => function ($providerInstance, $providerValue, $personTypeId) {
             return $GLOBALS['SALE_INPUT_PARAMS']['REQUISITE'][$providerValue];
         });
     }
     if (isset($relatedData["BANK_DETAIL"]) && is_array($relatedData["BANK_DETAIL"])) {
         $GLOBALS["SALE_INPUT_PARAMS"]["BANK_DETAIL"] = $relatedData["BANK_DETAIL"];
         self::$relatedData['BANK_DETAIL'] = array('GET_INSTANCE_VALUE' => function ($providerInstance, $providerValue, $personTypeId) {
             return $GLOBALS['SALE_INPUT_PARAMS']['BANK_DETAIL'][$providerValue];
         });
     }
     if (isset($relatedData["CRM_COMPANY"]) && is_array($relatedData["CRM_COMPANY"])) {
         $GLOBALS["SALE_INPUT_PARAMS"]["CRM_COMPANY"] = $relatedData["CRM_COMPANY"];
         self::$relatedData['CRM_COMPANY'] = array('GET_INSTANCE_VALUE' => function ($providerInstance, $providerValue, $personTypeId) {
             return $GLOBALS['SALE_INPUT_PARAMS']['CRM_COMPANY'][$providerValue];
         });
     }
     if (isset($relatedData["CRM_CONTACT"]) && is_array($relatedData["CRM_CONTACT"])) {
         $GLOBALS["SALE_INPUT_PARAMS"]["CRM_CONTACT"] = $relatedData["CRM_CONTACT"];
         self::$relatedData['CRM_CONTACT'] = array('GET_INSTANCE_VALUE' => function ($providerInstance, $providerValue, $personTypeId) {
             return $GLOBALS['SALE_INPUT_PARAMS']['CRM_CONTACT'][$providerValue];
         });
     }
     if (isset($relatedData["MC_REQUISITE"]) && is_array($relatedData["MC_REQUISITE"])) {
         $GLOBALS["SALE_INPUT_PARAMS"]["MC_REQUISITE"] = $relatedData["MC_REQUISITE"];
         self::$relatedData['MC_REQUISITE'] = array('GET_INSTANCE_VALUE' => function ($providerInstance, $providerValue, $personTypeId) {
             return $GLOBALS['SALE_INPUT_PARAMS']['MC_REQUISITE'][$providerValue];
         });
     }
     if (isset($relatedData["MC_BANK_DETAIL"]) && is_array($relatedData["MC_BANK_DETAIL"])) {
         $GLOBALS["SALE_INPUT_PARAMS"]["MC_BANK_DETAIL"] = $relatedData["MC_BANK_DETAIL"];
         self::$relatedData['MC_BANK_DETAIL'] = array('GET_INSTANCE_VALUE' => function ($providerInstance, $providerValue, $personTypeId) {
             return $GLOBALS['SALE_INPUT_PARAMS']['MC_BANK_DETAIL'][$providerValue];
         });
     }
     if (isset($relatedData["CRM_MYCOMPANY"]) && is_array($relatedData["CRM_MYCOMPANY"])) {
         $GLOBALS["SALE_INPUT_PARAMS"]["CRM_MYCOMPANY"] = $relatedData["CRM_MYCOMPANY"];
         self::$relatedData['CRM_MYCOMPANY'] = array('GET_INSTANCE_VALUE' => function ($providerInstance, $providerValue, $personTypeId) {
             return $GLOBALS['SALE_INPUT_PARAMS']['CRM_MYCOMPANY'][$providerValue];
         });
     }
     if ($relatedData) {
         $eventManager = \Bitrix\Main\EventManager::getInstance();
         $eventManager->addEventHandler('sale', 'OnGetBusinessValueProviders', array('\\CSalePaySystemAction', 'getProviders'));
     }
 }
Example #6
0
    function ExportOrders2Xml($arFilter = array(), $nTopCount = 0, $currency = "", $crmMode = false, $time_limit = 0, $version = false, $arOptions = array())
    {
        global $DB;
        $count = false;
        if (IntVal($nTopCount) > 0) {
            $count = array("nTopCount" => $nTopCount);
        }
        $bNewVersion = strlen($version) > 0;
        $bExportFromCrm = isset($arOptions["EXPORT_FROM_CRM"]) && $arOptions["EXPORT_FROM_CRM"] === "Y";
        if (IntVal($time_limit) > 0) {
            //This is an optimization. We assume than no step can take more than one year.
            if ($time_limit > 0) {
                $end_time = time() + $time_limit;
            } else {
                $end_time = time() + 365 * 24 * 3600;
            }
            // One year
            //$version
            $lastOrderPrefix = "LAST_ORDER_ID";
            if ($crmMode) {
                $lastOrderPrefix = md5(serialize($arFilter));
                if (!empty($_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix]) && IntVal($nTopCount) > 0) {
                    $count["nTopCount"] = $count["nTopCount"] + count($_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix]);
                }
            } else {
                if (IntVal($_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix]) > 0) {
                    $arFilter["<ID"] = $_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix];
                }
            }
        }
        $arResultStat = array("ORDERS" => 0, "CONTACTS" => 0, "COMPANIES" => 0);
        $accountNumberPrefix = COption::GetOptionString("sale", "1C_SALE_ACCOUNT_NUMBER_SHOP_PREFIX", "");
        $dbPaySystem = CSalePaySystem::GetList(array("ID" => "ASC"), array("ACTIVE" => "Y"), false, false, array("ID", "NAME", "ACTIVE"));
        while ($arPaySystem = $dbPaySystem->Fetch()) {
            $paySystems[$arPaySystem["ID"]] = $arPaySystem["NAME"];
        }
        $dbDelivery = CSaleDelivery::GetList(array("ID" => "ASC"), array("ACTIVE" => "Y"), false, false, array("ID", "NAME", "ACTIVE"));
        while ($arDelivery = $dbDelivery->Fetch()) {
            $delivery[$arDelivery["ID"]] = $arDelivery["NAME"];
        }
        $rsDeliveryHandlers = CSaleDeliveryHandler::GetAdminList(array("SID" => "ASC"));
        while ($arHandler = $rsDeliveryHandlers->Fetch()) {
            if (is_array($arHandler["PROFILES"])) {
                foreach ($arHandler["PROFILES"] as $k => $v) {
                    $delivery[$arHandler["SID"] . ":" . $k] = $v["TITLE"] . " (" . $arHandler["NAME"] . ")";
                }
            }
        }
        $arStore = array();
        $arMeasures = array();
        if (CModule::IncludeModule("catalog")) {
            $dbList = CCatalogStore::GetList(array("SORT" => "DESC", "ID" => "ASC"), array("ACTIVE" => "Y", "ISSUING_CENTER" => "Y"), false, false, array("ID", "SORT", "TITLE", "ADDRESS", "DESCRIPTION", "PHONE", "EMAIL", "XML_ID"));
            while ($arStoreTmp = $dbList->Fetch()) {
                if (strlen($arStoreTmp["XML_ID"]) <= 0) {
                    $arStoreTmp["XML_ID"] = $arStoreTmp["ID"];
                }
                $arStore[$arStoreTmp["ID"]] = $arStoreTmp;
            }
            $dbList = CCatalogMeasure::getList(array(), array(), false, false, array("CODE", "MEASURE_TITLE"));
            while ($arList = $dbList->Fetch()) {
                $arMeasures[$arList["CODE"]] = $arList["MEASURE_TITLE"];
            }
        }
        if (empty($arMeasures)) {
            $arMeasures[796] = GetMessage("SALE_EXPORT_SHTUKA");
        }
        $dbExport = CSaleExport::GetList();
        while ($arExport = $dbExport->Fetch()) {
            $arAgent[$arExport["PERSON_TYPE_ID"]] = unserialize($arExport["VARS"]);
        }
        $dateFormat = CSite::GetDateFormat("FULL");
        if ($crmMode) {
            echo "<" . "?xml version=\"1.0\" encoding=\"UTF-8\"?" . ">\n";
            $arCharSets = array();
            $dbSitesList = CSite::GetList($b = "", $o = "");
            while ($arSite = $dbSitesList->Fetch()) {
                $arCharSets[$arSite["ID"]] = $arSite["CHARSET"];
            }
        } else {
            echo "<" . "?xml version=\"1.0\" encoding=\"windows-1251\"?" . ">\n";
        }
        ?>
		<<?php 
        echo GetMessage("SALE_EXPORT_COM_INFORMATION");
        ?>
 <?php 
        echo GetMessage("SALE_EXPORT_SHEM_VERSION");
        ?>
="<?php 
        echo $bNewVersion ? "2.08" : "2.05";
        ?>
" <?php 
        echo GetMessage("SALE_EXPORT_SHEM_DATE_CREATE");
        ?>
="<?php 
        echo date("Y-m-d");
        ?>
T<?php 
        echo date("G:i:s");
        ?>
" <?php 
        echo GetMessage("SALE_EXPORT_DATE_FORMAT");
        ?>
="<?php 
        echo GetMessage("SALE_EXPORT_DATE_FORMAT_DF");
        ?>
=yyyy-MM-dd; <?php 
        echo GetMessage("SALE_EXPORT_DATE_FORMAT_DLF");
        ?>
=DT" <?php 
        echo GetMessage("SALE_EXPORT_DATE_FORMAT_DATETIME");
        ?>
="<?php 
        echo GetMessage("SALE_EXPORT_DATE_FORMAT_DF");
        ?>
=<?php 
        echo GetMessage("SALE_EXPORT_DATE_FORMAT_TIME");
        ?>
; <?php 
        echo GetMessage("SALE_EXPORT_DATE_FORMAT_DLF");
        ?>
=T" <?php 
        echo GetMessage("SALE_EXPORT_DEL_DT");
        ?>
="T" <?php 
        echo GetMessage("SALE_EXPORT_FORM_SUMM");
        ?>
="<?php 
        echo GetMessage("SALE_EXPORT_FORM_CC");
        ?>
=18; <?php 
        echo GetMessage("SALE_EXPORT_FORM_CDC");
        ?>
=2; <?php 
        echo GetMessage("SALE_EXPORT_FORM_CRD");
        ?>
=." <?php 
        echo GetMessage("SALE_EXPORT_FORM_QUANT");
        ?>
="<?php 
        echo GetMessage("SALE_EXPORT_FORM_CC");
        ?>
=18; <?php 
        echo GetMessage("SALE_EXPORT_FORM_CDC");
        ?>
=2; <?php 
        echo GetMessage("SALE_EXPORT_FORM_CRD");
        ?>
=.">
		<?php 
        $arOrder = array("ID" => "DESC");
        if ($crmMode) {
            $arOrder = array("DATE_UPDATE" => "ASC");
        }
        $arSelect = array("ID", "LID", "PERSON_TYPE_ID", "PAYED", "DATE_PAYED", "EMP_PAYED_ID", "CANCELED", "DATE_CANCELED", "EMP_CANCELED_ID", "REASON_CANCELED", "STATUS_ID", "DATE_STATUS", "PAY_VOUCHER_NUM", "PAY_VOUCHER_DATE", "EMP_STATUS_ID", "PRICE_DELIVERY", "ALLOW_DELIVERY", "DATE_ALLOW_DELIVERY", "EMP_ALLOW_DELIVERY_ID", "PRICE", "CURRENCY", "DISCOUNT_VALUE", "SUM_PAID", "USER_ID", "PAY_SYSTEM_ID", "DELIVERY_ID", "DATE_INSERT", "DATE_INSERT_FORMAT", "DATE_UPDATE", "USER_DESCRIPTION", "ADDITIONAL_INFO", "PS_STATUS", "PS_STATUS_CODE", "PS_STATUS_DESCRIPTION", "PS_STATUS_MESSAGE", "PS_SUM", "PS_CURRENCY", "PS_RESPONSE_DATE", "COMMENTS", "TAX_VALUE", "STAT_GID", "RECURRING_ID", "ACCOUNT_NUMBER", "SUM_PAID", "DELIVERY_DOC_DATE", "DELIVERY_DOC_NUM", "TRACKING_NUMBER", "STORE_ID", "ID_1C", "VERSION");
        $bCrmModuleIncluded = false;
        if ($bExportFromCrm) {
            $arSelect[] = "UF_COMPANY_ID";
            $arSelect[] = "UF_CONTACT_ID";
            if (IsModuleInstalled("crm") && CModule::IncludeModule("crm")) {
                $bCrmModuleIncluded = true;
            }
        }
        $dbOrderList = CSaleOrder::GetList($arOrder, $arFilter, false, $count, $arSelect);
        while ($arOrder = $dbOrderList->Fetch()) {
            if ($crmMode) {
                if ($bNewVersion && is_array($_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix]) && in_array($arOrder["ID"], $_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix]) && empty($arFilter["ID"])) {
                    continue;
                }
                ob_start();
            }
            $arResultStat["ORDERS"]++;
            $agentParams = $arAgent[$arOrder["PERSON_TYPE_ID"]];
            $arProp = array();
            $arProp["ORDER"] = $arOrder;
            if (IntVal($arOrder["USER_ID"]) > 0) {
                $dbUser = CUser::GetByID($arOrder["USER_ID"]);
                if ($arUser = $dbUser->Fetch()) {
                    $arProp["USER"] = $arUser;
                }
            }
            if ($bExportFromCrm) {
                $arProp["CRM"] = array();
                $companyID = isset($arOrder["UF_COMPANY_ID"]) ? intval($arOrder["UF_COMPANY_ID"]) : 0;
                $contactID = isset($arOrder["UF_CONTACT_ID"]) ? intval($arOrder["UF_CONTACT_ID"]) : 0;
                if ($companyID > 0) {
                    $arProp["CRM"]["CLIENT_ID"] = "CRMCO" . $companyID;
                } else {
                    $arProp["CRM"]["CLIENT_ID"] = "CRMC" . $contactID;
                }
                $clientInfo = array("LOGIN" => "", "NAME" => "", "LAST_NAME" => "", "SECOND_NAME" => "");
                if ($bCrmModuleIncluded) {
                    if ($companyID > 0) {
                        $arCompanyFilter = array('=ID' => $companyID);
                        $dbCompany = CCrmCompany::GetListEx(array(), $arCompanyFilter, false, array("nTopCount" => 1), array("TITLE"));
                        $arCompany = $dbCompany->Fetch();
                        unset($dbCompany, $arCompanyFilter);
                        if (is_array($arCompany)) {
                            if (isset($arCompany["TITLE"])) {
                                $clientInfo["NAME"] = $arCompany["TITLE"];
                            }
                        }
                        unset($arCompany);
                    } else {
                        if ($contactID > 0) {
                            $arContactFilter = array('=ID' => $contactID);
                            $dbContact = CCrmContact::GetListEx(array(), $arContactFilter, false, array("nTopCount" => 1), array("NAME", "LAST_NAME", "SECOND_NAME"));
                            $arContact = $dbContact->Fetch();
                            unset($dbContact, $arContactFilter);
                            if (is_array($arContact)) {
                                if (isset($arContact["NAME"])) {
                                    $clientInfo["NAME"] = $arContact["NAME"];
                                }
                                if (isset($arContact["LAST_NAME"])) {
                                    $clientInfo["LAST_NAME"] = $arContact["LAST_NAME"];
                                }
                                if (isset($arContact["SECOND_NAME"])) {
                                    $clientInfo["SECOND_NAME"] = $arContact["SECOND_NAME"];
                                }
                            }
                            unset($arContact);
                        }
                    }
                }
                $arProp["CRM"]["CLIENT"] = $clientInfo;
                unset($clientInfo);
            }
            if (IntVal($arOrder["PAY_SYSTEM_ID"]) > 0) {
                $arProp["ORDER"]["PAY_SYSTEM_NAME"] = $paySystems[$arOrder["PAY_SYSTEM_ID"]];
            }
            if (strlen($arOrder["DELIVERY_ID"]) > 0) {
                $arProp["ORDER"]["DELIVERY_NAME"] = $delivery[$arOrder["DELIVERY_ID"]];
            }
            $dbOrderPropVals = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $arOrder["ID"]), false, false, array("ID", "CODE", "VALUE", "ORDER_PROPS_ID", "PROP_TYPE"));
            $locationStreetPropertyValue = '';
            while ($arOrderPropVals = $dbOrderPropVals->Fetch()) {
                if ($arOrderPropVals["PROP_TYPE"] == "CHECKBOX") {
                    if ($arOrderPropVals["VALUE"] == "Y") {
                        $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = "true";
                    } else {
                        $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = "false";
                    }
                } elseif ($arOrderPropVals["PROP_TYPE"] == "TEXT" || $arOrderPropVals["PROP_TYPE"] == "TEXTAREA") {
                    $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $arOrderPropVals["VALUE"];
                } elseif ($arOrderPropVals["PROP_TYPE"] == "SELECT" || $arOrderPropVals["PROP_TYPE"] == "RADIO") {
                    $arVal = CSaleOrderPropsVariant::GetByValue($arOrderPropVals["ORDER_PROPS_ID"], $arOrderPropVals["VALUE"]);
                    $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $arVal["NAME"];
                } elseif ($arOrderPropVals["PROP_TYPE"] == "MULTISELECT") {
                    $curVal = explode(",", $arOrderPropVals["VALUE"]);
                    foreach ($curVal as $vm) {
                        $arVal = CSaleOrderPropsVariant::GetByValue($arOrderPropVals["ORDER_PROPS_ID"], $vm);
                        $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] .= ", " . $arVal["NAME"];
                    }
                    $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = substr($arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]], 2);
                } elseif ($arOrderPropVals["PROP_TYPE"] == "LOCATION") {
                    $arVal = CSaleLocation::GetByID($arOrderPropVals["VALUE"], LANGUAGE_ID);
                    if (CSaleLocation::isLocationProEnabled()) {
                        if (intval($arVal['ID'])) {
                            try {
                                $res = \Bitrix\Sale\Location\LocationTable::getPathToNode($arVal['ID'], array('select' => array('LNAME' => 'NAME.NAME', 'TYPE_ID'), 'filter' => array('=NAME.LANGUAGE_ID' => LANGUAGE_ID)));
                                $types = \Bitrix\Sale\Location\Admin\TypeHelper::getTypeCodeIdMapCached();
                                $path = array();
                                while ($item = $res->fetch()) {
                                    // copy street to STREET property
                                    if ($types['ID2CODE'][$item['TYPE_ID']] == 'STREET') {
                                        $locationStreetPropertyValue = $item['LNAME'];
                                    }
                                    $path[] = $item['LNAME'];
                                }
                                $locationString = implode(' - ', $path);
                            } catch (\Bitrix\Main\SystemException $e) {
                                $locationString = '';
                            }
                        } else {
                            $locationString = '';
                        }
                    } else {
                        $locationString = $arVal["COUNTRY_NAME"] . (strlen($arVal["COUNTRY_NAME"]) <= 0 || strlen($arVal["REGION_NAME"]) <= 0 ? "" : " - ") . $arVal["REGION_NAME"] . (strlen($arVal["COUNTRY_NAME"]) <= 0 || strlen($arVal["CITY_NAME"]) <= 0 ? "" : " - ") . $arVal["CITY_NAME"];
                    }
                    $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $locationString;
                    $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"] . "_CITY"] = $arVal["CITY_NAME"];
                    $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"] . "_COUNTRY"] = $arVal["COUNTRY_NAME"];
                    $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"] . "_REGION"] = $arVal["REGION_NAME"];
                } else {
                    $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $arOrderPropVals["VALUE"];
                }
            }
            $resShipment = \Bitrix\Sale\Internals\ShipmentTable::getList(array('select' => array('DELIVERY_ID', 'ALLOW_DELIVERY', 'DEDUCTED', 'DATE_ALLOW_DELIVERY', 'DATE_DEDUCTED'), 'filter' => array('ORDER_ID' => $arOrder['ID'], '=SYSTEM' => 'N'), 'limit' => array(1)));
            $arShipment = $resShipment->fetch();
            $resPayment = \Bitrix\Sale\Internals\PaymentTable::getList(array('select' => array('PAY_VOUCHER_NUM', 'PAY_SYSTEM_ID', 'PAY_VOUCHER_DATE'), 'filter' => array('ORDER_ID' => $arOrder['ID'], '!PAY_SYSTEM_ID' => \Bitrix\Sale\Internals\PaySystemInner::getId()), 'limit' => array(1)));
            $arPayment = $resPayment->fetch();
            foreach ($agentParams as $k => $v) {
                if (strpos($k, "REKV_") !== false) {
                    if (!is_array($v)) {
                        $agent["REKV"][$k] = $v;
                    } else {
                        if (strlen($v["TYPE"]) <= 0) {
                            $agent["REKV"][$k] = $v["VALUE"];
                        } else {
                            $agent["REKV"][$k] = $arProp[$v["TYPE"]][$v["VALUE"]];
                        }
                    }
                } else {
                    if (!is_array($v)) {
                        $agent[$k] = $v;
                    } else {
                        if (strlen($v["TYPE"]) <= 0) {
                            $agent[$k] = $v["VALUE"];
                        } else {
                            $agent[$k] = $arProp[$v["TYPE"]][$v["VALUE"]];
                        }
                        if ($k == 'STREET' && strlen($locationStreetPropertyValue)) {
                            $agent[$k] = $locationStreetPropertyValue . (strlen($agent[$k]) ? ', ' : '') . $agent[$k];
                        }
                    }
                }
            }
            ?>
			<<?php 
            echo GetMessage("SALE_EXPORT_DOCUMENT");
            ?>
>
				<<?php 
            echo GetMessage("SALE_EXPORT_ID");
            ?>
><?php 
            echo $arOrder["ID"];
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_ID");
            ?>
>
				<<?php 
            echo GetMessage("SALE_EXPORT_NUMBER");
            ?>
><?php 
            echo $accountNumberPrefix . $arOrder["ACCOUNT_NUMBER"];
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_NUMBER");
            ?>
>
				<<?php 
            echo GetMessage("SALE_EXPORT_DATE");
            ?>
><?php 
            echo $DB->FormatDate($arOrder["DATE_INSERT_FORMAT"], $dateFormat, "YYYY-MM-DD");
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_DATE");
            ?>
>
				<<?php 
            echo GetMessage("SALE_EXPORT_HOZ_OPERATION");
            ?>
><?php 
            echo GetMessage("SALE_EXPORT_ITEM_ORDER");
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_HOZ_OPERATION");
            ?>
>
				<<?php 
            echo GetMessage("SALE_EXPORT_ROLE");
            ?>
><?php 
            echo GetMessage("SALE_EXPORT_SELLER");
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_ROLE");
            ?>
>
				<<?php 
            echo GetMessage("SALE_EXPORT_CURRENCY");
            ?>
><?php 
            echo htmlspecialcharsbx(strlen($currency) > 0 ? substr($currency, 0, 3) : substr($arOrder["CURRENCY"], 0, 3));
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_CURRENCY");
            ?>
>
				<<?php 
            echo GetMessage("SALE_EXPORT_CURRENCY_RATE");
            ?>
>1</<?php 
            echo GetMessage("SALE_EXPORT_CURRENCY_RATE");
            ?>
>
				<<?php 
            echo GetMessage("SALE_EXPORT_AMOUNT");
            ?>
><?php 
            echo $arOrder["PRICE"];
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_AMOUNT");
            ?>
>
				<?php 
            if ($bNewVersion) {
                ?>
					<<?php 
                echo GetMessage("SALE_EXPORT_VERSION");
                ?>
><?php 
                echo IntVal($arOrder["VERSION"]) > 0 ? $arOrder["VERSION"] : 0;
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VERSION");
                ?>
>
					<?php 
                if (strlen($arOrder["ID_1C"]) > 0) {
                    ?>
<<?php 
                    echo GetMessage("SALE_EXPORT_ID_1C");
                    ?>
><?php 
                    echo htmlspecialcharsbx($arOrder["ID_1C"]);
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_ID_1C");
                    ?>
><?php 
                }
            }
            if ($crmMode) {
                ?>
<DateUpdate><?php 
                echo $DB->FormatDate($arOrder["DATE_UPDATE"], $dateFormat, "YYYY-MM-DD HH:MI:SS");
                ?>
</DateUpdate><?php 
            }
            $deliveryAdr = CSaleExport::ExportContragents($arOrder, $arProp, $agent, $arResultStat, $bNewVersion, $bExportFromCrm ? array("EXPORT_FROM_CRM" => "Y") : array());
            ?>
				<<?php 
            echo GetMessage("SALE_EXPORT_TIME");
            ?>
><?php 
            echo $DB->FormatDate($arOrder["DATE_INSERT_FORMAT"], $dateFormat, "HH:MI:SS");
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_TIME");
            ?>
>
				<<?php 
            echo GetMessage("SALE_EXPORT_COMMENTS");
            ?>
><?php 
            echo htmlspecialcharsbx($arOrder["COMMENTS"]);
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_COMMENTS");
            ?>
>
				<?php 
            $dbOrderTax = CSaleOrderTax::GetList(array(), array("ORDER_ID" => $arOrder["ID"]), false, false, array("ID", "TAX_NAME", "VALUE", "VALUE_MONEY", "CODE", "IS_IN_PRICE"));
            $i = -1;
            $orderTax = 0;
            while ($arOrderTax = $dbOrderTax->Fetch()) {
                $arOrderTax["VALUE_MONEY"] = roundEx($arOrderTax["VALUE_MONEY"], 2);
                $orderTax += $arOrderTax["VALUE_MONEY"];
                $i++;
                if ($i == 0) {
                    echo "<" . GetMessage("SALE_EXPORT_TAXES") . ">";
                }
                ?>
					<<?php 
                echo GetMessage("SALE_EXPORT_TAX");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo htmlspecialcharsbx($arOrderTax["TAX_NAME"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_IN_PRICE");
                ?>
><?php 
                echo $arOrderTax["IS_IN_PRICE"] == "Y" ? "true" : "false";
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_IN_PRICE");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_AMOUNT");
                ?>
><?php 
                echo $arOrderTax["VALUE_MONEY"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_AMOUNT");
                ?>
>
					</<?php 
                echo GetMessage("SALE_EXPORT_TAX");
                ?>
>
					<?php 
            }
            if ($i != -1) {
                echo "</" . GetMessage("SALE_EXPORT_TAXES") . ">";
            }
            ?>
				<?php 
            if (DoubleVal($arOrder["DISCOUNT_VALUE"]) > 0) {
                ?>
					<<?php 
                echo GetMessage("SALE_EXPORT_DISCOUNTS");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_DISCOUNT");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_ORDER_DISCOUNT");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_AMOUNT");
                ?>
><?php 
                echo $arOrder["DISCOUNT_VALUE"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_AMOUNT");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_IN_PRICE");
                ?>
>false</<?php 
                echo GetMessage("SALE_EXPORT_IN_PRICE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_DISCOUNT");
                ?>
>
					</<?php 
                echo GetMessage("SALE_EXPORT_DISCOUNTS");
                ?>
>
					<?php 
            }
            $storeBasket = "";
            if (IntVal($arOrder["STORE_ID"]) > 0 && !empty($arStore[$arOrder["STORE_ID"]])) {
                ?>
					<<?php 
                echo GetMessage("SALE_EXPORT_STORIES");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_STORY");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ID");
                ?>
><?php 
                echo $arStore[$arOrder["STORE_ID"]]["XML_ID"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ID");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo htmlspecialcharsbx($arStore[$arOrder["STORE_ID"]]["TITLE"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ADDRESS");
                ?>
>
								<<?php 
                echo GetMessage("SALE_EXPORT_PRESENTATION");
                ?>
><?php 
                echo htmlspecialcharsbx($arStore[$arOrder["STORE_ID"]]["ADDRESS"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_PRESENTATION");
                ?>
>
								<<?php 
                echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
                ?>
>
									<<?php 
                echo GetMessage("SALE_EXPORT_TYPE");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_STREET");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_TYPE");
                ?>
>
									<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo htmlspecialcharsbx($arStore[$arOrder["STORE_ID"]]["ADDRESS"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
								</<?php 
                echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
                ?>
>
							</<?php 
                echo GetMessage("SALE_EXPORT_ADDRESS");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_CONTACTS");
                ?>
>
								<<?php 
                echo GetMessage("SALE_EXPORT_CONTACT");
                ?>
>
									<<?php 
                echo GetMessage("SALE_EXPORT_TYPE");
                ?>
><?php 
                echo $bNewVersion ? GetMessage("SALE_EXPORT_WORK_PHONE_NEW") : GetMessage("SALE_EXPORT_WORK_PHONE");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_TYPE");
                ?>
>
									<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo htmlspecialcharsbx($arStore[$arOrder["STORE_ID"]]["PHONE"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
								</<?php 
                echo GetMessage("SALE_EXPORT_CONTACT");
                ?>
>
							</<?php 
                echo GetMessage("SALE_EXPORT_CONTACTS");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_STORY");
                ?>
>
					</<?php 
                echo GetMessage("SALE_EXPORT_STORIES");
                ?>
>
					<?php 
                /*
                $storeBasket = "				
                	<".GetMessage("SALE_EXPORT_STORIES").">
                		<".GetMessage("SALE_EXPORT_STORY").">
                			<".GetMessage("SALE_EXPORT_ID").">".$arStore[$arOrder["STORE_ID"]]["XML_ID"]."</".GetMessage("SALE_EXPORT_ID").">
                			<".GetMessage("SALE_EXPORT_ITEM_NAME").">".htmlspecialcharsbx($arStore[$arOrder["STORE_ID"]]["TITLE"])."</".GetMessage("SALE_EXPORT_ITEM_NAME").">
                		</".GetMessage("SALE_EXPORT_STORY").">
                	</".GetMessage("SALE_EXPORT_STORIES").">
                	";
                */
            }
            ?>
				<<?php 
            echo GetMessage("SALE_EXPORT_ITEMS");
            ?>
>
				<?php 
            $dbBasket = \Bitrix\Sale\Internals\BasketTable::getList(array('select' => array("ID", "NOTES", "PRODUCT_XML_ID", "CATALOG_XML_ID", "NAME", "PRICE", "QUANTITY", "DISCOUNT_PRICE", "VAT_RATE", "MEASURE_CODE"), 'filter' => array("ORDER_ID" => $arOrder["ID"]), 'order' => array("NAME" => "ASC")));
            $basketSum = 0;
            $priceType = "";
            $bVat = false;
            $vatRate = 0;
            $vatSum = 0;
            while ($arBasket = $dbBasket->fetch()) {
                if (strlen($priceType) <= 0) {
                    $priceType = $arBasket["NOTES"];
                }
                ?>
					<<?php 
                echo GetMessage("SALE_EXPORT_ITEM");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_ID");
                ?>
><?php 
                echo htmlspecialcharsbx($arBasket["PRODUCT_XML_ID"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ID");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_CATALOG_ID");
                ?>
><?php 
                echo htmlspecialcharsbx($arBasket["CATALOG_XML_ID"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_CATALOG_ID");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo htmlspecialcharsbx($arBasket["NAME"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
						<?php 
                if ($bNewVersion) {
                    if (IntVal($arBasket["MEASURE_CODE"]) <= 0) {
                        $arBasket["MEASURE_CODE"] = 796;
                    }
                    ?>
							<<?php 
                    echo GetMessage("SALE_EXPORT_UNIT");
                    ?>
>
								<<?php 
                    echo GetMessage("SALE_EXPORT_CODE");
                    ?>
><?php 
                    echo $arBasket["MEASURE_CODE"];
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_CODE");
                    ?>
>
								<<?php 
                    echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT");
                    ?>
><?php 
                    echo htmlspecialcharsbx($arMeasures[$arBasket["MEASURE_CODE"]]);
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT");
                    ?>
>
							</<?php 
                    echo GetMessage("SALE_EXPORT_UNIT");
                    ?>
>
							<<?php 
                    echo GetMessage("SALE_EXPORT_KOEF");
                    ?>
>1</<?php 
                    echo GetMessage("SALE_EXPORT_KOEF");
                    ?>
>
							<?php 
                } else {
                    ?>
							<<?php 
                    echo GetMessage("SALE_EXPORT_BASE_UNIT");
                    ?>
 <?php 
                    echo GetMessage("SALE_EXPORT_CODE");
                    ?>
="796" <?php 
                    echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT");
                    ?>
="<?php 
                    echo GetMessage("SALE_EXPORT_SHTUKA");
                    ?>
" <?php 
                    echo GetMessage("SALE_EXPORT_INTERNATIONAL_ABR");
                    ?>
="<?php 
                    echo GetMessage("SALE_EXPORT_RCE");
                    ?>
"><?php 
                    echo GetMessage("SALE_EXPORT_SHT");
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_BASE_UNIT");
                    ?>
>
							<?php 
                }
                if (DoubleVal($arBasket["DISCOUNT_PRICE"]) > 0) {
                    ?>
							<<?php 
                    echo GetMessage("SALE_EXPORT_DISCOUNTS");
                    ?>
>
								<<?php 
                    echo GetMessage("SALE_EXPORT_DISCOUNT");
                    ?>
>
									<<?php 
                    echo GetMessage("SALE_EXPORT_ITEM_NAME");
                    ?>
><?php 
                    echo GetMessage("SALE_EXPORT_ITEM_DISCOUNT");
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_ITEM_NAME");
                    ?>
>
									<<?php 
                    echo GetMessage("SALE_EXPORT_AMOUNT");
                    ?>
><?php 
                    echo $arBasket["DISCOUNT_PRICE"];
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_AMOUNT");
                    ?>
>
									<<?php 
                    echo GetMessage("SALE_EXPORT_IN_PRICE");
                    ?>
>true</<?php 
                    echo GetMessage("SALE_EXPORT_IN_PRICE");
                    ?>
>
								</<?php 
                    echo GetMessage("SALE_EXPORT_DISCOUNT");
                    ?>
>
							</<?php 
                    echo GetMessage("SALE_EXPORT_DISCOUNTS");
                    ?>
>
							<?php 
                }
                ?>
						<<?php 
                echo GetMessage("SALE_EXPORT_PRICE_PER_ITEM");
                ?>
><?php 
                echo $arBasket["PRICE"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_PRICE_PER_ITEM");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_QUANTITY");
                ?>
><?php 
                echo $arBasket["QUANTITY"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_QUANTITY");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_AMOUNT");
                ?>
><?php 
                echo $arBasket["PRICE"] * $arBasket["QUANTITY"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_AMOUNT");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
								<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_TYPE_NOMENKLATURA");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
								<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_ITEM");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
							</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
								<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_TYPE_OF_NOMENKLATURA");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
								<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_ITEM");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
							</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<?php 
                $dbProp = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "ASC"), array("BASKET_ID" => $arBasket["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")), false, false, array("NAME", "VALUE", "CODE"));
                while ($arProp = $dbProp->Fetch()) {
                    ?>
								<<?php 
                    echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                    ?>
>
									<<?php 
                    echo GetMessage("SALE_EXPORT_ITEM_NAME");
                    ?>
><?php 
                    echo htmlspecialcharsbx($arProp["NAME"]);
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_ITEM_NAME");
                    ?>
>
									<<?php 
                    echo GetMessage("SALE_EXPORT_VALUE");
                    ?>
><?php 
                    echo htmlspecialcharsbx($arProp["VALUE"]);
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_VALUE");
                    ?>
>
								</<?php 
                    echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                    ?>
>
								<?php 
                }
                ?>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
                ?>
>
						<?php 
                if (DoubleVal($arBasket["VAT_RATE"]) > 0) {
                    $bVat = true;
                    $vatRate = DoubleVal($arBasket["VAT_RATE"]);
                    $basketVatSum = $arBasket["PRICE"] / ($arBasket["VAT_RATE"] + 1) * $arBasket["VAT_RATE"];
                    $vatSum += roundEx($basketVatSum * $arBasket["QUANTITY"], 2);
                    ?>
							<<?php 
                    echo GetMessage("SALE_EXPORT_TAX_RATES");
                    ?>
>
								<<?php 
                    echo GetMessage("SALE_EXPORT_TAX_RATE");
                    ?>
>
									<<?php 
                    echo GetMessage("SALE_EXPORT_ITEM_NAME");
                    ?>
><?php 
                    echo GetMessage("SALE_EXPORT_VAT");
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_ITEM_NAME");
                    ?>
>
									<<?php 
                    echo GetMessage("SALE_EXPORT_RATE");
                    ?>
><?php 
                    echo $arBasket["VAT_RATE"] * 100;
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_RATE");
                    ?>
>
								</<?php 
                    echo GetMessage("SALE_EXPORT_TAX_RATE");
                    ?>
>
							</<?php 
                    echo GetMessage("SALE_EXPORT_TAX_RATES");
                    ?>
>
							<<?php 
                    echo GetMessage("SALE_EXPORT_TAXES");
                    ?>
>
								<<?php 
                    echo GetMessage("SALE_EXPORT_TAX");
                    ?>
>
									<<?php 
                    echo GetMessage("SALE_EXPORT_ITEM_NAME");
                    ?>
><?php 
                    echo GetMessage("SALE_EXPORT_VAT");
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_ITEM_NAME");
                    ?>
>
									<<?php 
                    echo GetMessage("SALE_EXPORT_IN_PRICE");
                    ?>
>true</<?php 
                    echo GetMessage("SALE_EXPORT_IN_PRICE");
                    ?>
>
									<<?php 
                    echo GetMessage("SALE_EXPORT_AMOUNT");
                    ?>
><?php 
                    echo roundEx($basketVatSum, 2);
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_AMOUNT");
                    ?>
>
								</<?php 
                    echo GetMessage("SALE_EXPORT_TAX");
                    ?>
>
							</<?php 
                    echo GetMessage("SALE_EXPORT_TAXES");
                    ?>
>
							<?php 
                }
                ?>
						<?php 
                echo $storeBasket;
                ?>
					</<?php 
                echo GetMessage("SALE_EXPORT_ITEM");
                ?>
>
					<?php 
                $basketSum += $arBasket["PRICE"] * $arBasket["QUANTITY"];
            }
            if (IntVal($arOrder["PRICE_DELIVERY"]) > 0) {
                ?>
					<<?php 
                echo GetMessage("SALE_EXPORT_ITEM");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_ID");
                ?>
>ORDER_DELIVERY</<?php 
                echo GetMessage("SALE_EXPORT_ID");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_ORDER_DELIVERY");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
						<?php 
                if ($bNewVersion) {
                    ?>
							<<?php 
                    echo GetMessage("SALE_EXPORT_UNIT");
                    ?>
>
							<<?php 
                    echo GetMessage("SALE_EXPORT_CODE");
                    ?>
>796</<?php 
                    echo GetMessage("SALE_EXPORT_CODE");
                    ?>
>
							<<?php 
                    echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT");
                    ?>
><?php 
                    echo htmlspecialcharsbx($arMeasures[796]);
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT");
                    ?>
>
							</<?php 
                    echo GetMessage("SALE_EXPORT_UNIT");
                    ?>
>
							<<?php 
                    echo GetMessage("SALE_EXPORT_KOEF");
                    ?>
>1</<?php 
                    echo GetMessage("SALE_EXPORT_KOEF");
                    ?>
>
						<?php 
                } else {
                    ?>
							<<?php 
                    echo GetMessage("SALE_EXPORT_BASE_UNIT");
                    ?>
 <?php 
                    echo GetMessage("SALE_EXPORT_CODE");
                    ?>
="796" <?php 
                    echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT");
                    ?>
="<?php 
                    echo GetMessage("SALE_EXPORT_SHTUKA");
                    ?>
" <?php 
                    echo GetMessage("SALE_EXPORT_INTERNATIONAL_ABR");
                    ?>
="<?php 
                    echo GetMessage("SALE_EXPORT_RCE");
                    ?>
"><?php 
                    echo GetMessage("SALE_EXPORT_SHT");
                    ?>
</<?php 
                    echo GetMessage("SALE_EXPORT_BASE_UNIT");
                    ?>
>
						<?php 
                }
                ?>
						<<?php 
                echo GetMessage("SALE_EXPORT_PRICE_PER_ITEM");
                ?>
><?php 
                echo $arOrder["PRICE_DELIVERY"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_PRICE_PER_ITEM");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_QUANTITY");
                ?>
>1</<?php 
                echo GetMessage("SALE_EXPORT_QUANTITY");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_AMOUNT");
                ?>
><?php 
                echo $arOrder["PRICE_DELIVERY"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_AMOUNT");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
								<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_TYPE_NOMENKLATURA");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
								<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_SERVICE");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
							</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
								<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_TYPE_OF_NOMENKLATURA");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
								<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_SERVICE");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
							</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
                ?>
>
						<?php 
                if ($bVat) {
                    $deliveryTax = roundEx($arOrder["PRICE_DELIVERY"] / ($vatRate + 1) * $vatRate, 2);
                    if ($orderTax > $vatSum && $orderTax == roundEx($vatSum + $deliveryTax, 2)) {
                        ?>
								<<?php 
                        echo GetMessage("SALE_EXPORT_TAX_RATES");
                        ?>
>
									<<?php 
                        echo GetMessage("SALE_EXPORT_TAX_RATE");
                        ?>
>
										<<?php 
                        echo GetMessage("SALE_EXPORT_ITEM_NAME");
                        ?>
><?php 
                        echo GetMessage("SALE_EXPORT_VAT");
                        ?>
</<?php 
                        echo GetMessage("SALE_EXPORT_ITEM_NAME");
                        ?>
>
										<<?php 
                        echo GetMessage("SALE_EXPORT_RATE");
                        ?>
><?php 
                        echo $vatRate * 100;
                        ?>
</<?php 
                        echo GetMessage("SALE_EXPORT_RATE");
                        ?>
>
									</<?php 
                        echo GetMessage("SALE_EXPORT_TAX_RATE");
                        ?>
>
								</<?php 
                        echo GetMessage("SALE_EXPORT_TAX_RATES");
                        ?>
>
								<<?php 
                        echo GetMessage("SALE_EXPORT_TAXES");
                        ?>
>
									<<?php 
                        echo GetMessage("SALE_EXPORT_TAX");
                        ?>
>
										<<?php 
                        echo GetMessage("SALE_EXPORT_ITEM_NAME");
                        ?>
><?php 
                        echo GetMessage("SALE_EXPORT_VAT");
                        ?>
</<?php 
                        echo GetMessage("SALE_EXPORT_ITEM_NAME");
                        ?>
>
										<<?php 
                        echo GetMessage("SALE_EXPORT_IN_PRICE");
                        ?>
>true</<?php 
                        echo GetMessage("SALE_EXPORT_IN_PRICE");
                        ?>
>
										<<?php 
                        echo GetMessage("SALE_EXPORT_AMOUNT");
                        ?>
><?php 
                        echo $deliveryTax;
                        ?>
</<?php 
                        echo GetMessage("SALE_EXPORT_AMOUNT");
                        ?>
>
									</<?php 
                        echo GetMessage("SALE_EXPORT_TAX");
                        ?>
>
								</<?php 
                        echo GetMessage("SALE_EXPORT_TAXES");
                        ?>
>
								<?php 
                    }
                }
                ?>
					</<?php 
                echo GetMessage("SALE_EXPORT_ITEM");
                ?>
>
					<?php 
            }
            ?>
				</<?php 
            echo GetMessage("SALE_EXPORT_ITEMS");
            ?>
>
				<<?php 
            echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
            ?>
>
					<?php 
            if (strlen($arOrder["DATE_PAYED"]) > 0) {
                ?>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_DATE_PAID");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo $arOrder["DATE_PAYED"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<?php 
            }
            if (strlen($arPayment["PAY_VOUCHER_NUM"]) > 0) {
                ?>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_PAY_NUMBER");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo htmlspecialcharsbx($arPayment["PAY_VOUCHER_NUM"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<?php 
            }
            if (IntVal($arPayment["PAY_SYSTEM_ID"]) > 0) {
                ?>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_PAY_SYSTEM");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo htmlspecialcharsbx($paySystems[$arPayment["PAY_SYSTEM_ID"]]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_PAY_SYSTEM_ID");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo htmlspecialcharsbx($arPayment["PAY_SYSTEM_ID"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<?php 
            }
            if (strlen($arShipment["DATE_ALLOW_DELIVERY"]) > 0) {
                ?>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_DATE_ALLOW_DELIVERY");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo $arShipment["DATE_ALLOW_DELIVERY"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<?php 
            }
            if (strlen($arShipment["DELIVERY_ID"]) > 0) {
                ?>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_DELIVERY_SERVICE");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo htmlspecialcharsbx($delivery[$arShipment["DELIVERY_ID"]]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<?php 
            }
            ?>
					<<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
><?php 
            echo GetMessage("SALE_EXPORT_ORDER_PAID");
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
><?php 
            echo $arOrder["PAYED"] == "Y" ? "true" : "false";
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
>
					</<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
					<<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
><?php 
            echo GetMessage("SALE_EXPORT_ALLOW_DELIVERY");
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
><?php 
            echo $arShipment["ALLOW_DELIVERY"] == "Y" ? "true" : "false";
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
>
					</<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
					<<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
><?php 
            echo GetMessage("SALE_EXPORT_CANCELED");
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
><?php 
            echo $arOrder["CANCELED"] == "Y" ? "true" : "false";
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
>
					</<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
					<<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
><?php 
            echo GetMessage("SALE_EXPORT_FINAL_STATUS");
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
><?php 
            echo $arOrder["STATUS_ID"] == "F" ? "true" : "false";
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
>
					</<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
					<<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
><?php 
            echo GetMessage("SALE_EXPORT_ORDER_STATUS");
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
><?php 
            $arStatus = CSaleStatus::GetLangByID($arOrder["STATUS_ID"]);
            echo htmlspecialcharsbx("[" . $arOrder["STATUS_ID"] . "] " . $arStatus["NAME"]);
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
>
					</<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
					<<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
					<<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
><?php 
            echo GetMessage("SALE_EXPORT_ORDER_STATUS_ID");
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
>
					<<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
><?php 
            echo htmlspecialcharsbx($arOrder["STATUS_ID"]);
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
>
					</<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
					<?php 
            if (strlen($arOrder["DATE_CANCELED"]) > 0) {
                ?>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_DATE_CANCEL");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo $arOrder["DATE_CANCELED"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_CANCEL_REASON");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo htmlspecialcharsbx($arOrder["REASON_CANCELED"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<?php 
            }
            if (strlen($arOrder["DATE_STATUS"]) > 0) {
                ?>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_DATE_STATUS");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo $arOrder["DATE_STATUS"];
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<?php 
            }
            if (strlen($arOrder["USER_DESCRIPTION"]) > 0) {
                ?>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_USER_DESCRIPTION");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
							<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo htmlspecialcharsbx($arOrder["USER_DESCRIPTION"]);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<?php 
            }
            $dbSite = CSite::GetByID($arOrder["LID"]);
            $arSite = $dbSite->Fetch();
            ?>
					<<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
><?php 
            echo GetMessage("SALE_EXPORT_SITE_NAME");
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_ITEM_NAME");
            ?>
>
						<<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
>[<?php 
            echo $arOrder["LID"];
            ?>
] <?php 
            echo htmlspecialcharsbx($arSite["NAME"]);
            ?>
</<?php 
            echo GetMessage("SALE_EXPORT_VALUE");
            ?>
>
					</<?php 
            echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
            ?>
>
					<?php 
            if (!empty($agent["REKV"])) {
                foreach ($agent["REKV"] as $k => $v) {
                    if (strlen($agentParams[$k]["NAME"]) > 0 && strlen($v) > 0) {
                        ?>
								<<?php 
                        echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                        ?>
>
									<<?php 
                        echo GetMessage("SALE_EXPORT_ITEM_NAME");
                        ?>
><?php 
                        echo htmlspecialcharsbx($agentParams[$k]["NAME"]);
                        ?>
</<?php 
                        echo GetMessage("SALE_EXPORT_ITEM_NAME");
                        ?>
>
									<<?php 
                        echo GetMessage("SALE_EXPORT_VALUE");
                        ?>
><?php 
                        echo htmlspecialcharsbx($v);
                        ?>
</<?php 
                        echo GetMessage("SALE_EXPORT_VALUE");
                        ?>
>
								</<?php 
                        echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                        ?>
>
								<?php 
                    }
                }
            }
            if (strlen($deliveryAdr) > 0) {
                ?>
						<<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
><?php 
                echo GetMessage("SALE_EXPORT_DELIVERY_ADDRESS");
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_ITEM_NAME");
                ?>
>
						<<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
><?php 
                echo htmlspecialcharsbx($deliveryAdr);
                ?>
</<?php 
                echo GetMessage("SALE_EXPORT_VALUE");
                ?>
>
						</<?php 
                echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
                ?>
>

						<?php 
            }
            ?>
				</<?php 
            echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
            ?>
>
			</<?php 
            echo GetMessage("SALE_EXPORT_DOCUMENT");
            ?>
>
			<?php 
            if ($crmMode) {
                $c = ob_get_clean();
                $c = CharsetConverter::ConvertCharset($c, $arCharSets[$arOrder["LID"]], "utf-8");
                echo $c;
                $_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix][] = $arOrder["ID"];
            } else {
                $_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix] = $arOrder["ID"];
            }
            if (IntVal($time_limit) > 0 && time() > $end_time) {
                break;
            }
        }
        ?>
		</<?php 
        echo GetMessage("SALE_EXPORT_COM_INFORMATION");
        ?>
>
		<?php 
        return $arResultStat;
    }
    } elseif ($save_order_result == "ok_pay") {
        $okMessage = GetMessage("SOD_OK_PAY");
    } elseif ($save_order_result == "ok_delivery") {
        $okMessage = GetMessage("SOD_OK_DELIVERY");
    } elseif ($save_order_result == "ok_comment") {
        $okMessage = GetMessage("SOD_OK_COMMENT");
    } elseif ($save_order_result == "ok_ps") {
        $okMessage = GetMessage("SOD_OK_PS");
    } else {
        $okMessage = GetMessage("SOD_OK_OK");
    }
    CAdminMessage::ShowNote($okMessage);
}
$res = \Bitrix\Sale\Internals\PaymentTable::getList(array('select' => array('CNT'), 'filter' => array('ORDER_ID' => $ID), 'runtime' => array('CNT' => array('data_type' => 'integer', 'expression' => array('COUNT(ID)')))));
$payment = $res->fetch();
$res = \Bitrix\Sale\Internals\ShipmentTable::getList(array('select' => array('CNT'), 'filter' => array('ORDER_ID' => $ID), 'runtime' => array('CNT' => array('data_type' => 'integer', 'expression' => array('COUNT(ID)')))));
$shipment = $res->fetch();
if ($payment['CNT'] > 1 || $shipment['CNT'] - 1 > 1) {
    $note = BeginNote();
    $note .= GetMessage('SOD_ERROR_SEVERAL_P_D');
    $note .= EndNote();
    echo $note;
}
if (!$bUserCanViewOrder) {
    CAdminMessage::ShowMessage(str_replace("#ID#", $ID, GetMessage("SOD_NO_PERMS2VIEW")) . ". ");
} else {
    if (!$boolLocked) {
        CSaleOrder::Lock($ID);
    }
    $customOrderView = COption::GetOptionString("sale", "path2custom_view_order", "");
    if (strlen($customOrderView) > 0 && file_exists($_SERVER["DOCUMENT_ROOT"] . $customOrderView) && is_file($_SERVER["DOCUMENT_ROOT"] . $customOrderView)) {
Example #8
0
function GetUniformDestribution($arBasket, $discount, $priceTotal)
{
    foreach ($arBasket as $key => $val) {
        $val["PRICE_DEFAULT"] = $val["PRICE"];
        $val["DISCOUNT_RATION_PERCENT"] = round($val["PRICE"] * 100 / $priceTotal, 5);
        $val["DISCOUNT_RATION_VALUE"] = round($discount * $val["DISCOUNT_RATION_PERCENT"] / 100, 5);
        $val["PRICE"] -= $val["DISCOUNT_RATION_VALUE"];
        $arBasket[$key] = $val;
    }
    return $arBasket;
}
if (CModule::IncludeModule("sale")) {
    if ($arOrder = CSaleOrder::GetByID($ORDER_ID)) {
        if (isset($_REQUEST['SHIPMENT_ID']) && intval($_REQUEST['SHIPMENT_ID']) > 0) {
            $shipmentId = $_REQUEST['SHIPMENT_ID'];
            $res = \Bitrix\Sale\Internals\ShipmentTable::getList(array('select' => array('PRICE_DELIVERY'), 'filter' => array('ID' => $_REQUEST['SHIPMENT_ID'])));
            $data = $res->fetch();
            $arOrder['PRICE_DELIVERY'] = $data['PRICE_DELIVERY'];
        }
        $rep_file_name = GetRealPath2Report($doc . ".php");
        if (strlen($rep_file_name) <= 0) {
            ShowError("PRINT TEMPLATE NOT FOUND");
            die;
        }
        $arOrderProps = array();
        $dbOrderPropVals = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $ORDER_ID), false, false, array("ID", "CODE", "VALUE", "ORDER_PROPS_ID", "PROP_TYPE"));
        while ($arOrderPropVals = $dbOrderPropVals->Fetch()) {
            $arCurOrderPropsTmp = CSaleOrderProps::GetRealValue($arOrderPropVals["ORDER_PROPS_ID"], $arOrderPropVals["CODE"], $arOrderPropVals["PROP_TYPE"], $arOrderPropVals["VALUE"], LANGUAGE_ID);
            foreach ($arCurOrderPropsTmp as $key => $value) {
                $arOrderProps[$key] = $value;
            }
Example #9
0
 function getShipment($arOrder)
 {
     $result = array();
     $ShipmentParams['select'] = array("ID", "DATE_INSERT", "CURRENCY", "PRICE_DELIVERY", "DATE_INSERT", "COMMENTS", "DATE_ALLOW_DELIVERY", "STATUS_ID", "DEDUCTED", "DATE_DEDUCTED", "REASON_UNDO_DEDUCTED", "RESERVED", "DELIVERY_ID", "DELIVERY_NAME", "CANCELED", "DATE_CANCELED", "REASON_CANCELED", "REASON_MARKED", "ORDER_ID");
     $ShipmentParams['filter']['ORDER_ID'] = $arOrder['ID'];
     $ShipmentParams['filter']['=SYSTEM'] = 'N';
     $limit = 0;
     $inc = 0;
     if (self::getVersionSchema() < self::PARTIAL_VERSION) {
         $limit = 1;
     }
     $resShipment = \Bitrix\Sale\Internals\ShipmentTable::getList($ShipmentParams);
     while ($arShipment = $resShipment->fetch()) {
         foreach ($arShipment as $field => $value) {
             if (self::isFormattedDateFields('Shipment', $field)) {
                 $arShipment[$field] = self::getFormatDate($value);
             }
         }
         $result['deliveryServices'][$arShipment['DELIVERY_ID']] = $arShipment['DELIVERY_NAME'];
         if ($limit == 0 || $inc < $limit) {
             $result['shipment'][] = $arShipment;
         }
         $inc++;
     }
     return $result;
 }
Example #10
0
         $code = $property->getField("CODE");
         $colName = "PROP_" . (strlen($code) > 0 ? $code : $property->getField("ORDER_PROPS_ID"));
         $row->AddField($colName, $property->getViewHtml());
     }
 } else {
     foreach ($arOrderProps + $arOrderPropsCode as $key => $value) {
         $row->AddField("PROP_" . $key, "");
     }
 }
 $row->AddField("EXTERNAL_ORDER", $arOrder["EXTERNAL_ORDER"] != "Y" ? Loc::getMessage("SO_NO") : Loc::getMessage("SO_YES"));
 //SHIPMENTS etc.
 $shipmentFields = array("SHIPMENTS", "ALLOW_DELIVERY", "DATE_ALLOW_DELIVERY", "DELIVERY", "DEDUCTED", "DELIVERY_DOC_NUM", "DELIVERY_DOC_DATE");
 $shipmentFields = array_intersect($arVisibleColumns, $shipmentFields);
 if (!empty($shipmentFields)) {
     $shipments = array();
     $res = \Bitrix\Sale\Internals\ShipmentTable::getList(array('order' => array('ID' => 'ASC'), 'filter' => array('ORDER_ID' => $arOrder['ID'], '!=SYSTEM' => 'Y')));
     while ($shipment = $res->fetch()) {
         $shipment["ID_LINKED"] = '[<a href="/bitrix/admin/sale_order_shipment_edit.php?order_id=' . $arOrder['ID'] . '&shipment_id=' . $shipment["ID"] . '&lang=' . LANGUAGE_ID . '">' . $shipment["ID"] . '</a>]';
         $shipments[] = $shipment;
     }
     if (in_array("SHIPMENTS", $arVisibleColumns)) {
         $fieldValue = "";
         if (empty($shipmentStatuses)) {
             $dbRes = StatusTable::getList(array('select' => array('ID', 'NAME' => 'Bitrix\\Sale\\Internals\\StatusLangTable:STATUS.NAME'), 'filter' => array('=Bitrix\\Sale\\Internals\\StatusLangTable:STATUS.LID' => LANGUAGE_ID, '=TYPE' => 'D')));
             while ($shipmentStatus = $dbRes->fetch()) {
                 $shipmentStatuses[$shipmentStatus["ID"]] = $shipmentStatus["NAME"] . " [" . $shipmentStatus["ID"] . "]";
             }
         }
         $shipmentCount = count($shipments);
         foreach ($shipments as $shipment) {
             $fieldValue .= $shipment["ID_LINKED"] . ", " . (strlen($shipment["DELIVERY_NAME"]) > 0 ? htmlspecialcharsbx($shipment["DELIVERY_NAME"]) . ", " : "") . '<span style="white-space:nowrap;">' . htmlspecialcharsEx(SaleFormatCurrency($shipment["PRICE_DELIVERY"], $shipment["CURRENCY"])) . "</span>, " . ($shipment["ALLOW_DELIVERY"] == "Y" ? Loc::getMessage("SOA_SHIPMENTS_ALLOW_DELIVERY") : Loc::getMessage("SOA_SHIPMENTS_NOT_ALLOW_DELIVERY")) . ", " . ($shipment["CANCELED"] == "Y" ? Loc::getMessage("SOA_SHIPMENTS_CANCELED") . ", " : "") . ($shipment["DEDUCTED"] == "Y" ? Loc::getMessage("SOA_SHIPMENTS_DEDUCTED") . ", " : "") . ($shipment["MARKED"] == "Y" ? Loc::getMessage("SOA_SHIPMENTS_MARKED") . ", " : "") . (strlen($shipment["TRACKING_NUMBER"]) > 0 ? htmlspecialcharsbx($shipment["TRACKING_NUMBER"]) . ", " : "");
Example #11
0
 /**
  * @return Entity\Result
  * @throws Main\ArgumentException
  * @throws Main\ArgumentNullException
  * @throws Main\ObjectNotFoundException
  */
 public function save()
 {
     $result = new Entity\Result();
     $itemsFromDb = array();
     if ($this->getOrder()->getId() > 0) {
         $itemsFromDbList = Internals\ShipmentTable::getList(array("filter" => array("ORDER_ID" => $this->getOrder()->getId()), "select" => array("ID", "DELIVERY_NAME")));
         while ($itemsFromDbItem = $itemsFromDbList->fetch()) {
             $itemsFromDb[$itemsFromDbItem["ID"]] = $itemsFromDbItem;
         }
     }
     /** @var Shipment $shipment */
     foreach ($this->collection as $shipment) {
         if ($shipment->isSystem()) {
             continue;
         }
         if (($systemShipment = $this->getSystemShipment()) && $systemShipment->getId() == 0) {
             /** @var Result $r */
             $r = $this->cloneShipment($shipment, $systemShipment);
             if ($r->isSuccess()) {
                 break;
             } else {
                 $result->addErrors($r->getErrors());
             }
         }
     }
     /** @var Shipment $shipment */
     foreach ($this->collection as $shipment) {
         $r = $shipment->save();
         if (!$r->isSuccess()) {
             $result->addErrors($r->getErrors());
         }
         if (isset($itemsFromDb[$shipment->getId()])) {
             unset($itemsFromDb[$shipment->getId()]);
         }
     }
     foreach ($itemsFromDb as $k => $v) {
         Internals\ShipmentTable::deleteWithItems($k);
         /** @var Order $order */
         if (!($order = $this->getOrder())) {
             throw new Main\ObjectNotFoundException('Entity "Order" not found');
         }
         if ($order->getId() > 0) {
             OrderHistory::addAction('SHIPMENT', $order->getId(), 'SHIPMENT_REMOVED', $k, null, array('ID' => $k, 'DELIVERY_NAME' => $v['DELIVERY_NAME']));
         }
     }
     if ($this->getOrder()->getId() > 0) {
         OrderHistory::collectEntityFields('SHIPMENT', $this->getOrder()->getId());
     }
     return $result;
 }
Example #12
0
 function InitParamArrays($arOrder, $orderID = 0, $psParams = "", $relatedData = array(), $payment = array())
 {
     if (!is_array($relatedData)) {
         $relatedData = array();
     }
     $GLOBALS["SALE_INPUT_PARAMS"] = array();
     $GLOBALS["SALE_CORRESPONDENCE"] = array();
     if (!is_array($arOrder) || count($arOrder) <= 0 || !array_key_exists("ID", $arOrder)) {
         $arOrder = array();
         $orderID = IntVal($orderID);
         if ($orderID > 0) {
             $arOrderTmp = CSaleOrder::GetByID($orderID);
         }
         if (!empty($arOrderTmp)) {
             foreach ($arOrderTmp as $k => $v) {
                 $arOrder["~" . $k] = $v;
                 $arOrder[$k] = htmlspecialcharsbx($v);
             }
         }
     } else {
         if ($orderID == 0 && $arOrder['ID'] > 0) {
             $orderID = $arOrder['ID'];
         }
     }
     if (empty($payment)) {
         $payment = \Bitrix\Sale\Internals\PaymentTable::getRow(array('select' => array('ID', 'PAY_SYSTEM_ID', 'SUM', 'PAID', 'DATE_BILL'), 'filter' => array('ORDER_ID' => $orderID, '!PAY_SYSTEM_ID' => \Bitrix\Sale\Internals\PaySystemInner::getId())));
     }
     if (count($arOrder) > 0) {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"] = $arOrder;
     }
     if (!empty($payment)) {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"] = $payment['SUM'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PRICE"] = $payment['SUM'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PAYMENT_ID"] = $payment['ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PAYED"] = $payment['PAID'];
     } else {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"] = DoubleVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PRICE"]) - DoubleVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SUM_PAID"]);
     }
     $arDateInsert = explode(" ", $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT"]);
     if (is_array($arDateInsert) && count($arDateInsert) > 0) {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT_DATE"] = $arDateInsert[0];
     } else {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT_DATE"] = $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT"];
     }
     if (!empty($payment)) {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_BILL_DATE"] = ConvertTimeStamp(MakeTimeStamp($payment["DATE_BILL"]), 'SHORT');
     }
     $userID = IntVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["USER_ID"]);
     if ($userID > 0) {
         $dbUser = CUser::GetByID($userID);
         if ($arUser = $dbUser->GetNext()) {
             $GLOBALS["SALE_INPUT_PARAMS"]["USER"] = $arUser;
         }
     }
     $arCurOrderProps = array();
     if (isset($relatedData["PROPERTIES"]) && is_array($relatedData["PROPERTIES"])) {
         $properties = $relatedData["PROPERTIES"];
         foreach ($properties as $key => $value) {
             $arCurOrderProps["~" . $key] = $value;
             $arCurOrderProps[$key] = htmlspecialcharsEx($value);
         }
     } else {
         $dbOrderPropVals = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["ID"]), false, false, array("ID", "CODE", "VALUE", "ORDER_PROPS_ID", "PROP_TYPE"));
         while ($arOrderPropVals = $dbOrderPropVals->Fetch()) {
             $arCurOrderPropsTmp = CSaleOrderProps::GetRealValue($arOrderPropVals["ORDER_PROPS_ID"], $arOrderPropVals["CODE"], $arOrderPropVals["PROP_TYPE"], $arOrderPropVals["VALUE"], LANGUAGE_ID);
             foreach ($arCurOrderPropsTmp as $key => $value) {
                 $arCurOrderProps["~" . $key] = $value;
                 $arCurOrderProps[$key] = htmlspecialcharsEx($value);
             }
         }
     }
     if (!empty($payment)) {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PAY_SYSTEM_ID"] = $payment['PAY_SYSTEM_ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~PAY_SYSTEM_ID"] = $payment['PAY_SYSTEM_ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["ORDER_PAYMENT_ID"] = $payment['ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~ORDER_PAYMENT_ID"] = $payment['ID'];
     }
     $shipment = \Bitrix\Sale\Internals\ShipmentTable::getRow(array('select' => array('DELIVERY_ID'), 'filter' => array('ORDER_ID' => $orderID, 'SYSTEM' => 'N')));
     if ($shipment) {
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DELIVERY_ID"] = $shipment['DELIVERY_ID'];
         $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~DELIVERY_ID"] = $shipment['DELIVERY_ID'];
     }
     if (count($arCurOrderProps) > 0) {
         $GLOBALS["SALE_INPUT_PARAMS"]["PROPERTY"] = $arCurOrderProps;
     }
     if (strlen($psParams) <= 0) {
         $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => !empty($payment) ? intval($payment['PAY_SYSTEM_ID']) : intval($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PAY_SYSTEM_ID"]), "PERSON_TYPE_ID" => IntVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PERSON_TYPE_ID"])), false, false, array("PARAMS"));
         if ($arPaySysAction = $dbPaySysAction->Fetch()) {
             $psParams = $arPaySysAction["PARAMS"];
         }
     }
     $GLOBALS["SALE_CORRESPONDENCE"] = CSalePaySystemAction::UnSerializeParams($psParams);
     foreach ($GLOBALS["SALE_CORRESPONDENCE"] as $key => $val) {
         $GLOBALS["SALE_CORRESPONDENCE"][$key]["~VALUE"] = $val["VALUE"];
         $GLOBALS["SALE_CORRESPONDENCE"][$key]["VALUE"] = htmlspecialcharsEx($val["VALUE"]);
     }
     // fields with no interface
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_STREET']["TYPE"] = 'PROPERTY';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_STREET']["VALUE"] = 'LOCATION_STREET';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_STREET']["~VALUE"] = 'LOCATION_STREET';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_VILLAGE']["TYPE"] = 'PROPERTY';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_VILLAGE']["VALUE"] = 'LOCATION_VILLAGE';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_VILLAGE']["~VALUE"] = 'LOCATION_VILLAGE';
     $GLOBALS["SALE_CORRESPONDENCE"]['ORDER_PAYMENT_ID']["TYPE"] = 'ORDER';
     $GLOBALS["SALE_CORRESPONDENCE"]['ORDER_PAYMENT_ID']["VALUE"] = 'PAYMENT_ID';
     $GLOBALS["SALE_CORRESPONDENCE"]['ORDER_PAYMENT_ID']["~VALUE"] = 'PAYMENT_ID';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYED']["TYPE"] = 'ORDER';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYED']["VALUE"] = 'PAYED';
     $GLOBALS["SALE_CORRESPONDENCE"]['PAYED']["~VALUE"] = 'PAYED';
     if (isset($relatedData["BASKET_ITEMS"]) && is_array($relatedData["BASKET_ITEMS"])) {
         $GLOBALS["SALE_INPUT_PARAMS"]["BASKET_ITEMS"] = $relatedData["BASKET_ITEMS"];
     }
     if (isset($relatedData["TAX_LIST"]) && is_array($relatedData["TAX_LIST"])) {
         $GLOBALS["SALE_INPUT_PARAMS"]["TAX_LIST"] = $relatedData["TAX_LIST"];
     }
 }
Example #13
0
 /**
  * Perform reading main data from database, no cache is used
  * @return void
  */
 protected function obtainDataOrders()
 {
     $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', 'PAY_VOUCHER_NUM', 'PAY_VOUCHER_DATE', 'EMP_STATUS_ID', 'PRICE_DELIVERY', 'ALLOW_DELIVERY', 'DATE_ALLOW_DELIVERY', 'EMP_ALLOW_DELIVERY_ID', 'DEDUCTED', 'DATE_DEDUCTED', 'EMP_DEDUCTED_ID', 'REASON_UNDO_DEDUCTED', 'RESERVED', 'PRICE', 'CURRENCY', 'DISCOUNT_VALUE', 'SUM_PAID', 'USER_ID', 'PAY_SYSTEM_ID', 'DELIVERY_ID', 'DATE_INSERT', 'DATE_UPDATE', 'USER_DESCRIPTION', 'ADDITIONAL_INFO', 'COMMENTS', 'TAX_VALUE', 'STAT_GID', 'RECURRING_ID', 'RECOUNT_FLAG', 'DELIVERY_DOC_NUM', 'DELIVERY_DOC_DATE', 'STORE_ID', 'ORDER_TOPIC', 'RESPONSIBLE_ID', 'DATE_PAY_BEFORE', 'DATE_BILL', 'ACCOUNT_NUMBER', 'TRACKING_NUMBER', 'XML_ID');
     $usePageNavigation = true;
     $navyParams = array();
     $navyParams = \CDBResult::GetNavParams();
     if ($navyParams['SHOW_ALL']) {
         $usePageNavigation = false;
     } else {
         $navyParams['PAGEN'] = (int) $navyParams['PAGEN'];
         $navyParams['SIZEN'] = (int) $navyParams['SIZEN'];
     }
     if (isset($this->arParams["ORDERS_PER_PAGE"]) && intval($this->arParams["ORDERS_PER_PAGE"]) > 0) {
         $navyParams['SIZEN'] = $this->arParams["ORDERS_PER_PAGE"];
     }
     if (isset($_REQUEST['show_all']) && $_REQUEST['show_all'] == "Y") {
         $usePageNavigation = false;
     }
     $getListParams = array('order' => array($this->sortBy => $this->sortOrder), 'filter' => $this->filter, 'select' => $select);
     if ($usePageNavigation) {
         $getListParams['limit'] = $navyParams['SIZEN'];
         $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
     }
     $totalPages = 0;
     if ($usePageNavigation) {
         $countQuery = new \Bitrix\Main\Entity\Query(\Bitrix\Sale\Internals\OrderTable::getEntity());
         $countQuery->addSelect(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(1)'));
         $countQuery->setFilter($getListParams['filter']);
         $totalCount = $countQuery->setLimit(null)->setOffset(null)->exec()->fetch();
         unset($countQuery);
         $totalCount = (int) $totalCount['CNT'];
         if ($totalCount > 0) {
             $totalPages = ceil($totalCount / $navyParams['SIZEN']);
             if ($navyParams['PAGEN'] > $totalPages) {
                 $navyParams['PAGEN'] = $totalPages;
             }
             $getListParams['limit'] = $navyParams['SIZEN'];
             $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
         } else {
             $navyParams['PAGEN'] = 1;
             $getListParams['limit'] = $navyParams['SIZEN'];
             $getListParams['offset'] = 0;
         }
     }
     $this->dbQueryResult['ORDERS'] = new \CDBResult(\Bitrix\Sale\Internals\OrderTable::getList($getListParams));
     if ($usePageNavigation) {
         $this->dbQueryResult['ORDERS']->NavStart($getListParams['limit'], $navyParams['SHOW_ALL'], $navyParams['PAGEN']);
         $this->dbQueryResult['ORDERS']->NavRecordCount = $totalCount;
         $this->dbQueryResult['ORDERS']->NavPageCount = $totalPages;
         $this->dbQueryResult['ORDERS']->NavPageNomer = $navyParams['PAGEN'];
     } else {
         $this->dbQueryResult['ORDERS']->NavStart($this->arParams["ORDERS_PER_PAGE"], false);
     }
     if (empty($this->dbQueryResult['ORDERS'])) {
         return;
     }
     while ($arOrder = $this->dbQueryResult['ORDERS']->GetNext()) {
         $arOBasket = array();
         $dbBasket = CSaleBasket::GetList(array('NAME' => 'asc'), array("ORDER_ID" => $arOrder["ID"]), false, false, array('*'));
         while ($arBasket = $dbBasket->Fetch()) {
             if (CSaleBasketHelper::isSetItem($arBasket)) {
                 continue;
             }
             $arOBasket[$arBasket['ID']] = $arBasket;
         }
         $arOShipment = array();
         $dbShipment = \Bitrix\Sale\Internals\ShipmentTable::getList(array('select' => array('DELIVERY_NAME', 'SYSTEM', 'DELIVERY_ID'), 'filter' => array('ORDER_ID' => $arOrder['ID'])));
         while ($arShipment = $dbShipment->fetch()) {
             if ($arShipment['SYSTEM'] == 'Y') {
                 continue;
             }
             $arOShipment[] = $arShipment;
         }
         $dbPayment = \Bitrix\Sale\Internals\PaymentTable::getList(array('select' => array('PAY_SYSTEM_NAME', 'PAY_SYSTEM_ID'), 'filter' => array('ORDER_ID' => $arOrder['ID'])));
         $arOPayment = array();
         while ($arPayment = $dbPayment->fetch()) {
             $arOPayment[] = $arPayment;
         }
         $this->dbResult['ORDERS'][] = array("ORDER" => $arOrder, "BASKET_ITEMS" => $arOBasket, "SHIPMENT" => $arOShipment, "PAYMENT" => $arOPayment);
     }
 }
Example #14
0
    unset($countQuery);
    $totalCount = (int) $totalCount['CNT'];
    if ($totalCount > 0) {
        $totalPages = ceil($totalCount / $navyParams['SIZEN']);
        if ($navyParams['PAGEN'] > $totalPages) {
            $navyParams['PAGEN'] = $totalPages;
        }
        $params['limit'] = $navyParams['SIZEN'];
        $params['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
    } else {
        $navyParams['PAGEN'] = 1;
        $params['limit'] = $navyParams['SIZEN'];
        $params['offset'] = 0;
    }
}
$dbResultList = new CAdminResult(ShipmentTable::getList($params), $tableId);
if ($usePageNavigation) {
    $dbResultList->NavStart($params['limit'], $navyParams['SHOW_ALL'], $navyParams['PAGEN']);
    $dbResultList->NavRecordCount = $totalCount;
    $dbResultList->NavPageCount = $totalPages;
    $dbResultList->NavPageNomer = $navyParams['PAGEN'];
} else {
    $dbResultList->NavStart();
}
//$dbResultList = new CAdminResult($shipments, $tableId);
//$dbResultList->NavStart();
$lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("group_admin_nav")));
$lAdmin->AddHeaders($headers);
$allSelectedFields = array("ORDER_ID" => false, "PAID" => false, "DATE_PAID" => false);
$visibleHeaders = $lAdmin->GetVisibleHeaderColumns();
$allSelectedFields = array_merge($allSelectedFields, array_fill_keys($visibleHeaders, true));
Example #15
0
 /**
  * @param int $shipmentId
  * @param StatusResult $params
  * @param bool|false $isStatusChanged
  * @return Result
  * @throws ArgumentNullException
  * @throws \Exception
  */
 public function updateShipment($shipmentId, StatusResult $params)
 {
     if ($shipmentId <= 0) {
         throw new ArgumentNullException('id');
     }
     $dateTime = new \Bitrix\Main\Type\DateTime();
     return ShipmentTable::update($shipmentId, array('TRACKING_STATUS' => $params->status, 'TRACKING_LAST_CHECK' => $dateTime, 'TRACKING_LAST_CHANGE' => \Bitrix\Main\Type\DateTime::createFromTimestamp($params->lastChangeTimestamp), 'TRACKING_DESCRIPTION' => $params->description, 'TRACKING_NUMBER' => $params->trackingNumber));
 }