Exemple #1
0
    /**
     * @param Order $order
     * @param $formId
     * @return string
     */
    public static function getScripts(Order $order, $formId)
    {
        Asset::getInstance()->addJs("/bitrix/js/sale/admin/order_edit.js");
        Asset::getInstance()->addJs("/bitrix/js/sale/admin/order_ajaxer.js");
        $currencyId = $order->getCurrency();
        $currencies = array();
        if (Loader::includeModule('currency')) {
            \CJSCore::Init(array('currency'));
            $currencyFormat = \CCurrencyLang::getFormatDescription($currencyId);
            $currencies = array(array('CURRENCY' => $currencyId, 'FORMAT' => array('FORMAT_STRING' => $currencyFormat['FORMAT_STRING'], 'DEC_POINT' => $currencyFormat['DEC_POINT'], 'THOUSANDS_SEP' => $currencyFormat['THOUSANDS_SEP'], 'DECIMALS' => $currencyFormat['DECIMALS'], 'THOUSANDS_VARIANT' => $currencyFormat['THOUSANDS_VARIANT'], 'HIDE_ZERO' => "N")));
        }
        $curFormat = \CCurrencyLang::getCurrencyFormat($currencyId);
        $currencyLang = trim(str_replace("#", '', $curFormat["FORMAT_STRING"]));
        $langPhrases = array("SALE_ORDEREDIT_DISCOUNT_UNKNOWN", "SALE_ORDEREDIT_REFRESHING_DATA", "SALE_ORDEREDIT_FIX", "SALE_ORDEREDIT_UNFIX");
        $result = '
			<script type="text/javascript">
				BX.ready(function(){
					BX.Sale.Admin.OrderEditPage.orderId = "' . $order->getId() . '";
					BX.Sale.Admin.OrderEditPage.siteId = "' . $order->getSiteId() . '";
					BX.Sale.Admin.OrderEditPage.languageId = "' . LANGUAGE_ID . '";
					BX.Sale.Admin.OrderEditPage.formId = "' . $formId . '_form";
					BX.Sale.Admin.OrderEditPage.adminTabControlId = "' . $formId . '";
					' . (!empty($currencies) ? 'BX.Currency.setCurrencies(' . \CUtil::PhpToJSObject($currencies, false, true, true) . ');' : '') . 'BX.Sale.Admin.OrderEditPage.currency = "' . $currencyId . '";
					BX.Sale.Admin.OrderEditPage.currencyLang = "' . \CUtil::JSEscape($currencyLang) . '";';
        if ($formId == "sale_order_create") {
            $result .= '
					BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters(BX.Sale.Admin.OrderPayment.prototype.getCreateOrderFieldsUpdaters());';
        }
        foreach ($langPhrases as $phrase) {
            $result .= ' BX.message({' . $phrase . ': "' . \CUtil::JSEscape(Loc::getMessage($phrase)) . '"});';
        }
        $result .= '});
			</script>
		';
        return $result;
    }
Exemple #2
0
    private static function getEditTemplate($data, $index, $post = array())
    {
        $paid = $post ? $post['PAID'] : $data['PAID'];
        $id = $post ? $post['PAYMENT_ID'] : $data['ID'];
        $paidString = $paid == 'Y' ? 'YES' : 'NO';
        if (!$post) {
            if ($data['SUM'] > 0) {
                $sum = $data['SUM'];
            } else {
                $sum = $data['ORDER_PRICE'] - $data['ORDER_PAYMENT_SUM'] <= 0 ? 0 : $data['ORDER_PRICE'] - $data['ORDER_PAYMENT_SUM'];
            }
        } else {
            $sum = $post['SUM'];
        }
        $psData = self::getPaySystemParams(isset($post['PAY_SYSTEM_ID']) ? $post['PAY_SYSTEM_ID'] : $data['PAY_SYSTEM_ID'], $data['PERSON_TYPE_ID']);
        if (isset($psData["LOGOTIP_PATH"])) {
            $data['PAY_SYSTEM_LOGOTIP'] = $psData["LOGOTIP_PATH"];
        }
        $paymentStatus = '<span><span id="BUTTON_PAID_' . $index . '" ' . ($paid != 'Y' ? 'class="notpay"' : '') . '>' . Loc::getMessage('SALE_ORDER_PAYMENT_STATUS_' . $paidString) . '</span><span class="triangle"> &#9662;</span></span>';
        $note = BeginNote();
        $note .= Loc::getMessage('SALE_ORDER_PAYMENT_RETURN_ALERT');
        $note .= EndNote();
        $hiddenPaySystemInnerId = '';
        if ($index == 1) {
            $hiddenPaySystemInnerId = '<input type="hidden" value="' . PaySystemInner::getId() . '" id="PAYMENT_INNER_BUDGET_ID">';
        }
        $notPaidBlock = $paid == 'N' && !empty($data['EMP_PAID_ID']) ? '' : 'style="display:none;"';
        $return = $post['IS_RETURN'] == 'Y' ? '' : 'style="display:none;"';
        $returnInformation = '
		<tr ' . $return . ' class="return">
			<td class="adm-detail-content-cell-l fwb">' . Loc::getMessage('SALE_ORDER_PAYMENT_RETURN_TO') . ':</td>
			<td class="adm-detail-content-cell-r">
				<select name="PAYMENT[' . $index . '][OPERATION_ID]" id="OPERATION_ID_' . $index . '" class="adm-bus-select">
					<option value="RETURN">' . Loc::getMessage('SALE_ORDER_PAYMENT_RETURN_ACCOUNT') . '</option>
				</select>
			</td>
		</tr>
		<tr ' . $return . ' class="return">
			<td colspan="2" style="text-align: center">' . $note . '</td>
		</tr>
		<tr ' . $notPaidBlock . ' class="not_paid">
			<td class="adm-detail-content-cell-l" width="40%"><br>' . Loc::getMessage('SALE_ORDER_PAYMENT_PAY_RETURN_NUM') . ':</td>
			<td class="adm-detail-content-cell-r tal">
				<br>
				<input type="text" class="adm-bus-input" name="PAYMENT[' . $index . '][PAY_RETURN_NUM]" id="PAYMENT_RETURN_NUM_' . $index . '" value="' . htmlspecialcharsbx($post['PAY_RETURN_NUM'] ? $post['PAY_RETURN_NUM'] : $data['PAY_RETURN_NUM']) . '" maxlength="20">
			</td>
		</tr>
		<tr ' . $notPaidBlock . ' class="not_paid">
			<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_PAYMENT_PAY_RETURN_DATE') . ':</td>
			<td class="adm-detail-content-cell-r tal">
				<div class="adm-input-wrap adm-calendar-second" style="display: inline-block;">
					<input type="text" class="adm-input adm-calendar-to" name="PAYMENT[' . $index . '][PAY_RETURN_DATE]" id="PAYMENT_RETURN_DATE_' . $index . '" size="15" value="' . htmlspecialcharsbx($post['PAY_RETURN_DATE'] ? $post['PAY_RETURN_DATE'] : $data['PAY_RETURN_DATE']) . '">
					<span class="adm-calendar-icon" title="' . Loc::getMessage('SALE_ORDER_PAYMENT_CHOOSE_DATE') . '" onclick="BX.calendar({node:this, field:\'PAYMENT_RETURN_DATE_' . $index . '\', form: \'\', bTime: false, bHideTime: false});"></span>
				</div>
			</td>
		</tr>
		<tr ' . $notPaidBlock . ' class="not_paid">
			<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_PAYMENT_RETURN_COMMENT') . ':</td>
			<td class="adm-detail-content-cell-r tal">
				<div class="adm-input-wrap adm-calendar-second" style="display: inline-block;">
					<textarea name="PAYMENT[' . $index . '][PAY_RETURN_COMMENT]" id="PAYMENT_RETURN_COMMENTS_' . $index . '">' . htmlspecialcharsbx(isset($post['PAY_RETURN_COMMENT']) ? $post['PAY_RETURN_COMMENT'] : $data['PAY_RETURN_COMMENT']) . '</textarea>
				</div>
			</td>
		</tr>';
        $lang = Main\Application::getInstance()->getContext()->getLanguage();
        $title = $id > 0 ? Loc::getMessage('SALE_ORDER_PAYMENT_BLOCK_EDIT_PAYMENT_TITLE') . '#' . $id : Loc::getMessage('SALE_ORDER_PAYMENT_BLOCK_NEW_PAYMENT_TITLE') . '#' . $index;
        $curFormat = \CCurrencyLang::getCurrencyFormat($data['CURRENCY']);
        $currencyLang = trim(str_replace("#", '', $curFormat["FORMAT_STRING"]));
        $disabled = $data['PAID'] == 'Y' ? 'readonly' : '';
        $companyList = OrderEdit::getCompanyList();
        if (!empty($companyList)) {
            $companies = \Bitrix\Sale\Helpers\Admin\OrderEdit::makeSelectHtml('PAYMENT[' . $index . '][COMPANY_ID]', $companyList, isset($post["COMPANY_ID"]) ? $post["COMPANY_ID"] : $data["COMPANY_ID"], true, array("class" => "adm-bus-select", "id" => "COMPANY_ID"));
        } else {
            $companies = str_replace("#URL#", "/bitrix/admin/sale_company_edit.php?lang=" . $lang, Loc::getMessage('SALE_ORDER_PAYMENT_ADD_COMPANY'));
        }
        $result = '<div>
			<div class="adm-bus-pay" id="payment_container_' . $index . '">
				<input type="hidden" name="PAYMENT[' . $index . '][PAYMENT_ID]" id="payment_id_' . $index . '" value="' . $id . '">
				<input type="hidden" name="PAYMENT[' . $index . '][INDEX]" value="' . $index . '" class="index">
				<input type="hidden" name="PAYMENT[' . $index . '][PAID]" id="PAYMENT_PAID_' . $index . '" value="' . (empty($paid) ? 'N' : $paid) . '">
				<input type="hidden" name="PAYMENT[' . $index . '][IS_RETURN]" id="PAYMENT_IS_RETURN_' . $index . '" value="' . ($post['IS_RETURN'] ? $post['IS_RETURN'] : 'N') . '">
				' . $hiddenPaySystemInnerId . '
				<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">' . $title . '</div>
							<div class="adm-bus-pay-section-action-block">' . (!isset($data['ID']) || $data['ID'] <= 0 ? '<div class="adm-bus-pay-section-action" id="SECTION_' . $index . '_DELETE">' . Loc::getMessage('SALE_ORDER_PAYMENT_DELETE') . '</div>' : '') . '</div>
						</div>
						<div class="adm-bus-pay-section-content" id="SECTION_' . $index . '">
							<div class="adm-bus-pay-section-sidebar">
								<div class="adm-bus-pay-section-sidebar-service-logo">
									<img id="LOGOTIP_' . $index . '" src="' . $data['PAY_SYSTEM_LOGOTIP'] . '" alt="">
								</div>
							</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_PAYMENT_METHOD') . '</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 fwb" width="40%">' . Loc::getMessage('SALE_ORDER_PAYMENT_PAY_SYSTEM') . ':</td>
												<td class="adm-detail-content-cell-r">' . self::makePaymentSelectHtml('PAYMENT[' . $index . '][PAY_SYSTEM_ID]', self::getPaySystemList(), isset($post['PAY_SYSTEM_ID']) ? $post['PAY_SYSTEM_ID'] : $data['PAY_SYSTEM_ID'], array("class" => "adm-bus-select", "id" => "PAY_SYSTEM_ID_" . $index)) . '</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_PAYMENT_SUM') . '</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_PAYMENT_PAYABLE_SUM') . ':</td>
												<td class="adm-detail-content-cell-r tal"><input type="text" class="adm-bus-input-price" name="PAYMENT[' . $index . '][SUM]" id="PAYMENT_SUM_' . $index . '" value="' . round($sum, 2) . '" ' . $disabled . '> ' . $currencyLang . '<br></td>
											</tr>
										</tbody>
									</table>
								</div>
								<div class="adm-bus-table-container caption border" style="padding-top:10px;">
									<div class="adm-bus-table-caption-title" style="background: #eef5f5;">' . Loc::getMessage('SALE_ORDER_PAYMENT_STATUS') . '</div>
									<table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table alternation edit-table" id="PAYMENT_BLOCK_STATUS_' . $index . '">
										<tbody>
											<tr>
												<td class="adm-detail-content-cell-l vat payment-status" width="40%">
													' . $paymentStatus . '
												</td>
												<td class="adm-detail-content-cell-r tal" id="PAYMENT_CHANGE_USER_INFO_' . $index . '">
													' . $data['DATE_PAID'] . '
													<a href="/bitrix/admin/user_edit.php?lang=' . $lang . '&ID=' . $data['EMP_PAID_ID'] . '">' . htmlspecialcharsbx($data['EMP_PAID_ID_NAME']) . ' ' . htmlspecialcharsbx($data['EMP_PAID_ID_LAST_NAME']) . '</a>
												</td>
											</tr>
										</tbody>
									</table>
									<table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table" id="PAYMENT_BLOCK_STATUS_INFO_' . $index . '">
										<tbody>
											<tr>
												<td class="adm-detail-content-cell-l" width="40%"><br>' . Loc::getMessage('SALE_ORDER_PAYMENT_PAY_VOUCHER_NUM') . ':</td>
												<td class="adm-detail-content-cell-r tal">
													<br>
													<input type="text" class="adm-bus-input" id="PAYMENT_NUM" name="PAYMENT[' . $index . '][PAY_VOUCHER_NUM]" value="' . htmlspecialcharsbx(isset($post['PAY_VOUCHER_NUM']) ? $post['PAY_VOUCHER_NUM'] : $data['PAY_VOUCHER_NUM']) . '" maxlength="20">
												</td>
											</tr>
											<tr>
												<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage('SALE_ORDER_PAYMENT_PAY_VOUCHER_DATE') . ':</td>
												<td class="adm-detail-content-cell-r tal">
													<div class="adm-input-wrap adm-calendar-second" style="display: inline-block;">
														<input type="text" class="adm-input adm-calendar-to" id="PAYMENT_DATE_' . $index . '" name="PAYMENT[' . $index . '][PAY_VOUCHER_DATE]" size="15" value="' . htmlspecialcharsbx($post['PAY_VOUCHER_DATE'] ? $post['PAY_VOUCHER_DATE'] : $data['PAY_VOUCHER_DATE']) . '">
														<span class="adm-calendar-icon" title="' . Loc::getMessage('SALE_ORDER_PAYMENT_CHOOSE_DATE') . '" onclick="BX.calendar({node:this, field:\'PAYMENT_DATE_' . $index . '\', form: \'\', bTime: false, bHideTime: false});"></span>
													</div>
												</td>
											</tr>
											' . $returnInformation . '
										</tbody>
									</table>
								</div>';
        if (isset($data['PS_STATUS']) && !empty($data['PS_STATUS'])) {
            $result .= '<div class="adm-bus-table-container caption border">
									<div class="adm-bus-table-caption-title" style="background: #eef5f5;">' . Loc::getMessage('SALE_ORDER_PAYMENT_PS_STATUS_TITLE') . '</div>
									<a href="javascript:void(0);" id="PS_INFO_' . $index . '">' . Loc::getMessage('SALE_ORDER_PAYMENT_TOGGLE_DOWN') . '</a>
									<table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table" style="display: none">
										<tbody>
										<tr>
											<td class="adm-detail-content-cell-l vat" width="40%">' . Loc::getMessage('SALE_ORDER_PAYMENT_PS_STATUS') . ':</td>
											<td class="adm-detail-content-cell-r tal">' . $data['PS_STATUS'] . '</td>
										</tr>
										<tr>
											<td class="adm-detail-content-cell-l vat" width="40%">' . Loc::getMessage('SALE_ORDER_PAYMENT_PS_STATUS_CODE') . ':</td>
											<td class="adm-detail-content-cell-r tal">' . $data['PS_STATUS_CODE'] . '</td>
										</tr>
										<tr>
											<td class="adm-detail-content-cell-l vat" width="40%">' . Loc::getMessage('SALE_ORDER_PAYMENT_PS_STATUS_DESCRIPTION') . ':</td>
											<td class="adm-detail-content-cell-r tal">' . $data['PS_STATUS_DESCRIPTION'] . '</td>
										</tr>
										<tr>
											<td class="adm-detail-content-cell-l vat" width="40%">' . Loc::getMessage('SALE_ORDER_PAYMENT_PS_CURRENCY') . ':</td>
											<td class="adm-detail-content-cell-r tal">' . $data['PS_CURRENCY'] . '</td>
										</tr>
										<tr>
											<td class="adm-detail-content-cell-l vat" width="40%">' . Loc::getMessage('SALE_ORDER_PAYMENT_PS_SUM') . ':</td>
											<td class="adm-detail-content-cell-r tal">' . $data['PS_SUM'] . '</td>
										</tr>
										<tr>
											<td class="adm-detail-content-cell-l vat" width="40%">' . Loc::getMessage('SALE_ORDER_PAYMENT_PS_DATE') . ':</td>
											<td class="adm-detail-content-cell-r tal">' . $data['PS_RESPONSE_DATE'] . '</td>
										</tr>
										</tbody>
									</table>
								</div>';
        }
        $result .= '
								<div class="adm-bus-table-container caption border">
									<div class="adm-bus-table-caption-title" style="background: #eef5f5;">' . Loc::getMessage('SALE_ORDER_PAYMENT_BLOCK_COMPANY') . '</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_PAYMENT_COMPANY_BY') . ':</td>
												<td class="adm-detail-content-cell-r">' . $companies . '</td>
										</tr>
									</tbody>
								</table>
							</div>
						</div>
						<div class="clb"></div>
					</div>
				</div>
			</div>
		</div>
		</div>';
        $params = array('index' => $index, 'functionOnSave' => 'saveInHiddenFields', 'isPaid' => $data['PAID'] == 'Y', 'viewForm' => false, 'isAvailableChangeStatus' => true);
        $result .= self::initJsPayment($params);
        return $result;
    }
    $DELIVERY_ID = $fields["DELIVERY_ID"];
} elseif (isset($_REQUEST["DELIVERY_ID"])) {
    $DELIVERY_ID = $_REQUEST["DELIVERY_ID"];
} else {
    $DELIVERY_ID = 0;
}
$DELIVERY_ID = intval($DELIVERY_ID);
if ($DELIVERY_ID <= 0) {
    $strError .= Loc::getMessage("SALE_ESDE_ERROR_ID");
}
$currencyLang = "";
$deliveryService = null;
if ($DELIVERY_ID > 0) {
    $deliveryService = \Bitrix\Sale\Delivery\Services\Manager::getService($DELIVERY_ID);
    if ($deliveryService && \Bitrix\Main\Loader::includeModule('currency')) {
        $curFormat = \CCurrencyLang::getCurrencyFormat($deliveryService->getCurrency());
        $currencyLang = trim(str_replace("#", '', $curFormat["FORMAT_STRING"]));
    } else {
        $currencyLang = $deliveryService->getCurrency();
    }
}
if ($deliveryService && $ID <= 0 && isset($_GET["ES_CODE"]) && strlen($_GET["ES_CODE"]) > 0) {
    $embeddedList = $deliveryService->getEmbeddedExtraServicesList();
    if (isset($embeddedList[$_GET["ES_CODE"]])) {
        $fields = $embeddedList[$_GET["ES_CODE"]];
        $fields["CODE"] = $_GET["ES_CODE"];
        $fields["ID"] = strval(mktime());
    }
}
$aTabs = array(array("DIV" => "edit_main", "TAB" => Loc::getMessage("SALE_ESDE_TAB_GENERAL"), "ICON" => "sale", "TITLE" => Loc::getMessage("SALE_ESDE_TAB_GENERAL_TITLE")));
$tabControl = new CAdminTabControl("tabControl", $aTabs);
Exemple #4
0
 public static function getExtraServiceEditControl($extraService, $index, $view = false)
 {
     ob_start();
     echo '<table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table" id="BLOCK_EXTRA_SERVICE_' . $index . '">';
     echo '<tbody>';
     foreach ($extraService as $itemId => $item) {
         echo '<tr><td class="adm-detail-content-cell-l" width="40%">' . htmlspecialcharsbx($item->getName()) . ':</td>';
         echo '<td class="adm-detail-content-cell-r tal">';
         if ($view) {
             echo $item->getViewControl();
         } else {
             echo $item->getEditControl('SHIPMENT[' . $index . '][EXTRA_SERVICES][' . $itemId . ']');
         }
         $order = self::$shipment->getCollection()->getOrder();
         $currency = $order->getCurrency();
         $price = $item->getPrice();
         $curFormat = \CCurrencyLang::getCurrencyFormat($currency);
         $currencyLang = trim(str_replace("#", '', $curFormat["FORMAT_STRING"]));
         if ($price !== false) {
             echo ' (' . SaleFormatCurrency($price, $currency) . ')';
         } else {
             echo ' (' . $currencyLang . ')';
         }
         echo '</td></tr>';
     }
     echo '</tbody></table>';
     $result = ob_get_contents();
     ob_end_clean();
     return $result;
 }