1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
lift.php
См. документацию.
1<?php
2
3namespace Sale\Handlers\Delivery\Additional\ExtraServices;
4
5use Bitrix\Sale\Shipment;
6use Bitrix\Main\Localization\Loc;
7use Bitrix\Sale\Delivery\ExtraServices\Base;
8
9Loc::loadMessages(__FILE__);
10
11class Lift extends Base
12{
13 public function __construct($id, array $structure, $currency, $value = null, array $additionalParams = array())
14 {
15 $structure["PARAMS"]["ONCHANGE"] = $this->createJSOnchange($id);
16 parent::__construct($id, $structure, $currency, $value);
17 $this->params["TYPE"] = "STRING";
18 }
19
20 public static function getClassTitle()
21 {
22 return Loc::getMessage('SALE_DLVRS_ADD_ESL_TITLE');
23 }
24
25 public function setValue($value)
26 {
27 $this->value = intval($value) >= 0 ? intval($value) : 0;
28 }
29
30 public function getCostShipment(Shipment $shipment = null)
31 {
32 if(!$shipment)
33 return 0;
34
35 if(!isset($this->params['PRICES']) || !is_array($this->params['PRICES']))
36 return 0;
37
38 $weight = $shipment->getWeight()/1000;
39
40 foreach($this->params['PRICES'] as $k => $v)
41 {
42 if(empty($v['W1']) && empty($v['W2']) && empty($v['P']))
43 continue;
44
45 if($weight >= floatval($v['W1']) && (floatval($v['W2']) <= 0 || $weight <= floatval($v['W2'])))
46 return floatval($v['P'])*floatval($this->value);
47 }
48
49 return 0;
50 }
51
52 public static function getAdminParamsName()
53 {
54 return Loc::getMessage('SALE_DLVRS_ADD_ESL_PARAMS_NAME');
55 }
56
57 public static function getAdminParamsControl($name, array $params = array(), $currency = "")
58 {
59 $result = '';
60
61 if(isset($params["PARAMS"]["PRICES"]) && is_array($params["PARAMS"]["PRICES"]))
62 $count = count($params["PARAMS"]["PRICES"]);
63 else
64 $count = 0;
65
66 for($i = 0; $i < $count+5; $i++)
67 {
68 $w1 = isset($params["PARAMS"]["PRICES"][$i]["W1"]) ? $params["PARAMS"]["PRICES"][$i]["W1"] : '';
69 $w2 = isset($params["PARAMS"]["PRICES"][$i]["W2"]) ? $params["PARAMS"]["PRICES"][$i]["W2"] : '';
70 $price = isset($params["PARAMS"]["PRICES"][$i]["P"]) ? roundEx($params["PARAMS"]["PRICES"][$i]["P"], SALE_VALUE_PRECISION) : '';
71
72 $result .= Loc::getMessage('SALE_DLVRS_ADD_ESL_WEIGHT_FROM').
73 '&nbsp;<input type="text" size="5" name="'.$name.'[PARAMS][PRICES]['.$i.'][W1]" value="'.$w1.'">&nbsp;-&nbsp;'.
74 '<input type="text" size="5" name="'.$name.'[PARAMS][PRICES]['.$i.'][W2]" value="'.$w2.'">&nbsp;'.
75 Loc::getMessage('SALE_DLVRS_ADD_ESL_KG').
76 '&nbsp;-&nbsp;'.
77 '<input type="text" size="5" name="'.$name.'[PARAMS][PRICES]['.$i.'][P]" value="'.$price.'">'.
78 ($currency <> '' ? " (".htmlspecialcharsbx($currency).")" : "").'<br>';
79 }
80
81 return $result;
82 }
83
84 protected function createJSOnchange($id)
85 {
86 return "BX.onCustomEvent('onDeliveryExtraServiceValueChange', [{'id' : '".$id."', 'value': this.value, 'price': '0'}]);";
87 }
88
89 public static function prepareParamsToSave(array $params)
90 {
91 if(!isset($params["PARAMS"]["PRICES"]) || !is_array($params["PARAMS"]["PRICES"]))
92 return $params;
93
94 foreach($params["PARAMS"]["PRICES"] as $k => $v)
95 if(empty($v['W1']) && empty($v['W2']) && empty($v['P']))
96 unset($params["PARAMS"]["PRICES"][$k]);
97
98 return $params;
99 }
100
101 public static function isEmbeddedOnly()
102 {
103 return true;
104 }
105}
$count
Определения admin_tab.php:4
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
roundEx($value, $prec=0)
Определения tools.php:4635
$name
Определения menu_edit.php:35
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$currency
Определения template.php:266
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
const SALE_VALUE_PRECISION
Определения include.php:46
$k
Определения template_pdf.php:567