|
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
|
|
|
DomCssAndJavascriptByDanielGP; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Builds a <select> based on a given array |
|
44
|
|
|
* |
|
45
|
|
|
* @version 20080618 |
|
46
|
|
|
* @param array $aElements |
|
47
|
|
|
* @param mixed $sDefaultValue |
|
48
|
|
|
* @param string $selectName |
|
49
|
|
|
* @param array $featArray |
|
50
|
|
|
* @return string |
|
51
|
|
|
*/ |
|
52
|
|
|
protected function setArrayToSelect($aElements, $sDefaultValue, $selectName, $featArray = null) |
|
53
|
|
|
{ |
|
54
|
|
|
if (!is_array($aElements)) { |
|
|
|
|
|
|
55
|
|
|
return ''; |
|
56
|
|
|
} |
|
57
|
|
|
if (isset($featArray['readonly'])) { |
|
58
|
|
|
$inputFeatures = [ |
|
59
|
|
|
'name' => $selectName, |
|
60
|
|
|
'id' => $this->buildSelectId($selectName, $featArray), |
|
61
|
|
|
'readonly' => 'readonly', |
|
62
|
|
|
'class' => 'input_readonly', |
|
63
|
|
|
'value' => $sDefaultValue, |
|
64
|
|
|
]; |
|
65
|
|
|
return $this->setStringIntoShortTag('input', $inputFeatures) . $aElements[$sDefaultValue]; |
|
66
|
|
|
} |
|
67
|
|
|
return $this->setArrayToSelectNotReadOnly($aElements, $sDefaultValue, $selectName, $featArray); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Returns a table from an query |
|
72
|
|
|
* |
|
73
|
|
|
* @param array $aElements |
|
74
|
|
|
* @param array $ftrs |
|
75
|
|
|
* @param boolean $bKpFlPge |
|
76
|
|
|
* @return string |
|
77
|
|
|
*/ |
|
78
|
|
|
protected function setArrayToTable($aElements, $ftrs = null, $bKpFlPge = true) |
|
79
|
|
|
{ |
|
80
|
|
|
$rows = count($aElements); |
|
81
|
|
|
if ($rows == 0) { |
|
82
|
|
|
$divTab = [ |
|
83
|
|
|
'start' => '', |
|
84
|
|
|
'end' => '', |
|
85
|
|
|
]; |
|
86
|
|
|
if (array_key_exists('showGroupingCounter', $ftrs)) { |
|
|
|
|
|
|
87
|
|
|
if (array_key_exists('grouping_cell_type', $ftrs) && ($ftrs['grouping_cell_type'] == 'tab')) { |
|
88
|
|
|
$ditTitle = 'No data found'; |
|
89
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
|
90
|
|
|
$ditTitle .= ' (0)'; |
|
91
|
|
|
} |
|
92
|
|
|
$divTab = [ |
|
93
|
|
|
'start' => '<div class="tabbertab tabbertabdefault" id="tab_NoData" title="' . $ditTitle . '">', |
|
94
|
|
|
'end' => '</div><!-- from tab_NoData -->', |
|
95
|
|
|
]; |
|
96
|
|
|
if (!isset($ftrs['noGlobalTab'])) { |
|
97
|
|
|
$divTab = [ |
|
98
|
|
|
'start' => '<div class="tabber" id="tab">' . $divTab['start'], |
|
99
|
|
|
'end' => $divTab['end'] . '</div><!-- from global Tab -->', |
|
100
|
|
|
]; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
return $divTab['start'] |
|
105
|
|
|
. $this->setFeedbackModern('error', 'Error', $this->lclMsgCmn('i18n_NoData')) |
|
106
|
|
|
. $divTab['end']; |
|
107
|
|
|
} |
|
108
|
|
|
if (isset($ftrs['limits'])) { |
|
109
|
|
|
$ftrs['limits'][1] = min($ftrs['limits'][1], $ftrs['limits'][2]); |
|
110
|
|
|
if ($ftrs['limits'][2] > $ftrs['limits'][1]) { |
|
111
|
|
|
$iStartingPageRecord = 1; |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
$sReturn = ''; |
|
115
|
|
|
if (isset($ftrs['hidden_columns'])) { |
|
116
|
|
|
$hdClmns = $this->setArrayValuesAsKey($ftrs['hidden_columns']); |
|
117
|
|
|
} else { |
|
118
|
|
|
$hdClmns = ['']; |
|
119
|
|
|
} |
|
120
|
|
|
$checkboxFormId = ''; |
|
121
|
|
|
if ((isset($ftrs['actions']['checkbox_inlineEdit'])) || (isset($ftrs['actions']['checkbox']))) { |
|
122
|
|
|
$checkboxFormId = 'frm' . date('YmdHis'); |
|
123
|
|
|
$sReturn .= '<form id="' . $checkboxFormId . '" name="' . $checkboxFormId |
|
124
|
|
|
. '" method="post" ' . ' action="' . $this->tCmnRequest->server->get('PHP_SELF') . '" >'; |
|
125
|
|
|
} |
|
126
|
|
|
$tbl = []; |
|
127
|
|
|
$tbl['Def'] = '<table' |
|
128
|
|
|
. (isset($ftrs['table_style']) ? ' style="' . $ftrs['table_style'] . '"' : '') |
|
129
|
|
|
. (isset($ftrs['table_class']) ? ' class="' . $ftrs['table_class'] . '"' : '') |
|
130
|
|
|
. '>'; |
|
131
|
|
|
if (!isset($ftrs['grouping_cell_type'])) { |
|
132
|
|
|
$ftrs['grouping_cell_type'] = 'row'; |
|
133
|
|
|
} |
|
134
|
|
|
switch ($ftrs['grouping_cell_type']) { |
|
135
|
|
|
case 'row': |
|
136
|
|
|
$sReturn .= $tbl['Def']; |
|
137
|
|
|
break; |
|
138
|
|
|
case 'tab': |
|
139
|
|
|
if (!isset($ftrs['noGlobalTab'])) { |
|
140
|
|
|
$sReturn .= '<div class="tabber" id="tab">'; |
|
141
|
|
|
} |
|
142
|
|
|
break; |
|
143
|
|
|
} |
|
144
|
|
|
$groupCounter = 0; |
|
145
|
|
|
$iTableColumns = 0; |
|
146
|
|
|
$remebered_value = -1; |
|
147
|
|
|
$remindGroupValue = null; |
|
148
|
|
|
$color_no = null; |
|
149
|
|
|
if (!isset($ftrs['headers_breaked'])) { |
|
150
|
|
|
$ftrs['headers_breaked'] = true; |
|
151
|
|
|
} |
|
152
|
|
|
for ($rCntr = 0; $rCntr < $rows; $rCntr++) { |
|
153
|
|
|
if ($rCntr == 0) { |
|
154
|
|
|
$header = array_diff_key($aElements[$rCntr], $hdClmns); |
|
155
|
|
|
$iTableColumns = count($header); |
|
156
|
|
|
if (isset($ftrs['computed_columns'])) { |
|
157
|
|
|
$iTableColumns += count($ftrs['computed_columns']); |
|
158
|
|
|
} |
|
159
|
|
|
if (isset($ftrs['actions'])) { |
|
160
|
|
|
$iTableColumns += 1; |
|
161
|
|
|
} |
|
162
|
|
|
if (isset($ftrs['grouping_cell'])) { |
|
163
|
|
|
$iTableColumns -= 1; |
|
164
|
|
|
} |
|
165
|
|
|
$tbl['Head'] = '<thead>'; |
|
166
|
|
|
if ($ftrs['grouping_cell_type'] == 'row') { |
|
167
|
|
|
$sReturn .= $tbl['Head']; |
|
168
|
|
|
} |
|
169
|
|
|
if (isset($iStartingPageRecord)) { |
|
170
|
|
|
$pgn = $this->setPagination($ftrs['limits'][0], $ftrs['limits'][1], $ftrs['limits'][2], $bKpFlPge); |
|
171
|
|
|
$sReturn .= $this->setStringIntoTag($this->setStringIntoTag($pgn, 'th', [ |
|
172
|
|
|
'colspan' => $iTableColumns |
|
173
|
|
|
]), 'tr'); |
|
174
|
|
|
} |
|
175
|
|
|
$tbl['Header'] = '<tr>'; |
|
176
|
|
|
if (isset($ftrs['grouping_cell'])) { // Grouping columns |
|
177
|
|
|
$header = array_diff_key($header, [$ftrs['grouping_cell'] => '']); |
|
178
|
|
|
} |
|
179
|
|
|
if (isset($ftrs['actions'])) { // Action column |
|
180
|
|
|
$tbl['Header'] .= '<th> </th>'; |
|
181
|
|
|
} |
|
182
|
|
|
if (isset($ftrs['RowStyle'])) { //Exclude style columns from displaying |
|
183
|
|
|
$tmpClmns = $this->setArrayValuesAsKey([$ftrs['RowStyle']]); |
|
184
|
|
|
$header = array_diff_key($header, $tmpClmns); |
|
185
|
|
|
$hdClmns = array_merge($hdClmns, $tmpClmns); |
|
186
|
|
|
unset($tmpClmns); |
|
187
|
|
|
} |
|
188
|
|
|
$tbl['Header'] .= $this->setTableHeader($header, $ftrs['headers_breaked']); // Regular columns |
|
189
|
|
|
if (isset($ftrs['computed_columns'])) { // Computed columns |
|
190
|
|
|
$tbl['Header'] .= $this->setTableHeader($ftrs['computed_columns'], $ftrs['headers_breaked']); |
|
191
|
|
|
} |
|
192
|
|
|
$tbl['Header'] .= '</tr></thead><tbody>'; |
|
193
|
|
|
if ($ftrs['grouping_cell_type'] == 'row') { |
|
194
|
|
|
$sReturn .= $tbl['Header']; |
|
195
|
|
|
} |
|
196
|
|
|
} |
|
197
|
|
|
$row_current = array_diff_key($aElements[$rCntr], $hdClmns); |
|
198
|
|
|
if (isset($ftrs['row_colored_alternated'])) { |
|
199
|
|
|
if ($ftrs['row_colored_alternated'][0] == '#') { |
|
200
|
|
|
$color_column_value = $rCntr; |
|
201
|
|
|
} else { |
|
202
|
|
|
$color_column_value = $row_current[$ftrs['row_colored_alternated'][0]]; |
|
203
|
|
|
} |
|
204
|
|
|
if ($remebered_value != $color_column_value) { |
|
205
|
|
|
if (isset($color_no)) { |
|
206
|
|
|
$color_no = 1; |
|
207
|
|
|
} else { |
|
208
|
|
|
$color_no = 2; |
|
209
|
|
|
} |
|
210
|
|
|
$remebered_value = $color_column_value; |
|
211
|
|
|
} |
|
212
|
|
|
$color = ' style="background-color: ' . $ftrs['row_colored_alternated'][$color_no] . ';"'; |
|
213
|
|
|
} else { |
|
214
|
|
|
if (isset($ftrs['RowStyle'])) { |
|
215
|
|
|
$color = ' style="' . $aElements[$rCntr][$ftrs['RowStyle']] . '"'; |
|
216
|
|
|
} else { |
|
217
|
|
|
$color = ''; |
|
218
|
|
|
} |
|
219
|
|
|
} |
|
220
|
|
|
$tbl['tr_Color'] = '<tr' . $color . '>'; |
|
221
|
|
|
// Grouping column |
|
222
|
|
|
if (isset($ftrs['grouping_cell'])) { |
|
223
|
|
|
foreach ($aElements[$rCntr] as $key => $value) { |
|
224
|
|
|
if (($ftrs['grouping_cell'] == $key) && ($remindGroupValue != $value)) { |
|
225
|
|
|
switch ($ftrs['grouping_cell_type']) { |
|
226
|
|
|
case 'row': |
|
227
|
|
|
$sReturn .= $tbl['tr_Color'] . '<td ' . 'colspan="' . $iTableColumns . '">' |
|
228
|
|
|
. $this->setStringIntoTag($value, 'div', ['class' => 'rowGroup rounded']) |
|
229
|
|
|
. '</td></tr>'; |
|
230
|
|
|
break; |
|
231
|
|
|
case 'tab': |
|
232
|
|
|
if (is_null($remindGroupValue)) { |
|
233
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
|
234
|
|
|
$groupCounter = 0; |
|
235
|
|
|
} |
|
236
|
|
|
} else { |
|
237
|
|
|
$sReturn .= '</tbody></table>'; |
|
238
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
|
239
|
|
|
$sReturn .= $this->updateDivTitleName($remindGroupValue, $groupCounter); |
|
240
|
|
|
$groupCounter = 0; |
|
241
|
|
|
} |
|
242
|
|
|
$sReturn .= '</div>'; |
|
243
|
|
|
} |
|
244
|
|
|
$sReturn .= '<div class="tabbertab'; |
|
245
|
|
|
if (isset($ftrs['grouping_default_tab'])) { |
|
246
|
|
|
$sReturn .= ($ftrs['grouping_default_tab'] == $value ? ' tabbertabdefault' : ''); |
|
247
|
|
|
} |
|
248
|
|
|
$sReturn .= '" id="tab_' . $this->cleanStringForId($value) . '" ' |
|
249
|
|
|
. 'title="' . $value . '">' |
|
250
|
|
|
. $tbl['Def'] . $tbl['Head'] . $tbl['Header']; |
|
251
|
|
|
break; |
|
252
|
|
|
} |
|
253
|
|
|
$remindGroupValue = $value; |
|
254
|
|
|
} |
|
255
|
|
|
} |
|
256
|
|
|
} |
|
257
|
|
|
if (isset($ftrs['grouping_cell'])) { |
|
258
|
|
|
if ($ftrs['grouping_cell_type'] == 'tab') { |
|
259
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
|
260
|
|
|
$groupCounter++; |
|
261
|
|
|
} |
|
262
|
|
|
} |
|
263
|
|
|
} |
|
264
|
|
|
$sReturn .= $tbl['tr_Color']; |
|
265
|
|
|
// Action column |
|
266
|
|
|
$checkboxName = ''; |
|
267
|
|
|
$checkboxNameS = ''; |
|
268
|
|
|
if (isset($ftrs['actions'])) { |
|
269
|
|
|
$sReturn .= '<td style="white-space:nowrap;">'; |
|
270
|
|
|
$action_argument = 0; |
|
271
|
|
|
if (isset($ftrs['actions']['key'])) { |
|
272
|
|
|
$actionKey = $ftrs['actions']['key']; |
|
273
|
|
|
} else { |
|
274
|
|
|
$actionKey = 'view'; |
|
275
|
|
|
} |
|
276
|
|
|
if (isset($ftrs['action_prefix'])) { |
|
277
|
|
|
$actPrfx = $ftrs['action_prefix'] . '&'; |
|
278
|
|
|
$actionKey = 'view2'; |
|
279
|
|
|
} else { |
|
280
|
|
|
$actPrfx = ''; |
|
281
|
|
|
} |
|
282
|
|
|
foreach ($ftrs['actions'] as $key => $value) { |
|
283
|
|
|
if ($action_argument != 0) { |
|
284
|
|
|
$sReturn .= ' '; |
|
285
|
|
|
} |
|
286
|
|
|
switch ($key) { |
|
287
|
|
|
case 'checkbox': |
|
288
|
|
|
$checkboxName = $value . '[]'; |
|
289
|
|
|
$checkboxNameS = $value; |
|
290
|
|
|
$sReturn .= ' <input type="checkbox" name="' . $checkboxName |
|
291
|
|
|
. '" id="n' . $aElements[$rCntr][$value] |
|
292
|
|
|
. '" value="' . $aElements[$rCntr][$value] . '" '; |
|
293
|
|
|
if (isset($_REQUEST[$checkboxNameS])) { |
|
294
|
|
|
if (is_array($_REQUEST[$checkboxNameS])) { |
|
295
|
|
|
if (in_array($aElements[$rCntr][$value], $_REQUEST[$checkboxNameS])) { |
|
296
|
|
|
$sReturn .= 'checked="checked" '; |
|
297
|
|
|
} |
|
298
|
|
|
} else { |
|
299
|
|
|
if ($aElements[$rCntr][$value] == $_REQUEST[$checkboxNameS]) { |
|
300
|
|
|
$sReturn .= 'checked="checked" '; |
|
301
|
|
|
} |
|
302
|
|
|
} |
|
303
|
|
|
} |
|
304
|
|
|
if (strpos($_REQUEST['view'], 'multiEdit') !== false) { |
|
305
|
|
|
$sReturn .= 'disabled="disabled" '; |
|
306
|
|
|
} |
|
307
|
|
|
$sReturn .= '/>'; |
|
308
|
|
|
break; |
|
309
|
|
|
case 'checkbox_inlineEdit': |
|
310
|
|
|
$checkboxName = $value . '[]'; |
|
311
|
|
|
$checkboxNameS = $value; |
|
312
|
|
|
$sReturn .= ' <input type="checkbox" name="' . $checkboxName |
|
313
|
|
|
. '" id="n' . $aElements[$rCntr][$value] . '" value="' |
|
314
|
|
|
. $aElements[$rCntr][$value] . '"/>'; |
|
315
|
|
|
break; |
|
316
|
|
|
case 'delete': |
|
317
|
|
|
$sReturn .= '<a href="#" onclick="javascript:setQuest(\'' . $value[0] . '\',\''; |
|
318
|
|
|
$iActArgs = count($value[1]); |
|
319
|
|
|
for ($cntr2 = 0; $cntr2 < $iActArgs; $cntr2++) { |
|
320
|
|
|
$sReturn .= $value[1][$cntr2] . '=' . $aElements[$rCntr][$value[1][$cntr2]]; |
|
321
|
|
|
} |
|
322
|
|
|
$sReturn .= '\');" id="' . $key . $rCntr . '"><i class="fa fa-times"> </i></a>'; |
|
323
|
|
|
break; |
|
324
|
|
|
case 'edit': |
|
325
|
|
|
case 'list2': |
|
326
|
|
|
case 'schedule': |
|
327
|
|
|
$vIc = ($key == 'edit' ? 'pencil' : ($key == 'list2' ? 'list' : 'hourglass-half')); |
|
328
|
|
|
$sReturn .= $this->setDynamicActionToSpecialCell($value, $aElements, [ |
|
329
|
|
|
'vIcon' => 'fa fa-' . $vIc, |
|
330
|
|
|
'aPrefix' => $actPrfx, |
|
331
|
|
|
'aKey' => $actionKey, |
|
332
|
|
|
'rCounter' => $rCntr, |
|
333
|
|
|
'Features' => $ftrs, |
|
334
|
|
|
'key' => $key, |
|
335
|
|
|
]); |
|
336
|
|
|
break; |
|
337
|
|
|
} |
|
338
|
|
|
$action_argument += 1; |
|
339
|
|
|
} |
|
340
|
|
|
$sReturn .= '</td>'; |
|
341
|
|
|
} |
|
342
|
|
|
// Regular columns |
|
343
|
|
|
$sReturn .= $this->setTableCell($row_current, $ftrs); |
|
344
|
|
|
// Computed columns |
|
345
|
|
|
if (isset($ftrs['computed_columns'])) { |
|
346
|
|
|
$rowComputed = []; |
|
347
|
|
|
$decimals = []; |
|
348
|
|
|
foreach ($ftrs['computed_columns'] as $key => $value) { |
|
349
|
|
|
if ($value[0] == '%') { |
|
350
|
|
|
$dec = $value[2] + 2; |
|
351
|
|
|
} else { |
|
352
|
|
|
$dec = $value[2]; |
|
353
|
|
|
} |
|
354
|
|
|
switch ($value[1]) { |
|
355
|
|
|
case '/': |
|
356
|
|
|
// next variable is only to avoid a long line |
|
357
|
|
|
$shorter = [ |
|
358
|
|
|
$aElements[$rCntr][$value[3]], |
|
359
|
|
|
$aElements[$rCntr][$value[4]], |
|
360
|
|
|
]; |
|
361
|
|
|
$aElements[$rCntr][$key] = $this->setDividedResult($shorter[0], $shorter[1], $dec); |
|
362
|
|
|
break; |
|
363
|
|
|
case '+': |
|
364
|
|
|
// next variable is only to avoid a long line |
|
365
|
|
|
$iTemp = $this->setArrayValuesAsKey([ |
|
366
|
|
|
$value[0], |
|
367
|
|
|
$value[1], |
|
368
|
|
|
$value[2] |
|
369
|
|
|
]); |
|
370
|
|
|
$aTemp = array_diff($value, $iTemp); |
|
371
|
|
|
$aElements[$rCntr][$key] = 0; |
|
372
|
|
|
foreach ($aTemp as $sValue) { |
|
373
|
|
|
$aElements[$rCntr][$key] += $aElements[$rCntr][$sValue]; |
|
374
|
|
|
} |
|
375
|
|
|
break; |
|
376
|
|
|
default: |
|
377
|
|
|
$rowComputed[$key] = ''; |
|
378
|
|
|
break; |
|
379
|
|
|
} |
|
380
|
|
|
if ($value[0] == '%') { |
|
381
|
|
|
$rowComputed[$key] = ($aElements[$rCntr][$key] * 100); |
|
382
|
|
|
$dec -= 2; |
|
383
|
|
|
} else { |
|
384
|
|
|
$rowComputed[$key] = $aElements[$rCntr][$key]; |
|
385
|
|
|
} |
|
386
|
|
|
$decimals[$key] = $dec; |
|
387
|
|
|
} |
|
388
|
|
|
// displaying them |
|
389
|
|
|
$sReturn .= $this->setTableCell($rowComputed, ['decimals' => $decimals]); |
|
390
|
|
|
} |
|
391
|
|
|
$sReturn .= '</tr>'; |
|
392
|
|
|
} |
|
393
|
|
|
if (isset($iStartingPageRecord)) { |
|
394
|
|
|
$pgn = $this->setPagination($ftrs['limits'][0], $ftrs['limits'][1], $ftrs['limits'][2]); |
|
395
|
|
|
$sReturn .= '<tr>' . $this->setStringIntoTag($pgn, 'th', ['colspan' => $iTableColumns]) . '</tr>'; |
|
396
|
|
|
} |
|
397
|
|
|
$sReturn .= '</tbody></table>'; |
|
398
|
|
|
if ($ftrs['grouping_cell_type'] == 'tab') { |
|
399
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
|
400
|
|
|
$sReturn .= $this->updateDivTitleName($remindGroupValue, $groupCounter); |
|
401
|
|
|
} |
|
402
|
|
|
$sReturn .= '</div><!-- from ' . $remindGroupValue . ' -->'; |
|
403
|
|
|
if (!isset($ftrs['noGlobalTab'])) { |
|
404
|
|
|
$sReturn .= '</div><!-- from global tab -->'; |
|
405
|
|
|
} |
|
406
|
|
|
} |
|
407
|
|
|
if (isset($ftrs['actions']['checkbox'])) { |
|
408
|
|
|
if (strpos($_REQUEST['view'], 'multiEdit') === false) { |
|
409
|
|
|
$sReturn .= '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
|
410
|
|
|
. '\',\'' . $checkboxName . '\',true);">Check All</a> ' |
|
|
|
|
|
|
411
|
|
|
. '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
|
412
|
|
|
. '\',\'' . $checkboxName . '\',false);">Uncheck All</a> ' |
|
413
|
|
|
. '<input type="hidden" name="action" value="multiEdit_' . $checkboxNameS . '" />'; |
|
|
|
|
|
|
414
|
|
|
if (isset($ftrs['hiddenInput'])) { |
|
415
|
|
|
if (is_array($ftrs['hiddenInput'])) { |
|
416
|
|
|
foreach ($ftrs['hiddenInput'] as $valueF) { |
|
417
|
|
|
$sReturn .= '<input type="hidden" name="' . $valueF |
|
418
|
|
|
. '" value="' . $_REQUEST[$valueF] . '" />'; |
|
419
|
|
|
} |
|
420
|
|
|
} else { |
|
421
|
|
|
$sReturn .= '<input type="hidden" name="' . $ftrs['hiddenInput'] |
|
422
|
|
|
. '" value="' . $_REQUEST[$ftrs['hiddenInput']] . '" />'; |
|
423
|
|
|
} |
|
424
|
|
|
} |
|
425
|
|
|
$sReturn .= '<input style="margin: 0 3em 0 3em;" type="submit" ' . 'value="Edit selected" />'; |
|
426
|
|
|
} |
|
427
|
|
|
$sReturn .= '</form>'; |
|
428
|
|
|
} |
|
429
|
|
|
if (isset($ftrs['actions']['checkbox_inlineEdit'])) { |
|
430
|
|
|
$sReturn .= '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
|
431
|
|
|
. '\',\'' . $checkboxName . '\',true);">Check All</a> ' |
|
432
|
|
|
. '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
|
433
|
|
|
. '\',\'' . $checkboxName . '\',false);">Uncheck All</a> '; |
|
434
|
|
|
if (isset($ftrs['visibleInput'])) { |
|
435
|
|
|
$sReturn .= $ftrs['visibleInput']; |
|
436
|
|
|
} |
|
437
|
|
|
$sReturn .= '<input type="hidden" name="view" value="save_' . $checkboxNameS . '" />'; |
|
438
|
|
|
if (isset($ftrs['hiddenInput'])) { |
|
439
|
|
|
if (is_array($ftrs['hiddenInput'])) { |
|
440
|
|
|
foreach ($ftrs['hiddenInput'] as $valueF) { |
|
441
|
|
|
$sReturn .= '<input type="hidden" name="' . $valueF |
|
442
|
|
|
. '" value="' . $_REQUEST[$valueF] . '" />'; |
|
443
|
|
|
} |
|
444
|
|
|
} else { |
|
445
|
|
|
$sReturn .= '<input type="hidden" name="' . $ftrs['hiddenInput'] |
|
446
|
|
|
. '" value="' . $_REQUEST[$ftrs['hiddenInput']] . '" />'; |
|
447
|
|
|
} |
|
448
|
|
|
} |
|
449
|
|
|
$sReturn .= '<input style="margin: 0 3em 0 3em;" type="submit" value="Store the modification" />'; |
|
450
|
|
|
$sReturn .= '</form>'; |
|
451
|
|
|
} |
|
452
|
|
|
return $sReturn; |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
/** |
|
456
|
|
|
* Set a control to a user-friendly calendar |
|
457
|
|
|
* |
|
458
|
|
|
* @param string $controlName |
|
459
|
|
|
* @param string $additionalStyle |
|
460
|
|
|
* @return string |
|
461
|
|
|
*/ |
|
462
|
|
|
public function setCalendarControl($controlName, $additionalStyle = '') |
|
463
|
|
|
{ |
|
464
|
|
|
return $this->setStringIntoTag(' ', 'span', [ |
|
465
|
|
|
'onclick' => implode('', [ |
|
466
|
|
|
'javascript:NewCssCal(\'' . $controlName, |
|
467
|
|
|
'\',\'yyyyMMdd\',\'dropdown\',false,\'24\',false);', |
|
468
|
|
|
]), |
|
469
|
|
|
'class' => 'fa fa-calendar', |
|
470
|
|
|
'id' => $controlName . '_picker', |
|
471
|
|
|
'style' => 'cursor:pointer;' . $additionalStyle, |
|
472
|
|
|
]); |
|
473
|
|
|
} |
|
474
|
|
|
|
|
475
|
|
|
/** |
|
476
|
|
|
* Set a control to a user-friendly calendar with time included |
|
477
|
|
|
* |
|
478
|
|
|
* @param string $controlName |
|
479
|
|
|
* @param string $additionalStyle |
|
480
|
|
|
* @return string |
|
481
|
|
|
*/ |
|
482
|
|
|
public function setCalendarControlWithTime($controlName, $additionalStyle = '') |
|
483
|
|
|
{ |
|
484
|
|
|
return $this->setStringIntoTag(' ', 'span', [ |
|
485
|
|
|
'onclick' => implode('', [ |
|
486
|
|
|
'javascript:NewCssCal(\'' . $controlName, |
|
487
|
|
|
'\',\'yyyyMMdd\',\'dropdown\',true,\'24\',true);', |
|
488
|
|
|
]), |
|
489
|
|
|
'class' => 'fa fa-calendar', |
|
490
|
|
|
'id' => $controlName . '_picker', |
|
491
|
|
|
'style' => 'cursor:pointer;' . $additionalStyle, |
|
492
|
|
|
]); |
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
|
|
private function setDynamicActionToSpecialCell($val, $aElements, $inP) |
|
496
|
|
|
{ |
|
497
|
|
|
$aArgumemts = []; |
|
498
|
|
|
$aArgumemts[] = $this->tCmnSuperGlobals->getScriptName() . '?' . $inP['aPrefix'] . $inP['aKey'] . '=' . $val[0]; |
|
499
|
|
|
$iActArgs = count($val[1]); |
|
500
|
|
|
for ($counter = 0; $counter < $iActArgs; $counter++) { |
|
501
|
|
|
$aArgumemts[] = $val[1][$counter] . '=' . $aElements[$inP['rCounter']][$val[1][$counter]]; |
|
502
|
|
|
} |
|
503
|
|
|
$id = $inP['key'] . $inP['rCounter']; |
|
504
|
|
|
if (isset($inP['Features']['NoAjaxEditing'])) { |
|
505
|
|
|
return '<a href="' . implode('&', $aArgumemts) . '" id="' . $id . '"><i class="' |
|
506
|
|
|
. $inP['vIcon'] . '"> </i></a>'; |
|
507
|
|
|
} |
|
508
|
|
|
return '<a href="#" onclick="javascript:loadAE(\'' . implode('&', $aArgumemts) . '\');"' |
|
509
|
|
|
. ' id="' . $id . '"><i class="' . $inP['vIcon'] . '"> </i></a>'; |
|
510
|
|
|
} |
|
511
|
|
|
|
|
512
|
|
|
/** |
|
513
|
|
|
* Outputs an HTML footer |
|
514
|
|
|
* |
|
515
|
|
|
* @param array $footerInjected |
|
516
|
|
|
* @return string |
|
517
|
|
|
*/ |
|
518
|
|
|
protected function setFooterCommon($footerInjected = null) |
|
519
|
|
|
{ |
|
520
|
|
|
$sHK = $this->tCmnSuperGlobals->get('specialHook'); |
|
521
|
|
|
if (!is_null($sHK) && (in_array('noHeader', $sHK))) { |
|
522
|
|
|
return ''; |
|
523
|
|
|
} |
|
524
|
|
|
return $this->setFooterCommonInjected($footerInjected) . '</body></html>'; |
|
525
|
|
|
} |
|
526
|
|
|
|
|
527
|
|
|
protected function setFooterCommonInjected($footerInjected = null) |
|
528
|
|
|
{ |
|
529
|
|
|
$sReturn = ''; |
|
530
|
|
|
if (!is_null($footerInjected)) { |
|
531
|
|
|
$sReturn = $footerInjected; |
|
532
|
|
|
if (is_array($footerInjected)) { |
|
533
|
|
|
$sReturn = implode('', $footerInjected); |
|
534
|
|
|
} |
|
535
|
|
|
} |
|
536
|
|
|
return $sReturn; |
|
537
|
|
|
} |
|
538
|
|
|
|
|
539
|
|
|
/** |
|
540
|
|
|
* Outputs an HTML header |
|
541
|
|
|
* |
|
542
|
|
|
* @param array $headerFeatures |
|
543
|
|
|
* @return string |
|
544
|
|
|
*/ |
|
545
|
|
|
protected function setHeaderCommon($headerFeatures = null) |
|
546
|
|
|
{ |
|
547
|
|
|
$sReturn = []; |
|
548
|
|
|
$sHK = $this->tCmnSuperGlobals->get('specialHook'); |
|
549
|
|
|
if (!is_null($sHK) && (in_array('noHeader', $sHK))) { |
|
550
|
|
|
$sReturn[] = ''; // no Header |
|
551
|
|
|
} else { |
|
552
|
|
|
$fixedHeaderElements = [ |
|
553
|
|
|
'start' => '<!DOCTYPE html>', |
|
554
|
|
|
'lang' => '<html lang="en-US">', |
|
555
|
|
|
'head' => '<head>', |
|
556
|
|
|
'charset' => '<meta charset="utf-8" />', |
|
557
|
|
|
'viewport' => '<meta name="viewport" content="' . implode(', ', [ |
|
558
|
|
|
'width=device-width', |
|
559
|
|
|
'height=device-height', |
|
560
|
|
|
'initial-scale=1', |
|
561
|
|
|
]) . '" />', |
|
562
|
|
|
]; |
|
563
|
|
|
if (!is_null($headerFeatures)) { |
|
564
|
|
|
if (is_array($headerFeatures)) { |
|
|
|
|
|
|
565
|
|
|
$aFeatures = []; |
|
566
|
|
|
foreach ($headerFeatures as $key => $value) { |
|
567
|
|
|
switch ($key) { |
|
568
|
|
|
case 'css': |
|
569
|
|
|
if (is_array($value)) { |
|
570
|
|
|
foreach ($value as $value2) { |
|
571
|
|
|
$aFeatures[] = $this->setCssFile(filter_var($value2, FILTER_SANITIZE_URL)); |
|
572
|
|
|
} |
|
573
|
|
|
} else { |
|
574
|
|
|
$aFeatures[] = $this->setCssFile(filter_var($value, FILTER_SANITIZE_URL)); |
|
575
|
|
|
} |
|
576
|
|
|
break; |
|
577
|
|
|
case 'javascript': |
|
578
|
|
|
if (is_array($value)) { |
|
579
|
|
|
foreach ($value as $value2) { |
|
580
|
|
|
$vl = filter_var($value2, FILTER_SANITIZE_URL); |
|
581
|
|
|
$aFeatures[] = $this->setJavascriptFile($vl); |
|
582
|
|
|
} |
|
583
|
|
|
} else { |
|
584
|
|
|
$aFeatures[] = $this->setJavascriptFile(filter_var($value, FILTER_SANITIZE_URL)); |
|
585
|
|
|
} |
|
586
|
|
|
break; |
|
587
|
|
|
case 'lang': |
|
588
|
|
|
$fixedHeaderElements['lang'] = '<html lang="' |
|
589
|
|
|
. filter_var($value, FILTER_SANITIZE_STRING) . '">'; |
|
590
|
|
|
break; |
|
591
|
|
|
case 'title': |
|
592
|
|
|
$aFeatures[] = '<title>' |
|
593
|
|
|
. filter_var($value, FILTER_SANITIZE_STRING) . '</title>'; |
|
594
|
|
|
break; |
|
595
|
|
|
} |
|
596
|
|
|
} |
|
597
|
|
|
$sReturn[] = implode('', $fixedHeaderElements) |
|
598
|
|
|
. implode('', $aFeatures) |
|
599
|
|
|
. '</head>' |
|
600
|
|
|
. '<body>'; |
|
601
|
|
|
} else { |
|
602
|
|
|
$sReturn[] = implode('', $fixedHeaderElements) |
|
603
|
|
|
. '</head>' |
|
604
|
|
|
. '<body>' |
|
605
|
|
|
. '<p style="background-color:red;color:#FFF;">The parameter sent to ' |
|
606
|
|
|
. __FUNCTION__ . ' must be an array</p>' |
|
607
|
|
|
. $this->setFooterCommon(); |
|
608
|
|
|
throw new \Exception($sReturn); |
|
609
|
|
|
} |
|
610
|
|
|
} |
|
611
|
|
|
} |
|
612
|
|
|
return implode('', $sReturn); |
|
613
|
|
|
} |
|
614
|
|
|
|
|
615
|
|
|
/** |
|
616
|
|
|
* Generates a table cell |
|
617
|
|
|
* |
|
618
|
|
|
* @param array $aElements |
|
619
|
|
|
* @param array $features |
|
620
|
|
|
* @return string |
|
621
|
|
|
*/ |
|
622
|
|
|
private function setTableCell($aElements, $features = null) |
|
623
|
|
|
{ |
|
624
|
|
|
$sReturn = null; |
|
625
|
|
|
foreach ($aElements as $key => $value) { |
|
626
|
|
|
$value = str_replace(['& ', '\"', "\'"], ['& ', '"', "'"], $value); |
|
627
|
|
|
if ((isset($features['grouping_cell'])) && ($features['grouping_cell'] == $key)) { |
|
628
|
|
|
// just skip |
|
629
|
|
|
} else { |
|
630
|
|
|
$sReturn .= '<td '; |
|
631
|
|
|
if (isset($features['column_formatting'][$key])) { |
|
632
|
|
|
switch ($features['column_formatting'][$key]) { |
|
633
|
|
|
case '@': |
|
634
|
|
|
$sReturn .= 'style="text-align:left;">' . $value; |
|
635
|
|
|
break; |
|
636
|
|
|
case 'right': |
|
637
|
|
|
$sReturn .= 'style="text-align:right;">' . $value; |
|
638
|
|
|
break; |
|
639
|
|
|
default: |
|
640
|
|
|
$sReturn .= '???'; |
|
641
|
|
|
break; |
|
642
|
|
|
} |
|
643
|
|
|
} else { |
|
644
|
|
|
if (is_numeric($value)) { |
|
645
|
|
|
$sReturn .= $this->setTableCellNumeric($key, $value, $features); |
|
646
|
|
|
} else { |
|
647
|
|
|
$outputet = false; |
|
648
|
|
|
if ((strpos($value, '-') !== false) && (strlen($value) == 10)) { |
|
649
|
|
|
if (preg_match("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $value, $regs)) { |
|
650
|
|
|
$outputet = true; |
|
651
|
|
|
$sReturn .= 'style="text-align:right;width: 10px;">' |
|
652
|
|
|
. $regs[3] . '.' . $regs[2] . '.' . $regs[1]; |
|
653
|
|
|
} |
|
654
|
|
|
} |
|
655
|
|
|
if (!$outputet) { |
|
656
|
|
|
$sReturn .= 'style="text-align:left;">' . $value; |
|
657
|
|
|
} |
|
658
|
|
|
} |
|
659
|
|
|
} |
|
660
|
|
|
$sReturn .= '</td>'; |
|
661
|
|
|
} |
|
662
|
|
|
} |
|
663
|
|
|
return $sReturn; |
|
664
|
|
|
} |
|
665
|
|
|
|
|
666
|
|
|
private function setTableCellDecimals($key, $features) |
|
667
|
|
|
{ |
|
668
|
|
|
$decimals = 0; |
|
669
|
|
|
if (isset($features['no_of_decimals'])) { |
|
670
|
|
|
$decimals = $features['no_of_decimals']; |
|
671
|
|
|
} |
|
672
|
|
|
if (isset($features['decimals']) && array_key_exists($key, $features['decimals'])) { |
|
673
|
|
|
$decimals = $features['decimals'][$key]; |
|
674
|
|
|
} |
|
675
|
|
|
return $decimals; |
|
676
|
|
|
} |
|
677
|
|
|
|
|
678
|
|
|
private function setTableCellNumeric($key, $value, $features) |
|
679
|
|
|
{ |
|
680
|
|
|
$styleToReturn = 'style="text-align: right;">'; |
|
681
|
|
|
if (substr($value, 0, 1) === '0') { |
|
682
|
|
|
return $styleToReturn . $value; |
|
683
|
|
|
} |
|
684
|
|
|
$decimals = $this->setTableCellDecimals($key, $features); |
|
685
|
|
|
$nDc = ['MinFractionDigits' => $decimals, 'MaxFractionDigits' => $decimals]; |
|
686
|
|
|
return $styleToReturn . $this->setNumberFormat($value, $nDc); |
|
687
|
|
|
} |
|
688
|
|
|
|
|
689
|
|
|
/** |
|
690
|
|
|
* Generates a table header |
|
691
|
|
|
* |
|
692
|
|
|
* @param array $aElements |
|
693
|
|
|
* @param boolean $bHeadersBreaked |
|
694
|
|
|
* @return string |
|
695
|
|
|
*/ |
|
696
|
|
|
private function setTableHeader($aElements, $bHeadersBreaked) |
|
697
|
|
|
{ |
|
698
|
|
|
$aTableHeader = $aElements; |
|
699
|
|
|
if ($bHeadersBreaked) { |
|
700
|
|
|
$aTableHeader = $this->setArrayToArrayKbr($aElements); |
|
701
|
|
|
} |
|
702
|
|
|
$sReturn[] = null; |
|
|
|
|
|
|
703
|
|
|
foreach (array_keys($aTableHeader) as $value) { |
|
704
|
|
|
$sReturn[] = $this->setStringIntoTag($value, 'th'); |
|
705
|
|
|
} |
|
706
|
|
|
return implode('', $sReturn); |
|
707
|
|
|
} |
|
708
|
|
|
|
|
709
|
|
|
/** |
|
710
|
|
|
* Create an upper right box with choices for languages |
|
711
|
|
|
* (requires flag-icon.min.css to be loaded) |
|
712
|
|
|
* (makes usage of custom class "upperRightBox" and id = "visibleOnHover", provided here as scss file) |
|
713
|
|
|
* |
|
714
|
|
|
* @param array $aAvailableLanguages |
|
715
|
|
|
* @return string |
|
716
|
|
|
*/ |
|
717
|
|
|
protected function setUpperRightBoxLanguages($aAvailableLanguages) |
|
718
|
|
|
{ |
|
719
|
|
|
$this->handleLanguageIntoSession(); |
|
720
|
|
|
return '<div class="upperRightBox">' |
|
721
|
|
|
. '<div style="text-align:right;">' |
|
722
|
|
|
. '<span class="flag-icon flag-icon-' . strtolower(substr($this->tCmnSession->get('lang'), -2)) |
|
723
|
|
|
. '" style="margin-right:2px;"> </span>' |
|
724
|
|
|
. $aAvailableLanguages[$this->tCmnSession->get('lang')] |
|
725
|
|
|
. '</div><!-- default Language -->' |
|
726
|
|
|
. $this->setUpperRightVisibleOnHoverLanguages($aAvailableLanguages) |
|
727
|
|
|
. '</div><!-- upperRightBox end -->'; |
|
728
|
|
|
} |
|
729
|
|
|
|
|
730
|
|
|
private function setUpperRightVisibleOnHoverLanguages($aAvailableLanguages) |
|
731
|
|
|
{ |
|
732
|
|
|
$linkWithoutLanguage = ''; |
|
733
|
|
|
$alR = $this->tCmnSuperGlobals->query->all(); |
|
734
|
|
|
if (count($alR) > 0) { |
|
735
|
|
|
$linkWithoutLanguage = $this->setArrayToStringForUrl('&', $alR, ['lang']) . '&'; |
|
736
|
|
|
} |
|
737
|
|
|
$sReturn = []; |
|
738
|
|
|
foreach ($aAvailableLanguages as $key => $value) { |
|
739
|
|
|
if ($this->tCmnSession->get('lang') !== $key) { |
|
740
|
|
|
$sReturn[] = '<a href="?' . $linkWithoutLanguage . 'lang=' . $key . '" style="display:block;">' |
|
741
|
|
|
. '<span class="flag-icon flag-icon-' . strtolower(substr($key, -2)) |
|
742
|
|
|
. '" style="margin-right:2px;"> </span>' . $value . '</a>'; |
|
743
|
|
|
} |
|
744
|
|
|
} |
|
745
|
|
|
return '<div id="visibleOnHover">' . implode('', $sReturn) . '</div><!-- visibleOnHover end -->'; |
|
746
|
|
|
} |
|
747
|
|
|
|
|
748
|
|
|
} |
|
749
|
|
|
|