Пример #1
0
 public function processAdditionalInfoShipmentEdit(Shipment $shipment, array $requestData)
 {
     if (empty($requestData['REQUEST_SELF']) || $requestData['REQUEST_SELF'] != 'Y') {
         return null;
     }
     $shipmentId = $shipment->getId();
     if (intval($shipmentId) <= 0) {
         return null;
     }
     $dt = new \Bitrix\Main\Type\DateTime();
     $arResult = CSaleDeliveryHandler::executeAction(\CSaleDelivery::getCodeById($shipment->getDeliveryId()), 'REQUEST_SELF', \CAllSaleDelivery::convertOrderNewToOld($shipment));
     if (!$arResult) {
         return null;
     }
     $res = \Bitrix\Sale\Internals\OrderDeliveryReqTable::add(array("SHIPMENT_ID" => $shipmentId, "ORDER_ID" => $shipment->getCollection()->getOrder()->getId(), "DATE_REQUEST" => $dt, "PARAMS" => array("TYPE" => "REQUEST_SELF", "RESULT" => $arResult)));
     if (!$res->isSuccess()) {
         return null;
     }
     if (isset($arResult["TRACKING_NUMBER"])) {
         $shipment->setField("TRACKING_NUMBER", $arResult["TRACKING_NUMBER"]);
     }
     if (isset($arResult["DELIVERY_DOC_NUM"])) {
         $shipment->setField("DELIVERY_DOC_NUM", $arResult["DELIVERY_DOC_NUM"]);
         $shipment->setField("DELIVERY_DOC_DATE", $dt);
     }
     return $shipment;
 }
Пример #2
0
 public static function execHandlerAction($orderId, $actionId)
 {
     global $DB, $USER;
     $arResult = array();
     $arOrder = CSaleOrder::GetById($orderId);
     $handlerActions = CSaleDeliveryHandler::getActionsList($arOrder["DELIVERY_ID"]);
     if (!array_key_exists($actionId, $handlerActions)) {
         $arResult = array("RESULT" => "ERROR", "TEXT" => GetMessage("SALE_DHLP_HANDLER_HAS_NO_ACTION"));
     }
     $dt = new \Bitrix\Main\Type\DateTime();
     $depList = \Bitrix\Sale\Internals\OrderDeliveryReqTable::getList(array('filter' => array('=ORDER_ID' => $orderId)));
     $dep = $depList->fetch();
     if ($dep && !is_null($dep["DATE_REQUEST"])) {
         $arResult = array("RESULT" => "ERROR", "TEXT" => GetMessage("SALE_DHLP_HANDLER_REQUEST_ALREADY_SENT"));
     }
     if (empty($arResult)) {
         $arUserGroups = $USER->GetUserGroupArray();
         $arOrder["ITEMS"] = array();
         $dbItemsList = CSaleBasket::GetList(array("SET_PARENT_ID" => "DESC", "TYPE" => "DESC", "NAME" => "ASC"), array("ORDER_ID" => $orderId));
         while ($arItem = $dbItemsList->GetNext()) {
             $arItem["DIMENSIONS"] = unserialize($arItem["~DIMENSIONS"]);
             unset($arItem["~DIMENSIONS"]);
             $arOrder["ITEMS"][] = $arItem;
         }
         $arResult = CSaleDeliveryHandler::executeAction($arOrder["DELIVERY_ID"], $actionId, $arOrder);
         if ($actionId == "REQUEST_SELF" && isset($arResult["TRACKING_NUMBER"])) {
             $bUserCanEditOrder = CSaleOrder::CanUserUpdateOrder($orderId, $arUserGroups);
             if ($bUserCanEditOrder) {
                 if ($dep) {
                     \Bitrix\Sale\Internals\OrderDeliveryReqTable::update($dep["ID"], array("DATE_REQUEST" => $dt));
                 } else {
                     \Bitrix\Sale\Internals\OrderDeliveryReqTable::add(array("ORDER_ID" => $orderId, "DATE_REQUEST" => $dt));
                 }
                 $fields = array();
                 if (isset($arResult["TRACKING_NUMBER"])) {
                     $fields["TRACKING_NUMBER"] = $arResult["TRACKING_NUMBER"];
                 }
                 if (isset($arResult["DELIVERY_DOC_NUM"])) {
                     $fields["DELIVERY_DOC_NUM"] = $arResult["DELIVERY_DOC_NUM"];
                     $fields["DELIVERY_DOC_DATE"] = Date($DB->DateFormatToPHP(CLang::GetDateFormat("SHORT", $arOrder["LID"])));
                 }
                 CSaleOrder::Update($orderId, $fields);
             }
         }
         CSaleOrderChange::AddRecord($orderId, "ORDER_DELIVERY_REQUEST_SENT", $arResult);
     }
     return $arResult;
 }
Пример #3
0
								function fEditTrackingNumberResult(res)
								{
									BX.closeWait();
								}
							</script>
						</td>
					</tr>
				</tr>
				<?php 
        $tabControl->EndCustomField("ORDER_TRACKING_NUMBER", "");
        // additional delivery info (only for automated delivery systems and if delivery price was calculated)
        if (is_array($arDeliveryData) && !empty($arDeliveryData) && strpos($arOrder["DELIVERY_ID"], ":") !== false && $arOrder["PRICE_DELIVERY"] != 0) {
            $arDeliveryId = explode(":", $arOrder["DELIVERY_ID"]);
            $profileId = $arDeliveryId[1];
            $arDeliveryOrder = array("PRICE" => $orderTotalPrice, "WEIGHT" => $orderTotalWeight, "LOCATION_FROM" => COption::GetOptionString('sale', 'location', '', $LID), "LOCATION_TO" => $locationData, "LOCATION_ZIP" => $locationZip, "ITEMS" => $arBasketItems);
            $depList = \Bitrix\Sale\Internals\OrderDeliveryReqTable::getList(array('filter' => array('=ORDER_ID' => $ID)));
            if ($dep = $depList->fetch()) {
                $arDeliveryOrder["EXTRA_PARAMS"] = unserialize($dep["PARAMS"]);
            }
            $arPacks = CSaleDeliveryHelper::getBoxesFromConfig($profileId, $arDeliveryData["CONFIG"]["CONFIG"]);
            $arDeliveryResult = CSaleDeliveryHandler::CalculateFull($arDeliveryData["SID"], $profileId, $arDeliveryOrder, $arOrder["CURRENCY"], $LID);
            $delDiscountDiff = roundEx($arDeliveryResult["VALUE"] - $arOrder["PRICE_DELIVERY"], SALE_VALUE_PRECISION);
            $tabControl->BeginCustomField("ORDER_DELIVERY_ADDITIONAL_INFO", "");
            if (!empty($arPacks)) {
                $arBox = array_shift(array_values($arPacks));
                ?>
						<tr>
							<td width="40%"></td>
							<td width="60%">
								<a class="dashed-link" href="javascript:void(0);" onclick="fToggleDeliveryInfo();"><?php 
                echo GetMessage("SOD_SHOW_DELIVERY_ADDITIONAL_INFO");