1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
insurance.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 Insurance 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, $additionalParams);
17 $this->params["TYPE"] = "Y/N";
18 }
19
20 public static function getClassTitle()
21 {
22 return Loc::getMessage('SALE_DLVRS_ADD_ESI_TITLE');
23 }
24
25 public function getCostShipment(Shipment $shipment = null)
26 {
27 if($this->value != "Y")
28 return 0;
29
30 return $this->getPriceShipment($shipment);
31 }
32
33 protected function getShipmentProductsPrice(Shipment $shipment = null)
34 {
35 $result = 0;
36
38 foreach($shipment->getShipmentItemCollection() as $shipmentItem)
39 {
40 $basketItem = $shipmentItem->getBasketItem();
41
42 if($basketItem)
43 $result += $basketItem->getPrice()*$basketItem->getQuantity();
44 }
45
46 return $result;
47 }
48
49 public static function getAdminParamsName()
50 {
51 return Loc::getMessage('SALE_DLVRS_ADD_ESI_PARAMS_NAME');
52 }
53
54 public static function getAdminParamsControl($name, array $params, $currency = "")
55 {
56 return \Bitrix\Sale\Internals\Input\Manager::getEditHtml(
57 $name."[PARAMS][FEE]",
58 array("TYPE" => "NUMBER"),
59 $params["PARAMS"]["FEE"]
60 )." %";
61 }
62
63 protected function createJSOnchange($id)
64 {
65 return "BX.onCustomEvent('onDeliveryExtraServiceValueChange', [{'id' : '".$id."', 'value': this.checked, 'price': '0'}]);";
66 }
67
68 public static function isEmbeddedOnly()
69 {
70 return true;
71 }
72
73 public function getPriceShipment(Shipment $shipment = null)
74 {
75 if(!isset($this->params["FEE"]))
76 return 0;
77
78 if(!$shipment)
79 return 0;
80
81 $shipmentPrice = $this->getShipmentProductsPrice($shipment);
82
83 return $this->convertToOperatingCurrency(
84 $shipmentPrice * floatval($this->params["FEE"]) / 100
85 );
86 }
87}
</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
$name
Определения menu_edit.php:35
$currency
Определения template.php:266
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799