Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
quantity.php
1<?php
2
4
6
7Loc::loadMessages(__FILE__);
8
9class Quantity extends Base
10{
11 public function __construct($id, array $structure, $currency, $value = null, array $additionalParams = array())
12 {
13 if(isset($structure["PARAMS"]["PRICE"]))
14 $structure["PARAMS"]["ONCHANGE"] = $this->createJSOnchange($id, $structure["PARAMS"]["PRICE"]);
15
16 parent::__construct($id, $structure, $currency, $value);
17 $this->params["TYPE"] = "STRING";
18 }
19
20 public static function getClassTitle()
21 {
22 return Loc::getMessage("DELIVERY_EXTRA_SERVICE_QUANTITY_TITLE");
23 }
24
25 public function setValue($value)
26 {
27 $this->value = intval($value) >= 0 ? intval($value) : 0;
28 }
29
30 public function getCost()
31 {
32 return floatval($this->getPrice())*floatval($this->value);
33 }
34
35 public static function getAdminParamsName()
36 {
37 return Loc::getMessage("DELIVERY_EXTRA_SERVICE_QUANTITY_PRICE");
38 }
39
40 public static function getAdminParamsControl($name, array $params = array(), $currency = "")
41 {
42 if(!empty($params["PARAMS"]["PRICE"]))
43 $price = roundEx(floatval($params["PARAMS"]["PRICE"]), SALE_VALUE_PRECISION);
44 else
45 $price = 0;
46
47 return '<input type="text" name="'.$name.'[PARAMS][PRICE]" value="'.$price.'">'.($currency <> '' ? " (".htmlspecialcharsbx($currency).")" : "");
48 }
49
50 public function setOperatingCurrency($currency)
51 {
52 $this->params["ONCHANGE"] = $this->createJSOnchange($this->id, $this->getPrice());
53 parent::setOperatingCurrency($currency);
54 }
55
56 protected function createJSOnchange($id, $price)
57 {
58 $price = roundEx(floatval($price), SALE_VALUE_PRECISION);
59 return "BX.onCustomEvent('onDeliveryExtraServiceValueChange', [{'id' : '".$id."', 'value': this.value, 'price': this.value*parseFloat('".$price."')}]);";
60 }
61}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
__construct($id, array $structure, $currency, $value=null, array $additionalParams=array())
Definition quantity.php:11
static getAdminParamsControl($name, array $params=array(), $currency="")
Definition quantity.php:40