Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
orderfinanceinfo.php
1<?php
2
4
7
8Loc::loadMessages(__FILE__);
9
11{
12 public static function getView(Order $order, $useCurrentBudget = true)
13 {
14 $data = self::prepareData($order);
15
16 $result =
17 '<div class="adm-bus-pay">
18 <div class="adm-bus-component-content-container">
19 <div class="adm-bus-pay-section">
20 <div class="adm-bus-pay-section-content posr">
21 <input type="hidden" value="'.$data['PRICE'].'" id="sale-order-financeinfo-price">
22 <input type="hidden" value="'.$data['SUM_PAID'].'" id="sale-order-financeinfo-sum-paid">
23 <input type="hidden" value="'.$data['PAYABLE'].'" id="sale-order-financeinfo-payable">
24 <table class="adm-bus-pay-statuspay " '.(isset($data['OVERPAYMENT']) ? 'style="width: 1000px"' : '').'>
25 <thead>
26 <tr>
27 <td>'.Loc::getMessage('SALE_ORDER_FINANCEINFO_FOR_PAYMENT').'</td>
28 <td class="separator"></td>
29 <td style="color: #749511;">'.Loc::getMessage('SALE_ORDER_FINANCEINFO_SUM_PAID').'</td>
30 <td class="separator"></td>
31 <td style="color: #f29129;">'.Loc::getMessage('SALE_ORDER_FINANCEINFO_PAYABLE').'</td>
32 </tr>
33 </thead>
34 <tbody>
35 <tr>
36 <td id="sale-order-financeinfo-price-view">'.SaleFormatCurrency(floatval($data['PRICE']), $data['CURRENCY']).'</td>
37 <td class="separator"></td>
38 <td id="sale-order-financeinfo-sum-paid-view">'.SaleFormatCurrency(floatval($data['SUM_PAID']), $data['CURRENCY']).'</td>
39 <td class="separator"></td>
40 <td id="sale-order-financeinfo-payable-view">'.SaleFormatCurrency(floatval($data['PAYABLE']), $data['CURRENCY']).'</td>
41 </tr>
42 </tbody>
43 </table>
44 </div>
45 </div>
46 <div class="adm-bus-pay-section"'.(floatval($data['BUYER_BUDGET']) <= 0 ? ' style="display:none;"' : '').'>
47 <input id="sale-order-financeinfo-user-budget-input" type="hidden" value="'.floatval($data['BUYER_BUDGET']).'">
48 <div class="adm-bus-pay-section-content posr">
49 <div class="adm-bus-pay-wallet">
50 '.Loc::getMessage('SALE_ORDER_FINANCEINFO_BALANCE_INNER_BUDGET').': <strong id="sale-order-financeinfo-user-budget">' . SaleFormatCurrency($data['BUYER_BUDGET'], $data['CURRENCY']) . '</strong>';
51
52 if ($useCurrentBudget)
53 $result .= '<span class="adm-bus-pay-use-current-budget" onclick="BX.Sale.Admin.GeneralPayment.useCurrentBudget(this);">'.Loc::getMessage('SALE_ORDER_FINANCEINFO_USE_INNER_BUDGET').'</span>';
54
55 $result .= '</div>
56 </div>
57 </div>
58 </div>
59 </div>';
60
61 return $result;
62 }
63
64 public static function prepareData(Order $order)
65 {
66 $currencyBudget = 0;
67 if ($order->getUserId() > 0)
68 {
69 $res = \CSaleUserAccount::getList(
70 [],
71 [
72 'USER_ID' => $order->getUserId(),
73 'CURRENCY' => $order->getCurrency(),
74 'LOCKED' => 'N'
75 ],
76 false,
77 false,
78 [
79 'CURRENT_BUDGET',
80 ]
81 );
82 $userAccount = $res->Fetch();
83 $currencyBudget = (float)($userAccount['CURRENT_BUDGET'] ?? 0);
84 }
85
86 $payable = $order->getPrice() - $order->getSumPaid();
87 $price = $order->getPrice();
88 $sumPaid = $order->getSumPaid();
89
90 return [
91 'PRICE' => ($price) ? $price : 0,
92 'SUM_PAID' => ($sumPaid) ? $sumPaid : 0,
93 'PAYABLE' => ($payable >= 0) ? $payable : 0,
94 'CURRENCY' => $order->getCurrency(),
95 'BUYER_BUDGET' => $currencyBudget,
96 'STATUS_ID' => $order->getField('STATUS_ID')
97 ];
98 }
99
100 public static function getScripts()
101 {
102 \Bitrix\Main\Page\Asset::getInstance()->addJs("/bitrix/js/sale/admin/order_financeinfo.js");
103
104 return '
105 <script type="text/javascript">
106 BX.ready(function(){
107 BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters( BX.Sale.Admin.FinanceInfo.getFieldsUpdaters() );
108 });
109 </script>
110 ';
111 }
112}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getView(Order $order, $useCurrentBudget=true)