dolibarr  20.0.0-beta
ticket.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2018 Jean-François FERRY <hello@librethic.io>
3  * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
4  * Copyright (C) 2022-2023 Udo Tamm <dev@dolibit.de>
5  * Copyright (C) 2023 Alexandre Spangaro <aspangaro@easya.solutions>
6  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7  * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 // Load Dolibarr environment
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT."/core/class/html.formcategory.class.php";
32 require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
33 require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php";
34 require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php";
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array("admin", "ticket"));
38 
39 // Access control
40 if (!$user->admin) {
42 }
43 
44 // Parameters
45 $value = GETPOST('value', 'alpha');
46 $action = GETPOST('action', 'aZ09');
47 $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
48 
49 $label = GETPOST('label', 'alpha');
50 $scandir = GETPOST('scan_dir', 'alpha');
51 $type = 'ticket';
52 
53 $error = 0;
54 $reg = array();
55 
56 /*
57  * Actions
58  */
59 
60 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
61 
62 if ($action == 'updateMask') {
63  $maskconstticket = GETPOST('maskconstticket', 'aZ09');
64  $maskticket = GETPOST('maskticket', 'alpha');
65 
66  if ($maskconstticket && preg_match('/_MASK$/', $maskconstticket)) {
67  $res = dolibarr_set_const($db, $maskconstticket, $maskticket, 'chaine', 0, '', $conf->entity);
68  }
69 
70  if (!($res > 0)) {
71  $error++;
72  }
73 
74  if (!$error) {
75  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
76  } else {
77  setEventMessages($langs->trans("Error"), null, 'errors');
78  }
79 } elseif ($action == 'set') {
80  // Activate a model
81  $ret = addDocumentModel($value, $type, $label, $scandir);
82 } elseif ($action == 'del') {
83  $ret = delDocumentModel($value, $type);
84  if ($ret > 0) {
85  if ($conf->global->TICKET_ADDON_PDF == "$value") {
86  dolibarr_del_const($db, 'TICKET_ADDON_PDF', $conf->entity);
87  }
88  }
89 } elseif (preg_match('/set_(.*)/', $action, $reg)) {
90  $code = $reg[1];
91  $value = GETPOSTISSET($code) ? GETPOSTINT($code) : 1;
92  if ($code == 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS' && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
93  $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
94  $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
95  if (!($res > 0)) {
96  $error++;
97  }
98  } else {
99  $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
100  if (!($res > 0)) {
101  $error++;
102  }
103  }
104 } elseif (preg_match('/del_(.*)/', $action, $reg)) {
105  $code = $reg[1];
106  $res = dolibarr_del_const($db, $code, $conf->entity);
107  if (!($res > 0)) {
108  $error++;
109  }
110 } elseif ($action == 'setdoc') {
111  // Set default model
112  if (dolibarr_set_const($db, "TICKET_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
113  // The constant that was read before the new set
114  // We therefore requires a variable to have a coherent view
115  $conf->global->TICKET_ADDON_PDF = $value;
116  }
117 
118  // Activate the model
119  $ret = delDocumentModel($value, $type);
120  if ($ret > 0) {
121  $ret = addDocumentModel($value, $type, $label, $scandir);
122  }
123 } elseif ($action == 'setmod') {
124  // TODO check if the chosen numbering module can be activated
125  // by calling the canBeActivated method
126 
127  dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity);
128 } elseif ($action == 'setvarworkflow') {
129  // For compatibility when javascript is not enabled
130  if (empty($conf->use_javascript_ajax)) {
131  $param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha');
132  $res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity);
133  if (!($res > 0)) {
134  $error++;
135  }
136 
137  $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha');
138  $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
139  if (!($res > 0)) {
140  $error++;
141  }
142 
143  $param_auto_notify_close = GETPOST('TICKET_NOTIFY_AT_CLOSING', 'alpha');
144  $res = dolibarr_set_const($db, 'TICKET_NOTIFY_AT_CLOSING', $param_auto_notify_close, 'chaine', 0, '', $conf->entity);
145  if (!($res > 0)) {
146  $error++;
147  }
148  }
149 
150  $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha');
151  $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity);
152  if (!($res > 0)) {
153  $error++;
154  }
155 
156  if (GETPOSTISSET('product_category_id')) {
157  $param_ticket_product_category = GETPOSTINT('product_category_id');
158  $res = dolibarr_set_const($db, 'TICKET_PRODUCT_CATEGORY', $param_ticket_product_category, 'chaine', 0, '', $conf->entity);
159  if (!($res > 0)) {
160  $error++;
161  }
162  }
163 
164  $param_delay_first_response = GETPOSTINT('delay_first_response');
165  $res = dolibarr_set_const($db, 'TICKET_DELAY_BEFORE_FIRST_RESPONSE', $param_delay_first_response, 'chaine', 0, '', $conf->entity);
166  if (!($res > 0)) {
167  $error++;
168  }
169 
170  $param_delay_between_responses = GETPOSTINT('delay_between_responses');
171  $res = dolibarr_set_const($db, 'TICKET_DELAY_SINCE_LAST_RESPONSE', $param_delay_between_responses, 'chaine', 0, '', $conf->entity);
172  if (!($res > 0)) {
173  $error++;
174  }
175 } elseif ($action == 'setvar') {
176  include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
177 
178  $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha');
179  $notification_email_description = "Sender of ticket replies sent from Dolibarr";
180  if (!empty($notification_email)) {
181  $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, $notification_email_description, $conf->entity);
182  } else { // If an empty e-mail address is providen, use the global "FROM" since an empty field will cause other issues
183  $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $conf->global->MAIN_MAIL_EMAIL_FROM, 'chaine', 0, $notification_email_description, $conf->entity);
184  }
185  if (!($res > 0)) {
186  $error++;
187  }
188 
189  // altairis : differentiate notification email FROM and TO
190  $notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha');
191  $notification_email_to_description = "Notified e-mail for ticket replies sent from Dolibarr";
192  if (!empty($notification_email_to)) {
193  $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, $notification_email_to_description, $conf->entity);
194  } else {
195  $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, $notification_email_to_description, $conf->entity);
196  }
197  if (!($res > 0)) {
198  $error++;
199  }
200 
201  $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'restricthtml');
202  $mail_intro_description = "Introduction text of ticket replies sent from Dolibarr";
203  if (!empty($mail_intro)) {
204  $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, $mail_intro_description, $conf->entity);
205  } else {
206  $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', '', 'chaine', 0, $mail_intro_description, $conf->entity);
207  }
208  if (!($res > 0)) {
209  $error++;
210  }
211 
212  $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'restricthtml');
213  $signature_description = "Signature of ticket replies sent from Dolibarr";
214  if (!empty($mail_signature)) {
215  $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, $signature_description, $conf->entity);
216  } else {
217  $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', '', 'chaine', 0, $signature_description, $conf->entity);
218  }
219  if (!($res > 0)) {
220  $error++;
221  }
222 
223  // For compatibility when javascript is not enabled
224  if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2 && empty($conf->use_javascript_ajax)) {
225  $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
226  $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
227  if (!($res > 0)) {
228  $error++;
229  }
230  }
231 }
232 
233 
234 /*
235  * View
236  */
237 
238 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
239 
240 $formcategory = new FormCategory($db);
241 
242 // Page Header
243 $help_url = 'EN:Module_Ticket|FR:Module_Ticket_FR';
244 $page_name = 'TicketSetup';
245 llxHeader('', $langs->trans($page_name), $help_url);
246 
247 // Subheader
248 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
249 
250 print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
251 
252 // Configuration header
253 $head = ticketAdminPrepareHead();
254 
255 print dol_get_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "ticket");
256 
257 print '<span class="opacitymedium">'.$langs->trans("TicketSetupDictionaries").'</span> : <a href="'.DOL_URL_ROOT.'/admin/dict.php">'.$langs->trans("ClickHereToGoTo", $langs->transnoentitiesnoconv("DictionarySetup")).'</a><br>';
258 
259 print dol_get_fiche_end();
260 
261 
262 /*
263  * Tickets numbering model
264  */
265 
266 print load_fiche_titre($langs->trans("TicketNumberingModules"), '', '');
267 
268 print '<div class="div-table-responsive-no-min">';
269 print '<table class="noborder centpercent">';
270 print '<tr class="liste_titre">';
271 print '<td width="100">'.$langs->trans("Name").'</td>';
272 print '<td>'.$langs->trans("Description").'</td>';
273 print '<td>'.$langs->trans("Example").'</td>';
274 print '<td align="center" width="60">'.$langs->trans("Activated").'</td>';
275 print '<td align="center" width="40">'.$langs->trans("ShortInfo").'</td>';
276 print "</tr>\n";
277 
278 clearstatcache();
279 
280 foreach ($dirmodels as $reldir) {
281  $dir = dol_buildpath($reldir."core/modules/ticket");
282 
283  if (is_dir($dir)) {
284  $handle = opendir($dir);
285  if (is_resource($handle)) {
286  while (($file = readdir($handle)) !== false) {
287  if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) {
288  $file = $reg[1];
289  $classname = substr($file, 4);
290 
291  include_once $dir.'/'.$file.'.php';
292 
293  $module = new $file();
294  '@phan-var-force ModeleNumRefTicket $module';
295 
296  // Show modules according to features level
297  if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
298  continue;
299  }
300 
301  if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
302  continue;
303  }
304 
305  if ($module->isEnabled()) {
306  print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
307  print $module->info($langs);
308  print '</td>';
309 
310  // Show example of numbering model
311  print '<td class="nowrap">';
312  $tmp = $module->getExample();
313  if (preg_match('/^Error/', $tmp)) {
314  $langs->load("errors");
315  print '<div class="error">'.$langs->trans($tmp).'</div>';
316  } elseif ($tmp == 'NotConfigured') {
317  print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
318  } else {
319  print $tmp;
320  }
321 
322  print '</td>'."\n";
323 
324  print '<td class="center">';
325  if ($conf->global->TICKET_ADDON == 'mod_'.$classname) {
326  print img_picto($langs->trans("Activated"), 'switch_on');
327  } else {
328  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
329  }
330  print '</td>';
331 
332  $ticket = new Ticket($db);
333  $ticket->initAsSpecimen();
334 
335  // Info
336  $htmltooltip = '';
337  $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
338  $nextval = $module->getNextValue($mysoc, $ticket);
339  if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
340  $htmltooltip .= ''.$langs->trans("NextValue").': ';
341  if ($nextval) {
342  $htmltooltip .= $nextval.'<br>';
343  } else {
344  $htmltooltip .= $langs->trans($module->error).'<br>';
345  }
346  }
347 
348  print '<td class="center">';
349  print $formcategory->textwithpicto('', $htmltooltip, 1, 0);
350  print '</td>';
351 
352  print '</tr>';
353  }
354  }
355  }
356  closedir($handle);
357  }
358  }
359 }
360 
361 print '</table>';
362 print '</div>';
363 print '<br>';
364 
365 
366 
367 /*
368  * Document templates generators
369  */
370 
371 print load_fiche_titre($langs->trans("TicketsModelModule"), '', '');
372 
373 // Load array def with activated templates
374 $def = array();
375 $sql = "SELECT nom";
376 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
377 $sql .= " WHERE type = '".$db->escape($type)."'";
378 $sql .= " AND entity = ".$conf->entity;
379 $resql = $db->query($sql);
380 if ($resql) {
381  $i = 0;
382  $num_rows = $db->num_rows($resql);
383  while ($i < $num_rows) {
384  $array = $db->fetch_array($resql);
385  if (is_array($array)) {
386  array_push($def, $array[0]);
387  }
388  $i++;
389  }
390 } else {
391  dol_print_error($db);
392 }
393 
394 
395 print '<div class="div-table-responsive-no-min">';
396 print '<table class="noborder cenpercent">'."\n";
397 print '<tr class="liste_titre">'."\n";
398 print '<td>'.$langs->trans("Name").'</td>';
399 print '<td>'.$langs->trans("Description").'</td>';
400 print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
401 print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
402 print '<td class="center" width="50">'.$langs->trans("Preview").'</td>';
403 print '<td class="center" width="40">'.$langs->trans("ShortInfo").'</td>';
404 print "</tr>\n";
405 
406 clearstatcache();
407 
408 foreach ($dirmodels as $reldir) {
409  foreach (array('', '/doc') as $valdir) {
410  $realpath = $reldir."core/modules/ticket".$valdir;
411  $dir = dol_buildpath($realpath);
412 
413  if (is_dir($dir)) {
414  $handle = opendir($dir);
415  if (is_resource($handle)) {
416  $filelist = array();
417  while (($file = readdir($handle)) !== false) {
418  $filelist[] = $file;
419  }
420  closedir($handle);
421  arsort($filelist);
422 
423  foreach ($filelist as $file) {
424  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
425  if (file_exists($dir.'/'.$file)) {
426  $name = substr($file, 4, dol_strlen($file) - 16);
427  $classname = substr($file, 0, dol_strlen($file) - 12);
428 
429  require_once $dir.'/'.$file;
430  $module = new $classname($db);
431  '@phan-var-force CommonDocGenerator $module';
432 
433  $modulequalified = 1;
434  if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
435  $modulequalified = 0;
436  }
437  if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
438  $modulequalified = 0;
439  }
440 
441  if ($modulequalified) {
442  print '<tr class="oddeven"><td width="100">';
443  print(empty($module->name) ? $name : $module->name);
444  print "</td><td>\n";
445  if (method_exists($module, 'info')) {
446  print $module->info($langs);
447  } else {
448  print $module->description;
449  }
450  print '</td>';
451 
452  // Active / Status
453  if (in_array($name, $def)) {
454  print '<td class="center">'."\n";
455  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
456  print img_picto($langs->trans("Enabled"), 'switch_on');
457  print '</a>';
458  print '</td>';
459  } else {
460  print '<td class="center">'."\n";
461  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
462  print "</td>";
463  }
464 
465  // Default Template
466  print '<td class="center">';
467  if (getDolGlobalString("TICKET_ADDON_PDF") == $name) {
468  print img_picto($langs->trans("Default"), 'on');
469  } else {
470  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
471  }
472  print '</td>';
473 
474  // Preview
475  print '<td class="center">';
476  if ($module->type == 'pdf') {
477  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.urlencode($name).'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
478  } else {
479  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
480  }
481  print '</td>';
482 
483  // Info
484  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
485  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
486  if ($module->type == 'pdf') {
487  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
488  }
489  $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
490 
491  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
492  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
493  $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
494  //$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
495  //$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
496  //$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
497 
498 
499  print '<td class="center">';
500  print $formcategory->textwithpicto('', $htmltooltip, 1, 0);
501  print '</td>';
502 
503  print "</tr>\n";
504  }
505  }
506  }
507  }
508  }
509  }
510  }
511 }
512 
513 print '</table>';
514 print '</div><br>';
515 
516 
517 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
518 print '<input type="hidden" name="token" value="'.newToken().'">';
519 print '<input type="hidden" name="action" value="setvarworkflow">';
520 print '<input type="hidden" name="page_y" value="">';
521 
522 /*
523  * Other Parameters
524  */
525 
526 print load_fiche_titre($langs->trans("Other"), '', '');
527 print '<div class="div-table-responsive-no-min">';
528 print '<table class="noborder centpercent">';
529 
530 print '<tr class="liste_titre">';
531 print '<td>'.$langs->trans("Parameter").'</td>';
532 print '<td>'.$langs->trans("Status")."</td>\n";
533 print '<td class="center" width="40">'.$langs->trans("ShortInfo").'</td>';
534 print "</tr>\n";
535 
536 // Auto mark ticket as read when created from backoffice
537 print '<tr class="oddeven"><td>'.$langs->trans("TicketsAutoReadTicket").'</td>';
538 print '<td class="left">';
539 if ($conf->use_javascript_ajax) {
540  print ajax_constantonoff('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND');
541 } else {
542  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
543  print $formcategory->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, getDolGlobalString('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND'));
544 }
545 print '</td>';
546 print '<td class="center">';
547 print $formcategory->textwithpicto('', $langs->trans("TicketsAutoReadTicketHelp"), 1, 'help');
548 print '</td>';
549 print '</tr>';
550 
551 // Auto assign ticket to user who created it
552 print '<tr class="oddeven">';
553 print '<td>'.$langs->trans("TicketsAutoAssignTicket").'</td>';
554 print '<td class="left">';
555 if ($conf->use_javascript_ajax) {
556  print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE');
557 } else {
558  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
559  print $formcategory->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, getDolGlobalString('TICKET_AUTO_ASSIGN_USER_CREATE'));
560 }
561 print '</td>';
562 print '<td class="center">';
563 print $formcategory->textwithpicto('', $langs->trans("TicketsAutoAssignTicketHelp"), 1, 'help');
564 print '</td>';
565 print '</tr>';
566 
567 // Auto notify contacts when closing the ticket
568 print '<tr class="oddeven"><td>'.$langs->trans("TicketsAutoNotifyClose").'</td>';
569 print '<td class="left">';
570 if ($conf->use_javascript_ajax) {
571  print ajax_constantonoff('TICKET_NOTIFY_AT_CLOSING');
572 } else {
573  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
574  print $formcategory->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, getDolGlobalString('TICKET_NOTIFY_AT_CLOSING'));
575 }
576 print '</td>';
577 print '<td class="center">';
578 print $formcategory->textwithpicto('', $langs->trans("TicketsAutoNotifyCloseHelp"), 1, 'help');
579 print '</td>';
580 print '</tr>';
581 
582 if (isModEnabled('product')) {
583  $htmlname = "product_category_id";
584  print '<tr class="oddeven"><td>'.$langs->trans("TicketChooseProductCategory").'</td>';
585  print '<td class="left">';
586  $formcategory->selectProductCategory(getDolGlobalString('TICKET_PRODUCT_CATEGORY'), $htmlname);
587  if ($conf->use_javascript_ajax) {
588  print ajax_combobox('select_'.$htmlname);
589  }
590  print '</td>';
591  print '<td class="center">';
592  print $formcategory->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help');
593  print '</td>';
594  print '</tr>';
595 }
596 
597 print '<tr class="oddeven">';
598 print '<td>'.$langs->trans("TicketsDelayBeforeFirstAnswer")."</td>";
599 print '<td class="left">
600  <input type="number" value="'.getDolGlobalString('TICKET_DELAY_BEFORE_FIRST_RESPONSE').'" name="delay_first_response" class="width50">
601  </td>';
602 print '<td class="center">';
603 print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help');
604 print '</td>';
605 print '</tr>';
606 
607 print '<tr class="oddeven">';
608 print '<td>'.$langs->trans("TicketsDelayBetweenAnswers")."</td>";
609 print '<td class="left">
610  <input type="number" value="'.getDolGlobalString('TICKET_DELAY_SINCE_LAST_RESPONSE').'" name="delay_between_responses" class="width50">
611  </td>';
612 print '<td class="center">';
613 print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help');
614 print '</td>';
615 print '</tr>';
616 
617 // Allow classification modification even if the ticket is closed
618 print '<tr class="oddeven"><td>'.$langs->trans("TicketsAllowClassificationModificationIfClosed").'</td>';
619 print '<td class="left">';
620 if ($conf->use_javascript_ajax) {
621  print ajax_constantonoff('TICKET_ALLOW_CLASSIFICATION_MODIFICATION_EVEN_IF_CLOSED');
622 } else {
623  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
624  print $formcategory->selectarray("TICKET_ALLOW_CLASSIFICATION_MODIFICATION_EVEN_IF_CLOSED", $arrval, getDolGlobalString('TICKET_ALLOW_CLASSIFICATION_MODIFICATION_EVEN_IF_CLOSED'));
625 }
626 print '</td>';
627 print '<td class="center">';
628 print $formcategory->textwithpicto('', $langs->trans("TicketsAllowClassificationModificationIfClosedHelp"), 1, 'help');
629 print '</td>';
630 print '</tr>';
631 
632 print '</table><br>';
633 
634 print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition');
635 
636 print '</form>';
637 
638 /*
639  * Notification
640  */
641 // Admin var of module
642 print load_fiche_titre($langs->trans("Notification"), '', '');
643 
644 print '<table class="noborder centpercent">';
645 
646 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
647 print '<input type="hidden" name="token" value="'.newToken().'">';
648 print '<input type="hidden" name="action" value="setvar">';
649 print '<input type="hidden" name="page_y" value="">';
650 
651 print '<tr class="liste_titre">';
652 print '<td colspan="2">'.$langs->trans("Email").'</td>';
653 print '<td class="center" width="40">'.$langs->trans("ShortInfo").'</td>';
654 print "</tr>\n";
655 
656 if (!getDolGlobalString('FCKEDITOR_ENABLE_MAIL')) {
657  print '<tr>';
658  print '<td colspan="2"><div class="info">'.$langs->trans("TicketCkEditorEmailNotActivated").'</div></td>';
659  print '<td class="center" width="40">'.$langs->trans("ShortInfo").'</td>';
660  print "</tr>\n";
661 }
662 
663 // TODO Use module notification instead...
664 
665 // Email to send notifications
666 print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationFrom").'</td>';
667 print '<td class="left">';
668 print '<input type="text" class="minwidth200" name="TICKET_NOTIFICATION_EMAIL_FROM" value="' . getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'"></td>';
669 print '<td class="center">';
670 print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help');
671 print '</td>';
672 print '</tr>';
673 
674 // Email for notification of TICKET_CREATE
675 print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationTo").'</td>';
676 print '<td class="left">';
677 print '<input type="text" class="minwidth200" name="TICKET_NOTIFICATION_EMAIL_TO" value="'.(getDolGlobalString('TICKET_NOTIFICATION_EMAIL_TO') ? $conf->global->TICKET_NOTIFICATION_EMAIL_TO : '').'"></td>';
678 print '<td class="center">';
679 print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help');
680 print '</td>';
681 print '</tr>';
682 
683 // Also send to TICKET_NOTIFICATION_EMAIL_TO for responses (not only creation)
684 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
685  print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailAlsoSendToMainAddress").'</td>';
686  print '<td class="left">';
687  if ($conf->use_javascript_ajax) {
688  print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
689  } else {
690  $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
691  print $formcategory->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS);
692  }
693  print '</td>';
694  print '<td class="center">';
695  print $formcategory->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help');
696  print '</td>';
697  print '</tr>';
698 }
699 
700 // Message header
701 //$mail_intro = getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'));
702 $mail_intro = getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO', '');
703 print '<tr class="oddeven"><td>'.$langs->trans("TicketMessageMailIntro");
704 print '</td><td>';
705 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
706 $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 90, 'dolibarr_mailings', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAIL'), ROWS_2, 70);
707 $doleditor->Create();
708 print '</td>';
709 print '<td class="center">';
710 print $formcategory->textwithpicto('', $langs->trans("TicketMessageMailIntroHelpAdmin"), 1, 'help');
711 print '</td></tr>';
712 
713 // Message footer
714 //$mail_signature = getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailFooterText'));
715 $mail_signature = getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE');
716 print '<tr class="oddeven"><td>'.$langs->trans("TicketMessageMailFooter").'</label>';
717 print '</td><td>';
718 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
719 $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 90, 'dolibarr_mailings', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAIL'), ROWS_2, 70);
720 $doleditor->Create();
721 print '</td>';
722 print '<td class="center">';
723 print $formcategory->textwithpicto('', $langs->trans("TicketMessageMailFooterHelpAdmin"), 1, 'help');
724 print '</td></tr>';
725 
726 print '</table>';
727 
728 print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition');
729 
730 print '</form>';
731 
732 // End of page
733 llxFooter();
734 $db->close();
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1940
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:656
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:580
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1971
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:456
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='inline-block')
On/off button for constant.
Definition: ajax.lib.php:641
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:55
llxFooter()
Empty footer.
Definition: wrapper.php:69
Class to manage a WYSIWYG editor.
Class to manage forms for categories.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:745
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
Class to generate the form for creating a new ticket.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
ticketAdminPrepareHead()
Build tabs for admin page.
Definition: ticket.lib.php:32