1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
quantity.php
См. документацию.
1<?php
2
3namespace Bitrix\Sale\Delivery\ExtraServices;
4
5use Bitrix\Main\Localization\Loc;
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
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}
__construct($id, array $structure, $currency, $value=null, array $additionalParams=array())
Определения quantity.php:11
setOperatingCurrency($currency)
Определения quantity.php:50
createJSOnchange($id, $price)
Определения quantity.php:56
static getAdminParamsControl($name, array $params=array(), $currency="")
Определения quantity.php:40
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
roundEx($value, $prec=0)
Определения tools.php:4635
$name
Определения menu_edit.php:35
$currency
Определения template.php:266
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
const SALE_VALUE_PRECISION
Определения include.php:46