|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* |
|
5
|
|
|
* The MIT License (MIT) |
|
6
|
|
|
* |
|
7
|
|
|
* Copyright (c) 2015 Daniel Popiniuc |
|
8
|
|
|
* |
|
9
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
10
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
11
|
|
|
* in the Software without restriction, including without limitation the rights |
|
12
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
13
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
14
|
|
|
* furnished to do so, subject to the following conditions: |
|
15
|
|
|
* |
|
16
|
|
|
* The above copyright notice and this permission notice shall be included in all |
|
17
|
|
|
* copies or substantial portions of the Software. |
|
18
|
|
|
* |
|
19
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
20
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
21
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
22
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
23
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
24
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
25
|
|
|
* SOFTWARE. |
|
26
|
|
|
* |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
namespace danielgp\common_lib; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* DOM component functions |
|
33
|
|
|
* |
|
34
|
|
|
* @author Daniel Popiniuc |
|
35
|
|
|
*/ |
|
36
|
|
|
trait DomComponentsByDanielGP |
|
37
|
|
|
{ |
|
38
|
|
|
|
|
39
|
|
|
use CommonBasic, |
|
40
|
|
|
DomHeaderFooterByDanielGP; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Returns a table from an query |
|
44
|
|
|
* |
|
45
|
|
|
* @param array $aElements |
|
46
|
|
|
* @param array $ftrs |
|
47
|
|
|
* @param boolean $bKpFlPge |
|
48
|
|
|
* @return string |
|
49
|
|
|
*/ |
|
50
|
|
|
protected function setArrayToTable($aElements, $ftrs = [], $bKpFlPge = true) |
|
51
|
|
|
{ |
|
52
|
|
|
$rows = count($aElements); |
|
53
|
|
|
if ($rows == 0) { |
|
54
|
|
|
$divTab = [ |
|
55
|
|
|
'start' => '', |
|
56
|
|
|
'end' => '', |
|
57
|
|
|
]; |
|
58
|
|
|
if (array_key_exists('showGroupingCounter', $ftrs)) { |
|
59
|
|
|
if (array_key_exists('grouping_cell_type', $ftrs) && ($ftrs['grouping_cell_type'] == 'tab')) { |
|
60
|
|
|
$ditTitle = 'No data found'; |
|
61
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
|
62
|
|
|
$ditTitle .= ' (0)'; |
|
63
|
|
|
} |
|
64
|
|
|
$divTab = [ |
|
65
|
|
|
'start' => '<div class="tabbertab tabbertabdefault" id="tab_NoData" title="' . $ditTitle . '">', |
|
66
|
|
|
'end' => '</div><!-- from tab_NoData -->', |
|
67
|
|
|
]; |
|
68
|
|
|
if (!isset($ftrs['noGlobalTab'])) { |
|
69
|
|
|
$divTab = [ |
|
70
|
|
|
'start' => '<div class="tabber" id="tab">' . $divTab['start'], |
|
71
|
|
|
'end' => $divTab['end'] . '</div><!-- from global Tab -->', |
|
72
|
|
|
]; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
return $divTab['start'] |
|
77
|
|
|
. $this->setFeedbackModern('error', 'Error', $this->lclMsgCmn('i18n_NoData')) |
|
78
|
|
|
. $divTab['end']; |
|
79
|
|
|
} |
|
80
|
|
|
if (isset($ftrs['limits'])) { |
|
81
|
|
|
$ftrs['limits'][1] = min($ftrs['limits'][1], $ftrs['limits'][2]); |
|
82
|
|
|
if ($ftrs['limits'][2] > $ftrs['limits'][1]) { |
|
83
|
|
|
$iStartingPageRecord = 1; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
$sReturn = ''; |
|
87
|
|
|
if (isset($ftrs['hidden_columns'])) { |
|
88
|
|
|
$hdClmns = $this->setArrayValuesAsKey($ftrs['hidden_columns']); |
|
89
|
|
|
} else { |
|
90
|
|
|
$hdClmns = ['']; |
|
91
|
|
|
} |
|
92
|
|
|
$checkboxFormId = ''; |
|
93
|
|
|
if ((isset($ftrs['actions']['checkbox_inlineEdit'])) || (isset($ftrs['actions']['checkbox']))) { |
|
94
|
|
|
$checkboxFormId = 'frm' . date('YmdHis'); |
|
95
|
|
|
$sReturn .= '<form id="' . $checkboxFormId . '" name="' . $checkboxFormId |
|
96
|
|
|
. '" method="post" ' . ' action="' . $this->tCmnRequest->server->get('PHP_SELF') . '" >'; |
|
97
|
|
|
} |
|
98
|
|
|
$tbl = []; |
|
99
|
|
|
$tbl['Def'] = '<table' |
|
100
|
|
|
. (isset($ftrs['table_style']) ? ' style="' . $ftrs['table_style'] . '"' : '') |
|
101
|
|
|
. (isset($ftrs['table_class']) ? ' class="' . $ftrs['table_class'] . '"' : '') |
|
102
|
|
|
. '>'; |
|
103
|
|
|
if (!isset($ftrs['grouping_cell_type'])) { |
|
104
|
|
|
$ftrs['grouping_cell_type'] = 'row'; |
|
105
|
|
|
} |
|
106
|
|
|
switch ($ftrs['grouping_cell_type']) { |
|
107
|
|
|
case 'row': |
|
108
|
|
|
$sReturn .= $tbl['Def']; |
|
109
|
|
|
break; |
|
110
|
|
|
case 'tab': |
|
111
|
|
|
if (!isset($ftrs['noGlobalTab'])) { |
|
112
|
|
|
$sReturn .= '<div class="tabber" id="tab">'; |
|
113
|
|
|
} |
|
114
|
|
|
break; |
|
115
|
|
|
} |
|
116
|
|
|
$groupCounter = 0; |
|
117
|
|
|
$iTableColumns = 0; |
|
118
|
|
|
$remebered_value = -1; |
|
119
|
|
|
$remindGroupValue = null; |
|
120
|
|
|
$color_no = null; |
|
121
|
|
|
if (!isset($ftrs['headers_breaked'])) { |
|
122
|
|
|
$ftrs['headers_breaked'] = true; |
|
123
|
|
|
} |
|
124
|
|
|
for ($rCntr = 0; $rCntr < $rows; $rCntr++) { |
|
125
|
|
|
if ($rCntr == 0) { |
|
126
|
|
|
$header = array_diff_key($aElements[$rCntr], $hdClmns); |
|
127
|
|
|
$iTableColumns = count($header); |
|
128
|
|
|
if (isset($ftrs['computed_columns'])) { |
|
129
|
|
|
$iTableColumns += count($ftrs['computed_columns']); |
|
130
|
|
|
} |
|
131
|
|
|
if (isset($ftrs['actions'])) { |
|
132
|
|
|
$iTableColumns += 1; |
|
133
|
|
|
} |
|
134
|
|
|
if (isset($ftrs['grouping_cell'])) { |
|
135
|
|
|
$iTableColumns -= 1; |
|
136
|
|
|
} |
|
137
|
|
|
$tbl['Head'] = '<thead>'; |
|
138
|
|
|
if ($ftrs['grouping_cell_type'] == 'row') { |
|
139
|
|
|
$sReturn .= $tbl['Head']; |
|
140
|
|
|
} |
|
141
|
|
|
if (isset($iStartingPageRecord)) { |
|
142
|
|
|
$pgn = '' |
|
143
|
|
|
. $this->setPagination($ftrs['limits'][0], $ftrs['limits'][1], $ftrs['limits'][2], $bKpFlPge); |
|
144
|
|
|
$sReturn .= $this->setStringIntoTag($this->setStringIntoTag($pgn, 'th', [ |
|
145
|
|
|
'colspan' => $iTableColumns |
|
146
|
|
|
]), 'tr'); |
|
147
|
|
|
} |
|
148
|
|
|
$tbl['Header'] = '<tr>'; |
|
149
|
|
|
if (isset($ftrs['grouping_cell'])) { // Grouping columns |
|
150
|
|
|
$header = array_diff_key($header, [$ftrs['grouping_cell'] => '']); |
|
151
|
|
|
} |
|
152
|
|
|
if (isset($ftrs['actions'])) { // Action column |
|
153
|
|
|
$tbl['Header'] .= '<th> </th>'; |
|
154
|
|
|
} |
|
155
|
|
|
if (isset($ftrs['RowStyle'])) { //Exclude style columns from displaying |
|
156
|
|
|
$tmpClmns = $this->setArrayValuesAsKey([$ftrs['RowStyle']]); |
|
157
|
|
|
$header = array_diff_key($header, $tmpClmns); |
|
158
|
|
|
$hdClmns = array_merge($hdClmns, $tmpClmns); |
|
159
|
|
|
unset($tmpClmns); |
|
160
|
|
|
} |
|
161
|
|
|
$tbl['Header'] .= $this->setTableHeader($header, $ftrs['headers_breaked']); // Regular columns |
|
162
|
|
|
if (isset($ftrs['computed_columns'])) { // Computed columns |
|
163
|
|
|
$tbl['Header'] .= $this->setTableHeader($ftrs['computed_columns'], $ftrs['headers_breaked']); |
|
164
|
|
|
} |
|
165
|
|
|
$tbl['Header'] .= '</tr></thead><tbody>'; |
|
166
|
|
|
if ($ftrs['grouping_cell_type'] == 'row') { |
|
167
|
|
|
$sReturn .= $tbl['Header']; |
|
168
|
|
|
} |
|
169
|
|
|
} |
|
170
|
|
|
$row_current = array_diff_key($aElements[$rCntr], $hdClmns); |
|
171
|
|
|
if (isset($ftrs['row_colored_alternated'])) { |
|
172
|
|
|
if ($ftrs['row_colored_alternated'][0] == '#') { |
|
173
|
|
|
$color_column_value = $rCntr; |
|
174
|
|
|
} else { |
|
175
|
|
|
$color_column_value = $row_current[$ftrs['row_colored_alternated'][0]]; |
|
176
|
|
|
} |
|
177
|
|
|
if ($remebered_value != $color_column_value) { |
|
178
|
|
|
if (isset($color_no)) { |
|
179
|
|
|
$color_no = 1; |
|
180
|
|
|
} else { |
|
181
|
|
|
$color_no = 2; |
|
182
|
|
|
} |
|
183
|
|
|
$remebered_value = $color_column_value; |
|
184
|
|
|
} |
|
185
|
|
|
$color = ' style="background-color: ' . $ftrs['row_colored_alternated'][$color_no] . ';"'; |
|
186
|
|
|
} else { |
|
187
|
|
|
if (isset($ftrs['RowStyle'])) { |
|
188
|
|
|
$color = ' style="' . $aElements[$rCntr][$ftrs['RowStyle']] . '"'; |
|
189
|
|
|
} else { |
|
190
|
|
|
$color = ''; |
|
191
|
|
|
} |
|
192
|
|
|
} |
|
193
|
|
|
$tbl['tr_Color'] = '<tr' . $color . '>'; |
|
194
|
|
|
// Grouping column |
|
195
|
|
|
if (isset($ftrs['grouping_cell'])) { |
|
196
|
|
|
foreach ($aElements[$rCntr] as $key => $value) { |
|
197
|
|
|
if (($ftrs['grouping_cell'] == $key) && ($remindGroupValue != $value)) { |
|
198
|
|
|
switch ($ftrs['grouping_cell_type']) { |
|
199
|
|
|
case 'row': |
|
200
|
|
|
$sReturn .= $tbl['tr_Color'] . '<td ' . 'colspan="' . $iTableColumns . '">' |
|
201
|
|
|
. $this->setStringIntoTag($value, 'div', ['class' => 'rowGroup rounded']) |
|
202
|
|
|
. '</td></tr>'; |
|
203
|
|
|
break; |
|
204
|
|
|
case 'tab': |
|
205
|
|
|
if (is_null($remindGroupValue)) { |
|
206
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
|
207
|
|
|
$groupCounter = 0; |
|
208
|
|
|
} |
|
209
|
|
|
} else { |
|
210
|
|
|
$sReturn .= '</tbody></table>'; |
|
211
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
|
212
|
|
|
$sReturn .= $this->updateDivTitleName($remindGroupValue, $groupCounter); |
|
213
|
|
|
$groupCounter = 0; |
|
214
|
|
|
} |
|
215
|
|
|
$sReturn .= '</div>'; |
|
216
|
|
|
} |
|
217
|
|
|
$sReturn .= '<div class="tabbertab'; |
|
218
|
|
|
if (isset($ftrs['grouping_default_tab'])) { |
|
219
|
|
|
$sReturn .= ($ftrs['grouping_default_tab'] == $value ? ' tabbertabdefault' : ''); |
|
220
|
|
|
} |
|
221
|
|
|
$sReturn .= '" id="tab_' . $this->cleanStringForId($value) . '" ' |
|
222
|
|
|
. 'title="' . $value . '">' |
|
223
|
|
|
. $tbl['Def'] . $tbl['Head'] . $tbl['Header']; |
|
224
|
|
|
break; |
|
225
|
|
|
} |
|
226
|
|
|
$remindGroupValue = $value; |
|
227
|
|
|
} |
|
228
|
|
|
} |
|
229
|
|
|
} |
|
230
|
|
|
if (isset($ftrs['grouping_cell'])) { |
|
231
|
|
|
if ($ftrs['grouping_cell_type'] == 'tab') { |
|
232
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
|
233
|
|
|
$groupCounter++; |
|
234
|
|
|
} |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
|
|
$sReturn .= $tbl['tr_Color']; |
|
238
|
|
|
// Action column |
|
239
|
|
|
$checkboxName = ''; |
|
240
|
|
|
$checkboxNameS = ''; |
|
241
|
|
|
if (isset($ftrs['actions'])) { |
|
242
|
|
|
$sReturn .= '<td style="white-space:nowrap;">'; |
|
243
|
|
|
$action_argument = 0; |
|
244
|
|
|
if (isset($ftrs['actions']['key'])) { |
|
245
|
|
|
$actionKey = $ftrs['actions']['key']; |
|
246
|
|
|
} else { |
|
247
|
|
|
$actionKey = 'view'; |
|
248
|
|
|
} |
|
249
|
|
|
if (isset($ftrs['action_prefix'])) { |
|
250
|
|
|
$actPrfx = $ftrs['action_prefix'] . '&'; |
|
251
|
|
|
$actionKey = 'view2'; |
|
252
|
|
|
} else { |
|
253
|
|
|
$actPrfx = ''; |
|
254
|
|
|
} |
|
255
|
|
|
foreach ($ftrs['actions'] as $key => $value) { |
|
256
|
|
|
if ($action_argument != 0) { |
|
257
|
|
|
$sReturn .= ' '; |
|
258
|
|
|
} |
|
259
|
|
|
switch ($key) { |
|
260
|
|
|
case 'checkbox': |
|
261
|
|
|
$checkboxName = $value . '[]'; |
|
262
|
|
|
$checkboxNameS = $value; |
|
263
|
|
|
$sReturn .= ' <input type="checkbox" name="' . $checkboxName |
|
264
|
|
|
. '" id="n' . $aElements[$rCntr][$value] |
|
265
|
|
|
. '" value="' . $aElements[$rCntr][$value] . '" '; |
|
266
|
|
|
if (!is_null($this->tCmnSuperGlobals->get($checkboxNameS))) { |
|
267
|
|
|
$inputToCheck = $this->tCmnSuperGlobals->get($checkboxNameS); |
|
268
|
|
|
if (is_array($inputToCheck)) { |
|
269
|
|
|
if (in_array($aElements[$rCntr][$value], $inputToCheck)) { |
|
270
|
|
|
$sReturn .= 'checked="checked" '; |
|
271
|
|
|
} |
|
272
|
|
|
} else { |
|
273
|
|
|
if ($aElements[$rCntr][$value] == $inputToCheck) { |
|
274
|
|
|
$sReturn .= 'checked="checked" '; |
|
275
|
|
|
} |
|
276
|
|
|
} |
|
277
|
|
|
} |
|
278
|
|
|
if (strpos($this->tCmnSuperGlobals->get('view'), 'multiEdit') !== false) { |
|
279
|
|
|
$sReturn .= 'disabled="disabled" '; |
|
280
|
|
|
} |
|
281
|
|
|
$sReturn .= '/>'; |
|
282
|
|
|
break; |
|
283
|
|
|
case 'checkbox_inlineEdit': |
|
284
|
|
|
$checkboxName = $value . '[]'; |
|
285
|
|
|
$checkboxNameS = $value; |
|
286
|
|
|
$sReturn .= ' <input type="checkbox" name="' . $checkboxName |
|
287
|
|
|
. '" id="n' . $aElements[$rCntr][$value] . '" value="' |
|
288
|
|
|
. $aElements[$rCntr][$value] . '"/>'; |
|
289
|
|
|
break; |
|
290
|
|
|
case 'delete': |
|
291
|
|
|
$sReturn .= '<a href="#" onclick="javascript:setQuest(\'' . $value[0] . '\',\''; |
|
292
|
|
|
$iActArgs = count($value[1]); |
|
293
|
|
|
for ($cntr2 = 0; $cntr2 < $iActArgs; $cntr2++) { |
|
294
|
|
|
$sReturn .= $value[1][$cntr2] . '=' . $aElements[$rCntr][$value[1][$cntr2]]; |
|
295
|
|
|
} |
|
296
|
|
|
$sReturn .= '\');" id="' . $key . $rCntr . '"><i class="fa fa-times"> </i></a>'; |
|
297
|
|
|
break; |
|
298
|
|
|
case 'edit': |
|
299
|
|
|
case 'list2': |
|
300
|
|
|
case 'schedule': |
|
301
|
|
|
$vIc = ($key == 'edit' ? 'pencil' : ($key == 'list2' ? 'list' : 'hourglass-half')); |
|
302
|
|
|
$sReturn .= $this->setDynamicActionToSpecialCell($value, $aElements, [ |
|
303
|
|
|
'vIcon' => 'fa fa-' . $vIc, |
|
304
|
|
|
'aPrefix' => $actPrfx, |
|
305
|
|
|
'aKey' => $actionKey, |
|
306
|
|
|
'rCounter' => $rCntr, |
|
307
|
|
|
'Features' => $ftrs, |
|
308
|
|
|
'key' => $key, |
|
309
|
|
|
]); |
|
310
|
|
|
break; |
|
311
|
|
|
} |
|
312
|
|
|
$action_argument += 1; |
|
313
|
|
|
} |
|
314
|
|
|
$sReturn .= '</td>'; |
|
315
|
|
|
} |
|
316
|
|
|
// Regular columns |
|
317
|
|
|
$sReturn .= $this->setTableCell($row_current, $ftrs); |
|
318
|
|
|
// Computed columns |
|
319
|
|
|
if (isset($ftrs['computed_columns'])) { |
|
320
|
|
|
$rowComputed = []; |
|
321
|
|
|
$decimals = []; |
|
322
|
|
|
foreach ($ftrs['computed_columns'] as $key => $value) { |
|
323
|
|
|
if ($value[0] == '%') { |
|
324
|
|
|
$dec = $value[2] + 2; |
|
325
|
|
|
} else { |
|
326
|
|
|
$dec = $value[2]; |
|
327
|
|
|
} |
|
328
|
|
|
switch ($value[1]) { |
|
329
|
|
|
case '/': |
|
330
|
|
|
// next variable is only to avoid a long line |
|
331
|
|
|
$shorter = [ |
|
332
|
|
|
$aElements[$rCntr][$value[3]], |
|
333
|
|
|
$aElements[$rCntr][$value[4]], |
|
334
|
|
|
]; |
|
335
|
|
|
$aElements[$rCntr][$key] = $this->setDividedResult($shorter[0], $shorter[1], $dec); |
|
336
|
|
|
break; |
|
337
|
|
|
case '+': |
|
338
|
|
|
// next variable is only to avoid a long line |
|
339
|
|
|
$iTemp = $this->setArrayValuesAsKey([ |
|
340
|
|
|
$value[0], |
|
341
|
|
|
$value[1], |
|
342
|
|
|
$value[2] |
|
343
|
|
|
]); |
|
344
|
|
|
$aTemp = array_diff($value, $iTemp); |
|
345
|
|
|
$aElements[$rCntr][$key] = 0; |
|
346
|
|
|
foreach ($aTemp as $sValue) { |
|
347
|
|
|
$aElements[$rCntr][$key] += $aElements[$rCntr][$sValue]; |
|
348
|
|
|
} |
|
349
|
|
|
break; |
|
350
|
|
|
default: |
|
351
|
|
|
$rowComputed[$key] = ''; |
|
352
|
|
|
break; |
|
353
|
|
|
} |
|
354
|
|
|
if ($value[0] == '%') { |
|
355
|
|
|
$rowComputed[$key] = ($aElements[$rCntr][$key] * 100); |
|
356
|
|
|
$dec -= 2; |
|
357
|
|
|
} else { |
|
358
|
|
|
$rowComputed[$key] = $aElements[$rCntr][$key]; |
|
359
|
|
|
} |
|
360
|
|
|
$decimals[$key] = $dec; |
|
361
|
|
|
} |
|
362
|
|
|
// displaying them |
|
363
|
|
|
$sReturn .= $this->setTableCell($rowComputed, ['decimals' => $decimals]); |
|
364
|
|
|
} |
|
365
|
|
|
$sReturn .= '</tr>'; |
|
366
|
|
|
} |
|
367
|
|
|
if (isset($iStartingPageRecord)) { |
|
368
|
|
|
$pgn = $this->setPagination($ftrs['limits'][0], $ftrs['limits'][1], $ftrs['limits'][2]); |
|
369
|
|
|
$sReturn .= '<tr>' . $this->setStringIntoTag($pgn, 'th', ['colspan' => $iTableColumns]) . '</tr>'; |
|
370
|
|
|
} |
|
371
|
|
|
$sReturn .= '</tbody></table>'; |
|
372
|
|
|
if ($ftrs['grouping_cell_type'] == 'tab') { |
|
373
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
|
374
|
|
|
$sReturn .= $this->updateDivTitleName($remindGroupValue, $groupCounter); |
|
375
|
|
|
} |
|
376
|
|
|
$sReturn .= '</div><!-- from ' . $remindGroupValue . ' -->'; |
|
377
|
|
|
if (!isset($ftrs['noGlobalTab'])) { |
|
378
|
|
|
$sReturn .= '</div><!-- from global tab -->'; |
|
379
|
|
|
} |
|
380
|
|
|
} |
|
381
|
|
|
if (isset($ftrs['actions']['checkbox'])) { |
|
382
|
|
|
if (strpos($this->tCmnSuperGlobals->get('view'), 'multiEdit') === false) { |
|
383
|
|
|
$sReturn .= '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
|
384
|
|
|
. '\',\'' . $checkboxName . '\',true);">Check All</a> ' |
|
|
|
|
|
|
385
|
|
|
. '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
|
386
|
|
|
. '\',\'' . $checkboxName . '\',false);">Uncheck All</a> ' |
|
387
|
|
|
. '<input type="hidden" name="action" value="multiEdit_' . $checkboxNameS . '" />'; |
|
|
|
|
|
|
388
|
|
|
if (isset($ftrs['hiddenInput'])) { |
|
389
|
|
|
if (is_array($ftrs['hiddenInput'])) { |
|
390
|
|
|
foreach ($ftrs['hiddenInput'] as $valueF) { |
|
391
|
|
|
$sReturn .= '<input type="hidden" name="' . $valueF |
|
392
|
|
|
. '" value="' . $this->tCmnSuperGlobals->get($valueF) . '" />'; |
|
393
|
|
|
} |
|
394
|
|
|
} else { |
|
395
|
|
|
$sReturn .= '<input type="hidden" name="' . $ftrs['hiddenInput'] |
|
396
|
|
|
. '" value="' . $this->tCmnSuperGlobals->get($ftrs['hiddenInput']) . '" />'; |
|
397
|
|
|
} |
|
398
|
|
|
} |
|
399
|
|
|
$sReturn .= '<input style="margin: 0 3em 0 3em;" type="submit" ' . 'value="Edit selected" />'; |
|
400
|
|
|
} |
|
401
|
|
|
$sReturn .= '</form>'; |
|
402
|
|
|
} |
|
403
|
|
|
if (isset($ftrs['actions']['checkbox_inlineEdit'])) { |
|
404
|
|
|
$sReturn .= '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
|
405
|
|
|
. '\',\'' . $checkboxName . '\',true);">Check All</a> ' |
|
406
|
|
|
. '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
|
407
|
|
|
. '\',\'' . $checkboxName . '\',false);">Uncheck All</a> '; |
|
408
|
|
|
if (isset($ftrs['visibleInput'])) { |
|
409
|
|
|
$sReturn .= $ftrs['visibleInput']; |
|
410
|
|
|
} |
|
411
|
|
|
$sReturn .= '<input type="hidden" name="view" value="save_' . $checkboxNameS . '" />'; |
|
412
|
|
|
if (isset($ftrs['hiddenInput'])) { |
|
413
|
|
|
if (is_array($ftrs['hiddenInput'])) { |
|
414
|
|
|
foreach ($ftrs['hiddenInput'] as $valueF) { |
|
415
|
|
|
$sReturn .= '<input type="hidden" name="' . $valueF . '" value="' |
|
416
|
|
|
. $this->tCmnSuperGlobals->get($valueF) . '" />'; |
|
417
|
|
|
} |
|
418
|
|
|
} else { |
|
419
|
|
|
$sReturn .= '<input type="hidden" name="' . $ftrs['hiddenInput'] |
|
420
|
|
|
. '" value="' . $this->tCmnSuperGlobals->get($ftrs['hiddenInput']) . '" />'; |
|
421
|
|
|
} |
|
422
|
|
|
} |
|
423
|
|
|
$sReturn .= '<input style="margin: 0 3em 0 3em;" type="submit" value="Store the modification" />'; |
|
424
|
|
|
$sReturn .= '</form>'; |
|
425
|
|
|
} |
|
426
|
|
|
return $sReturn; |
|
427
|
|
|
} |
|
428
|
|
|
|
|
429
|
|
|
private function setDynamicActionToSpecialCell($val, $aElements, $inP) |
|
430
|
|
|
{ |
|
431
|
|
|
$aArgumemts = []; |
|
432
|
|
|
$aArgumemts[] = $this->tCmnSuperGlobals->getScriptName() . '?' . $inP['aPrefix'] . $inP['aKey'] . '=' . $val[0]; |
|
433
|
|
|
$iActArgs = count($val[1]); |
|
434
|
|
|
for ($counter = 0; $counter < $iActArgs; $counter++) { |
|
435
|
|
|
$aArgumemts[] = $val[1][$counter] . '=' . $aElements[$inP['rCounter']][$val[1][$counter]]; |
|
436
|
|
|
} |
|
437
|
|
|
$id = $inP['key'] . $inP['rCounter']; |
|
438
|
|
|
if (isset($inP['Features']['NoAjaxEditing'])) { |
|
439
|
|
|
return '<a href="' . implode('&', $aArgumemts) . '" id="' . $id . '"><i class="' |
|
440
|
|
|
. $inP['vIcon'] . '"> </i></a>'; |
|
441
|
|
|
} |
|
442
|
|
|
return '<a href="#" onclick="javascript:loadAE(\'' . implode('&', $aArgumemts) . '\');"' |
|
443
|
|
|
. ' id="' . $id . '"><i class="' . $inP['vIcon'] . '"> </i></a>'; |
|
444
|
|
|
} |
|
445
|
|
|
|
|
446
|
|
|
/** |
|
447
|
|
|
* Generates a table cell |
|
448
|
|
|
* |
|
449
|
|
|
* @param array $aElements |
|
450
|
|
|
* @param array $features |
|
451
|
|
|
* @return string |
|
452
|
|
|
*/ |
|
453
|
|
|
private function setTableCell($aElements, $features = null) |
|
454
|
|
|
{ |
|
455
|
|
|
$sReturn = null; |
|
456
|
|
|
foreach ($aElements as $key => $value) { |
|
457
|
|
|
$value = str_replace(['& ', '\"', "\'"], ['& ', '"', "'"], $value); |
|
458
|
|
|
if ((isset($features['grouping_cell'])) && ($features['grouping_cell'] == $key)) { |
|
459
|
|
|
// just skip |
|
460
|
|
|
} else { |
|
461
|
|
|
$sReturn .= '<td '; |
|
462
|
|
|
if (isset($features['column_formatting'][$key])) { |
|
463
|
|
|
switch ($features['column_formatting'][$key]) { |
|
464
|
|
|
case '@': |
|
465
|
|
|
$sReturn .= 'style="text-align:left;">' . $value; |
|
466
|
|
|
break; |
|
467
|
|
|
case 'right': |
|
468
|
|
|
$sReturn .= 'style="text-align:right;">' . $value; |
|
469
|
|
|
break; |
|
470
|
|
|
default: |
|
471
|
|
|
$sReturn .= '???'; |
|
472
|
|
|
break; |
|
473
|
|
|
} |
|
474
|
|
|
} else { |
|
475
|
|
|
if (is_numeric($value)) { |
|
476
|
|
|
$sReturn .= $this->setTableCellNumeric($key, $value, $features); |
|
477
|
|
|
} else { |
|
478
|
|
|
$outputet = false; |
|
479
|
|
|
if ((strpos($value, '-') !== false) && (strlen($value) == 10)) { |
|
480
|
|
|
if (preg_match("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $value, $regs)) { |
|
481
|
|
|
$outputet = true; |
|
482
|
|
|
$sReturn .= 'style="text-align:right;width: 10px;">' |
|
483
|
|
|
. $regs[3] . '.' . $regs[2] . '.' . $regs[1]; |
|
484
|
|
|
} |
|
485
|
|
|
} |
|
486
|
|
|
if (!$outputet) { |
|
487
|
|
|
$sReturn .= 'style="text-align:left;">' . $value; |
|
488
|
|
|
} |
|
489
|
|
|
} |
|
490
|
|
|
} |
|
491
|
|
|
$sReturn .= '</td>'; |
|
492
|
|
|
} |
|
493
|
|
|
} |
|
494
|
|
|
return $sReturn; |
|
495
|
|
|
} |
|
496
|
|
|
|
|
497
|
|
|
private function setTableCellDecimals($key, $features) |
|
498
|
|
|
{ |
|
499
|
|
|
$decimals = 0; |
|
500
|
|
|
if (isset($features['no_of_decimals'])) { |
|
501
|
|
|
$decimals = $features['no_of_decimals']; |
|
502
|
|
|
} |
|
503
|
|
|
if (isset($features['decimals']) && array_key_exists($key, $features['decimals'])) { |
|
504
|
|
|
$decimals = $features['decimals'][$key]; |
|
505
|
|
|
} |
|
506
|
|
|
return $decimals; |
|
507
|
|
|
} |
|
508
|
|
|
|
|
509
|
|
|
private function setTableCellNumeric($key, $value, $features) |
|
510
|
|
|
{ |
|
511
|
|
|
$styleToReturn = 'style="text-align: right;">'; |
|
512
|
|
|
if (substr($value, 0, 1) === '0') { |
|
513
|
|
|
return $styleToReturn . $value; |
|
514
|
|
|
} |
|
515
|
|
|
$decimals = $this->setTableCellDecimals($key, $features); |
|
516
|
|
|
$nDc = ['MinFractionDigits' => $decimals, 'MaxFractionDigits' => $decimals]; |
|
517
|
|
|
return $styleToReturn . $this->setNumberFormat($value, $nDc); |
|
518
|
|
|
} |
|
519
|
|
|
|
|
520
|
|
|
/** |
|
521
|
|
|
* Generates a table header |
|
522
|
|
|
* |
|
523
|
|
|
* @param array $aElements |
|
524
|
|
|
* @param boolean $bHeadersBreaked |
|
525
|
|
|
* @return string |
|
526
|
|
|
*/ |
|
527
|
|
|
private function setTableHeader($aElements, $bHeadersBreaked) |
|
528
|
|
|
{ |
|
529
|
|
|
$aTableHeader = $aElements; |
|
530
|
|
|
if ($bHeadersBreaked) { |
|
531
|
|
|
$aTableHeader = $this->setArrayToArrayKbr($aElements); |
|
532
|
|
|
} |
|
533
|
|
|
$sReturn = []; |
|
534
|
|
|
foreach (array_keys($aTableHeader) as $value) { |
|
535
|
|
|
$sReturn[] = $this->setStringIntoTag($value, 'th'); |
|
536
|
|
|
} |
|
537
|
|
|
return implode('', $sReturn); |
|
538
|
|
|
} |
|
539
|
|
|
} |
|
540
|
|
|
|