Esempio n. 1
0
    /**
     * @param $data
     * @param $index
     * @param $formType
     * @return string
     * @throws Main\ArgumentNullException
     */
    public static function getViewTemplate($data, $index, $formType)
    {
        $index++;
        $allowDeliveryString = $data['ALLOW_DELIVERY'] == 'Y' ? 'YES' : 'NO';
        $deductedString = $data['DEDUCTED'] == 'Y' ? 'YES' : 'NO';
        $isActive = $formType != 'edit';
        $triangle = $isActive ? '<span class="triangle"> &#9662;</span>' : '';
        if ($data['ALLOW_DELIVERY'] == 'Y') {
            $class = !$isActive ? 'class="not_active"' : '';
        } else {
            $class = !$isActive ? 'class="notdelivery not_active"' : 'class="notdelivery"';
        }
        $allowDelivery = '<span><span id="BUTTON_ALLOW_DELIVERY_' . $index . '" ' . $class . '>' . Loc::getMessage('SALE_ORDER_SHIPMENT_ALLOW_DELIVERY_' . $allowDeliveryString) . '</span>' . $triangle . '</span>';
        if ($data['DEDUCTED'] == 'Y') {
            $class = !$isActive ? 'class="not_active"' : '';
        } else {
            $class = !$isActive ? 'class="notdeducted not_active"' : 'class="notdeducted"';
        }
        $deducted = '<span><span id="BUTTON_DEDUCTED_' . $index . '" ' . $class . '>' . Loc::getMessage('SALE_ORDER_SHIPMENT_DEDUCTED_' . $deductedString) . '</span>' . $triangle . '</span>';
        $map = $data['DELIVERY_ID'] > 0 ? self::getMap($data['DELIVERY_ID'], $index, $data['DELIVERY_STORE_ID']) : '';
        $lang = Main\Application::getInstance()->getContext()->getLanguage();
        $service = null;
        $extraServiceHTML = '';
        $mainLogoPath = '/bitrix/images/sale/logo-default-d.gif';
        $shortLogoPath = '/bitrix/images/sale/logo-default-d.gif';
        if ($data['DELIVERY_ID'] > 0) {
            $service = Services\Manager::getService($data['DELIVERY_ID']);
            $extraServiceManager = new \Bitrix\Sale\Delivery\ExtraServices\Manager($data['DELIVERY_ID']);
            $extraServiceManager->setOperationCurrency($data['CURRENCY']);
            if ($data['EXTRA_SERVICES']) {
                $extraServiceManager->setValues($data['EXTRA_SERVICES']);
            }
            if ($service && $service->getLogotip() > 0) {
                $mainLogo = self::getMainImgPath($service->getLogotip());
                $shortLogo = self::getShortImgPath($service->getLogotip());
                $mainLogoPath = $mainLogo['src'];
                $shortLogoPath = $shortLogo['src'];
            }
            $extraService = $extraServiceManager->getItems();
            if ($extraService) {
                $extraServiceHTML = self::getExtraServiceEditControl($extraService, $index, true);
            }
        }
        $companyList = OrderEdit::getCompanyList();
        $shipmentStatusList = OrderShipmentStatus::getShipmentStatusList();
        $jsShipmentStatus = array();
        foreach ($shipmentStatusList as $id => $name) {
            $jsShipmentStatus[] = array('ID' => $id, 'NAME' => htmlspecialcharsbx($name));
        }
        $profileBlock = '';
        if ($service) {
            $deliveryName = $service->getName();
            if ($service->getParentService()) {
                $profileBlock = '<tr>
									<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_DELIVERY_SERVICE_PROFILE') . ':</td>
									<td class="adm-detail-content-cell-r">
										' . htmlspecialcharsbx($service->getName()) . '
									</td>
								</tr>';
                $deliveryName = $service->getParentService()->getName();
            }
        } else {
            list($deliveryName, $profileBlock) = explode(':', $data['DELIVERY_NAME']);
            if ($profileBlock) {
                $profileBlock = '<tr>
									<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_DELIVERY_SERVICE_PROFILE') . ':</td>
									<td class="adm-detail-content-cell-r">
										' . htmlspecialcharsbx($profileBlock) . '
									</td>
								</tr>';
            }
        }
        $class = !$isActive ? 'class="not_active"' : '';
        $shipmentStatus = '<span><span id="BUTTON_SHIPMENT_' . $index . '" ' . $class . '>' . htmlspecialcharsbx($shipmentStatusList[$data['STATUS_ID']]) . '</span>' . $triangle . '</span>';
        $shippingBlockId = '';
        if ($isActive || strlen($data['TRACKING_NUMBER']) > 0) {
            $shippingBlockId = '<tr>
									<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_TRACKING_NUMBER') . ':</td>
									<td class="adm-detail-content-cell-r tal">
										<input type="text" id="TRACKING_NUMBER_' . $index . '_EDIT" name="SHIPMENT[' . $index . '][TRACKING_NUMBER]" style="display: none;" value="' . htmlspecialcharsbx($data['TRACKING_NUMBER']) . '">
										<span id="TRACKING_NUMBER_' . $index . '_VIEW">' . htmlspecialcharsbx($data['TRACKING_NUMBER']) . '</span>';
            if ($isActive) {
                $shippingBlockId .= '<div class="bx-adm-edit-pencil" id="TRACKING_NUMBER_PENCIL_' . $index . '"></div>';
            }
            $shippingBlockId .= '</td></tr>';
        }
        $shippingBlockDocNum = '';
        if (strlen($data['DELIVERY_DOC_NUM']) > 0) {
            $shippingBlockDocNum = '<tr>
								<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_DELIVERY_DOC_NUM') . ':</td>
								<td class="adm-detail-content-cell-r tal">
									' . htmlspecialcharsbx($data['DELIVERY_DOC_NUM']) . '
								</td>
							</tr>';
        }
        $shippingBlockDocDate = '';
        if (strlen($data['DELIVERY_DOC_DATE']) > 0) {
            $shippingBlockDocDate = '<tr>
								<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_DELIVERY_DOC_DATE') . ':</td>
								<td class="adm-detail-content-cell-r tal">
									' . htmlspecialcharsbx($data['DELIVERY_DOC_DATE']) . '
								</td>
							</tr>';
        }
        $result = '
			<input type="hidden" name="SHIPMENT[' . $index . '][DEDUCTED]" id="STATUS_DEDUCTED_' . $index . '" value="' . ($data['DEDUCTED'] == "" ? "N" : $data['DEDUCTED']) . '">
			<input type="hidden" name="SHIPMENT[' . $index . '][ALLOW_DELIVERY]" id="STATUS_ALLOW_DELIVERY_' . $index . '" value="' . ($data['ALLOW_DELIVERY'] == "" ? "N" : $data['ALLOW_DELIVERY']) . '">
			<input type="hidden" name="SHIPMENT[' . $index . '][STATUS_ID]" id="STATUS_SHIPMENT_' . $index . '" value="' . $data['STATUS_ID'] . '">
		<div class="adm-bus-pay" id="shipment_container_' . $index . '">
			<input type="hidden" name="SHIPMENT[' . $index . '][SHIPMENT_ID]" id="SHIPMENT_ID_' . $index . '" value="' . $data['ID'] . '">
			<div class="adm-bus-component-content-container">
				<div class="adm-bus-pay-section">
					<div class="adm-bus-pay-section-title-container">
						<div class="adm-bus-pay-section-title">' . Loc::getMessage('SALE_ORDER_SHIPMENT_TITLE') . ' <span id="shipment_' . $data['ID'] . '">#' . $data['ID'] . '</span></div>
						<div class="adm-bus-pay-section-action-block">
							<div class="adm-bus-pay-section-action" id="SHIPMENT_SECTION_' . $index . '_DELETE">' . Loc::getMessage('SALE_ORDER_SHIPMENT_BLOCK_SHIPMENT_DELETE') . '</div>
							<div class="adm-bus-pay-section-action" id="SHIPMENT_SECTION_' . $index . '_EDIT"><a href="/bitrix/admin/sale_order_shipment_edit.php?order_id=' . $data['ORDER_ID'] . '&shipment_id=' . $data['ID'] . '&backurl=' . urlencode($_SERVER['REQUEST_URI']) . '">' . Loc::getMessage('SALE_ORDER_SHIPMENT_BLOCK_SHIPMENT_EDIT') . '</a></div>
							<div class="adm-bus-pay-section-action" id="SHIPMENT_SECTION_' . $index . '_TOGGLE">' . Loc::getMessage('SALE_ORDER_SHIPMENT_BLOCK_SHIPMENT_TOGGLE') . '</div>
						</div>
					</div>
					<div class="adm-bus-pay-section-content" id="SHIPMENT_SECTION_' . $index . '">
						<div class="adm-bus-pay-section-sidebar">
							<div style="background: url(\'' . $mainLogoPath . '\')" id="delivery_service_logo_' . $index . '" class="adm-shipment-block-logo"></div>
							' . $map . '
						</div>
						<div class="adm-bus-pay-section-right">
							<div class="adm-bus-table-container caption border">
								<div class="adm-bus-table-caption-title" style="background: #eef5f5;">' . Loc::getMessage('SALE_ORDER_SHIPMENT_BLOCK_SERVICE') . '</div>
								<table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table ">
									<tbody>
										<tr>
											<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_DELIVERY_SERVICE') . ':</td>
											<td class="adm-detail-content-cell-r">
												' . htmlspecialcharsbx($deliveryName) . '
											</td>
										</tr>
										' . $profileBlock . '
									</tbody>
								</table>
							</div>
							<div class="adm-bus-table-container caption border">
								<div class="adm-bus-table-caption-title" style="background: #eef5f5;">' . Loc::getMessage('SALE_ORDER_SHIPMENT_DELIVERY_BLOCK_PRICE') . '</div>
								<table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table">
									<tbody>
										<tr>
											<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_DELIVERY_SUM_PRICE') . ':</td>
											<td class="adm-detail-content-cell-r tal">
												' . SaleFormatCurrency(floatval($data['BASE_PRICE_DELIVERY']), $data['CURRENCY']) . '
											</td>
										</tr>
										<tr id="sale-order-shipment-discounts-row-' . $index . '" style="display: none;">
											<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_DISCOUNT') . ':</td>
											<td class="adm-detail-content-cell-r tal" id="sale-order-shipment-discounts-container-' . $index . '"></td>
										</tr>
										<tr style="display: none;">
											<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_DELIVERY_SUM_DISCOUNT_PRICE') . ':</td>
											<td class="adm-detail-content-cell-r tal" id="PRICE_DELIVERY_' . $index . '">' . SaleFormatCurrency(floatval($data['PRICE_DELIVERY']), $data['CURRENCY']) . '<br></td>
										</tr>
									</tbody>
								</table>
							</div>
							<div class="adm-bus-table-container caption border">
								<div class="adm-bus-table-caption-title" style="background: #eef5f5;">' . Loc::getMessage('SALE_ORDER_SHIPMENT_BLOCK_SHIPMENT') . '</div>
								<table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table ">
									<tbody>
										<tr>
											<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_OFFICE') . ':</td>
											<td class="adm-detail-content-cell-r">
												' . (isset($companyList[$data['COMPANY_ID']]) ? htmlspecialcharsbx($companyList[$data['COMPANY_ID']]) : Loc::getMessage('SALE_ORDER_SHIPMENT_NO_COMPANY')) . '
											</td>
										</tr>
									</tbody>
								</table>
							</div>
							<div class="adm-bus-table-container caption border">
								<div class="adm-bus-moreInfo_part1">
									<div class="adm-bus-table-caption-title" style="background: #eef5f5;">' . Loc::getMessage('SALE_ORDER_SHIPMENT_BLOCK_STATUS') . '</div>
									<table class="adm-detail-content-table edit-table" border="0" width="100%" cellpadding="0" cellspacing="0">
										<tbody>
											<tr>
												<td class="adm-detail-content-cell-l vat" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_ALLOW_DELIVERY') . ':</td>
												<td class="adm-detail-content-cell-r delivery-status">' . $allowDelivery . '</td>
											</tr>
											' . (!empty($data['EMP_ALLOW_DELIVERY_ID']) ? '
											<tr>
												<td class="adm-detail-content-cell-l vat" width="40%"></td>
												<td class="adm-detail-content-cell-r">
													<div>' . Loc::getMessage('SALE_ORDER_SHIPMENT_MODIFY_BY') . ': <span style="color: #66878F" id="order_additional_info_date_responsible">' . htmlspecialcharsbx($data['DATE_ALLOW_DELIVERY']) . '</span>  <a href="/bitrix/admin/user_edit.php?lang=' . $lang . '&ID=' . $data['EMP_ALLOW_DELIVERY_ID'] . '" id="order_additional_info_emp_responsible">' . htmlspecialcharsbx($data['EMP_ALLOW_DELIVERY_ID_LAST_NAME']) . ' ' . htmlspecialcharsbx($data['EMP_ALLOW_DELIVERY_ID_NAME']) . '</a></div>
												</td>
											</tr>
											' : '') . '
											<tr>
												<td class="adm-detail-content-cell-l vat" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_DEDUCTED') . ':</td>
												<td class="adm-detail-content-cell-r"><div class="delivery-status">' . $deducted . '</div></td>
											</tr>
											' . (!empty($data['EMP_DEDUCTED_ID']) ? '
											<tr>
												<td class="adm-detail-content-cell-l vat" width="40%"></td>
												<td class="adm-detail-content-cell-r">
													<div>' . Loc::getMessage('SALE_ORDER_SHIPMENT_MODIFY_BY') . ': <span style="color: #66878F" id="order_additional_info_date_responsible">' . htmlspecialcharsbx($data['DATE_DEDUCTED']) . '</span>  <a href="/bitrix/admin/user_edit.php?lang=' . $lang . '&ID=' . $data['EMP_DEDUCTED_ID'] . '" id="order_additional_info_emp_responsible">' . htmlspecialcharsbx($data['EMP_DEDUCTED_ID_LAST_NAME']) . ' ' . htmlspecialcharsbx($data['EMP_DEDUCTED_ID_NAME']) . '</a></div>
												</td>
											</tr>
											' : '') . '
											<tr>
												<td class="adm-detail-content-cell-l vat" width="40%">' . Loc::getMessage('SALE_ORDER_SHIPMENT_DELIVERY_DOC_STATUS') . ':</td>
												<td class="adm-detail-content-cell-r">
													<div class="shipment-status">
														' . $shipmentStatus . '
													</div>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</div>';
        if (!empty($shippingBlockId) || !empty($shippingBlockDocNum) || !empty($shippingBlockDocDate) || !empty($extraServiceHTML)) {
            $result .= '<div class="adm-bus-table-container caption border">
				<div class="adm-bus-table-caption-title" style="background: #eef5f5;">' . Loc::getMessage('SALE_ORDER_SHIPMENT_BLOCK_DELIVERY_INFO') . '</div>
				<table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table ">
					<tbody>
						' . $shippingBlockId . $shippingBlockDocNum . $shippingBlockDocDate . '
					</tbody>
				</table>
				<div id="DELIVERY_INFO_' . $index . '">
				' . $extraServiceHTML . '
				</div>
			</div>';
        }
        $result .= '</div>
		<div class="clb"></div>
		<div class="adm-s-order-shipment-basket-structure">' . Loc::getMessage('SALE_ORDER_SHIPMENT_BASKET') . '</div>';
        $shipmentBasket = new OrderBasketShipment(self::$shipment, "BX.Sale.Admin.ShipmentBasketObj_" . $index, "shipment_basket_" . $index);
        $result .= $shipmentBasket->getView($index);
        $result .= '</div>';
        $result .= self::getShortViewTemplate($data, $index, $shortLogoPath, $formType);
        $result .= '</div>
			</div>
		</div>';
        $params = array('index' => $index, 'extra_service' => array(), 'shipment_statuses' => $jsShipmentStatus, 'isAjax' => true, 'active' => $isActive, 'discounts' => $data["DISCOUNTS"], 'discountsMode' => $formType == "edit" ? "edit" : "view", 'templateType' => 'view');
        $result .= self::initJsShipment($params);
        return $result;
    }
Esempio n. 2
0
 protected function changeDeliveryServiceAction()
 {
     $result = array();
     $profiles = array();
     $index = $this->request['index'];
     $formData = isset($this->request["formData"]) ? $this->request["formData"] : array();
     $formData['ID'] = $formData['order_id'];
     $deliveryId = intval($formData['SHIPMENT'][$index]['DELIVERY_ID']);
     if ($deliveryId <= 0) {
         return;
     }
     $order = $this->getOrder($formData);
     /** @var  \Bitrix\Sale\Delivery\Services\Base $service */
     $service = Sale\Delivery\Services\Manager::getService($deliveryId);
     if ($service->canHasProfiles()) {
         $profiles = Admin\Blocks\OrderShipment::getDeliveryServiceProfiles($deliveryId);
         if (!isset($formData['SHIPMENT'][$index]['PROFILE'])) {
             reset($profiles);
             $initProfile = current($profiles);
             $formData['SHIPMENT'][$index]['PROFILE'] = $initProfile['ID'];
             $this->request["formData"]['SHIPMENT'][$index]['PROFILE'] = $initProfile['ID'];
         }
     }
     $res = Admin\Blocks\OrderShipment::updateData($order, $formData['SHIPMENT']);
     $data = $res->getData();
     $shipment = array_shift($data['SHIPMENT']);
     if ($service->canHasProfiles()) {
         $profiles = Admin\Blocks\OrderShipment::checkProfilesRestriction($profiles, $shipment);
         $result["PROFILES"] = Admin\Blocks\OrderShipment::getProfileEditControl($profiles, $index, $shipment->getDeliveryId());
         foreach ($profiles as $profile) {
             if ($formData['SHIPMENT'][$index]['PROFILE'] == $profile['ID'] && !$profile['RESTRICTED']) {
                 $result['DELIVERY_ERROR'] = Loc::getMessage('SALE_OA_ERROR_DELIVERY_SERVICE');
                 break;
             }
         }
     }
     $deliveryService = Admin\Blocks\OrderShipment::getDeliveryServiceList($shipment);
     foreach ($deliveryService as $i => $dlService) {
         if ($dlService['ID'] <= 0) {
             continue;
         }
         if (!Sale\Delivery\Services\Manager::checkServiceRestriction($dlService['ID'], $shipment, '\\Bitrix\\Sale\\Delivery\\Restrictions\\BySite')) {
             unset($deliveryService[$i]);
         }
     }
     $deliveryServiceTree = Admin\Blocks\OrderShipment::makeDeliveryServiceTree($deliveryService);
     $result['DELIVERY_SERVICE_LIST'] = Admin\Blocks\OrderShipment::getTemplate($deliveryServiceTree);
     foreach ($deliveryService as $delivery) {
         if ($deliveryId == $delivery['ID'] && $delivery['RESTRICTED']) {
             $result['DELIVERY_ERROR'] = Loc::getMessage('SALE_OA_ERROR_DELIVERY_SERVICE');
             break;
         }
     }
     $storeMap = Admin\Blocks\OrderShipment::getMap($shipment->getDeliveryId(), $index);
     if ($storeMap) {
         $result['MAP'] = $storeMap;
     }
     $extraServiceManager = new \Bitrix\Sale\Delivery\ExtraServices\Manager($deliveryId);
     $extraServiceManager->setOperationCurrency($order->getCurrency());
     $deliveryExtraService = $shipment->getExtraServices();
     if ($deliveryExtraService) {
         $extraServiceManager->setValues($deliveryExtraService);
     }
     $extraService = $extraServiceManager->getItems();
     if ($extraService) {
         $result["EXTRA_SERVICES"] = Admin\Blocks\OrderShipment::getExtraServiceEditControl($extraService, $index);
     }
     $deliveryPrice = Admin\Blocks\OrderShipment::getDeliveryPrice($shipment);
     if ($shipment->getField('CUSTOM_PRICE_DELIVERY') == 'Y') {
         $result["CUSTOM_PRICE"] = $deliveryPrice;
     } else {
         $this->request['formData']['SHIPMENT'][$index]['PRICE_DELIVERY'] = $deliveryPrice;
     }
     $this->addResultData("SHIPMENT_DATA", $result);
     $this->formDataChanged = true;
 }