1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* Copyright (c) 2008-2012 Laurent Destailleur <[email protected]> |
4
|
|
|
* Copyright (C) 2010-2012 Regis Houssin <[email protected]> |
5
|
|
|
* Copyright (C) 2010-2018 Juanjo Menent <[email protected]> |
6
|
|
|
* Copyright (C) 2024 Rafael San José <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This program is free software; you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU General Public License as published by |
10
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
11
|
|
|
* (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU General Public License |
19
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace Dolibarr\Code\Core\Classes; |
23
|
|
|
|
24
|
|
|
use DoliDB; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* \file htdocs/core/class/html.formactions.class.php |
28
|
|
|
* \ingroup core |
29
|
|
|
* \brief File of class with predefined functions and HTML components |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Class to manage building of HTML components |
35
|
|
|
*/ |
36
|
|
|
class FormActions |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* @var DoliDB Database handler. |
40
|
|
|
*/ |
41
|
|
|
public $db; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var string Error code (or message) |
45
|
|
|
*/ |
46
|
|
|
public $error = ''; |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Constructor |
51
|
|
|
* |
52
|
|
|
* @param DoliDB $db Database handler |
53
|
|
|
*/ |
54
|
|
|
public function __construct($db) |
55
|
|
|
{ |
56
|
|
|
$this->db = $db; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
61
|
|
|
/** |
62
|
|
|
* Show list of action status |
63
|
|
|
* |
64
|
|
|
* @param string $formname Name of form where select is included |
65
|
|
|
* @param string $selected Preselected value (-1..100) |
66
|
|
|
* @param int $canedit 1=can edit, 0=read only |
67
|
|
|
* @param string $htmlname Name of html prefix for html fields (selectX and valX) |
68
|
|
|
* @param integer $showempty Show an empty line if select is used |
69
|
|
|
* @param integer $onlyselect 0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running) |
70
|
|
|
* @param string $morecss More css on select field |
71
|
|
|
* @return void |
72
|
|
|
*/ |
73
|
|
|
public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100') |
74
|
|
|
{ |
75
|
|
|
// phpcs:enable |
76
|
|
|
global $langs, $conf; |
77
|
|
|
|
78
|
|
|
$listofstatus = array( |
79
|
|
|
'na' => $langs->trans("ActionNotApplicable"), |
80
|
|
|
'0' => $langs->trans("ActionsToDoShort"), |
81
|
|
|
'50' => $langs->trans("ActionRunningShort"), |
82
|
|
|
'100' => $langs->trans("ActionDoneShort") |
83
|
|
|
); |
84
|
|
|
// +ActionUncomplete |
85
|
|
|
|
86
|
|
|
if (!empty($conf->use_javascript_ajax) || $onlyselect) { |
87
|
|
|
//var_dump($selected); |
88
|
|
|
if ($selected == 'done') { |
89
|
|
|
$selected = '100'; |
90
|
|
|
} |
91
|
|
|
print '<select ' . ($canedit ? '' : 'disabled ') . 'name="' . $htmlname . '" id="select' . $htmlname . '" class="flat' . ($morecss ? ' ' . $morecss : '') . '">'; |
92
|
|
|
if ($showempty) { |
93
|
|
|
print '<option value="-1"' . ($selected == '' ? ' selected' : '') . '> </option>'; |
94
|
|
|
} |
95
|
|
|
foreach ($listofstatus as $key => $val) { |
96
|
|
|
print '<option value="' . $key . '"' . (($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '') . '>' . $val . '</option>'; |
97
|
|
|
if ($key == '50' && $onlyselect == 2) { |
98
|
|
|
print '<option value="todo"' . ($selected == 'todo' ? ' selected' : '') . '>' . $langs->trans("ActionUncomplete") . ' (' . $langs->trans("ActionsToDoShort") . "+" . $langs->trans("ActionRunningShort") . ')</option>'; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
print '</select>'; |
102
|
|
|
if ($selected == 0 || $selected == 100) { |
103
|
|
|
$canedit = 0; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
print ajax_combobox('select' . $htmlname, array(), 0, 0, 'resolve', '-1', $morecss); |
107
|
|
|
|
108
|
|
|
if (empty($onlyselect)) { |
109
|
|
|
print ' <input type="text" id="val' . $htmlname . '" name="percentage" class="flat hideifna" value="' . ($selected >= 0 ? $selected : '') . '" size="2"' . ($canedit && ($selected >= 0) ? '' : ' disabled') . '>'; |
110
|
|
|
print '<span class="hideonsmartphone hideifna">%</span>'; |
111
|
|
|
} |
112
|
|
|
} else { |
113
|
|
|
print ' <input type="text" id="val' . $htmlname . '" name="percentage" class="flat" value="' . ($selected >= 0 ? $selected : '') . '" size="2"' . ($canedit ? '' : ' disabled') . '>%'; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
if (!empty($conf->use_javascript_ajax)) { |
117
|
|
|
print "\n"; |
118
|
|
|
print '<script nonce="' . getNonce() . '" type="text/javascript">'; |
119
|
|
|
print " |
120
|
|
|
var htmlname = '" . dol_escape_js($htmlname) . "'; |
121
|
|
|
|
122
|
|
|
$(document).ready(function () { |
123
|
|
|
select_status(); |
124
|
|
|
|
125
|
|
|
$('#select' + htmlname).change(function() { |
126
|
|
|
console.log('We change field select '+htmlname); |
127
|
|
|
select_status(); |
128
|
|
|
}); |
129
|
|
|
}); |
130
|
|
|
|
131
|
|
|
function select_status() { |
132
|
|
|
var defaultvalue = $('#select' + htmlname).val(); |
133
|
|
|
console.log('val='+defaultvalue); |
134
|
|
|
var percentage = $('input[name=percentage]'); |
135
|
|
|
var selected = '" . (isset($selected) ? dol_escape_js($selected) : '') . "'; |
136
|
|
|
var value = (selected>0?selected:(defaultvalue>=0?defaultvalue:'')); |
137
|
|
|
|
138
|
|
|
percentage.val(value); |
139
|
|
|
|
140
|
|
|
if (defaultvalue == 'na' || defaultvalue == -1) { |
141
|
|
|
percentage.prop('disabled', true); |
142
|
|
|
$('.hideifna').hide(); |
143
|
|
|
} |
144
|
|
|
else if (defaultvalue == 0) { |
145
|
|
|
percentage.val(0); |
146
|
|
|
percentage.removeAttr('disabled'); /* Not disabled, we want to change it to higher value */ |
147
|
|
|
$('.hideifna').show(); |
148
|
|
|
} |
149
|
|
|
else if (defaultvalue == 100) { |
150
|
|
|
percentage.val(100); |
151
|
|
|
percentage.prop('disabled', true); |
152
|
|
|
$('.hideifna').show(); |
153
|
|
|
} |
154
|
|
|
else { |
155
|
|
|
if (defaultvalue == 50 && (percentage.val() == 0 || percentage.val() == 100)) { percentage.val(50); } |
156
|
|
|
percentage.removeAttr('disabled'); |
157
|
|
|
$('.hideifna').show(); |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
</script>\n"; |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Show list of actions for element |
167
|
|
|
* |
168
|
|
|
* @param Object $object Object |
169
|
|
|
* @param string $typeelement 'invoice', 'propal', 'order', 'invoice_supplier', 'order_supplier', 'fichinter' |
170
|
|
|
* @param int $socid Socid of user |
171
|
|
|
* @param int $forceshowtitle Show title even if there is no actions to show |
172
|
|
|
* @param string $morecss More css on table |
173
|
|
|
* @param int $max Max number of record |
174
|
|
|
* @param string $moreparambacktopage More param for the backtopage |
175
|
|
|
* @param string $morehtmlcenter More html text on center of title line |
176
|
|
|
* @param int $assignedtouser Assign event by default to this user id (will be ignored if not enough permissions) |
177
|
|
|
* @return int Return integer <0 if KO, >=0 if OK |
178
|
|
|
*/ |
179
|
|
|
public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlcenter = '', $assignedtouser = 0) |
180
|
|
|
{ |
181
|
|
|
global $langs, $conf, $user, $hookmanager; |
182
|
|
|
|
183
|
|
|
require_once constant('DOL_DOCUMENT_ROOT') . '/comm/action/class/actioncomm.class.php'; |
184
|
|
|
|
185
|
|
|
$sortfield = 'a.datep,a.id'; |
186
|
|
|
$sortorder = 'DESC,DESC'; |
187
|
|
|
|
188
|
|
|
$actioncomm = new ActionComm($this->db); |
189
|
|
|
$listofactions = $actioncomm->getActions($socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0)); |
190
|
|
|
if (!is_array($listofactions)) { |
191
|
|
|
dol_print_error($this->db, 'FailedToGetActions'); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
require_once constant('DOL_DOCUMENT_ROOT') . '/comm/action/class/cactioncomm.class.php'; |
195
|
|
|
$caction = new CActionComm($this->db); |
196
|
|
|
$arraylist = $caction->liste_array(1, 'code', '', (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : 0), '', 1); |
197
|
|
|
|
198
|
|
|
$num = count($listofactions); |
199
|
|
|
if ($num || $forceshowtitle) { |
200
|
|
|
$title = $langs->trans("LatestLinkedEvents", $max ? $max : ''); |
201
|
|
|
|
202
|
|
|
$urlbacktopage = $_SERVER['PHP_SELF'] . '?id=' . $object->id . ($moreparambacktopage ? '&' . $moreparambacktopage : ''); |
203
|
|
|
|
204
|
|
|
$projectid = $object->fk_project; |
205
|
|
|
if ($typeelement == 'project') { |
206
|
|
|
$projectid = $object->id; |
207
|
|
|
} |
208
|
|
|
$taskid = 0; |
209
|
|
|
if ($typeelement == 'task') { |
210
|
|
|
$taskid = $object->id; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
$usercanaddaction = 0; |
214
|
|
|
if (empty($assignedtouser) || $assignedtouser == $user->id) { |
215
|
|
|
$usercanaddaction = $user->hasRight('agenda', 'myactions', 'create'); |
216
|
|
|
$assignedtouser = 0; |
217
|
|
|
} else { |
218
|
|
|
$usercanaddaction = $user->hasRight('agenda', 'allactions', 'create'); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
$url = ''; |
222
|
|
|
$morehtmlright = ''; |
223
|
|
|
if (isModEnabled('agenda') && $usercanaddaction) { |
224
|
|
|
$url = constant('BASE_URL') . '/comm/action/card.php?action=create&token=' . newToken() . '&datep=' . urlencode(dol_print_date(dol_now(), 'dayhourlog', 'tzuser')); |
225
|
|
|
$url .= '&origin=' . urlencode($typeelement) . '&originid=' . ((int) $object->id) . ((!empty($object->socid) && $object->socid > 0) ? '&socid=' . ((int) $object->socid) : ((!empty($socid) && $socid > 0) ? '&socid=' . ((int) $socid) : '')); |
226
|
|
|
$url .= ($projectid > 0 ? '&projectid=' . ((int) $projectid) : '') . ($taskid > 0 ? '&taskid=' . ((int) $taskid) : ''); |
227
|
|
|
$url .= ($assignedtouser > 0 ? '&assignedtouser=' . $assignedtouser : ''); |
228
|
|
|
$url .= '&backtopage=' . urlencode($urlbacktopage); |
229
|
|
|
$morehtmlright .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', $url); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
$parameters = array( |
233
|
|
|
'title' => &$title, |
234
|
|
|
'morehtmlright' => &$morehtmlright, |
235
|
|
|
'morehtmlcenter' => &$morehtmlcenter, |
236
|
|
|
'usercanaddaction' => $usercanaddaction, |
237
|
|
|
'url' => &$url, |
238
|
|
|
'typeelement' => $typeelement, |
239
|
|
|
'projectid' => $projectid, |
240
|
|
|
'assignedtouser' => $assignedtouser, |
241
|
|
|
'taskid' => $taskid, |
242
|
|
|
'urlbacktopage' => $urlbacktopage |
243
|
|
|
); |
244
|
|
|
|
245
|
|
|
$reshook = $hookmanager->executeHooks('showActionsLoadFicheTitre', $parameters, $object); |
246
|
|
|
|
247
|
|
|
if ($reshook < 0) { |
248
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
$error = 0; |
252
|
|
|
if (empty($reshook)) { |
253
|
|
|
print '<!-- formactions->showactions -->' . "\n"; |
254
|
|
|
print load_fiche_titre($title, $morehtmlright, '', 0, 0, '', $morehtmlcenter); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
$page = 0; |
258
|
|
|
$param = ''; |
259
|
|
|
|
260
|
|
|
print '<div class="div-table-responsive-no-min">'; |
261
|
|
|
print '<table class="centpercent noborder' . ($morecss ? ' ' . $morecss : '') . '">'; |
262
|
|
|
print '<tr class="liste_titre">'; |
263
|
|
|
print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
264
|
|
|
print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1); |
265
|
|
|
print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
266
|
|
|
print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
267
|
|
|
print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
268
|
|
|
print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1); |
269
|
|
|
print '</tr>'; |
270
|
|
|
print "\n"; |
271
|
|
|
|
272
|
|
|
if (is_array($listofactions) && count($listofactions)) { |
273
|
|
|
$cacheusers = array(); |
274
|
|
|
|
275
|
|
|
$cursorevent = 0; |
276
|
|
|
foreach ($listofactions as $actioncomm) { |
277
|
|
|
if ($max && $cursorevent >= $max) { |
278
|
|
|
break; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
print '<tr class="oddeven">'; |
282
|
|
|
|
283
|
|
|
// Ref |
284
|
|
|
print '<td class="nowraponall">' . $actioncomm->getNomUrl(1, -1) . '</td>'; |
285
|
|
|
|
286
|
|
|
// Date |
287
|
|
|
print '<td class="center nowraponall">' . dol_print_date($actioncomm->datep, 'dayhour', 'tzuserrel'); |
288
|
|
|
if ($actioncomm->datef) { |
289
|
|
|
$tmpa = dol_getdate($actioncomm->datep); |
290
|
|
|
$tmpb = dol_getdate($actioncomm->datef); |
291
|
|
|
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { |
292
|
|
|
if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes']) { |
293
|
|
|
print '-' . dol_print_date($actioncomm->datef, 'hour', 'tzuserrel'); |
294
|
|
|
} |
295
|
|
|
} else { |
296
|
|
|
print '-' . dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel'); |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
print '</td>'; |
300
|
|
|
|
301
|
|
|
// Owner |
302
|
|
|
print '<td class="nowraponall tdoverflowmax125">'; |
303
|
|
|
if (!empty($actioncomm->userownerid)) { |
304
|
|
|
if (isset($cacheusers[$actioncomm->userownerid]) && is_object($cacheusers[$actioncomm->userownerid])) { |
305
|
|
|
$tmpuser = $cacheusers[$actioncomm->userownerid]; |
306
|
|
|
} else { |
307
|
|
|
$tmpuser = new User($this->db); |
|
|
|
|
308
|
|
|
$tmpuser->fetch($actioncomm->userownerid); |
309
|
|
|
$cacheusers[$actioncomm->userownerid] = $tmpuser; |
310
|
|
|
} |
311
|
|
|
if ($tmpuser->id > 0) { |
312
|
|
|
print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); |
313
|
|
|
} |
314
|
|
|
} |
315
|
|
|
print '</td>'; |
316
|
|
|
|
317
|
|
|
$actionstatic = $actioncomm; |
318
|
|
|
|
319
|
|
|
// Example: Email sent from invoice card |
320
|
|
|
//$actionstatic->code = 'AC_BILL_SENTBYMAIL |
321
|
|
|
//$actionstatic->type_code = 'AC_OTHER_AUTO' |
322
|
|
|
|
323
|
|
|
// Type |
324
|
|
|
$labeltype = $actionstatic->type_code; |
325
|
|
|
if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) { |
326
|
|
|
$labeltype = 'AC_OTH'; |
327
|
|
|
} |
328
|
|
|
if (preg_match('/^TICKET_MSG/', $actionstatic->code)) { |
329
|
|
|
$labeltype = $langs->trans("Message"); |
330
|
|
|
} else { |
331
|
|
|
if (!empty($arraylist[$labeltype])) { |
332
|
|
|
$labeltype = $arraylist[$labeltype]; |
333
|
|
|
} |
334
|
|
|
if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) { |
335
|
|
|
$labeltype .= ' - ' . $arraylist[$actionstatic->code]; // Use code in priority on type_code |
336
|
|
|
} |
337
|
|
|
} |
338
|
|
|
print '<td class="tdoverflowmax100" title="' . dol_escape_htmltag($labeltype) . '">'; |
339
|
|
|
print $actioncomm->getTypePicto(); |
340
|
|
|
print $labeltype; |
341
|
|
|
print '</td>'; |
342
|
|
|
|
343
|
|
|
// Label |
344
|
|
|
print '<td class="tdoverflowmax200">'; |
345
|
|
|
print $actioncomm->getNomUrl(0); |
346
|
|
|
print '</td>'; |
347
|
|
|
|
348
|
|
|
// Status |
349
|
|
|
print '<td class="right">'; |
350
|
|
|
print $actioncomm->getLibStatut(3); |
351
|
|
|
print '</td>'; |
352
|
|
|
print '</tr>'; |
353
|
|
|
|
354
|
|
|
$cursorevent++; |
355
|
|
|
} |
356
|
|
|
} else { |
357
|
|
|
print '<tr class="oddeven"><td colspan="6"><span class="opacitymedium">' . $langs->trans("None") . '</span></td></tr>'; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
if ($max && $num > $max) { |
361
|
|
|
print '<tr class="oddeven"><td colspan="6"><span class="opacitymedium">' . $langs->trans("More") . '...</span></td></tr>'; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
print '</table>'; |
365
|
|
|
print '</div>'; |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
return $num; |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
|
372
|
|
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
373
|
|
|
/** |
374
|
|
|
* Output html select list of type of event |
375
|
|
|
* |
376
|
|
|
* @param array|string $selected Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too. |
377
|
|
|
* @param string $htmlname Name of select field |
378
|
|
|
* @param string $excludetype A type to exclude ('systemauto', 'system', '') |
379
|
|
|
* @param integer $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual", -2=Combined line is disabled (not implemented yet) |
380
|
|
|
* @param int $hideinfohelp 1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value |
381
|
|
|
* @param int $multiselect 1=Allow multiselect of action type |
382
|
|
|
* @param int $nooutput 1=No output |
383
|
|
|
* @param string $morecss More css to add to SELECT component. |
384
|
|
|
* @return string |
385
|
|
|
*/ |
386
|
|
|
public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = 'minwidth300') |
387
|
|
|
{ |
388
|
|
|
// phpcs:enable |
389
|
|
|
global $langs, $user, $form; |
390
|
|
|
|
391
|
|
|
if (!is_object($form)) { |
392
|
|
|
$form = new Form($this->db); |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
require_once constant('DOL_DOCUMENT_ROOT') . '/comm/action/class/cactioncomm.class.php'; |
396
|
|
|
require_once constant('DOL_DOCUMENT_ROOT') . '/core/class/html.form.class.php'; |
397
|
|
|
$caction = new CActionComm($this->db); |
398
|
|
|
|
399
|
|
|
// Suggest a list with manual events or all auto events |
400
|
|
|
$arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot, '', 0); // If we use param 'all' instead of 'code', there is no group by include in answer but the key 'type' of answer array contains the key for the group by. |
401
|
|
|
if (empty($multiselect)) { |
402
|
|
|
// Add empty line at start only if no multiselect |
403
|
|
|
array_unshift($arraylist, ' '); |
404
|
|
|
} |
405
|
|
|
//asort($arraylist); |
406
|
|
|
|
407
|
|
|
if ($selected == 'manual') { |
408
|
|
|
$selected = 'AC_OTH'; |
409
|
|
|
} |
410
|
|
|
if ($selected == 'auto') { |
411
|
|
|
$selected = 'AC_OTH_AUTO'; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
if (getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO')) { |
415
|
|
|
unset($arraylist['AC_OTH_AUTO']); |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
$out = ''; |
419
|
|
|
|
420
|
|
|
// Reformat the array |
421
|
|
|
$newarraylist = array(); |
422
|
|
|
foreach ($arraylist as $key => $value) { |
423
|
|
|
$disabled = ''; |
424
|
|
|
if (strpos($key, 'AC_ALL_') !== false && strpos($key, 'AC_ALL_AUTO') === false) { |
425
|
|
|
$disabled = 'disabled'; |
426
|
|
|
} |
427
|
|
|
$newarraylist[$key] = array('id' => $key, 'label' => $value, 'disabled' => $disabled); |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
if (!empty($multiselect)) { |
431
|
|
|
if (!is_array($selected) && !empty($selected)) { |
432
|
|
|
$selected = explode(',', $selected); |
433
|
|
|
} |
434
|
|
|
$out .= $form->multiselectarray($htmlname, $newarraylist, $selected, 0, 0, 'centpercent', 0, 0); |
435
|
|
|
} else { |
436
|
|
|
$out .= $form->selectarray($htmlname, $newarraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', $morecss, 1); |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) { |
440
|
|
|
$out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup") . ($hideinfohelp == -1 ? ". " . $langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
if ($nooutput) { |
444
|
|
|
return $out; |
445
|
|
|
} else { |
446
|
|
|
print $out; |
447
|
|
|
} |
448
|
|
|
return ''; |
449
|
|
|
} |
450
|
|
|
} |
451
|
|
|
|