Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
presetbasket.php
1<?php
2
4
15
16Loc::loadMessages(__FILE__);
17
18require_once __DIR__.'/../../../../general/admin_tool.php';
19
21{
22
26 public function __construct(Order $order, $jsObjName = "", $idPrefix = "", $createProductBasement = true, $mode = self::EDIT_MODE)
27 {
29 $this->createProductBasement = false;
30 }
31
32 protected static function getDefaultVisibleColumns()
33 {
34 return array(
35 "IMAGE" => Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_COL_IMAGE"),
36 "NAME" => Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_COL_NAME"),
37 "PROPS" => Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_COL_PROPS"),
38 "PRICE" => Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_COL_PRICE"),
39 );
40 }
41
42 public function getScripts($defTails = false)
43 {
44 if(!static::$jsInited)
45 {
46 \Bitrix\Main\Page\Asset::getInstance()->addJs("/bitrix/js/sale/admin/order_basket.js");
47 \Bitrix\Main\Page\Asset::getInstance()->addJs("/bitrix/js/sale/admin/discount_preset_basket.js");
48 static::$jsInited = true;
49 }
50
51 $langPhrases = array("SALE_ORDER_BASKET_TURN", "SALE_ORDER_BASKET_EXPAND", "SALE_ORDER_BASKET_UP_RATIO",
52 "SALE_ORDER_BASKET_PROD_EDIT", "SALE_ORDER_BASKET_DOWN_RATIO", "SALE_ORDER_BASKET_PROD_COUNT",
53 "SALE_ORDER_BASKET_NO_PICTURE", "SALE_ORDER_BASKET_PROD_CREATE", "SALE_ORDER_BASKET_ROW_SETTINGS",
54 "SALE_ORDER_BASKET_PROD_MENU_EDIT", "SALE_ORDER_BASKET_PROD_MENU_DELETE", "SALE_ORDER_BASKET_BASE_CATALOG_PRICE",
55 "SALE_ORDER_BASKET_PROD_EDIT_ITEM_SAVE", "SALE_ORDER_BASKET_KG", "SALE_ORDER_BASKET_COUPON",
56 "SALE_ORDER_BASKET_COUPON_STATUS", "SALE_ORDER_BASKET_COUPON_APPLY", "SALE_ORDER_BASKET_COUPON_DELETE",
57 "SALE_ORDER_BASKET_POSITION_EXISTS", "SALE_ORDER_BASKET_ADD_COUPON_ERROR"
58 );
59 $result = '<script type="text/javascript">';
60
61 foreach($langPhrases as $phrase)
62 $result .= ' BX.message({'.$phrase.': "'.\CUtil::jsEscape(Loc::getMessage($phrase)).'"});';
63
64 if(!$defTails)
65 $data = static::prepareData();
66
67 $result .= '
68 BX.ready(function(){
69 var obParams = {
70 tableId: "'.$this->idPrefix.'sale_order_edit_product_table",
71 idPrefix: "'.$this->idPrefix.'",
72 visibleColumns: '.\CUtil::phpToJSObject($this->visibleColumns).',
73 objName: "'.$this->jsObjName.'",
74 createProductBasement: '.($this->createProductBasement ? 'true' : 'false').',
75 columnsCount: '.count($this->visibleColumns).',
76 createBasketBottom: false,
77 isShowXmlId: '.($this->isShowXmlId ? 'true' : 'false').',
78 mode: "edit",
79 unRemovableFields: [],
80 formatQuantity: "'.Option::get('sale', 'format_quantity', 'AUTO').'",
81 weightUnit: "'.$this->weightUnit.'"
82 };';
83
84 if(!$defTails)
85 {
86 $result .= '
87 obParams.productsOrder = '.\CUtil::phpToJSObject($data["ITEMS_ORDER"]).';
88 obParams.products = '.\CUtil::phpToJSObject($data["ITEMS"]).';
89 obParams.iblocksSkuParams = '.\CUtil::phpToJSObject($data["IBLOCKS_SKU_PARAMS"]).';
90 obParams.iblocksSkuParamsOrder = '.\CUtil::phpToJSObject($data["IBLOCKS_SKU_PARAMS_ORDER"]).';
91 obParams.productsOffersSkuParams = '.\CUtil::phpToJSObject($data["PRODUCTS_OFFERS_SKU"]).';';
92 }
93
94 $result .=
95 $this->jsObjName.'= new BX.Sale.Admin.PresetBasket(obParams);
96 BX.Sale.Admin.OrderEditPage.registerFieldsUpdaters( '.$this->jsObjName.'.getFieldsUpdaters() );
97 });';
98
99 $result .= $this->settingsDialog->getScripts();
100
101 $result .= '</script>';
102 return $result;
103 }
104
105 public function getEdit($defTails = false)
106 {
107 $result = '
108 <div class="adm-s-gray-title" style="padding-right: 2px;">
109 '.Loc::getMessage("SALE_ORDER_BASKET_COMPOSITION").'
110 <div class="adm-s-gray-title-btn-container">
111 <span
112 class="adm-btn adm-btn-green adm-btn-add"
113 onClick="'.$this->jsObjName.'.addProductSearch({lang: \''.LANGUAGE_ID.'\', siteId: \''.$this->order->getSiteId().'\', orderId: '.intval($this->order->getId()).'});"
114 >'.
115 Loc::getMessage("SALE_ORDER_BASKET_PRODUCT_ADD").
116 '</span>
117 </div>
118 <div class="clb"></div>
119 </div>';
120
121 $result .= '
122 <div class="adm-s-order-table-ddi">
123 <table class="adm-s-order-table-ddi-table" style="width: 100%;" id="'.$this->idPrefix.'sale_order_edit_product_table">
124 <thead style="text-align: left;">
125 <tr>
126 <td>
127 </td> ';
128
129 foreach($this->visibleColumns as $name)
130 $result .= "<td>".htmlspecialcharsbx($name)."</td>";
131
132 $result .= '</tr>
133 </thead>';
134
135 if($defTails)
136 {
137 $result .='
138 <tbody style="border: 1px solid rgb(221, 221, 221);" id="'.$this->idPrefix.'sale-adm-order-basket-loading-row">
139 <tr>
140 <td colspan="'.(count($this->visibleColumns)+1).'" style="padding: 20px;">
141 <img src="/bitrix/images/sale/admin-loader.gif"/>
142 </td>
143 </tr>
144 </tbody>';
145 }
146
147 $result .='
148 <tbody style="border: 1px solid rgb(221, 221, 221);'.($defTails ? ' display:none;' : '').'" id="'.$this->idPrefix.'sale-adm-order-edit-basket-empty-row">
149 <tr>
150 <td colspan="'.(count($this->visibleColumns)+1).'" style="padding: 20px;">
151 '.Loc::getMessage("SALE_ORDER_BASKET_EMPTY_ROW").'.
152 </td>
153 </tr>
154 </tbody>';
155
156 $result .= '
157 </table>
158 </div>
159 <div class="adm-s-gray-title" style="padding-right: 2px;">
160 <div class="adm-s-gray-title-btn-container">';
161
162 $result .= '<span
163 class="adm-btn adm-btn-green adm-btn-add"
164 onClick="'.$this->jsObjName.'.addProductSearch({lang: \''.LANGUAGE_ID.'\', siteId: \''.$this->order->getSiteId().'\', index: 1, orderId: '.intval($this->order->getId()).'});"
165 >'.
166 Loc::getMessage("SALE_ORDER_BASKET_PRODUCT_ADD").
167 '</span>
168 </div>
169 <div class="clb"></div>
170 </div>
171 <input type="hidden" name="BASKET[ID_PREFIX]" value="'.$this->idPrefix.'">
172 <div class="adm-s-result-container">';
173
174 $result .= '
175 </div>
176 <div class="clb"></div>';
177 return $result;
178 }
179
180}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
__construct(Order $order, $jsObjName="", $idPrefix="", $createProductBasement=true, $mode=self::EDIT_MODE)