Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
orderinfo.php
1<?php
2
4
11
12Loc::loadMessages(__FILE__);
13
15{
19 public static function getScripts()
20 {
21 \Bitrix\Main\Page\Asset::getInstance()->addJs("/bitrix/js/sale/admin/order_info.js");
22
23 return '
24 <script type="text/javascript">
25 BX.ready(function(){
26 BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters( BX.Sale.Admin.OrderInfo.getFieldsUpdaters() );
27 });
28 </script>
29 ';
30 }
31
32 protected static function getPaymentsInfo(Order $order)
33 {
34 $payments = $order->getPaymentCollection();
35
36 if(!$payments)
37 return array();
38
39 $result = array();
40
42 foreach ($payments as $payment)
43 {
44 $id = $payment->getField("PAY_SYSTEM_ID");
45 $ptId = $order->getPersonTypeId();
46
47 if(!$id || !$ptId)
48 continue;
49
51
52 if(!$params)
53 continue;
54
55 $result[] = array(
56 "ID" => $payment->getId(),
57 "NAME" => $params["NAME"],
58 "LOGOTIP_PATH" => $params["LOGOTIP_PATH"],
59 "IS_PAYED" => $payment->isPaid()
60 );
61 }
62 return $result;
63 }
64
65 protected static function getShipmentsInfo(Order $order)
66 {
67 $result = array();
68 $shipments = $order->getShipmentCollection();
69
71 foreach($shipments as $shipment)
72 {
73 if($shipment->isSystem())
74 continue;
75
77 $deliveryService = $shipment->getDelivery();
78
79 if(!$deliveryService)
80 continue;
81
82 $result[] = array(
83 "ID" => $shipment->getId(),
84 "NAME" => $deliveryService->getName(),
85 "LOGOTIP_PATH" => $deliveryService->getLogotipPath(),
86 "IS_SHIPPED" => $shipment->isShipped(),
87 "DEDUCTED" => $shipment->getField('DEDUCTED')
88 );
89 }
90
91 return $result;
92 }
93
98 public static function getView(Order $order, $orderBasket)
99 {
100 $currency = $order->getCurrency();
101 $orderProps = $order->getPropertyCollection();
102
103 if($email = $orderProps->getUserEmail())
104 $email = $email->getViewHtml();
105
106 if($phone = $orderProps->getPhone())
107 {
108 $phoneVal = $phone->getValue();
109
110 if($phoneVal != '')
111 {
112 if(!is_array($phoneVal))
113 $phoneVal = array($phoneVal);
114
115 $phone = '';
116
117 foreach($phoneVal as $number)
118 {
119 $number = str_replace("'", "", htmlspecialcharsbx($number));
120
121 if($phone <> '')
122 $phone .= ', ';
123
124 $phone .= '<a href="javascript:void(0)" onclick="BX.Sale.Admin.OrderEditPage.desktopMakeCall(\''.$number.'\');">'.
125 $number.
126 '</a>';
127 }
128 }
129 else
130 {
131 $phone = '';
132 }
133 }
134
135 if($name = $orderProps->getPayerName())
136 $name = $name->getViewHtml();
137
138 $totalPrices = OrderEdit::getTotalPrices($order, $orderBasket, false);
139
140 //Here we can receive custom data
141 $event = new Event('sale', 'onSaleAdminOrderInfoBlockShow', array('ORDER' => $order, 'ORDER_BASKET' => $orderBasket));
142 $event->send();
143 $resultList = $event->getResults();
144 $customData = array();
145
146 if (is_array($resultList) && !empty($resultList))
147 {
148 foreach ($resultList as $eventResult)
149 {
151 if ($eventResult->getType() != EventResult::SUCCESS)
152 continue;
153
154 $params = $eventResult->getParameters();
155
156 if(!empty($params) && is_array($params))
157 $customData = array_merge($customData, $params);
158 }
159 }
161
162 $result = '
163 <div class="adm-bus-orderinfoblock adm-detail-tabs-block-pin" id="sale-order-edit-block-order-info">
164 <div class="adm-bus-orderinfoblock-container">
165 <div class="adm-bus-orderinfoblock-title">
166 <div class="adm-bus-orderinfoblock-title-text">'.Loc::getMessage("SALE_ORDER_INFO", array(
167 "#ID#" => $order->getId(),
168 "#NUM#" => $order->getField("ACCOUNT_NUMBER") <> '' ? $order->getField("ACCOUNT_NUMBER") : $order->getId(),
169 "#DATE#" => $order->getDateInsert()->toString())
170 )." [".$order->getSiteId()."]".'</div>
171 <div class="adm-bus-orderinfoblock-status success" id="order_info_order_status_name">'.$order->getField('STATUS_ID').'</div> <!-- TODO -->
172 </div>
173 '.static::getOrderInfoBlock($order).'
174 <div class="adm-bus-orderinfoblock-content">
175 <div class="adm-bus-orderinfoblock-content-block-customer">
176 <ul class="adm-bus-orderinfoblock-content-customer-info">
177 <li>
178 <span class="adm-bus-orderinfoblock-content-customer-info-param">'.Loc::getMessage("SALE_ORDER_INFO_FIO").':</span>
179 <span class="adm-bus-orderinfoblock-content-customer-info-separator"></span>
180 <span class="adm-bus-orderinfoblock-content-customer-info-value" id="order_info_buyer_name">'.$name.'</span>
181 </li>
182 <li>
183 <span class="adm-bus-orderinfoblock-content-customer-info-param">E-Mail:</span>
184 <span class="adm-bus-orderinfoblock-content-customer-info-separator"></span>
185 <span class="adm-bus-orderinfoblock-content-customer-info-value" id="order_info_buyer_email">'.$email.'</span>
186 </li>
187 <li>
188 <span class="adm-bus-orderinfoblock-content-customer-info-param">'.Loc::getMessage("SALE_ORDER_INFO_PHONE").':</span>
189 <span class="adm-bus-orderinfoblock-content-customer-info-separator"></span>
190 <span class="adm-bus-orderinfoblock-content-customer-info-value" id="order_info_buyer_phone">'.$phone.'</span>
191 </li>';
192
193 if(!empty($customData))
194 {
195 foreach($customData as $custom)
196 {
197 if(empty($custom['TITLE']))
198 throw new ArgumentNullException("customData['TITLE']");
199
200 if(empty($custom['VALUE']))
201 throw new ArgumentNullException("customData['VALUE']");
202
203 $result .='
204 <li>
205 <span class="adm-bus-orderinfoblock-content-customer-info-param">'.$custom['TITLE'].'</span>
206 <span class="adm-bus-orderinfoblock-content-customer-info-separator"></span>
207 <span class="adm-bus-orderinfoblock-content-customer-info-value"'.(!empty($custom['ID']) ? ' id="'.$custom['ID'].'"' : '' ).'>'.$custom['VALUE'].'</span>
208 </li>';
209 }
210 }
211
212 $result .= '
213 </ul>
214 </div>
215 <div class="adm-bus-orderinfoblock-content-block-order">
216 <ul class="adm-bus-orderinfoblock-content-order-info">
217 <li>
218 <span class="adm-bus-orderinfoblock-content-order-info-param">'.Loc::getMessage("SALE_ORDER_INFO_PRICE").'</span>
219 <span class="adm-bus-orderinfoblock-content-order-info-value" id="order_info_price_basket">'.
220 SaleFormatCurrency(floatval($totalPrices["PRICE_BASKET"]), $currency).
221 '</span>
222 </li>
223 <li class="adm-bus-orderinfoblock-content-redtext">
224 <span class="adm-bus-orderinfoblock-content-order-info-param">'.Loc::getMessage("SALE_ORDER_INFO_DISCOUNT_PRICE").'</span>
225 <span class="adm-bus-orderinfoblock-content-order-info-value" id="order_info_price_basket_discount">'.
226 SaleFormatCurrency(floatval($totalPrices["PRICE_BASKET_DISCOUNTED"]), $currency).
227 '</span>
228 </li>
229 <li>
230 <span class="adm-bus-orderinfoblock-content-order-info-param">'.Loc::getMessage("SALE_ORDER_INFO_DELIVERY_PRICE").'</span>
231 <span class="adm-bus-orderinfoblock-content-order-info-value" id="order_info_delivery_price">'.
232 SaleFormatCurrency(floatval($order->getDeliveryPrice()), $currency).
233 '</span>
234 </li>
235 </ul>
236 <ul class="adm-bus-orderinfoblock-content-order-info-result">
237 <li>
238 <span class="adm-bus-orderinfoblock-content-order-info-param">'.Loc::getMessage("SALE_ORDER_INFO_ALL_PRICE").'</span>
239 <span class="adm-bus-orderinfoblock-content-order-info-value" id="order_info_buyer_price">'.
240 SaleFormatCurrency(floatval($order->getPrice()), $currency).
241 '</span>
242 </li>
243 </ul>
244 </div>
245 <div class="adm-bus-orderinfoblock-content-block-last">
246 '.Loc::getMessage("SALE_ORDER_INFO_PAYED").': '.SaleFormatCurrency(floatval($order->getSumPaid()), $currency).
247 '<ul class="adm-bus-orderinfoblock-content-last">';
248
249 $updatersContent = "";
250
251 foreach(self::getPaymentsInfo($order) as $payment)
252 {
253 $result .= '<a href="#payment_'.$payment["ID"].'" style="text-decoration: none;">
254 <li id="sale-admin-order-icon-payment-'.$payment["ID"].'" class="adm-bus-orderinfoblock-content-last-icon '.
255 ($payment["IS_PAYED"] ? 'green' : 'red').
256 '" ';
257
258 if (strval($payment["LOGOTIP_PATH"]) != '')
259 {
260 $result .= 'style="background-image: url('.$payment["LOGOTIP_PATH"].');" ';
261 }
262
263 $result .= 'title="'.htmlspecialcharsbx($payment["NAME"]).'"'.
264 '><span></span></li></a>';
265
266 if($updatersContent <> '')
267 $updatersContent .=",\n";
268
269 $updatersContent .= "\tPAYMENT_PAID_".$payment["ID"].": function(paid) { BX.Sale.Admin.OrderInfo.setIconLamp('payment', '".$payment["ID"]."', (paid == 'Y' ? 'green' : 'red')); }";
270 }
271 $result .= '</ul>
272 '.Loc::getMessage("SALE_ORDER_INFO_SHIPMENT").'
273 <ul class="adm-bus-orderinfoblock-content-last">';
274 foreach(self::getShipmentsInfo($order) as $shipment)
275 {
276 $result .= '<a href="#shipment_'.$shipment["ID"].'" style="text-decoration: none;">
277 <li id="sale-admin-order-icon-shipment-'.$shipment["ID"].'" class="adm-bus-orderinfoblock-content-last-icon '.
278 ($shipment["DEDUCTED"] == "Y" ? 'green' : 'red').
279 '" ';
280
281 if (strval($shipment["LOGOTIP_PATH"]) != '')
282 {
283 $result .= 'style="background-image: url('.$shipment["LOGOTIP_PATH"].');" ';
284 }
285 $result .= 'title="'.htmlspecialcharsbx($shipment["NAME"]).'"'.
286 '><span></span></li></a>';
287
288 if($updatersContent <> '')
289 $updatersContent .=",\n";
290
291 $updatersContent .= "\tSHIPMENT_STATUS_".$shipment["ID"].": function(shipmentStatus) { BX.Sale.Admin.OrderInfo.setIconLamp('shipment', '".$shipment["ID"]."', (shipmentStatus == 'DF' ? 'green' : 'red')); }";
292 }
293
294 $result .= '</ul>
295 </div>
296 </div>
297 <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: 0;"></div>
298 </div>
299 </div>';
300
301 $orderEditOpts = \CUserOptions::GetOption("sale_admin", "sale_order_edit", array());
302 $isFixed = isset($orderEditOpts["fix_sale-order-edit-block-order-info"]) && $orderEditOpts["fix_sale-order-edit-block-order-info"] == "Y" ? true : false;
303 if($isFixed)
304 {
305 $result .= '
306 <script type="text/javascript">
307 BX.ready(function(){
308 setTimeout(function(){BX.Sale.Admin.OrderEditPage.toggleFix("sale-order-edit-block-order-info-pin", "sale-order-edit-block-order-info");},1);
309 });
310 </script>';
311 }
312
313 if($updatersContent <> '')
314 {
315 $result .= '
316 <script type="text/javascript">
317 BX.ready(function(){
318 BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters({
319 '.$updatersContent.'
320 });
321 });
322 </script>';
323
324 }
325 return $result;
326 }
327
328 protected static function getOrderInfoBlock(Order $order)
329 {
330 return '';
331 }
332}
static loadMessages($file)
Definition loc.php:64