Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
correction.php
1<?php
2
4
7
8Loc::loadMessages(Main\Application::getDocumentRoot() . BX_ROOT . '/modules/sale/admin/cashbox_correction.php');
9
11{
12 public const TABLE_ID = 'tbl_sale_cashbox_correction';
13
14 public static function getTableHeaders(): array
15 {
16 return [
17 [
18 'id' => 'ID',
19 'content' => Loc::getMessage('SALE_CHECK_CORRECTION_PAYMENT_ID'),
20 'sort' => 'ID',
21 'default' => true
22 ],
23 [
24 'id' => 'ORDER_ID',
25 'content' => Loc::getMessage('SALE_CHECK_CORRECTION_ORDER_ID'),
26 'sort' => 'ORDER_ID',
27 'default' => true
28 ],
29 [
30 'id' => 'PAID',
31 'content' => Loc::getMessage('SALE_CHECK_CORRECTION_ORDER_PAID'),
32 'sort' => 'PAID',
33 'default' => true
34 ],
35 [
36 'id' => 'PAY_SYSTEM_NAME',
37 'content' => Loc::getMessage('SALE_CHECK_CORRECTION_PAY_SYSTEM_NAME'),
38 'sort' => 'PAY_SYSTEM_NAME',
39 'default' => true
40 ],
41 [
42 'id' => 'SUM',
43 'content' => Loc::getMessage('SALE_CHECK_CORRECTION_ORDER_SUM'),
44 'sort' => 'SUM',
45 'default' => true
46 ],
47 [
48 'id' => 'DATE_BILL',
49 'content' => Loc::getMessage('SALE_CHECK_CORRECTION_ORDER_DATE_BILL'),
50 'sort' => 'DATE_BILL',
51 'default' => false
52 ],
53 ];
54 }
55
56 public static function getFilterFields(): array
57 {
58 return [
59 [
60 'id' => 'PAID',
61 'name' => Loc::getMessage('SALE_F_CORRECTION_PAID'),
62 'type' => 'checkbox',
63 'default' => true
64 ],
65 [
66 'id' => 'DATE_BILL',
67 'name' => Loc::getMessage('SALE_F_CORRECTION_DATE_BILL'),
68 'type' => 'date',
69 ],
70 [
71 'id' => 'ORDER_ID',
72 'name' => Loc::getMessage('SALE_F_CORRECTION_ORDER_ID'),
73 'type' => 'number',
74 'filterable' => '',
75 'quickSearch' => ''
76 ],
77 [
78 'id' => 'CHECK_PRINTED',
79 'name' => Loc::getMessage('SALE_F_CORRECTION_CHECK_PRINTED'),
80 'type' => 'checkbox',
81 'filterable' => '',
82 'quickSearch' => '',
83 'default' => true
84 ],
85 ];
86 }
87
88 public static function prepareFilter($filter)
89 {
90 $newFilter = $filter;
91 if (isset($newFilter['CHECK_PRINTED']))
92 {
93 if ($newFilter['CHECK_PRINTED'] === 'Y')
94 {
95 $newFilter['=PAYMENT_CHECK_PRINTED.STATUS'] = 'Y';
96 }
97 else
98 {
99 $newFilter[] = [
100 'LOGIC' => 'OR',
101 '=PAYMENT_CHECK_PRINTED.STATUS' => null,
102 '@PAYMENT_CHECK_PRINTED.STATUS' => ['N', 'P', 'E']
103 ];
104 }
105
106 unset($newFilter['CHECK_PRINTED']);
107 }
108
109 return $newFilter;
110 }
111
112 public static function getPaymentSelectParams($filter): array
113 {
114 return [
115 'select' => [
116 'ID', 'ORDER_ID', 'SUM', 'CURRENCY', 'PAY_SYSTEM_NAME',
117 'PAID', 'DATE_BILL', 'CHECK_PRINTED' => 'PAYMENT_CHECK_PRINTED.STATUS'
118 ],
119 'filter' => $filter,
120 'runtime' => [
122 'PAYMENT_CHECK_PRINTED',
123 \Bitrix\Sale\Cashbox\Internals\CashboxCheckTable::getEntity(),
124 ['=ref.PAYMENT_ID' => 'this.ID',],
125 ['join_type' => 'LEFT',]
126 )
127 ]
128 ];
129 }
130
131 public static function getFilterValues(): array
132 {
133 $newFilter = [];
134
135 $filterFields = self::getFilterFields();
136 $filterOption = new \Bitrix\Main\UI\Filter\Options(self::TABLE_ID);
137 $filterData = $filterOption->getFilter($filterFields);
138 $filterable = array();
139 $quickSearchKey = '';
140 foreach ($filterFields as $filterField)
141 {
142 if (isset($filterField['quickSearch']))
143 {
144 $quickSearchKey = $filterField['quickSearch'].$filterField['id'];
145 }
146 $filterable[$filterField['id']] = $filterField['filterable'];
147 }
148
149 foreach ($filterData as $fieldId => $fieldValue)
150 {
151 if ((is_array($fieldValue) && empty($fieldValue)) || (is_string($fieldValue) && $fieldValue == ''))
152 {
153 continue;
154 }
155
156 if (mb_substr($fieldId, -5) === '_from')
157 {
158 $realFieldId = mb_substr($fieldId, 0, -5);
159 if (!array_key_exists($realFieldId, $filterable))
160 {
161 continue;
162 }
163 if (mb_substr($realFieldId, -2) === '_1')
164 {
165 $newFilter[$realFieldId] = $fieldValue;
166 }
167 else
168 {
169 if (!empty($filterData[$realFieldId.'_numsel']) && $filterData[$realFieldId.'_numsel'] === 'more')
170 $filterPrefix = '>';
171 else
172 $filterPrefix = '>=';
173 $newFilter[$filterPrefix.$realFieldId] = trim($fieldValue);
174 }
175 }
176 elseif (mb_substr($fieldId, -3) === '_to')
177 {
178 $realFieldId = mb_substr($fieldId, 0, -3);
179 if (!array_key_exists($realFieldId, $filterable))
180 {
181 continue;
182 }
183 if (mb_substr($realFieldId, -2) === '_1')
184 {
185 $realFieldId = mb_substr($realFieldId, 0, -2);
186 $newFilter[$realFieldId.'_2'] = $fieldValue;
187 }
188 else
189 {
190 if (!empty($filterData[$realFieldId.'_numsel']) && $filterData[$realFieldId.'_numsel'] === 'less')
191 {
192 $filterPrefix = '<';
193 }
194 else
195 {
196 $filterPrefix = '<=';
197 }
198 $newFilter[$filterPrefix.$realFieldId] = trim($fieldValue);
199 }
200 }
201 else
202 {
203 if (array_key_exists($fieldId, $filterable))
204 {
205 $filterPrefix = $filterable[$fieldId];
206 $newFilter[$filterPrefix.$fieldId] = $fieldValue;
207 }
208 if ($quickSearchKey && $fieldId === 'FIND' && trim($fieldValue))
209 {
210 $newFilter[$quickSearchKey] = $fieldValue;
211 }
212 }
213 }
214
215 return $newFilter;
216 }
217}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29