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