dolibarr  x.y.z
html.formticket.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2015 Jean-François FERRY <hello@librethic.io>
3  * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
4  * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
5  * Copyright (C) 2021 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
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 
28 require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
29 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
30 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
31 
32 if (!class_exists('FormCompany')) {
33  include DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
34 }
35 
45 {
49  public $db;
50 
54  public $track_id;
55 
59  public $fk_user_create;
60 
61  public $message;
62  public $topic_title;
63 
64  public $action;
65 
66  public $withtopic;
67  public $withemail;
68 
72  public $withsubstit;
73 
74  public $withfile;
75  public $withfilereadonly;
76 
77  public $backtopage;
78 
79  public $ispublic; // to show information or not into public form
80 
81  public $withtitletopic;
82  public $withtopicreadonly;
83  public $withreadid;
84 
85  public $withcompany; // to show company drop-down list
86  public $withfromsocid;
87  public $withfromcontactid;
88  public $withnotifytiersatcreate;
89  public $withusercreate; // to show name of creating user in form
90  public $withcreatereadonly;
91 
92  public $withref; // to show ref field
93 
94  public $withcancel;
95 
96  public $type_code;
97  public $category_code;
98  public $severity_code;
99 
100 
105  public $substit = array();
106  public $param = array();
107 
111  public $error;
112  public $errors = array();
113 
114 
120  public function __construct($db)
121  {
122  global $conf;
123 
124  $this->db = $db;
125 
126  $this->action = 'add';
127 
128  $this->withcompany = isModEnabled("societe");
129  $this->withfromsocid = 0;
130  $this->withfromcontactid = 0;
131  $this->withreadid=0;
132  //$this->withtitletopic='';
133  $this->withnotifytiersatcreate = 0;
134  $this->withusercreate = 1;
135  $this->withcreatereadonly = 1;
136  $this->withemail = 0;
137  $this->withref = 0;
138  $this->withextrafields = 0; // to show extrafields or not
139  //$this->withtopicreadonly=0;
140  }
141 
152  public function showForm($withdolfichehead = 0, $mode = 'edit', $public = 0, Contact $with_contact = null, $action = '')
153  {
154  global $conf, $langs, $user, $hookmanager;
155 
156  // Load translation files required by the page
157  $langs->loadLangs(array('other', 'mails', 'ticket'));
158 
159  $form = new Form($this->db);
160  $formcompany = new FormCompany($this->db);
161  $ticketstatic = new Ticket($this->db);
162 
163  $soc = new Societe($this->db);
164  if (!empty($this->withfromsocid) && $this->withfromsocid > 0) {
165  $soc->fetch($this->withfromsocid);
166  }
167 
168  $ticketstat = new Ticket($this->db);
169 
170  $extrafields = new ExtraFields($this->db);
171  $extrafields->fetch_name_optionals_label($ticketstat->table_element);
172 
173  print "\n<!-- Begin form TICKET -->\n";
174 
175  if ($withdolfichehead) {
176  print dol_get_fiche_head(null, 'card', '', 0, '');
177  }
178 
179  print '<form method="POST" '.($withdolfichehead ? '' : 'style="margin-bottom: 30px;" ').'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="'.(!empty($this->param["returnurl"]) ? $this->param["returnurl"] : $_SERVER['PHP_SELF']).'">';
180  print '<input type="hidden" name="token" value="'.newToken().'">';
181  print '<input type="hidden" name="action" value="'.$this->action.'">';
182  foreach ($this->param as $key => $value) {
183  print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
184  }
185  print '<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.'">';
186 
187  print '<table class="border centpercent">';
188 
189  if ($this->withref) {
190  // Ref
191  $defaultref = $ticketstat->getDefaultRef();
192  print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>';
193  print '<input type="text" name="ref" value="'.dol_escape_htmltag(GETPOST("ref", 'alpha') ? GETPOST("ref", 'alpha') : $defaultref).'">';
194  print '</td></tr>';
195  }
196 
197  // TITLE
198  $email = GETPOSTISSET('email') ? GETPOST('email', 'alphanohtml') : '';
199  if ($this->withemail) {
200  print '<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans("Email").'</span></label></td><td>';
201  print '<input class="text minwidth200" id="email" name="email" value="'.$email.'" autofocus>';
202  print '</td></tr>';
203 
204  if ($with_contact) {
205  // contact search and result
206  $html_contact_search = '';
207  $html_contact_search .= '<tr id="contact_search_line">';
208  $html_contact_search .= '<td class="titlefield">';
209  $html_contact_search .= '<label for="contact"><span class="fieldrequired">' . $langs->trans('Contact') . '</span></label>';
210  $html_contact_search .= '<input type="hidden" id="contact_id" name="contact_id" value="" />';
211  $html_contact_search .= '</td>';
212  $html_contact_search .= '<td id="contact_search_result"></td>';
213  $html_contact_search .= '</tr>';
214  print $html_contact_search;
215  // contact lastname
216  $html_contact_lastname = '';
217  $html_contact_lastname .= '<tr id="contact_lastname_line" class="contact_field"><td class="titlefield"><label for="contact_lastname"><span class="fieldrequired">' . $langs->trans('Lastname') . '</span></label></td><td>';
218  $html_contact_lastname .= '<input type="text" id="contact_lastname" name="contact_lastname" value="' . dol_escape_htmltag(GETPOSTISSET('contact_lastname') ? GETPOST('contact_lastname', 'alphanohtml') : '') . '" />';
219  $html_contact_lastname .= '</td></tr>';
220  print $html_contact_lastname;
221  // contact firstname
222  $html_contact_firstname = '';
223  $html_contact_firstname .= '<tr id="contact_firstname_line" class="contact_field"><td class="titlefield"><label for="contact_firstname"><span class="fieldrequired">' . $langs->trans('Firstname') . '</span></label></td><td>';
224  $html_contact_firstname .= '<input type="text" id="contact_firstname" name="contact_firstname" value="' . dol_escape_htmltag(GETPOSTISSET('contact_firstname') ? GETPOST('contact_firstname', 'alphanohtml') : '') . '" />';
225  $html_contact_firstname .= '</td></tr>';
226  print $html_contact_firstname;
227  // company name
228  $html_company_name = '';
229  $html_company_name .= '<tr id="contact_company_name_line" class="contact_field"><td><label for="company_name"><span>' . $langs->trans('Company') . '</span></label></td><td>';
230  $html_company_name .= '<input type="text" id="company_name" name="company_name" value="' . dol_escape_htmltag(GETPOSTISSET('company_name') ? GETPOST('company_name', 'alphanohtml') : '') . '" />';
231  $html_company_name .= '</td></tr>';
232  print $html_company_name;
233  // contact phone
234  $html_contact_phone = '';
235  $html_contact_phone .= '<tr id="contact_phone_line" class="contact_field"><td><label for="contact_phone"><span>' . $langs->trans('Phone') . '</span></label></td><td>';
236  $html_contact_phone .= '<input type="text" id="contact_phone" name="contact_phone" value="' . dol_escape_htmltag(GETPOSTISSET('contact_phone') ? GETPOST('contact_phone', 'alphanohtml') : '') . '" />';
237  $html_contact_phone .= '</td></tr>';
238  print $html_contact_phone;
239 
240  // search contact form email
241  $langs->load('errors');
242  print '<script type="text/javascript">
243  jQuery(document).ready(function() {
244  var contact = jQuery.parseJSON("'.dol_escape_js(json_encode($with_contact), 2).'");
245  jQuery("#contact_search_line").hide();
246  if (contact) {
247  if (contact.id > 0) {
248  jQuery("#contact_search_line").show();
249  jQuery("#contact_id").val(contact.id);
250  jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
251  jQuery(".contact_field").hide();
252  } else {
253  jQuery(".contact_field").show();
254  }
255  }
256 
257  jQuery("#email").change(function() {
258  jQuery("#contact_search_line").show();
259  jQuery("#contact_search_result").html("'.dol_escape_js($langs->trans('Select2SearchInProgress')).'");
260  jQuery("#contact_id").val("");
261  jQuery("#contact_lastname").val("");
262  jQuery("#contact_firstname").val("");
263  jQuery("#company_name").val("");
264  jQuery("#contact_phone").val("");
265 
266  jQuery.getJSON(
267  "'.dol_escape_js(dol_buildpath('/public/ticket/ajax/ajax.php', 1)).'",
268  {
269  action: "getContacts",
270  email: jQuery("#email").val()
271  },
272  function(response) {
273  if (response.error) {
274  jQuery("#contact_search_result").html("<span class=\"error\">"+response.error+"</span>");
275  } else {
276  var contact_list = response.contacts;
277  if (contact_list.length == 1) {
278  var contact = contact_list[0];
279  jQuery("#contact_id").val(contact.id);
280  jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
281  jQuery(".contact_field").hide();
282  } else if (contact_list.length <= 0) {
283  jQuery("#contact_search_line").hide();
284  jQuery(".contact_field").show();
285  }
286  }
287  }
288  ).fail(function(jqxhr, textStatus, error) {
289  var error_msg = "'.dol_escape_js($langs->trans('ErrorAjaxRequestFailed')).'"+" ["+textStatus+"] : "+error;
290  jQuery("#contact_search_result").html("<span class=\"error\">"+error_msg+"</span>");
291  });
292  });
293  });
294  </script>';
295  }
296  }
297 
298  // If ticket created from another object
299  $subelement = '';
300  if (isset($this->param['origin']) && $this->param['originid'] > 0) {
301  // Parse element/subelement (ex: project_task)
302  $element = $subelement = $this->param['origin'];
303  $regs = array();
304  if (preg_match('/^([^_]+)_([^_]+)/i', $this->param['origin'], $regs)) {
305  $element = $regs[1];
306  $subelement = $regs[2];
307  }
308 
309  dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
310  $classname = ucfirst($subelement);
311  $objectsrc = new $classname($this->db);
312  $objectsrc->fetch(GETPOST('originid', 'int'));
313 
314  if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) {
315  $objectsrc->fetch_lines();
316  }
317 
318  $objectsrc->fetch_thirdparty();
319  $newclassname = $classname;
320  print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2"><input name="'.$subelement.'id" value="'.GETPOST('originid').'" type="hidden" />'.$objectsrc->getNomUrl(1).'</td></tr>';
321  }
322 
323  // Type of Ticket
324  print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans("TicketTypeRequest").'</span></label></td><td>';
325  $this->selectTypesTickets((GETPOST('type_code', 'alpha') ? GETPOST('type_code', 'alpha') : $this->type_code), 'type_code', '', 2, 1, 0, 0, 'minwidth200');
326  print '</td></tr>';
327 
328  // Group => Category
329  print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans("TicketCategory").'</span></label></td><td>';
330  $filter = '';
331  if ($public) {
332  $filter = 'public=1';
333  }
334  $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', $filter, 2, 1, 0, 0, 'minwidth200');
335  print '</td></tr>';
336 
337  // Severity => Priority
338  print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans("TicketSeverity").'</span></label></td><td>';
339  $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 1);
340  print '</td></tr>';
341 
342  // Subject
343  if ($this->withtitletopic) {
344  print '<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans("Subject").'</span></label></td><td>';
345  // Answer to a ticket : display of the thread title in readonly
346  if ($this->withtopicreadonly) {
347  print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title;
348  } else {
349  if (isset($this->withreadid) && $this->withreadid > 0) {
350  $subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withreadid.' : '.$this->topic_title;
351  } else {
352  $subject = GETPOST('subject', 'alpha');
353  }
354  print '<input class="text minwidth500" id="subject" name="subject" value="'.$subject.'" autofocus />';
355  }
356  print '</td></tr>';
357  }
358 
359  if (!empty($conf->knowledgemanagement->enabled)) {
360  // KM Articles
361  print '<tr id="KWwithajax"></tr>';
362  print '<!-- Script to manage change of ticket group -->
363  <script>
364  jQuery(document).ready(function() {
365  function groupticketchange() {
366  console.log("We called groupticketchange, so we try to load list KM linked to event");
367  $("#KWwithajax").html("");
368  idgroupticket = $("#selectcategory_code").val();
369 
370  console.log("We have selected id="+idgroupticket);
371 
372  if (idgroupticket != "") {
373  $.ajax({ url: \''.DOL_URL_ROOT.'/core/ajax/fetchKnowledgeRecord.php\',
374  data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.newToken().'\', lang:\''.$langs->defaultlang.'\'},
375  type: \'GET\',
376  success: function(response) {
377  var urllist = \'\';
378  console.log("We received response "+response);
379  response = JSON.parse(response)
380  for (key in response) {
381  answer = response[key].answer;
382  urllist += \'<li><a href="#" title="\'+response[key].title+\'" class="button_KMpopup" data-html="\'+answer+\'">\' +response[key].title+\'</a></li>\';
383  }
384  if (urllist != "") {
385  $("#KWwithajax").html(\'<td>'.$langs->trans("KMFoundForTicketGroup").'</td><td><ul>\'+urllist+\'</ul></td>\');
386  $("#KWwithajax").show();
387  $(".button_KMpopup").on("click",function(){
388  console.log("Open popup with jQuery(...).dialog() with KM article")
389  var $dialog = $("<div></div>").html($(this).attr("data-html"))
390  .dialog({
391  autoOpen: false,
392  modal: true,
393  height: (window.innerHeight - 150),
394  width: "80%",
395  title: $(this).attr("title"),
396  });
397  $dialog.dialog("open");
398  console.log($dialog);
399  })
400  }
401  },
402  error : function(output) {
403  console.error("Error on Fetch of KM articles");
404  },
405  });
406  }
407  };
408  $("#selectcategory_code").on("change",function() { groupticketchange(); });
409  if ($("#selectcategory_code").val() != "") {
410  groupticketchange();
411  }
412  });
413  </script>'."\n";
414  }
415 
416  // MESSAGE
417  $msg = GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : '';
418  print '<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans("Message").'</span></label></td><td>';
419 
420  // If public form, display more information
421  $toolbarname = 'dolibarr_notes';
422  if ($this->ispublic) {
423  $toolbarname = 'dolibarr_details';
424  print '<div class="warning">'.(getDolGlobalString("TICKET_PUBLIC_TEXT_HELP_MESSAGE", $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'))).'</div>';
425  }
426  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
427  $uselocalbrowser = true;
428  $doleditor = new DolEditor('message', $msg, '100%', 230, $toolbarname, 'In', true, $uselocalbrowser, getDolGlobalInt('FCKEDITOR_ENABLE_TICKET'), ROWS_8, '90%');
429  $doleditor->Create();
430  print '</td></tr>';
431 
432  if ($public && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
433  require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
434  print '<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans("SecurityCode").'</span></label></td><td>';
435  print '<span class="span-icon-security inline-block">';
436  print '<input id="securitycode" placeholder="'.$langs->trans("SecurityCode").'" class="flat input-icon-security width125" type="text" maxlength="5" name="code" tabindex="3" />';
437  print '</span>';
438  print '<span class="nowrap inline-block">';
439  print '<img class="inline-block valignmiddle" src="'.DOL_URL_ROOT.'/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />';
440  print '<a class="inline-block valignmiddle" href="" tabindex="4" data-role="button">'.img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"').'</a>';
441  print '</span>';
442  print '</td></tr>';
443  }
444 
445  // Categories
446  if (isModEnabled('categorie')) {
447  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
448  $cate_arbo = $form->select_all_categories(Categorie::TYPE_TICKET, '', 'parent', 64, 0, 1);
449 
450  if (count($cate_arbo)) {
451  // Categories
452  print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
453  print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
454  print "</td></tr>";
455  }
456  }
457 
458  // Attached files
459  if (!empty($this->withfile)) {
460  // Define list of attached files
461  $listofpaths = array();
462  $listofnames = array();
463  $listofmimes = array();
464  if (!empty($_SESSION["listofpaths"])) {
465  $listofpaths = explode(';', $_SESSION["listofpaths"]);
466  }
467 
468  if (!empty($_SESSION["listofnames"])) {
469  $listofnames = explode(';', $_SESSION["listofnames"]);
470  }
471 
472  if (!empty($_SESSION["listofmimes"])) {
473  $listofmimes = explode(';', $_SESSION["listofmimes"]);
474  }
475 
476  $out = '<tr>';
477  $out .= '<td>'.$langs->trans("MailFile").'</td>';
478  $out .= '<td>';
479  // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
480  $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
481  $out .= '<script type="text/javascript">';
482  $out .= 'jQuery(document).ready(function () {';
483  $out .= ' jQuery(".removedfile").click(function() {';
484  $out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
485  $out .= ' });';
486  $out .= '})';
487  $out .= '</script>'."\n";
488  if (count($listofpaths)) {
489  foreach ($listofpaths as $key => $val) {
490  $out .= '<div id="attachfile_'.$key.'">';
491  $out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
492  if (!$this->withfilereadonly) {
493  $out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
494  }
495  $out .= '<br></div>';
496  }
497  } else {
498  $out .= $langs->trans("NoAttachedFiles").'<br>';
499  }
500  if ($this->withfile == 2) { // Can add other files
501  $maxfilesizearray = getMaxFileSizeArray();
502  $maxmin = $maxfilesizearray['maxmin'];
503  if ($maxmin > 0) {
504  $out .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
505  }
506  $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
507  $out .= ' ';
508  $out .= '<input type="submit" class="button smallpaddingimp reposition" id="addfile" name="addfile" value="'.$langs->trans("MailingAddFile").'" />';
509  }
510  $out .= "</td></tr>\n";
511 
512  print $out;
513  }
514 
515  // User of creation
516  if ($this->withusercreate > 0 && $this->fk_user_create) {
517  print '<tr><td class="titlefield">'.$langs->trans("CreatedBy").'</td><td>';
518  $langs->load("users");
519  $fuser = new User($this->db);
520 
521  if ($this->withcreatereadonly) {
522  if ($res = $fuser->fetch($this->fk_user_create)) {
523  print $fuser->getNomUrl(1);
524  }
525  }
526  print ' &nbsp; ';
527  print "</td></tr>\n";
528  }
529 
530  // Customer or supplier
531  if ($this->withcompany) {
532  // altairis: force company and contact id for external user
533  if (empty($user->socid)) {
534  // Company
535  print '<tr><td class="titlefield">'.$langs->trans("ThirdParty").'</td><td>';
536  $events = array();
537  $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
538  print img_picto('', 'company', 'class="paddingright"');
539  print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events, 0, 'minwidth200');
540  print '</td></tr>';
541  if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
542  $htmlname = 'socid';
543  print '<script type="text/javascript">
544  $(document).ready(function () {
545  jQuery("#'.$htmlname.'").change(function () {
546  var obj = '.json_encode($events).';
547  $.each(obj, function(key,values) {
548  if (values.method.length) {
549  runJsCodeForEvent'.$htmlname.'(values);
550  }
551  });
552  });
553 
554  function runJsCodeForEvent'.$htmlname.'(obj) {
555  console.log("Run runJsCodeForEvent'.$htmlname.'");
556  var id = $("#'.$htmlname.'").val();
557  var method = obj.method;
558  var url = obj.url;
559  var htmlname = obj.htmlname;
560  var showempty = obj.showempty;
561  $.getJSON(url,
562  {
563  action: method,
564  id: id,
565  htmlname: htmlname,
566  showempty: showempty
567  },
568  function(response) {
569  $.each(obj.params, function(key,action) {
570  if (key.length) {
571  var num = response.num;
572  if (num > 0) {
573  $("#" + key).removeAttr(action);
574  } else {
575  $("#" + key).attr(action, action);
576  }
577  }
578  });
579  $("select#" + htmlname).html(response.value);
580  if (response.num) {
581  var selecthtml_str = response.value;
582  var selecthtml_dom=$.parseHTML(selecthtml_str);
583  if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
584  $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
585  }
586  } else {
587  $("#inputautocomplete"+htmlname).val("");
588  }
589  $("select#" + htmlname).change(); /* Trigger event change */
590  }
591  );
592  }
593  });
594  </script>';
595  }
596 
597  // Contact and type
598  print '<tr><td>'.$langs->trans("Contact").'</td><td>';
599  // If no socid, set to -1 to avoid full contacts list
600  $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
601  print img_picto('', 'contact', 'class="paddingright"');
602  print $form->selectcontacts($selectedCompany, $this->withfromcontactid, 'contactid', 3, '', '', 0, 'minwidth200');
603  print ' ';
604  $formcompany->selectTypeContact($ticketstatic, '', 'type', 'external', '', 0, 'maginleftonly');
605  print '</td></tr>';
606  } else {
607  print '<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.'"/></td>';
608  print '<td><input type="hidden" name="contactid" value="'.$user->contact_id.'"/></td>';
609  print '<td><input type="hidden" name="type" value="Z"/></td></tr>';
610  }
611 
612  // Notify thirdparty at creation
613  if (empty($this->ispublic)) {
614  print '<tr><td><label for="notify_tiers_at_create">'.$langs->trans("TicketNotifyTiersAtCreation").'</label></td><td>';
615  print '<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ? ' checked="checked"' : '').'>';
616  print '</td></tr>';
617  }
618 
619  // User assigned
620  print '<tr><td>';
621  print $langs->trans("AssignedTo");
622  print '</td><td>';
623  print img_picto('', 'user', 'class="pictofixedwidth"');
624  print $form->select_dolusers(GETPOST('fk_user_assign', 'int'), 'fk_user_assign', 1);
625  print '</td>';
626  print '</tr>';
627  }
628 
629  if ($subelement != 'project') {
630  if (isModEnabled('project') && !$this->ispublic) {
631  $formproject = new FormProjets($this->db);
632  print '<tr><td><label for="project"><span class="">'.$langs->trans("Project").'</span></label></td><td>';
633  print img_picto('', 'project').$formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
634  print '</td></tr>';
635  }
636  }
637 
638  // Other attributes
639  $parameters = array();
640  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $action); // Note that $action and $object may have been modified by hook
641  if (empty($reshook)) {
642  print $ticketstat->showOptionals($extrafields, 'create');
643  }
644 
645  print '</table>';
646 
647  if ($withdolfichehead) {
648  print dol_get_fiche_end();
649  }
650 
651  print '<br><br>';
652 
653  print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ? "SendResponse" : "CreateTicket"), ($this->withcancel ? "Cancel" : ""));
654 
655  /*
656  print '<div class="center">';
657  print '<input type="submit" class="button" name="add" value="'.$langs->trans(($this->withreadid > 0 ? "SendResponse" : "CreateTicket")).'" />';
658  if ($this->withcancel) {
659  print " &nbsp; &nbsp; &nbsp;";
660  print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
661  }
662  print '</div>';
663  */
664 
665  print '<input type="hidden" name="page_y">'."\n";
666 
667  print "</form>\n";
668  print "<!-- End form TICKET -->\n";
669  }
670 
685  public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '', $multiselect = 0)
686  {
687  global $langs, $user;
688 
689  $selected = is_array($selected) ? $selected : (!empty($selected) ? array($selected) : array());
690  $ticketstat = new Ticket($this->db);
691 
692  dol_syslog(get_class($this) . "::select_types_tickets " . implode(';', $selected) . ", " . $htmlname . ", " . $filtertype . ", " . $format . ", " . $multiselect, LOG_DEBUG);
693 
694  $filterarray = array();
695 
696  if ($filtertype != '' && $filtertype != '-1') {
697  $filterarray = explode(',', $filtertype);
698  }
699 
700  $ticketstat->loadCacheTypesTickets();
701 
702  print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.($multiselect?'[]':'').'"'.($multiselect?' multiple':'').'>';
703  if ($empty) {
704  print '<option value="">&nbsp;</option>';
705  }
706 
707  if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
708  foreach ($ticketstat->cache_types_tickets as $id => $arraytypes) {
709  // On passe si on a demande de filtrer sur des modes de paiments particuliers
710  if (count($filterarray) && !in_array($arraytypes['type'], $filterarray)) {
711  continue;
712  }
713 
714  // If 'showempty' is enabled we discard empty line because an empty line has already been output.
715  if ($empty && empty($arraytypes['code'])) {
716  continue;
717  }
718 
719  if ($format == 0) {
720  print '<option value="'.$id.'"';
721  }
722 
723  if ($format == 1) {
724  print '<option value="'.$arraytypes['code'].'"';
725  }
726 
727  if ($format == 2) {
728  print '<option value="'.$arraytypes['code'].'"';
729  }
730 
731  if ($format == 3) {
732  print '<option value="'.$id.'"';
733  }
734 
735  // If text is selected, we compare with code, otherwise with id
736  if (in_array($arraytypes['code'], $selected)) {
737  print ' selected="selected"';
738  } elseif (in_array($id, $selected)) {
739  print ' selected="selected"';
740  } elseif ($arraytypes['use_default'] == "1" && !$selected && !$empty) {
741  print ' selected="selected"';
742  }
743 
744  print '>';
745 
746  $value = '&nbsp;';
747  if ($format == 0) {
748  $value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
749  } elseif ($format == 1) {
750  $value = $arraytypes['code'];
751  } elseif ($format == 2) {
752  $value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
753  } elseif ($format == 3) {
754  $value = $arraytypes['code'];
755  }
756 
757  print $value ? $value : '&nbsp;';
758  print '</option>';
759  }
760  }
761  print '</select>';
762  if (isset($user->admin) && $user->admin && !$noadmininfo) {
763  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
764  }
765 
766  print ajax_combobox('select'.$htmlname);
767  }
768 
784  public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '', $use_multilevel = 0, $outputlangs = null)
785  {
786  global $conf, $langs, $user;
787 
788  dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
789 
790  if (is_null($outputlangs) || !is_object($outputlangs)) {
791  $outputlangs = $langs;
792  }
793  $outputlangs->load("ticket");
794 
795  $ticketstat = new Ticket($this->db);
796  $ticketstat->loadCacheCategoriesTickets();
797 
798  if ($use_multilevel <= 0) {
799  print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
800  if ($empty) {
801  print '<option value="">&nbsp;</option>';
802  }
803 
804  if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
805  foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
806  // Exclude some record
807  if ($filtertype == 'public=1') {
808  if (empty($arraycategories['public'])) {
809  continue;
810  }
811  }
812 
813  // We discard empty line if showempty is on because an empty line has already been output.
814  if ($empty && empty($arraycategories['code'])) {
815  continue;
816  }
817 
818  $label = ($arraycategories['label'] != '-' ? $arraycategories['label'] : '');
819  if ($outputlangs->trans("TicketCategoryShort".$arraycategories['code']) != ("TicketCategoryShort".$arraycategories['code'])) {
820  $label = $outputlangs->trans("TicketCategoryShort".$arraycategories['code']);
821  } elseif ($outputlangs->trans($arraycategories['code']) != $arraycategories['code']) {
822  $label = $outputlangs->trans($arraycategories['code']);
823  }
824 
825  if ($format == 0) {
826  print '<option value="'.$id.'"';
827  }
828 
829  if ($format == 1) {
830  print '<option value="'.$arraycategories['code'].'"';
831  }
832 
833  if ($format == 2) {
834  print '<option value="'.$arraycategories['code'].'"';
835  }
836 
837  if ($format == 3) {
838  print '<option value="'.$id.'"';
839  }
840 
841  // If selected is text, we compare with code, otherwise with id
842  if (preg_match('/[a-z]/i', $selected) && $selected == $arraycategories['code']) {
843  print ' selected="selected"';
844  } elseif ($selected == $id) {
845  print ' selected="selected"';
846  } elseif ($arraycategories['use_default'] == "1" && !$selected && !$empty) {
847  print ' selected="selected"';
848  }
849 
850  print '>';
851 
852  $value = '';
853  if ($format == 0) {
854  $value = ($maxlength ? dol_trunc($label, $maxlength) : $label);
855  }
856 
857  if ($format == 1) {
858  $value = $arraycategories['code'];
859  }
860 
861  if ($format == 2) {
862  $value = ($maxlength ? dol_trunc($label, $maxlength) : $label);
863  }
864 
865  if ($format == 3) {
866  $value = $arraycategories['code'];
867  }
868 
869  print $value ? $value : '&nbsp;';
870  print '</option>';
871  }
872  }
873  print '</select>';
874  if (isset($user->admin) && $user->admin && !$noadmininfo) {
875  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
876  }
877 
878  print ajax_combobox('select'.$htmlname);
879  } elseif ($htmlname!='') {
880  $selectedgroups = array();
881  $groupvalue = "";
882  $groupticket=GETPOST($htmlname, 'aZ09');
883  $child_id=GETPOST($htmlname.'_child_id', 'aZ09')?GETPOST($htmlname.'_child_id', 'aZ09'):0;
884  if (!empty($groupticket)) {
885  $tmpgroupticket = $groupticket;
886  $sql = "SELECT ctc.rowid, ctc.fk_parent, ctc.code FROM ".$this->db->prefix()."c_ticket_category as ctc WHERE ctc.code = '".$this->db->escape($tmpgroupticket)."'";
887  $resql = $this->db->query($sql);
888  if ($resql) {
889  $obj = $this->db->fetch_object($resql);
890  $selectedgroups[] = $obj->code;
891  while ($obj->fk_parent > 0) {
892  $sql = "SELECT ctc.rowid, ctc.fk_parent, ctc.code FROM ".$this->db->prefix()."c_ticket_category as ctc WHERE ctc.rowid ='".$this->db->escape($obj->fk_parent)."'";
893  $resql = $this->db->query($sql);
894  if ($resql) {
895  $obj = $this->db->fetch_object($resql);
896  $selectedgroups[] = $obj->code;
897  }
898  }
899  }
900  }
901 
902  $arrayidused = array();
903  $arrayidusedconcat = array();
904  $arraycodenotparent = array();
905  $arraycodenotparent[] = "";
906 
907  $stringtoprint = '<span class="supportemailfield bold">'.$langs->trans("GroupOfTicket").'</span> ';
908  $stringtoprint .= '<select id ="'.$htmlname.'" class="minwidth500" child_id="0">';
909  $stringtoprint .= '<option value="">&nbsp;</option>';
910 
911  $sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
912  $sql .= $this->db->ifsql("ctc.rowid NOT IN (SELECT ctcfather.rowid FROM llx_c_ticket_category as ctcfather JOIN llx_c_ticket_category as ctcjoin ON ctcfather.rowid = ctcjoin.fk_parent)", "'NOTPARENT'", "'PARENT'")." as isparent";
913  $sql .= " FROM ".$this->db->prefix()."c_ticket_category as ctc";
914  $sql .= " WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
915  if ($filtertype == 'public=1') {
916  $sql .= " AND ctc.public = 1";
917  }
918  $sql .= " AND ctc.fk_parent = 0";
919  $sql .= $this->db->order('ctc.pos', 'ASC');
920 
921  $resql = $this->db->query($sql);
922  if ($resql) {
923  $num_rows_level0 = $this->db->num_rows($resql);
924  $i = 0;
925  while ($i < $num_rows_level0) {
926  $obj = $this->db->fetch_object($resql);
927  if ($obj) {
928  $label = ($obj->label != '-' ? $obj->label : '');
929  if ($outputlangs->trans("TicketCategoryShort".$obj->code) != ("TicketCategoryShort".$obj->code)) {
930  $label = $outputlangs->trans("TicketCategoryShort".$obj->code);
931  } elseif ($outputlangs->trans($obj->code) != $obj->code) {
932  $label = $outputlangs->trans($obj->code);
933  }
934 
935  $grouprowid = $obj->rowid;
936  $groupvalue = $obj->code;
937  $grouplabel = $label;
938 
939  $isparent = $obj->isparent;
940  if (is_array($selectedgroups)) {
941  $iselected = in_array($obj->code, $selectedgroups) ?'selected':'';
942  } else {
943  $iselected = $groupticket == $obj->code ?'selected':'';
944  }
945  $stringtoprint .= '<option '.$iselected.' class="'.$htmlname.dol_escape_htmltag($grouprowid).'" value="'.dol_escape_htmltag($groupvalue).'" data-html="'.dol_escape_htmltag($grouplabel).'">'.dol_escape_htmltag($grouplabel).'</option>';
946  if ($isparent == 'NOTPARENT') {
947  $arraycodenotparent[] = $groupvalue;
948  }
949  $arrayidused[] = $grouprowid;
950  $arrayidusedconcat[] = $grouprowid;
951  }
952  $i++;
953  }
954  } else {
955  dol_print_error($this->db);
956  }
957  if (count($arrayidused) == 1) {
958  return '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.dol_escape_htmltag($groupvalue).'">';
959  } else {
960  $stringtoprint .= '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'_select" class="maxwidth500 minwidth400">';
961  $stringtoprint .= '<input type="hidden" name="'.$htmlname.'_child_id" id="'.$htmlname.'_select_child_id" class="maxwidth500 minwidth400">';
962  }
963  $stringtoprint .= '</select>&nbsp;';
964 
965  $levelid = 1; // The first combobox
966  while ($levelid <= $use_multilevel) { // Loop to take the child of the combo
967  $tabscript = array();
968  $stringtoprint .= '<select id ="'.$htmlname.'_child_'.$levelid.'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.'">';
969  $stringtoprint .= '<option value="">&nbsp;</option>';
970 
971  $sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
972  $sql .= " FROM ".$this->db->prefix()."c_ticket_category as ctc";
973  $sql .= " JOIN ".$this->db->prefix()."c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
974  $sql .= " WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
975  $sql .= " AND ctc.rowid NOT IN (".$this->db->sanitize(join(',', $arrayidusedconcat)).")";
976 
977  if ($filtertype == 'public=1') {
978  $sql .= " AND ctc.public = 1";
979  }
980  // Add a test to take only record that are direct child
981  if (!empty($arrayidused)) {
982  $sql .= " AND ctc.fk_parent IN ( ";
983  foreach ($arrayidused as $idused) {
984  $sql .= $idused.", ";
985  }
986  $sql = substr($sql, 0, -2);
987  $sql .= ")";
988  }
989  $sql .= $this->db->order('ctc.pos', 'ASC');
990 
991  $resql = $this->db->query($sql);
992  if ($resql) {
993  $num_rows = $this->db->num_rows($resql);
994  $i = 0;
995  $arrayidused=array();
996  while ($i < $num_rows) {
997  $obj = $this->db->fetch_object($resql);
998  if ($obj) {
999  $label = ($obj->label != '-' ? $obj->label : '');
1000  if ($outputlangs->trans("TicketCategoryShort".$obj->code) != ("TicketCategoryShort".$obj->code)) {
1001  $label = $outputlangs->trans("TicketCategoryShort".$obj->code);
1002  } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1003  $label = $outputlangs->trans($obj->code);
1004  }
1005 
1006  $grouprowid = $obj->rowid;
1007  $groupvalue = $obj->code;
1008  $grouplabel = $label;
1009  $isparent = $obj->isparent;
1010  $fatherid = $obj->fk_parent;
1011  $arrayidused[] = $grouprowid;
1012  $arrayidusedconcat[] = $grouprowid;
1013  $groupcodefather = $obj->codefather;
1014  if ($isparent == 'NOTPARENT') {
1015  $arraycodenotparent[] = $groupvalue;
1016  }
1017  if (is_array($selectedgroups)) {
1018  $iselected = in_array($obj->code, $selectedgroups) ?'selected':'';
1019  } else {
1020  $iselected = $groupticket == $obj->code ?'selected':'';
1021  }
1022  $stringtoprint .= '<option '.$iselected.' class="'.$htmlname.'_'.dol_escape_htmltag($fatherid).'_child_'.$levelid.'" value="'.dol_escape_htmltag($groupvalue).'" data-html="'.dol_escape_htmltag($grouplabel).'">'.dol_escape_htmltag($grouplabel).'</option>';
1023  if (empty($tabscript[$groupcodefather])) {
1024  $tabscript[$groupcodefather] = 'if ($("#'.$htmlname.($levelid > 1 ?'_child_'.($levelid-1):'').'").val() == "'.dol_escape_js($groupcodefather).'"){
1025  $(".'.$htmlname.'_'.dol_escape_htmltag($fatherid).'_child_'.$levelid.'").show()
1026  console.log("We show childs tickets of '.$groupcodefather.' group ticket")
1027  }else{
1028  $(".'.$htmlname.'_'.dol_escape_htmltag($fatherid).'_child_'.$levelid.'").hide()
1029  console.log("We hide childs tickets of '.$groupcodefather.' group ticket")
1030  }';
1031  }
1032  }
1033  $i++;
1034  }
1035  } else {
1036  dol_print_error($this->db);
1037  }
1038  $stringtoprint .='</select>';
1039 
1040  $stringtoprint .='<script>';
1041  $stringtoprint .='arraynotparents = '.json_encode($arraycodenotparent).';'; // when the last visible combo list is number x, this is the array of group
1042  $stringtoprint .='if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?'_child_'.($levelid-1):'').'").val())){
1043  console.log("'.$htmlname.'_child_'.$levelid.'")
1044  if($("#'.$htmlname.'_child_'.$levelid.'").val() == "" && ($("#'.$htmlname.'_child_'.$levelid.'").attr("child_id")>'.$child_id.')){
1045  $("#'.$htmlname.'_child_'.$levelid.'").hide();
1046  console.log("We hide '.$htmlname.'_child_'.$levelid.' input")
1047  }
1048  if(arraynotparents.includes("'.$groupticket.'") && '.$child_id.' == 0){
1049  $("#ticketcategory_select_child_id").val($("#'.$htmlname.'").attr("child_id"))
1050  $("#ticketcategory_select").val($("#'.$htmlname.'").val()) ;
1051  console.log("We choose '.$htmlname.' input and reload hidden input");
1052  }
1053  }
1054  $("#'.$htmlname.($levelid > 1 ?'_child_'.($levelid-1):'').'").change(function() {
1055  child_id = $("#'.$htmlname.($levelid > 1 ?'_child_'.$levelid:'').'").attr("child_id");
1056 
1057  /* Change of value to select this value*/
1058  if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.') {
1059  $("#ticketcategory_select").val($(this).val());
1060  $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1061  console.log("We choose to select "+ $(this).val());
1062  }else{
1063  if ($("#'.$htmlname.'_child_'.$levelid.' option").length <= 1) {
1064  $("#ticketcategory_select").val($(this).val());
1065  $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1066  console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1067  } else {
1068  console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1069  $("#ticketcategory_select").val("");
1070  $("#ticketcategory_select_child_id").val("");
1071  }
1072  }
1073 
1074  console.log("We select a new value into combo child_id="+child_id);
1075 
1076  // Hide all selected box that are child of the one modified
1077  $(".groupticketchild").each(function(){
1078  if ($(this).attr("child_id") > child_id) {
1079  console.log("hide child_id="+$(this).attr("child_id"));
1080  $(this).val("");
1081  $(this).hide();
1082  }
1083  })
1084 
1085  // Now we enable the next combo
1086  $("#'.$htmlname.'_child_'.$levelid.'").val("");
1087  if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.'_child_'.$levelid.' option").length > 1) {
1088  console.log($("#'.$htmlname.'_child_'.$levelid.' option").length);
1089  $("#'.$htmlname.'_child_'.$levelid.'").show()
1090  } else {
1091  $("#'.$htmlname.'_child_'.$levelid.'").hide()
1092  }
1093  ';
1094  $levelid++;
1095  foreach ($tabscript as $script) {
1096  $stringtoprint .= $script;
1097  }
1098  $stringtoprint .='})';
1099  $stringtoprint .='</script>';
1100  }
1101  $stringtoprint .='<script>';
1102  $stringtoprint .='$("#'.$htmlname.'_child_'.$use_multilevel.'").change(function() {
1103  $("#ticketcategory_select").val($(this).val());
1104  $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1105  console.log($("#ticketcategory_select").val());
1106  })';
1107  $stringtoprint .='</script>';
1108  $stringtoprint .= ajax_combobox($htmlname);
1109 
1110  return $stringtoprint;
1111  }
1112  }
1113 
1127  public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketseverity', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '')
1128  {
1129  global $langs, $user;
1130 
1131  $ticketstat = new Ticket($this->db);
1132 
1133  dol_syslog(get_class($this)."::selectSeveritiesTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
1134 
1135  $filterarray = array();
1136 
1137  if ($filtertype != '' && $filtertype != '-1') {
1138  $filterarray = explode(',', $filtertype);
1139  }
1140 
1141  $ticketstat->loadCacheSeveritiesTickets();
1142 
1143  print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
1144  if ($empty) {
1145  print '<option value="">&nbsp;</option>';
1146  }
1147 
1148  if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
1149  foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
1150  // On passe si on a demande de filtrer sur des modes de paiments particuliers
1151  if (count($filterarray) && !in_array($arrayseverities['type'], $filterarray)) {
1152  continue;
1153  }
1154 
1155  // We discard empty line if showempty is on because an empty line has already been output.
1156  if ($empty && empty($arrayseverities['code'])) {
1157  continue;
1158  }
1159 
1160  if ($format == 0) {
1161  print '<option value="'.$id.'"';
1162  }
1163 
1164  if ($format == 1) {
1165  print '<option value="'.$arrayseverities['code'].'"';
1166  }
1167 
1168  if ($format == 2) {
1169  print '<option value="'.$arrayseverities['code'].'"';
1170  }
1171 
1172  if ($format == 3) {
1173  print '<option value="'.$id.'"';
1174  }
1175 
1176  // If text is selected, we compare with code, otherwise with id
1177  if (preg_match('/[a-z]/i', $selected) && $selected == $arrayseverities['code']) {
1178  print ' selected="selected"';
1179  } elseif ($selected == $id) {
1180  print ' selected="selected"';
1181  } elseif ($arrayseverities['use_default'] == "1" && !$selected && !$empty) {
1182  print ' selected="selected"';
1183  }
1184 
1185  print '>';
1186 
1187  $value = '';
1188  if ($format == 0) {
1189  $value = ($maxlength ? dol_trunc($arrayseverities['label'], $maxlength) : $arrayseverities['label']);
1190  }
1191 
1192  if ($format == 1) {
1193  $value = $arrayseverities['code'];
1194  }
1195 
1196  if ($format == 2) {
1197  $value = ($maxlength ? dol_trunc($arrayseverities['label'], $maxlength) : $arrayseverities['label']);
1198  }
1199 
1200  if ($format == 3) {
1201  $value = $arrayseverities['code'];
1202  }
1203 
1204  print $value ? $value : '&nbsp;';
1205  print '</option>';
1206  }
1207  }
1208  print '</select>';
1209  if (isset($user->admin) && $user->admin && !$noadmininfo) {
1210  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1211  }
1212 
1213  print ajax_combobox('select'.$htmlname);
1214  }
1215 
1216  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1222  public function clear_attached_files()
1223  {
1224  // phpcs:enable
1225  global $conf, $user;
1226  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1227 
1228  // Set tmp user directory
1229  $vardir = $conf->user->dir_output."/".$user->id;
1230  $upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path
1231  if (is_dir($upload_dir)) {
1232  dol_delete_dir_recursive($upload_dir);
1233  }
1234 
1235  if (!empty($this->trackid)) { // TODO Always use trackid (ticXXX) instead of track_id (abcd123)
1236  $keytoavoidconflict = '-'.$this->trackid;
1237  } else {
1238  $keytoavoidconflict = empty($this->track_id) ? '' : '-'.$this->track_id;
1239  }
1240  unset($_SESSION["listofpaths".$keytoavoidconflict]);
1241  unset($_SESSION["listofnames".$keytoavoidconflict]);
1242  unset($_SESSION["listofmimes".$keytoavoidconflict]);
1243  }
1244 
1251  public function showMessageForm($width = '40%')
1252  {
1253  global $conf, $langs, $user, $hookmanager, $form, $mysoc;
1254 
1255  $formmail = new FormMail($this->db);
1256  $addfileaction = 'addfile';
1257 
1258  if (!is_object($form)) {
1259  $form = new Form($this->db);
1260  }
1261 
1262  // Load translation files required by the page
1263  $langs->loadLangs(array('other', 'mails'));
1264 
1265  // Clear temp files. Must be done at beginning, before call of triggers
1266  if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {
1267  $this->clear_attached_files();
1268  }
1269 
1270  // Define output language
1271  $outputlangs = $langs;
1272  $newlang = '';
1273  if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->param['langsmodels'])) {
1274  $newlang = $this->param['langsmodels'];
1275  }
1276  if (!empty($newlang)) {
1277  $outputlangs = new Translate("", $conf);
1278  $outputlangs->setDefaultLang($newlang);
1279  $outputlangs->load('other');
1280  }
1281 
1282  // Get message template for $this->param["models"] into c_email_templates
1283  $arraydefaultmessage = -1;
1284  if (isset($this->param['models']) && $this->param['models'] != 'none') {
1285  $model_id = 0;
1286  if (array_key_exists('models_id', $this->param)) {
1287  $model_id = (int) $this->param["models_id"];
1288  }
1289 
1290  $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); // If $model_id is empty, preselect the first one
1291  }
1292 
1293  // Define list of attached files
1294  $listofpaths = array();
1295  $listofnames = array();
1296  $listofmimes = array();
1297 
1298  if (!empty($this->trackid)) {
1299  $keytoavoidconflict = '-'.$this->trackid;
1300  } else {
1301  $keytoavoidconflict = empty($this->track_id) ? '' : '-'.$this->track_id; // track_id instead of trackid
1302  }
1303  //var_dump($keytoavoidconflict);
1304  if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {
1305  if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) {
1306  foreach ($this->param['fileinit'] as $file) {
1307  $formmail->add_attached_files($file, basename($file), dol_mimetype($file));
1308  }
1309  }
1310  }
1311  //var_dump($_SESSION);
1312  //var_dump($_SESSION["listofpaths".$keytoavoidconflict]);
1313  if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
1314  $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
1315  }
1316  if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
1317  $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
1318  }
1319  if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
1320  $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
1321  }
1322 
1323  // Define output language
1324  $outputlangs = $langs;
1325  $newlang = '';
1326  if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->param['langsmodels'])) {
1327  $newlang = $this->param['langsmodels'];
1328  }
1329  if (!empty($newlang)) {
1330  $outputlangs = new Translate("", $conf);
1331  $outputlangs->setDefaultLang($newlang);
1332  $outputlangs->load('other');
1333  }
1334 
1335  print "\n<!-- Begin message_form TICKET -->\n";
1336 
1337  $send_email = GETPOST('send_email', 'int') ? GETPOST('send_email', 'int') : 0;
1338 
1339  // Example 1 : Adding jquery code
1340  print '<script type="text/javascript">
1341  jQuery(document).ready(function() {
1342  send_email=' . $send_email.';
1343  if (send_email) {
1344  if (!jQuery("#send_msg_email").is(":checked")) {
1345  jQuery("#send_msg_email").prop("checked", true).trigger("change");
1346  }
1347  jQuery(".email_line").show();
1348  } else {
1349  if (!jQuery("#private_message").is(":checked")) {
1350  jQuery("#private_message").prop("checked", true).trigger("change");
1351  }
1352  jQuery(".email_line").hide();
1353  }
1354 
1355  jQuery("#send_msg_email").click(function() {
1356  if(jQuery(this).is(":checked")) {
1357  if (jQuery("#private_message").is(":checked")) {
1358  jQuery("#private_message").prop("checked", false).trigger("change");
1359  }
1360  jQuery(".email_line").show();
1361  }
1362  else {
1363  jQuery(".email_line").hide();
1364  }
1365  });
1366 
1367  jQuery("#private_message").click(function() {
1368  if (jQuery(this).is(":checked")) {
1369  if (jQuery("#send_msg_email").is(":checked")) {
1370  jQuery("#send_msg_email").prop("checked", false).trigger("change");
1371  }
1372  jQuery(".email_line").hide();
1373  }
1374  });';
1375  print '});
1376  </script>';
1377 
1378  print '<form method="post" name="ticket" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">';
1379  print '<input type="hidden" name="token" value="'.newToken().'">';
1380  print '<input type="hidden" name="action" value="'.$this->action.'">';
1381  print '<input type="hidden" name="actionbis" value="add_message">';
1382  print '<input type="hidden" name="backtopage" value="'.$this->backtopage.'">';
1383  if (!empty($this->trackid)) {
1384  print '<input type="hidden" name="trackid" value="'.$this->trackid.'">';
1385  } else {
1386  print '<input type="hidden" name="trackid" value="'.(empty($this->track_id) ? '' : $this->track_id).'">';
1387  $keytoavoidconflict = empty($this->track_id) ? '' : '-'.$this->track_id; // track_id instead of trackid
1388  }
1389  foreach ($this->param as $key => $value) {
1390  print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
1391  }
1392 
1393  // Get message template
1394  $model_id = 0;
1395  if (array_key_exists('models_id', $this->param)) {
1396  $model_id = $this->param["models_id"];
1397  $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
1398  }
1399 
1400  $result = $formmail->fetchAllEMailTemplate(!empty($this->param["models"]) ? $this->param["models"] : "", $user, $outputlangs);
1401  if ($result < 0) {
1402  setEventMessages($this->error, $this->errors, 'errors');
1403  }
1404  $modelmail_array = array();
1405  foreach ($formmail->lines_model as $line) {
1406  $modelmail_array[$line->id] = $line->label;
1407  }
1408 
1409  print '<table class="border" width="'.$width.'">';
1410 
1411  // External users can't send message email
1412  if ($user->hasRight("ticket", "write") && !$user->socid) {
1413  $ticketstat = new Ticket($this->db);
1414  $res = $ticketstat->fetch('', '', $this->track_id);
1415 
1416  print '<tr><td></td><td>';
1417  $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : ($conf->global->TICKETS_MESSAGE_FORCE_MAIL?'checked':''));
1418  print '<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.'/> ';
1419  print '<label for="send_msg_email">'.$langs->trans('SendMessageByEmail').'</label>';
1420  $texttooltip = $langs->trans("TicketMessageSendEmailHelp", '{s1}');
1421  $texttooltip = str_replace('{s1}', $langs->trans('MarkMessageAsPrivate'), $texttooltip);
1422  print ' '.$form->textwithpicto('', $texttooltip, 1, 'help');
1423  print '</td></tr>';
1424 
1425  // Private message (not visible by customer/external user)
1426  if (!$user->socid) {
1427  print '<tr><td></td><td>';
1428  $checkbox_selected = (GETPOST('private_message', 'alpha') == "1" ? ' checked' : '');
1429  print '<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.'/> ';
1430  print '<label for="private_message">'.$langs->trans('MarkMessageAsPrivate').'</label>';
1431  print ' '.$form->textwithpicto('', $langs->trans("TicketMessagePrivateHelp"), 1, 'help');
1432  print '</td></tr>';
1433  }
1434 
1435  // Zone to select its email template
1436  if (count($modelmail_array) > 0) {
1437  print '<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'."\n";
1438  print $langs->trans('SelectMailModel').': '.$formmail->selectarray('modelmailselected', $modelmail_array, $this->param['models_id'], 1, 0, "", "", 0, 0, 0, '', 'minwidth200');
1439  if ($user->admin) {
1440  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1441  }
1442  print ' &nbsp; ';
1443  print '<input type="submit" class="button" value="'.$langs->trans('Apply').'" name="modelselected" id="modelselected">';
1444  print '</div></td>';
1445  }
1446 
1447  // Subject
1448  print '<tr class="email_line"><td>'.$langs->trans('Subject').'</td>';
1449  print '<td><input type="text" class="text minwidth500" name="subject" value="['.$conf->global->MAIN_INFO_SOCIETE_NOM.' - '.$langs->trans("Ticket").' '.$ticketstat->ref.'] '.$langs->trans('TicketNewMessage').'" />';
1450  print '</td></tr>';
1451 
1452  // Recipients / adressed-to
1453  print '<tr class="email_line"><td>'.$langs->trans('MailRecipients').'</td><td>';
1454  if ($res) {
1455  // Retrieve email of all contacts (internal and external)
1456  $contacts = $ticketstat->getInfosTicketInternalContact();
1457  $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact());
1458 
1459  $sendto = array();
1460 
1461  // Build array to display recipient list
1462  if (is_array($contacts) && count($contacts) > 0) {
1463  foreach ($contacts as $key => $info_sendto) {
1464  if ($info_sendto['email'] != '') {
1465  $sendto[] = dol_escape_htmltag(trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">").' <small class="opacitymedium">('.dol_escape_htmltag($info_sendto['libelle']).")</small>";
1466  }
1467  }
1468  }
1469 
1470  if ($ticketstat->origin_email && !in_array($ticketstat->origin_email, $sendto)) {
1471  $sendto[] = dol_escape_htmltag($ticketstat->origin_email).' <small class="opacitymedium">('.$langs->trans("TicketEmailOriginIssuer").")</small>";
1472  }
1473 
1474  if ($ticketstat->fk_soc > 0) {
1475  $ticketstat->socid = $ticketstat->fk_soc;
1476  $ticketstat->fetch_thirdparty();
1477 
1478  if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
1479  $sendto[] = $ticketstat->thirdparty->email.' <small class="opacitymedium">('.$langs->trans('Customer').')</small>';
1480  }
1481  }
1482 
1483  if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) {
1484  $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO.' <small class="opacitymedium">(generic email)</small>';
1485  }
1486 
1487  // Print recipient list
1488  if (is_array($sendto) && count($sendto) > 0) {
1489  print img_picto('', 'email', 'class="pictofixedwidth"');
1490  print implode(', ', $sendto);
1491  } else {
1492  print '<div class="warning">'.$langs->trans('WarningNoEMailsAdded').' '.$langs->trans('TicketGoIntoContactTab').'</div>';
1493  }
1494  }
1495  print '</td></tr>';
1496  }
1497 
1498  $uselocalbrowser = false;
1499 
1500  // Intro
1501  // External users can't send message email
1502  /*
1503  if ($user->rights->ticket->write && !$user->socid && !empty($conf->global->TICKET_MESSAGE_MAIL_INTRO)) {
1504  $mail_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO;
1505  print '<tr class="email_line"><td><label for="mail_intro">';
1506  print $form->textwithpicto($langs->trans("TicketMessageMailIntro"), $langs->trans("TicketMessageMailIntroHelp"), 1, 'help');
1507  print '</label>';
1508 
1509  print '</td><td>';
1510  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1511 
1512  $doleditor = new DolEditor('mail_intro', $mail_intro, '100%', 90, 'dolibarr_details', '', false, $uselocalbrowser, getDolGlobalInt('FCKEDITOR_ENABLE_TICKET'), ROWS_2, 70);
1513 
1514  $doleditor->Create();
1515  print '</td></tr>';
1516  }
1517  */
1518 
1519  // Attached files
1520  if (!empty($this->withfile)) {
1521  $out = '<tr>';
1522  $out .= '<td width="180">'.$langs->trans("MailFile").'</td>';
1523  $out .= '<td>';
1524  // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
1525  $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
1526  $out .= '<script type="text/javascript">';
1527  $out .= 'jQuery(document).ready(function () {';
1528  $out .= ' jQuery(".removedfile").click(function() {';
1529  $out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
1530  $out .= ' });';
1531  $out .= '})';
1532  $out .= '</script>'."\n";
1533 
1534  if (count($listofpaths)) {
1535  foreach ($listofpaths as $key => $val) {
1536  $out .= '<div id="attachfile_'.$key.'">';
1537  $out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
1538  if (!$this->withfilereadonly) {
1539  $out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile reposition" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
1540  }
1541  $out .= '<br></div>';
1542  }
1543  } else {
1544  //$out .= $langs->trans("NoAttachedFiles").'<br>';
1545  }
1546  if ($this->withfile == 2) { // Can add other files
1547  $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
1548  $out .= ' ';
1549  $out .= '<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
1550  }
1551  $out .= "</td></tr>\n";
1552 
1553  print $out;
1554  }
1555 
1556  // MESSAGE
1557 
1558  $defaultmessage = "";
1559  if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1560  $defaultmessage = $arraydefaultmessage->content;
1561  }
1562  $defaultmessage = str_replace('\n', "\n", $defaultmessage);
1563 
1564  // Deal with format differences between message and signature (text / HTML)
1565  if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
1566  $this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']);
1567  } elseif (!dol_textishtml($defaultmessage) && isset($this->substit['__USER_SIGNATURE__']) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
1568  $defaultmessage = dol_nl2br($defaultmessage);
1569  }
1570  if (GETPOSTISSET("message") && !GETPOST('modelselected')) {
1571  $defaultmessage = GETPOST('message', 'restricthtml');
1572  } else {
1573  $defaultmessage = make_substitutions($defaultmessage, $this->substit);
1574  // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty)
1575  $defaultmessage = preg_replace("/^(<br>)+/", "", $defaultmessage);
1576  $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage);
1577  }
1578 
1579  print '<tr><td colspan="2"><label for="message"><span class="fieldrequired">'.$langs->trans("Message").'</span>';
1580  if ($user->hasRight("ticket", "write") && !$user->socid) {
1581  $texttooltip = $langs->trans("TicketMessageHelp");
1582  if (getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO') || getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE')) {
1583  $texttooltip .= '<br><br>'.$langs->trans("ForEmailMessageWillBeCompletedWith").'...';
1584  }
1585  if (getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO')) {
1586  $texttooltip .= '<br><u>'.$langs->trans("TicketMessageMailIntro").'</u><br>'.getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO');
1587  }
1588  if (getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE')) {
1589  $texttooltip .= '<br><br><u>'.$langs->trans("TicketMessageMailFooter").'</u><br>'.getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE');
1590  }
1591  print $form->textwithpicto('', $texttooltip, 1, 'help');
1592  }
1593  print '</label></td></tr>';
1594 
1595 
1596  print '<tr><td colspan="2">';
1597  //$toolbarname = 'dolibarr_details';
1598  $toolbarname = 'dolibarr_notes';
1599  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1600  $doleditor = new DolEditor('message', $defaultmessage, '100%', 200, $toolbarname, '', false, $uselocalbrowser, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, 70);
1601  $doleditor->Create();
1602  print '</td></tr>';
1603 
1604  // Footer
1605  // External users can't send message email
1606  /*if ($user->rights->ticket->write && !$user->socid && !empty($conf->global->TICKET_MESSAGE_MAIL_SIGNATURE)) {
1607  $mail_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
1608  print '<tr class="email_line"><td><label for="mail_intro">'.$langs->trans("TicketMessageMailFooter").'</label>';
1609  print $form->textwithpicto('', $langs->trans("TicketMessageMailFooterHelp"), 1, 'help');
1610  print '</td><td>';
1611  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1612  $doleditor = new DolEditor('mail_signature', $mail_signature, '100%', 90, 'dolibarr_details', '', false, $uselocalbrowser, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_2, 70);
1613  $doleditor->Create();
1614  print '</td></tr>';
1615  }
1616  */
1617 
1618  print '</table>';
1619 
1620  print '<center><br>';
1621  print '<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans("Add").'" />';
1622  if ($this->withcancel) {
1623  print " &nbsp; &nbsp; ";
1624  print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
1625  }
1626  print "</center>\n";
1627 
1628  print '<input type="hidden" name="page_y">'."\n";
1629 
1630  print "</form>\n";
1631  print "<!-- End form TICKET -->\n";
1632  }
1633 }
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:449
Class to manage contact/addresses.
Class to manage a WYSIWYG editor.
Class to manage standard extra fields.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Class to manage building of HTML components.
selectGroupTickets($selected='', $htmlname='ticketcategory', $filtertype='', $format=0, $empty=0, $noadmininfo=0, $maxlength=0, $morecss='', $use_multilevel=0, $outputlangs=null)
Return html list of ticket anaytic codes.
selectSeveritiesTickets($selected='', $htmlname='ticketseverity', $filtertype='', $format=0, $empty=0, $noadmininfo=0, $maxlength=0, $morecss='')
Return html list of ticket severitys (priorities)
showMessageForm($width='40%')
Show the form to add message on ticket.
selectTypesTickets($selected='', $htmlname='tickettype', $filtertype='', $format=0, $empty=0, $noadmininfo=0, $maxlength=0, $morecss='', $multiselect=0)
Return html list of tickets type.
__construct($db)
Constructor.
showForm($withdolfichehead=0, $mode='edit', $public=0, Contact $with_contact=null, $action='')
Show the form to input ticket.
clear_attached_files()
Clear list of attached files in send mail form (also stored in session)
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
Definition: user.class.php:45
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
Definition: files.lib.php:1401
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Class to generate the form for creating a new ticket.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
getMaxFileSizeArray()
Return the max allowed for file upload.
$conf db
API class for accounts.
Definition: inc.php:41