Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
orderbasketsettings.php
1<?php
3
6
7Loc::loadMessages(__FILE__);
8
10{
11 protected $idPrefix = "";
12 protected $settingsDlgObjectName = '';
13 protected $allColumns = array();
14 protected $visibleColumns = array();
15 protected $isShowPropsRawVisible = false;
16
17 protected static $jsInited = false;
18
19 public function __construct(array $params)
20 {
21 $this->idPrefix = $params["ID_PREFIX"];
22 $this->settingsDlgObjectName = $params["SETTINGS_DLG_OBJECT_NAME"];
23 $this->allColumns = $params["ALL_COLUMNS"];
24 $this->visibleColumns = $params["VISIBLE_COLUMNS"];
25 }
26
27 public function getScripts()
28 {
29 $result = '';
30
31 if(!static::$jsInited)
32 {
33 \Bitrix\Main\Page\Asset::getInstance()->addJs("/bitrix/js/sale/admin/order_basket_settings.js");
34
35 $result .= '
36 BX.message({
37 SALE_ORDER_BASKET_JS_SETTINGS_TITLE: "'.\CUtil::JSEscape(Loc::getMessage("SALE_ORDER_BASKET_JS_SETTINGS_TITLE")).'",
38 SALE_ORDER_BASKET_JS_SETTINGS_APPLY: "'.\CUtil::JSEscape(Loc::getMessage("SALE_ORDER_BASKET_JS_SETTINGS_APPLY")).'"
39 });
40 ';
41
42 static::$jsInited = true;
43 }
44
45 return $result;
46 }
47
48 public function getHtml()
49 {
50 $availableColumns = array_diff_key($this->allColumns, $this->visibleColumns);
51 $arAvailableColumnsHTML = "";
52
53 foreach ($availableColumns as $key => $value)
54 $arAvailableColumnsHTML .= "<option value=".$key.">".htmlspecialcharsbx($value)."</option>";
55
56 $arUserColumnsHTML = "";
57
58 foreach ($this->visibleColumns as $key => $value)
59 $arUserColumnsHTML .= "<option value=".$key.">".htmlspecialcharsbx($value)."</option>";
60
61 $settingsTemplate = '
62 <div id="'.$this->idPrefix.'columns_form">
63 <table width="100%">
64 <tr>
65 <td colspan="2" align="center">
66 <table>
67 <tr>
68 <td style="background-image:none" nowrap>
69 <div style="margin-bottom:5px">'.Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_AVAILABLE_COLUMNS").'</div>
70 <div class="scrollable">
71 <select
72 id="adm-sale-basket-sett-all-cols"
73 name="allColumns"
74 class="settings_select"
75 multiple
76 size="'.(count($this->allColumns) - count($this->visibleColumns)).'"
77 ondblclick="this.form.add_btn.onclick()"
78 onchange="'.$this->settingsDlgObjectName.'.onAvailableChange(this);"
79 >
80 '.$arAvailableColumnsHTML.'
81 </select>
82 </div>
83 </td>
84 <td style="background-image:none">
85 <div style="margin-bottom:5px">
86 <input type="button" name="add_btn" value="&gt;" title="'.Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_ADD_COLUMN").'" style="width:30px;" disabled onclick="jsSelectUtils.addSelectedOptions(this.form.allColumns, this.form.columns, false); jsSelectUtils.deleteSelectedOptions(this.form.allColumns); ">
87 </div>
88 <div style="margin-bottom:5px">
89 <input type="button" name="del_btn" value="&lt;" title="'.Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_DELETE_COLUMN").'" style="width:30px;" disabled onclick="jsSelectUtils.addSelectedOptions(this.form.columns, this.form.allColumns, false, true); jsSelectUtils.deleteSelectedOptions(this.form.columns);">
90 </div>
91 </td>
92 <td style="background-image:none" nowrap>
93 <div style="margin-bottom:5px">'.Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_SELECTED_COLUMNS").'</div>
94 <div class="scrollable">
95 <select
96 class="settings_select"
97 name="columns"
98 multiple
99 size="'.count($this->visibleColumns).'"
100 ondblclick="this.form.del_btn.onclick()"
101 onchange="'.$this->settingsDlgObjectName.'.onSelectedChange(this);"
102 >
103 '.$arUserColumnsHTML.'
104 </select>
105 </div>
106 </td>
107 <td style="background-image:none">
108 <div style="margin-bottom:5px"><input type="button" name="up_btn" value="'.Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_UP").'" title="'.Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_MOVE_UP").'" class="bx-grid-btn" style="width:60px;" disabled onclick="jsSelectUtils.moveOptionsUp(this.form.columns)"></div>
109 <div style="margin-bottom:5px"><input type="button" name="down_btn" value="'.Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_DOWN").'" title="'.Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_MOVE_DOWN").'" class="bx-grid-btn" style="width:60px;" disabled onclick="jsSelectUtils.moveOptionsDown(this.form.columns)"></div>
110 </td>
111 </tr>
112 ' . ($this->isShowPropsRawVisible ? $this->getShowPropsRowHtml() : '') . '
113 </table>
114 </td>
115 </tr>
116 </table>
117 </div>';
118
119 return $settingsTemplate;
120 }
121
122 public function setShowPropsVisible(bool $isVisible): void
123 {
124 $this->isShowPropsRawVisible = $isVisible;
125 }
126
127 protected function getShowPropsRowHtml(): string
128 {
129 $isShowPropVisible = static::loadIsShowPropsVisible();
130
131 return '
132 <tr id="adm-sale-basket-sett-show-props">
133 <td colspan="3">
134 <div style="margin-top: 15px;">
135 ' . Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_SHOW_PROPERTIES")
136 . ': <input type="checkbox" name="show_properties"'
137 . ($isShowPropVisible ? ' checked' : '').'>
138 </div>
139 </td>
140 </tr>';
141 }
142
143 public static function loadIsShowPropsVisible(): bool
144 {
145 return (Option::get('sale', 'order_basket_settings_show_props_visible', 'Y') === 'Y');
146 }
147
148 public static function saveIsShowPropsVisible(bool $isVisible): void
149 {
150 Option::set('sale', 'order_basket_settings_show_props_visible', ($isVisible ? 'Y' : 'N'));
151 }
152}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29