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