示例#1
0
 public static function prepareData(Order $order)
 {
     $currencyBudget = 0;
     if ($order->getUserId() > 0) {
         $res = \CSaleUserAccount::getList(array(), array('USER_ID' => $order->getUserId(), 'CURRENCY' => $order->getCurrency(), 'LOCKED' => 'N'), false, false, array('CURRENT_BUDGET'));
         $userAccount = $res->Fetch();
         $currencyBudget = $userAccount['CURRENT_BUDGET'];
     }
     $payable = $order->getPrice() - $order->getSumPaid();
     $price = $order->getPrice();
     $sumPaid = $order->getSumPaid();
     $data = array('PRICE' => $price ? $price : 0, 'SUM_PAID' => $sumPaid ? $sumPaid : 0, 'PAYABLE' => $payable >= 0 ? $payable : 0, 'CURRENCY' => $order->getCurrency(), 'BUYER_BUDGET' => $currencyBudget, 'STATUS_ID' => $order->getField('STATUS_ID'));
     return $data;
 }
示例#2
0
    public function getTotalHtml($needRecalculate = true)
    {
        $currency = $this->order->getCurrency();
        $basket = $this->order->getBasket();
        $totalPrices = OrderEdit::getTotalPrices($this->order, $this, $needRecalculate);
        if ($basket) {
            $weight = $basket->getWeight();
        } else {
            $weight = 0;
        }
        return '
				<div class="adm-s-result-container-itog">
					<table class="adm-s-result-container-itog-table">
						<tr>
							<tr>
								<td>' . Loc::getMessage("SALE_ORDER_BASKET_PRICE") . '</td>
								<td id="' . $this->idPrefix . 'sale_order_edit_basket_price_basket">' . \CCurrencyLang::currencyFormat(floatval($totalPrices["PRICE_BASKET"]), $currency, true) . '</td>
							</tr>
							<tr>
								<td>' . Loc::getMessage("SALE_ORDER_BASKET_PRICE_DISCOUNT") . '</td>
								<td id="' . $this->idPrefix . 'sale_order_edit_basket_price_discount">' . \CCurrencyLang::currencyFormat(floatval($totalPrices["PRICE_BASKET_DISCOUNTED"]), $currency, true) . '</td>
							</tr>
							<tr>
								<td>' . Loc::getMessage("SALE_ORDER_BASKET_PRICE_DELIVERY") . '</td>
								<td id="' . $this->idPrefix . 'sale_order_edit_basket_price_delivery">' . \CCurrencyLang::currencyFormat(floatval($totalPrices["PRICE_DELIVERY"]), $currency, true) . '</td>
							</tr>
							<tr>
								<td>' . Loc::getMessage("SALE_ORDER_BASKET_PRICE_DELIVERY_DISCOUNT") . '</td>
								<td id="' . $this->idPrefix . 'sale_order_edit_basket_price_delivery_discount">' . \CCurrencyLang::currencyFormat(floatval($totalPrices["PRICE_DELIVERY_DISCOUNTED"]), $currency, true) . '</td>
							</tr>
							<tr>
								<td>' . Loc::getMessage("SALE_ORDER_BASKET_TAX") . '</td>
								<td id="' . $this->idPrefix . 'sale_order_edit_basket_tax">' . \CCurrencyLang::currencyFormat(floatval($totalPrices["TAX_VALUE"]), $currency, true) . '</td>
							</tr>
							<tr>
								<td>' . Loc::getMessage("SALE_ORDER_BASKET_WEIGHT") . '</td>
								<td id="' . $this->idPrefix . 'sale_order_edit_basket_weight">' . roundEx(floatval($weight / $this->weightKoef), SALE_WEIGHT_PRECISION) . " " . $this->weightUnit . '</td>
							</tr>
							<tr>
								<td>' . Loc::getMessage("SALE_ORDER_BASKET_PAID") . '</td>
								<td id="' . $this->idPrefix . 'sale_order_edit_summ_paid">' . \CCurrencyLang::currencyFormat(floatval($totalPrices["SUM_PAID"]), $currency, true) . '</td>
							</tr>
							<tr class="adm-s-result-container-itog-table-result">
								<td>' . Loc::getMessage("SALE_ORDER_BASKET_PRICE_TOTAL") . '</td>
								<td id="' . $this->idPrefix . 'sale_order_edit_basket_price_total">' . \CCurrencyLang::currencyFormat(floatval($totalPrices["SUM_UNPAID"]), $currency, true) . '</td>
							</tr>
						</tr>
					</table>
				</div>
		';
    }
示例#3
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;
    }
 /**
  * @param Sale\Order $order
  *
  * @return array
  */
 public static function getOrderFields(Sale\Order $order)
 {
     $result = new Sale\Result();
     $paymentSystemId = false;
     $deliveryId = false;
     /** @var Sale\PaymentCollection $paymentCollection */
     if ($paymentCollection = $order->getPaymentCollection()) {
         /** @var Sale\Payment $payment */
         if ($payment = $paymentCollection->rewind()) {
             $paymentSystemId = $payment->getPaymentSystemId();
         }
     }
     /** @var Sale\ShipmentCollection $shipe */
     if ($shipmentCollection = $order->getShipmentCollection()) {
         /** @var Sale\Shipment $shipment */
         foreach ($shipmentCollection as $shipment) {
             if ($shipment->getDeliveryId() > 0) {
                 $deliveryId = $shipment->getDeliveryId();
                 break;
             }
         }
     }
     $fields = array("SITE_ID" => $order->getSiteId(), "LID" => $order->getSiteId(), "PERSON_TYPE_ID" => $order->getPersonTypeId(), "PRICE" => $order->getPrice(), "CURRENCY" => $order->getCurrency(), "USER_ID" => $order->getUserId(), "PAY_SYSTEM_ID" => $paymentSystemId, "PRICE_DELIVERY" => $order->getDeliveryPrice(), "DELIVERY_ID" => $deliveryId, "DISCOUNT_VALUE" => $order->getDiscountPrice(), "TAX_VALUE" => $order->getTaxValue(), "TRACKING_NUMBER" => $order->getField('TRACKING_NUMBER'), "PAYED" => $order->getField('PAYED'), "CANCELED" => $order->getField('CANCELED'), "STATUS_ID" => $order->getField('STATUS_ID'), "RESERVED" => $order->getField('RESERVED'));
     $orderFields = static::convertOrderToArray($order);
     if (is_array($orderFields)) {
         $orderFields = $fields + $orderFields;
         $orderFields = static::convertDateFieldsToOldFormat($orderFields);
     }
     $result->setData(array('FIELDS' => $fields, 'ORDER_FIELDS' => $orderFields));
     return $result;
 }
示例#5
0
    /**
     * @param Order $order
     * @return string HTML
     */
    public static function getView(Order $order, $orderBasket)
    {
        $currency = $order->getCurrency();
        $orderProps = $order->getPropertyCollection();
        if ($email = $orderProps->getUserEmail()) {
            $email = $email->getViewHtml();
        }
        if ($phone = $orderProps->getPhone()) {
            $phone = $phone->getViewHtml();
        }
        if ($name = $orderProps->getPayerName()) {
            $name = $name->getViewHtml();
        }
        $totalPrices = OrderEdit::getTotalPrices($order, $orderBasket, false);
        $result = '
			<div class="adm-bus-orderinfoblock adm-detail-tabs-block-pin" id="sale-order-edit-block-order-info">
				<div class="adm-bus-orderinfoblock-container">
				<div class="adm-bus-orderinfoblock-title">' . Loc::getMessage("SALE_ORDER_INFO", array("#ID#" => $order->getId(), "#NUM#" => strlen($order->getField("ACCOUNT_NUMBER")) > 0 ? $order->getField("ACCOUNT_NUMBER") : $order->getId(), "#DATE#" => $order->getDateInsert()->toString())) . " [" . $order->getSiteId() . "]" . '<div class="adm-bus-orderinfoblock-status success" id="order_info_order_status_name">' . $order->getField('STATUS_ID') . '</div> <!-- TODO -->
				</div>
				<div class="adm-bus-orderinfoblock-content">
					<div class="adm-bus-orderinfoblock-content-block-customer">
						<ul class="adm-bus-orderinfoblock-content-customer-info">
							<li>
								<span class="adm-bus-orderinfoblock-content-customer-info-param">' . Loc::getMessage("SALE_ORDER_INFO_FIO") . ':</span>
								<span class="adm-bus-orderinfoblock-content-customer-info-value" id="order_info_buyer_name">' . $name . '</span>
							</li>
							<li>
								<span class="adm-bus-orderinfoblock-content-customer-info-param">E-Mail:</span>
								<span class="adm-bus-orderinfoblock-content-customer-info-value"  id="order_info_buyer_email">' . $email . '</span>
							</li>
							<li>
								<span class="adm-bus-orderinfoblock-content-customer-info-param">' . Loc::getMessage("SALE_ORDER_INFO_PHONE") . ':</span>
								<span class="adm-bus-orderinfoblock-content-customer-info-value" id="order_info_buyer_phone">' . $phone . '</span>
							</li>
						</ul>
					</div>
					<div class="adm-bus-orderinfoblock-content-block-order">
						<ul class="adm-bus-orderinfoblock-content-order-info">
							<li>
								<span class="adm-bus-orderinfoblock-content-order-info-param">' . Loc::getMessage("SALE_ORDER_INFO_PRICE") . '</span>
								<span class="adm-bus-orderinfoblock-content-order-info-value" id="order_info_price_basket">' . SaleFormatCurrency(floatval($totalPrices["PRICE_BASKET"]), $currency) . '</span>
							</li>
							<li class="adm-bus-orderinfoblock-content-redtext">
								<span class="adm-bus-orderinfoblock-content-order-info-param">' . Loc::getMessage("SALE_ORDER_INFO_DISCOUNT_PRICE") . '</span>
								<span class="adm-bus-orderinfoblock-content-order-info-value" id="order_info_price_basket_discount">' . SaleFormatCurrency(floatval($totalPrices["PRICE_BASKET_DISCOUNTED"]), $currency) . '</span>
							</li>
							<li>
								<span class="adm-bus-orderinfoblock-content-order-info-param">' . Loc::getMessage("SALE_ORDER_INFO_DELIVERY_PRICE") . '</span>
								<span class="adm-bus-orderinfoblock-content-order-info-value" id="order_info_delivery_price">' . SaleFormatCurrency(floatval($order->getDeliveryPrice()), $currency) . '</span>
							</li>
						</ul>
						<ul class="adm-bus-orderinfoblock-content-order-info-result">
							<li>
								<span class="adm-bus-orderinfoblock-content-order-info-param">' . Loc::getMessage("SALE_ORDER_INFO_ALL_PRICE") . '</span>
								<span class="adm-bus-orderinfoblock-content-order-info-value" id="order_info_buyer_price">' . SaleFormatCurrency(floatval($order->getPrice()), $currency) . '</span>
							</li>
						</ul>
					</div>
					<div class="adm-bus-orderinfoblock-content-block-last">
						' . Loc::getMessage("SALE_ORDER_INFO_PAYED") . ': ' . SaleFormatCurrency(floatval($order->getSumPaid()), $currency) . '<ul class="adm-bus-orderinfoblock-content-last">';
        $updatersContent = "";
        foreach (self::getPaymentsInfo($order) as $payment) {
            $result .= '<a href="#payment_' . $payment["ID"] . '" style="text-decoration: none;">
				<li id="sale-admin-order-icon-payment-' . $payment["ID"] . '" class="adm-bus-orderinfoblock-content-last-icon ' . ($payment["IS_PAYED"] ? 'green' : 'red') . '" ';
            if (strval($payment["LOGOTIP_PATH"]) != '') {
                $result .= 'style="background-image: url(' . $payment["LOGOTIP_PATH"] . ');" ';
            }
            $result .= 'title="' . htmlspecialcharsbx($payment["NAME"]) . '"' . '><span></span></li></a>';
            if (strlen($updatersContent) > 0) {
                $updatersContent .= ",\n";
            }
            $updatersContent .= "\tPAYMENT_PAID_" . $payment["ID"] . ": function(paid) { BX.Sale.Admin.OrderInfo.setIconLamp('payment', '" . $payment["ID"] . "', (paid == 'Y' ? 'green' : 'red')); }";
        }
        $result .= '</ul>
						' . Loc::getMessage("SALE_ORDER_INFO_SHIPMENT") . '
						<ul class="adm-bus-orderinfoblock-content-last">';
        foreach (self::getShipmentsInfo($order) as $shipment) {
            $result .= '<a href="#shipment_' . $shipment["ID"] . '" style="text-decoration: none;">
				<li id="sale-admin-order-icon-shipment-' . $shipment["ID"] . '" class="adm-bus-orderinfoblock-content-last-icon ' . ($shipment["DEDUCTED"] == "Y" ? 'green' : 'red') . '" ';
            if (strval($shipment["LOGOTIP_PATH"]) != '') {
                $result .= 'style="background-image: url(' . $shipment["LOGOTIP_PATH"] . ');" ';
            }
            $result .= 'title="' . htmlspecialcharsbx($shipment["NAME"]) . '"' . '><span></span></li></a>';
            if (strlen($updatersContent) > 0) {
                $updatersContent .= ",\n";
            }
            $updatersContent .= "\tSHIPMENT_STATUS_" . $shipment["ID"] . ": function(shipmentStatus) { BX.Sale.Admin.OrderInfo.setIconLamp('shipment', '" . $shipment["ID"] . "', (shipmentStatus == 'DF' ? 'green' : 'red')); }";
        }
        $result .= '</ul>
					</div>
				</div>
				<div id="sale-order-edit-block-order-info-pin" onclick="BX.Sale.Admin.OrderEditPage.toggleFix(this.id, \'sale-order-edit-block-order-info\');" class="adm-detail-pin-btn-tabs" style="top: 9px;right: 5px;"></div>
				</div>
			</div>';
        $orderEditOpts = \CUserOptions::GetOption("sale_admin", "sale_order_edit", array());
        $isFixed = isset($orderEditOpts["fix_sale-order-edit-block-order-info"]) && $orderEditOpts["fix_sale-order-edit-block-order-info"] == "Y" ? true : false;
        if ($isFixed) {
            $result .= '
				<script type="text/javascript">
					BX.ready(function(){
						setTimeout(function(){BX.Sale.Admin.OrderEditPage.toggleFix("sale-order-edit-block-order-info-pin", "sale-order-edit-block-order-info");},1);
					});
				</script>';
        }
        if (strlen($updatersContent) > 0) {
            $result .= '
					<script type="text/javascript">
						BX.ready(function(){
							BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters({
							' . $updatersContent . '
							});
						});
					</script>';
        }
        return $result;
    }
示例#6
0
 /**
  * @param Sale\Order $order
  * @return int
  */
 public static function getUserBudgetByOrder(Sale\Order $order)
 {
     $budget = static::getUserBudget($order->getUserId(), $order->getCurrency());
     if ($userBudgetPool = static::getUserBudgetPool($order->getUserId())) {
         foreach ($userBudgetPool->get() as $userBudgetDat) {
             $budget += $userBudgetDat['SUM'];
         }
     }
     return $budget;
 }
示例#7
0
 /**
  * Fill empty order data.
  *
  * @param Order $order			Order object.
  * @return void
  */
 protected function fillEmptyOrderData(Order $order)
 {
     $this->orderData = array('ID' => $order->getId(), 'USER_ID' => $order->getUserId(), 'SITE_ID' => $order->getSiteId(), 'ORDER_PRICE' => $order->getPrice(), 'ORDER_WEIGHT' => 0, 'CURRENCY' => $order->getCurrency(), 'PERSON_TYPE_ID' => $order->getPersonTypeId(), 'BASKET_ITEMS' => array(), 'PRICE_DELIVERY' => 0, 'PRICE_DELIVERY_DIFF' => 0, 'DELIVERY_ID' => 0, 'CUSTOM_PRICE_DELIVERY' => 'N', 'SHIPMENT_CODE' => 0, 'SHIPMENT_ID' => 0);
     $paymentCollection = $order->getPaymentCollection();
     /** @var Payment $payment */
     foreach ($paymentCollection as $payment) {
         if ($payment->isInner()) {
             continue;
         }
         if (!isset($this->orderData['PAY_SYSTEM_ID'])) {
             $this->orderData['PAY_SYSTEM_ID'] = $payment->getPaymentSystemId();
             break;
         }
     }
     unset($payment, $paymentCollection);
     if (!isset($this->orderData['PAY_SYSTEM_ID'])) {
         $this->orderData['PAY_SYSTEM_ID'] = 0;
     }
 }
示例#8
0
 /**
  * Fill empty order data.
  *
  * @param Order $order			Order object.
  * @return void
  */
 protected function fillEmptyOrderData(Order $order)
 {
     $this->orderData = array('ID' => $order->getId(), 'USER_ID' => $order->getUserId(), 'SITE_ID' => $order->getSiteId(), 'ORDER_PRICE' => $order->getPrice(), 'ORDER_WEIGHT' => 0, 'CURRENCY' => $order->getCurrency(), 'BASKET_ITEMS' => array(), 'PRICE_DELIVERY' => 0, 'PRICE_DELIVERY_DIFF' => 0, 'DELIVERY_ID' => 0, 'CUSTOM_PRICE_DELIVERY' => 'N', 'SHIPMENT_CODE' => 0, 'SHIPMENT_ID' => 0);
 }