33require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
34require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
35require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
37if (!class_exists(
'FormCompany')) {
38 include DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
69 public $fk_user_create;
106 public $withfilereadonly;
121 public $withtitletopic;
125 public $withtopicreadonly;
138 public $withfromsocid;
142 public $withfromcontactid;
146 public $withnotifytiersatcreate;
150 public $withusercreate;
154 public $withcreatereadonly;
159 public $withextrafields;
177 public $category_code;
181 public $severity_code;
187 public $substit = array();
191 public $param = array();
200 public $errors = array();
214 $this->action =
'add';
217 $this->withfromsocid = 0;
218 $this->withfromcontactid = 0;
219 $this->withreadid = 0;
221 $this->withnotifytiersatcreate = 0;
222 $this->withusercreate = 1;
223 $this->withcreatereadonly = 1;
224 $this->withemail = 0;
226 $this->withextrafields = 0;
241 foreach ($fields as $field => $type) {
242 if (!
GETPOST($field, $type[
'check'])) {
244 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities($type[
'langs'])),
null,
'errors');
260 public function showForm($withdolfichehead = 0, $mode =
'edit', $public = 0, $with_contact =
null, $action =
'',
$object =
null)
262 global
$conf, $langs, $user, $hookmanager;
264 $permissiontomanage = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'ticket',
'write')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'ticket',
'manage_advance')));
267 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
269 if ($mode ==
'create') {
291 $form =
new Form($this->db);
293 $ticketstatic =
new Ticket($this->db);
296 if (!empty($this->withfromsocid) && $this->withfromsocid > 0) {
297 $soc->fetch($this->withfromsocid);
300 $ticketstat =
new Ticket($this->db);
303 $extrafields->fetch_name_optionals_label($ticketstat->table_element);
305 print
"\n<!-- Begin form TICKET -->\n";
307 if ($withdolfichehead) {
311 print
'<form method="POST" '.($withdolfichehead ?
'' :
'style="margin-bottom: 30px;" ').
'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="'.(!empty($this->param[
"returnurl"]) ? $this->param[
"returnurl"] : $_SERVER[
'PHP_SELF']).
'">';
313 print
'<input type="hidden" name="token" value="'.newToken().
'">';
314 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
316 print
'<input type="hidden" name="id" value="'.
$object->id .
'">';
318 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
319 foreach ($this->param as $key => $value) {
320 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
322 print
'<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.
'">';
324 print
'<table class="border centpercent">';
327 if ($this->withref) {
328 $defaultref = $ticketstat->getDefaultRef();
330 if ($mode ==
'edit') {
331 $defaultref = (string)
$object->ref;
333 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Ref").
'</span></td><td>';
334 print
'<input type="text" name="ref" value="'.dol_escape_htmltag($defaultref).
'">';
339 if ($this->withemail) {
340 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"Email").
'</span></label></td><td>';
341 print
'<input class="text minwidth200" id="email" name="email" value="'.$email.
'" autofocus>';
346 $html_contact_search =
'';
347 $html_contact_search .=
'<tr id="contact_search_line">';
348 $html_contact_search .=
'<td class="titlefield">';
349 $html_contact_search .=
'<label for="contact"><span class="fieldrequired">' . $langs->trans(
'Contact') .
'</span></label>';
350 $html_contact_search .=
'<input type="hidden" id="contact_id" name="contact_id" value="" />';
351 $html_contact_search .=
'</td>';
352 $html_contact_search .=
'<td id="contact_search_result"></td>';
353 $html_contact_search .=
'</tr>';
354 print $html_contact_search;
356 $html_contact_lastname =
'';
357 $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>';
358 $html_contact_lastname .=
'<input type="text" id="contact_lastname" name="contact_lastname" value="' . dolPrintHTMLForAttributeUrl(
GETPOSTISSET(
'contact_lastname') ?
GETPOST(
'contact_lastname',
'alphanohtml') :
'') .
'" />';
359 $html_contact_lastname .=
'</td></tr>';
360 print $html_contact_lastname;
362 $html_contact_firstname =
'';
363 $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>';
364 $html_contact_firstname .=
'<input type="text" id="contact_firstname" name="contact_firstname" value="' . dolPrintHTMLForAttribute(
GETPOSTISSET(
'contact_firstname') ?
GETPOST(
'contact_firstname',
'alphanohtml') :
'') .
'" />';
365 $html_contact_firstname .=
'</td></tr>';
366 print $html_contact_firstname;
368 $html_company_name =
'';
369 $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>';
370 $html_company_name .=
'<input type="text" id="company_name" name="company_name" value="' . dolPrintHTMLForAttribute(
GETPOSTISSET(
'company_name') ?
GETPOST(
'company_name',
'alphanohtml') :
'') .
'" />';
371 $html_company_name .=
'</td></tr>';
372 print $html_company_name;
374 $html_contact_phone =
'';
375 $html_contact_phone .=
'<tr id="contact_phone_line" class="contact_field"><td><label for="contact_phone"><span>' . $langs->trans(
'Phone') .
'</span></label></td><td>';
376 $html_contact_phone .=
'<input type="text" id="contact_phone" name="contact_phone" value="' . dolPrintHTMLForAttribute(
GETPOSTISSET(
'contact_phone') ?
GETPOST(
'contact_phone',
'alphanohtml') :
'') .
'" />';
377 $html_contact_phone .=
'</td></tr>';
378 print $html_contact_phone;
381 $langs->load(
'errors');
382 print
'<script nonce="'.getNonce().
'" type="text/javascript">
383 jQuery(document).ready(function() {
384 var contact = jQuery.parseJSON("'.
dol_escape_js(json_encode($with_contact), 2).
'");
385 jQuery("#contact_search_line").hide();
387 if (contact.id > 0) {
388 jQuery("#contact_search_line").show();
389 jQuery("#contact_id").val(contact.id);
390 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
391 jQuery(".contact_field").hide();
393 jQuery(".contact_field").show();
397 jQuery("#email").change(function() {
398 jQuery("#contact_search_line").show();
399 jQuery("#contact_search_result").html(\''.
dol_escape_js($langs->trans(
'Select2SearchInProgress')).
'\');
400 jQuery(
"#contact_id").val(
"");
401 jQuery(
"#contact_lastname").val(
"");
402 jQuery(
"#contact_firstname").val(
"");
403 jQuery(
"#company_name").val(
"");
404 jQuery(
"#contact_phone").val(
"");
409 action:
"getContacts",
410 token:
"'.currentToken().'",
411 email: jQuery(
"#email").val()
414 if (response.error) {
415 jQuery(
"#contact_search_result").html(
"<span class=\"error\">"+response.error+
"</span>");
417 var contact_list = response.contacts;
418 if (contact_list.length == 1) {
419 var contact = contact_list[0];
420 jQuery(
"#contact_id").val(contact.id);
421 jQuery(
"#contact_search_result").html(contact.firstname+
" "+contact.lastname);
422 jQuery(
".contact_field").hide();
423 }
else if (contact_list.length <= 0) {
424 jQuery(
"#contact_search_line").hide();
425 jQuery(
".contact_field").show();
429 ).
fail(
function(jqxhr, textStatus, error) {
430 var error_msg = \
''.dol_escape_js($langs->trans(
'ErrorAjaxRequestFailed')).
'\'+
" ["+textStatus+
"] : "+error;
431 jQuery(
"#contact_search_result").html(
"<span class=\"error\">"+error_msg+
"</span>");
439 // If ticket created from another object
441 if (isset($this->param['origin
']) && $this->param['originid
'] > 0) {
442 // Parse element/subelement (ex: project_task)
443 $element = $subelement = $this->param['origin
'];
445 if (preg_match('/^([^_]+)_([^_]+)/i
', $this->param['origin
'], $regs)) {
447 $subelement = $regs[2];
450 dol_include_once('/
'.$element.'/
class/
'.$subelement.'.class.php
');
451 $classname = ucfirst($subelement);
452 $objectsrc = new $classname($this->db);
454 $objectsrc->fetch(GETPOSTINT('originid
'));
456 if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines
')) {
457 $objectsrc->fetch_lines();
460 $objectsrc->fetch_thirdparty();
461 $newclassname = $classname;
462 print '<tr><td>
'.$langs->trans($newclassname).'</td><td colspan=
"2"><input
name=
"'.$subelement.'id" value=
"'.GETPOST('originid').'" type=
"hidden" />
'.$objectsrc->getNomUrl(1).'</td></tr>
';
466 print '<tr><td
class=
"titlefield"><span
class=
"fieldrequired"><label
for=
"selecttype_code">
'.$langs->trans("TicketTypeRequest").'</span></label></td><td>
';
467 $this->selectTypesTickets($type_code, 'type_code
', '', 2, 'ifone
', 0, 0, 'minwidth200 maxwidth500
');
471 print '<tr><td><span
class=
"fieldrequired"><label
for=
"selectcategory_code">
'.$langs->trans("TicketCategory").'</span></label></td><td>
';
474 $filter = '(
public:=:1)
';
476 $this->selectGroupTickets($category_code, 'category_code
', $filter, 2, 'ifone
', 0, 0, 'minwidth200 maxwidth500
');
479 // Severity => Priority
480 print '<tr><td><span
class=
"fieldrequired"><label
for=
"selectseverity_code">
'.$langs->trans("TicketSeverity").'</span></label></td><td>
';
481 $this->selectSeveritiesTickets($severity_code, 'severity_code
', '', 2, 'ifone
', 0, 0, 'minwidth200 maxwidth500
');
484 if (isModEnabled('knowledgemanagement
')) {
486 print '<tr
id=
"KWwithajax" class=
"hidden"><td></td></tr>
';
487 print '<!-- Script to manage change of ticket group -->
488 <script nonce=
"'.getNonce().'">
489 jQuery(document).ready(
function() {
490 function groupticketchange() {
491 console.log(
"We called groupticketchange, so we try to load list KM linked to event");
492 $(
"#KWwithajax").html(
"");
493 idgroupticket = $(
"#selectcategory_code").val();
495 console.log(
"We have selected id="+idgroupticket);
497 if (idgroupticket !=
"") {
498 $.ajax({ url: \
''.DOL_URL_ROOT.
'/core/ajax/fetchKnowledgeRecord.php\',
499 data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.
newToken().
'\', lang:\
''.$langs->defaultlang.
'\',
public:
'.($public).' },
501 success: function(response) {
503 console.log("We received response "+response);
504 if (typeof response == "object") {
505 console.log("response is already type object, no need to parse it");
507 console.log("response is type "+(typeof response));
508 response = JSON.parse(response);
510 for (key in response) {
511 answer = response[key].answer;
512 urllist += \'<li><a href="#" title="\'+response[key].title+\'" class="button_KMpopup" data-html="\'+answer+\'">\' +response[key].title+\'</a></li>\';
515 $("#KWwithajax").html(\'<td>'.$langs->trans(
"KMFoundForTicketGroup").
'</td><td><ul>\'+urllist+\'</ul></td>\');
516 $("#KWwithajax").show();
517 $(".button_KMpopup").on("click",function(){
518 console.log("Open popup with jQuery(...).dialog() with KM article")
519 var $dialog = $("<div></div>").html($(this).attr("data-html"))
523 height: (window.innerHeight - 150),
525 title: $(this).attr("title"),
527 $dialog.dialog("open");
528 console.log($dialog);
532 error : function(output) {
533 console.error("Error on Fetch of KM articles");
538 $("#selectcategory_code").on("change",function() { groupticketchange(); });
539 if ($("#selectcategory_code").val() != "") {
547 if ($this->withtitletopic) {
548 print
'<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans(
"Subject").
'</span></label></td><td>';
550 if ($this->withtopicreadonly) {
551 print $langs->trans(
'SubjectAnswerToTicket').
' '.$this->topic_title;
553 if (isset($this->withreadid) && $this->withreadid > 0) {
554 $subject = $langs->trans(
'SubjectAnswerToTicket').
' '.$this->withreadid.
' : '.$this->topic_title;
556 print
'<input class="text minwidth400imp" id="subject" name="subject" value="'.dolPrintHTMLForAttribute($subject).
'"'.(empty($this->withemail) ?
' autofocus' :
'').
' spellcheck="false">';
562 print
'<tr><td class="tdtop"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span></label></td><td class="tdtop">';
565 $toolbarname =
'dolibarr_notes';
566 if ($this->ispublic) {
567 $toolbarname =
'dolibarr_details';
568 print
'<div class="warning hideonsmartphone">'.(getDolGlobalString(
"TICKET_PUBLIC_TEXT_HELP_MESSAGE", $langs->trans(
'TicketPublicPleaseBeAccuratelyDescribe'))).
'</div>';
570 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
571 $uselocalbrowser =
false;
572 $ckeditorenabledforticket = (
getDolGlobalString(
'FCKEDITOR_ENABLE_TICKET') >= ($this->ispublic ? 2 : 1));
575 if (!$this->ispublic) {
577 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
578 $formmail =
new FormMail($this->db);
579 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formai.class.php';
580 $formai =
new FormAI($this->db);
582 $formmail->withfckeditor = $ckeditorenabledforticket ? 1 : 0;
584 $formmail->withaiprompt = (
isModEnabled(
'ai')) ?
'text' :
'';
586 $showlinktolayout = ($formmail->withfckeditor &&
getDolGlobalInt(
'MAIN_EMAIL_USE_LAYOUT')) ? $formmail->withlayout :
'';
587 $showlinktolayoutlabel = $langs->trans(
"FillMessageWithALayout");
588 $showlinktoai = ($formmail->withaiprompt ?
'textgenerationemail' :
'');
589 $showlinktoailabel = $langs->trans(
"AIEnhancements");
590 $htmlname =
'message';
592 $formai->substit = $this->substit;
596 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
601 if (!$ckeditorenabledforticket) {
604 $doleditor =
new DolEditor(
'message', $msg,
'100%', 230, $toolbarname,
'In',
true, $uselocalbrowser, $ckeditorenabledforticket, ROWS_8,
'90%');
605 $doleditor->Create();
611 print
'<tr><td class="wordbreak">'.$langs->trans(
"Categories").
'</td><td>';
612 print $form->selectCategories(Categorie::TYPE_TICKET,
'categories',
$object);
617 if (!empty($this->withfile)) {
619 $listofpaths = array();
620 $listofnames = array();
621 $listofmimes = array();
622 if (!empty($_SESSION[
"listofpaths"])) {
623 $listofpaths = explode(
';', $_SESSION[
"listofpaths"]);
626 if (!empty($_SESSION[
"listofnames"])) {
627 $listofnames = explode(
';', $_SESSION[
"listofnames"]);
630 if (!empty($_SESSION[
"listofmimes"])) {
631 $listofmimes = explode(
';', $_SESSION[
"listofmimes"]);
636 $out .= $langs->trans(
"LinkedFiles");
640 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
641 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
642 $out .=
'jQuery(document).ready(function () {';
643 $out .=
' jQuery(".removedfile").click(function() {';
644 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
647 $out .=
'</script>'.
"\n";
648 if (count($listofpaths)) {
649 foreach ($listofpaths as $key => $val) {
650 $out .=
'<div id="attachfile_'.$key.
'">';
651 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
652 if (!$this->withfilereadonly) {
653 $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.
'" />';
655 $out .=
'<br></div>';
658 if ($this->withfile == 2) {
660 $maxmin = $maxfilesizearray[
'maxmin'];
662 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
664 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
666 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="addfile" name="addfile" value="'.$langs->trans(
"MailingAddFile").
'" />';
668 $out .=
"</td></tr>\n";
671 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">
672 jQuery(document).ready(function () {
673 jQuery("#addedfile").on("change", function() {
674 // Dispara el clic automáticamente al seleccionar archivo
675 jQuery("#addfile").click();
677 // Oculta el botón redundante si JS está activo
678 jQuery("#addfile").hide();
686 if ($this->withusercreate > 0 && $this->fk_user_create) {
687 print
'<tr><td class="titlefield">'.$langs->trans(
"CreatedBy").
'</td><td>';
688 $langs->load(
"users");
689 $fuser =
new User($this->db);
691 if ($this->withcreatereadonly) {
692 if ($res = $fuser->fetch($this->fk_user_create)) {
693 print $fuser->getNomUrl(1);
697 print
"</td></tr>\n";
701 if ($this->withcompany) {
703 if (empty($user->socid)) {
705 print
'<tr><td class="titlefield">'.$langs->trans(
"ThirdParty").
'</td><td>';
707 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
708 print img_picto(
'',
'company',
'class="pictofixedwidth"');
709 print $form->select_company($this->withfromsocid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth200');
713 print
'<script nonce="'.getNonce().
'" type="text/javascript">
714 $(document).ready(function () {
715 jQuery("#'.$htmlname.
'").change(function () {
716 var obj = '.json_encode($events).
';
717 $.each(obj, function(key,values) {
718 if (values.method.length) {
719 runJsCodeForEvent'.$htmlname.
'(values);
724 function runJsCodeForEvent'.$htmlname.
'(obj) {
725 console.log("Run runJsCodeForEvent'.$htmlname.
'");
726 var id = $("#'.$htmlname.
'").val();
727 var method = obj.method;
729 var htmlname = obj.htmlname;
730 var showempty = obj.showempty;
739 $.each(obj.params, function(key,action) {
741 var num = response.num;
743 $("#" + key).removeAttr(action);
745 $("#" + key).attr(action, action);
749 $("select#" + htmlname).html(response.value);
751 var selecthtml_str = response.value;
752 var selecthtml_dom=$.parseHTML(selecthtml_str);
753 if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
754 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
757 $("#inputautocomplete"+htmlname).val("");
759 $("select#" + htmlname).change(); /* Trigger event change */
766 if ($mode ==
'create') {
768 print
'<tr><td>'.$langs->trans(
"Contact").
'</td><td>';
770 $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
771 print img_picto(
'',
'contact',
'class="pictofixedwidth"');
773 print $form->select_contact($selectedCompany, $this->withfromcontactid,
'contactid', 3,
'',
'', 1,
'maxwidth300 widthcentpercentminusx',
true);
776 $formcompany->selectTypeContact($ticketstatic,
'',
'type',
'external',
'', 0,
'maginleftonly maxwidth200');
780 print
'<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.
'"/></td>';
781 print
'<td><input type="hidden" name="contactid" value="'.$user->contact_id.
'"/></td>';
782 print
'<td><input type="hidden" name="type" value="Z"/></td></tr>';
786 if (empty($this->ispublic) && ($action ==
'create' || $action ==
'presend')) {
787 print
'<tr><td><label for="notify_tiers_at_create">'.$langs->trans(
"TicketNotifyTiersAtCreation").
'</label></td><td>';
788 print
'<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ?
' checked="checked"' :
'').
'>';
794 print $langs->trans(
"AssignedTo");
796 if ($permissiontomanage) {
797 print img_picto(
'',
'user',
'class="pictofixedwidth"');
798 print $form->select_dolusers($user_assign,
'fk_user_assign', 1);
800 $userstat =
new User($this->db);
801 $userstat->fetch($user_assign);
802 print $userstat->getNomUrl(-1);
808 if ($subelement !=
'project') {
811 print
'<tr><td><label for="project"><span class="">'.$langs->trans(
"Project").
'</span></label></td><td>';
812 print img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects(-1, $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
817 if ($subelement !=
'contract' && $subelement !=
'contrat') {
824 $langs->load(
'contracts');
826 print
'<tr><td><label for="contract"><span class="">'.$langs->trans(
"Contract").
'</span></label></td><td>';
827 print img_picto(
'',
'contract',
'class="pictofixedwidth"');
829 print $formcontract->select_contract($user->socid ?? -1,
GETPOSTINT(
'contractid'),
'contractid', 0, 1, 1, 1);
837 $parameters = array();
838 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $ticketstat, $action);
839 if (empty($reshook)) {
840 if ($mode ==
'create') {
841 print
$object->showOptionals($extrafields,
'create');
843 print
$object->showOptionals($extrafields,
'edit');
850 print
'<tr><td class="titlefield"></td><td><br>';
852 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
856 $dirModCaptcha = array_merge(array(
'main' =>
'/core/modules/security/captcha/'), is_array(
$conf->modules_parts[
'captcha']) ?
$conf->modules_parts[
'captcha'] : array());
858 $fullpathclassfile =
'';
859 foreach ($dirModCaptcha as $dir) {
860 $fullpathclassfile =
dol_buildpath($dir.
"modCaptcha".ucfirst($captcha).
'.class.php', 0, 2);
861 if ($fullpathclassfile) {
866 if ($fullpathclassfile) {
867 include_once $fullpathclassfile;
871 $classname =
"modCaptcha".ucfirst($captcha);
872 if (class_exists($classname)) {
874 $captchaobj =
new $classname($this->db,
$conf, $langs, $user);
875 '@phan-var-force ModeleCaptcha $captchaobj';
877 if (is_object($captchaobj) && method_exists($captchaobj,
'getCaptchaCodeForForm')) {
878 print $captchaobj->getCaptchaCodeForForm(
'');
880 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method getCaptchaCodeForForm()';
883 print
'Error, the captcha handler class '.$classname.
' was not found after the include';
886 print
'Error, the captcha handler '.$captcha.
' has no class file found modCaptcha'.ucfirst($captcha);
889 print
'<br></td></tr>';
894 if ($withdolfichehead) {
900 if ($mode ==
'create') {
901 print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"CreateTicket"), ($this->withcancel ?
"Cancel" :
""));
903 print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"Save"), ($this->withcancel ?
"Cancel" :
""));
918 print
'<input type="hidden" name="page_y">'.
"\n";
921 print
"<!-- End form TICKET -->\n";
939 public function selectTypesTickets($selected =
'', $htmlname =
'tickettype', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $multiselect = 0, $disabledefault = 0)
941 global $langs, $user;
943 $selected = is_array($selected) ? $selected : (!empty($selected) ? explode(
',', $selected) : array());
944 $ticketstat =
new Ticket($this->db);
946 dol_syslog(get_class($this) .
"::select_types_tickets " . implode(
';', $selected) .
", " . $htmlname .
", " . $filtertype .
", " . $format .
", " . $multiselect, LOG_DEBUG);
948 $filterarray = array();
950 if ($filtertype !=
'' && $filtertype !=
'-1') {
951 $filterarray = explode(
',', $filtertype);
954 $ticketstat->loadCacheTypesTickets();
956 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.($multiselect ?
'[]' :
'').
'"'.($multiselect ?
' multiple' :
'').
'>';
957 if ($empty && !$multiselect) {
958 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
961 if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
962 foreach ($ticketstat->cache_types_tickets as
$id => $arraytypes) {
964 if (count($filterarray) && !in_array($arraytypes[
'code'], $filterarray)) {
969 if ($empty && empty($arraytypes[
'code'])) {
974 print
'<option value="'.$id.
'"';
978 print
'<option value="'.$arraytypes[
'code'].
'"';
982 print
'<option value="'.$arraytypes[
'code'].
'"';
986 print
'<option value="'.$id.
'"';
990 if (in_array($arraytypes[
'code'], $selected)) {
991 print
' selected="selected"';
992 } elseif (in_array(
$id, $selected)) {
993 print
' selected="selected"';
994 } elseif ($arraytypes[
'use_default'] ==
"1" && empty($disabledefault) && empty($selected) && !$multiselect) {
995 print
' selected="selected"';
996 } elseif (count($ticketstat->cache_types_tickets) == 1 && (!$empty || $empty ==
'ifone')) {
997 print
' selected="selected"';
1004 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
1005 } elseif ($format == 1) {
1006 $value = $arraytypes[
'code'];
1007 } elseif ($format == 2) {
1008 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
1009 } elseif ($format == 3) {
1010 $value = $arraytypes[
'code'];
1013 print $value ? $value :
' ';
1018 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1019 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1040 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs =
null)
1042 global
$conf, $langs, $user;
1044 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1046 if (is_null($outputlangs) || !is_object($outputlangs)) {
1047 $outputlangs = $langs;
1049 $outputlangs->load(
"ticket");
1051 $publicgroups = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
1053 $ticketstat =
new Ticket($this->db);
1054 $ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1);
1056 if ($use_multilevel <= 0) {
1057 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1059 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
1062 $categorytickets =
$conf->cache[
'category_tickets'];
1063 '@phan-var-force array<int,array{code:string,label:string,use_default:int,pos:int,public:int,active:int,force_severity:?string,fk_parent:int}> $categorytickets';
1064 if (is_array($categorytickets) && count($categorytickets)) {
1065 foreach ($categorytickets as
$id => $arraycategories) {
1067 if ($publicgroups) {
1068 if (empty($arraycategories[
'public'])) {
1074 if ($empty && empty($arraycategories[
'code'])) {
1078 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
1079 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) !=
"TicketCategoryShort".$arraycategories[
'code']) {
1080 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
1081 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
1082 $label = $outputlangs->trans($arraycategories[
'code']);
1086 print
'<option value="'.$id.
'"';
1090 print
'<option value="'.$arraycategories[
'code'].
'"';
1094 print
'<option value="'.$arraycategories[
'code'].
'"';
1098 print
'<option value="'.$id.
'"';
1102 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
1103 print
' selected="selected"';
1104 } elseif (isset($selected) && $selected ==
$id) {
1105 print
' selected="selected"';
1106 } elseif ($arraycategories[
'use_default'] ==
"1" && empty($selected) && (!$empty || $empty ==
'ifone')) {
1107 print
' selected="selected"';
1108 } elseif (count($categorytickets) == 1 && (!$empty || $empty ==
'ifone')) {
1109 print
' selected="selected"';
1116 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
1120 $value = $arraycategories[
'code'];
1124 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
1128 $value = $arraycategories[
'code'];
1131 print $value ? $value :
' ';
1136 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1137 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1141 } elseif ($htmlname !=
'') {
1142 $selectedgroups = array();
1144 $groupticket =
GETPOST($htmlname,
'aZ09');
1145 $child_id =
GETPOST($htmlname.
'_child_id',
'aZ09') ?
GETPOST($htmlname.
'_child_id',
'aZ09') : 0;
1146 if (!empty($groupticket)) {
1147 $tmpgroupticket = $groupticket;
1148 $sql =
"SELECT ctc.rowid, ctc.fk_parent, ctc.code";
1149 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc WHERE ctc.code = '".$this->db->escape($tmpgroupticket).
"'";
1150 $resql = $this->db->query($sql);
1152 $obj = $this->db->fetch_object($resql);
1153 $selectedgroups[] = $obj->code;
1154 while ($obj->fk_parent > 0) {
1155 $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).
"'";
1156 $resql = $this->db->query($sql);
1158 $obj = $this->db->fetch_object($resql);
1159 $selectedgroups[] = $obj->code;
1165 $arrayidused = array();
1166 $arrayidusedconcat = array();
1167 $arraycodenotparent = array();
1168 $arraycodenotparent[] =
"";
1170 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
1171 $stringtoprint .=
'<select id="'.$htmlname.
'" class="minwidth500" child_id="0">';
1172 $stringtoprint .=
'<option value=""> </option>';
1174 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
1175 $sql .= $this->db->ifsql(
"ctc.rowid NOT IN (SELECT ctcfather.rowid FROM ".MAIN_DB_PREFIX.
"c_ticket_category as ctcfather JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as ctcjoin ON ctcfather.rowid = ctcjoin.fk_parent WHERE ctcjoin.active > 0)",
"'NOTPARENT'",
"'PARENT'").
" as isparent";
1176 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
1177 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int)
$conf->entity);
1178 $public = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
1180 $sql .=
" AND ctc.public = 1";
1182 $sql .=
" AND ctc.fk_parent = 0";
1183 $sql .= $this->db->order(
'ctc.pos',
'ASC');
1185 $resql = $this->db->query($sql);
1187 $num_rows_level0 = $this->db->num_rows($resql);
1189 while ($i < $num_rows_level0) {
1190 $obj = $this->db->fetch_object($resql);
1192 $label = ($obj->label !=
'-' ? $obj->label :
'');
1193 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code) {
1194 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1195 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1196 $label = $outputlangs->trans($obj->code);
1199 $grouprowid = $obj->rowid;
1200 $groupvalue = $obj->code;
1201 $grouplabel = $label;
1203 $isparent = $obj->isparent;
1204 if (is_array($selectedgroups)) {
1205 $iselected = in_array($obj->code, $selectedgroups) ?
'selected' :
'';
1207 $iselected = $groupticket == $obj->code ?
'selected' :
'';
1210 if ($isparent ==
'NOTPARENT') {
1211 $arraycodenotparent[] = $groupvalue;
1213 $arrayidused[] = $grouprowid;
1214 $arrayidusedconcat[] = $grouprowid;
1219 dol_print_error($this->db);
1221 if (count($arrayidused) == 1) {
1222 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
1224 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400" value="'.
GETPOST($htmlname).
'">';
1225 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400" '.
GETPOST($htmlname).
' value="'.
GETPOST($htmlname.
"_child_id").
'">';
1227 $stringtoprint .=
'</select> ';
1230 while ($levelid <= $use_multilevel) {
1231 $tabscript = array();
1232 $stringtoprint .=
'<select id="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
1233 $stringtoprint .=
'<option value=""> </option>';
1235 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
1236 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
1237 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
1238 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int)
$conf->entity);
1239 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(implode(
',', $arrayidusedconcat)).
")";
1241 $public = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
1243 $sql .=
" AND ctc.public = 1";
1246 if (!empty($arrayidused)) {
1247 $sql .=
" AND ctc.fk_parent IN ( ";
1248 foreach ($arrayidused as $idused) {
1249 $sql .= ((int) $idused).
", ";
1251 $sql = substr($sql, 0, -2);
1254 $sql .= $this->db->order(
'ctc.pos',
'ASC');
1256 $resql = $this->db->query($sql);
1258 $num_rows = $this->db->num_rows($resql);
1260 $arrayidused = array();
1261 while ($i < $num_rows) {
1262 $obj = $this->db->fetch_object($resql);
1264 $label = ($obj->label !=
'-' ? $obj->label :
'');
1265 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code) {
1266 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1267 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1268 $label = $outputlangs->trans($obj->code);
1271 $grouprowid = $obj->rowid;
1272 $groupvalue = $obj->code;
1273 $grouplabel = $label;
1274 $isparent = $obj->isparent;
1275 $fatherid = $obj->fk_parent;
1276 $arrayidused[] = $grouprowid;
1277 $arrayidusedconcat[] = $grouprowid;
1278 $groupcodefather = $obj->codefather;
1279 if ($isparent ==
'NOTPARENT') {
1280 $arraycodenotparent[] = $groupvalue;
1282 if (is_array($selectedgroups)) {
1283 $iselected = in_array($obj->code, $selectedgroups) ?
'selected' :
'';
1285 $iselected = $groupticket == $obj->code ?
'selected' :
'';
1288 if (empty($tabscript[$groupcodefather])) {
1289 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid - 1) :
'').
'").val() == \''.
dol_escape_js($groupcodefather).
'\'){
1290 $(
".'.$htmlname.'_'.dol_escape_htmltag($fatherid).'_child_'.$levelid.'").show()
1291 console.log(
"We show child tickets of '.$groupcodefather.' group ticket")
1293 $(
".'.$htmlname.'_'.dol_escape_htmltag($fatherid).'_child_'.$levelid.'").hide()
1294 console.log(
"We hide child tickets of '.$groupcodefather.' group ticket")
1301 dol_print_error($this->db);
1303 $stringtoprint .= '</select>
';
1305 $stringtoprint .= '<script nonce=
"'.getNonce().'">
';
1306 $stringtoprint .= 'arraynotparents =
'.json_encode($arraycodenotparent).';
'; // when the last visible combo list is number x, this is the array of group
1307 $stringtoprint .= 'if (arraynotparents.includes($(
"#'.$htmlname.($levelid > 1 ? '_child_'.($levelid - 1) : '').'").val())){
1308 console.log(
"'.$htmlname.'_child_'.$levelid.'")
1309 if($(
"#'.$htmlname.'_child_'.$levelid.'").val() ==
"" && ($(
"#'.$htmlname.'_child_'.$levelid.'").attr(
"child_id")>
'.$child_id.')){
1310 $(
"#'.$htmlname.'_child_'.$levelid.'").hide();
1311 console.log(
"We hide '.$htmlname.'_child_'.$levelid.' input")
1313 if(arraynotparents.includes(
"'.$groupticket.'") &&
'.$child_id.' == 0){
1314 $(
"#ticketcategory_select_child_id").val($(
"#'.$htmlname.'").attr(
"child_id"))
1315 $(
"#ticketcategory_select").val($(
"#'.$htmlname.'").val()) ;
1316 console.log(
"We choose '.$htmlname.' input and reload hidden input");
1319 $(
"#'.$htmlname.($levelid > 1 ? '_child_'.($levelid - 1) : '').'").change(
function() {
1320 child_id = $(
"#'.$htmlname.($levelid > 1 ? '_child_'.$levelid : '').'").attr(
"child_id");
1323 if (arraynotparents.includes($(
this).val()) || $(
this).attr(
"child_id") ==
'.$use_multilevel.') {
1324 $(
"#ticketcategory_select").val($(
this).val());
1325 $(
"#ticketcategory_select_child_id").val($(
this).attr(
"child_id")) ;
1326 console.log(
"We choose to select "+ $(
this).val());
1328 if ($(
"#'.$htmlname.'_child_'.$levelid.' option").length <= 1) {
1329 $(
"#ticketcategory_select").val($(
this).val());
1330 $(
"#ticketcategory_select_child_id").val($(
this).attr(
"child_id"));
1331 console.log(
"We choose to select "+ $(
this).val() +
" and next combo has no item, so we keep this selection");
1333 console.log(
"We choose to select "+ $(
this).val() +
" but next combo has some item, so we clean selected item");
1334 $(
"#ticketcategory_select").val(
"");
1335 $(
"#ticketcategory_select_child_id").val(
"");
1339 console.log(
"We select a new value into combo child_id="+child_id);
1342 $(
".groupticketchild").each(
function(){
1343 if ($(
this).attr(
"child_id") > child_id) {
1344 console.log(
"hide child_id="+$(
this).attr(
"child_id"));
1351 $(
"#'.$htmlname.'_child_'.$levelid.'").val(
"");
1352 if (!arraynotparents.includes($(
this).val()) && $(
"#'.$htmlname.'_child_'.$levelid.' option").length > 1) {
1353 console.log($(
"#'.$htmlname.'_child_'.$levelid.' option").length);
1354 $(
"#'.$htmlname.'_child_'.$levelid.'").show()
1356 $(
"#'.$htmlname.'_child_'.$levelid.'").hide()
1360 foreach ($tabscript as $script) {
1361 $stringtoprint .= $script;
1363 $stringtoprint .= '})
';
1364 $stringtoprint .= '</script>
';
1366 $stringtoprint .= '<script nonce=
"'.getNonce().'">
';
1367 $stringtoprint .= '$(
"#'.$htmlname.'_child_'.$use_multilevel.'").change(
function() {
1368 $(
"#ticketcategory_select").val($(
this).val());
1369 $(
"#ticketcategory_select_child_id").val($(
this).attr(
"child_id"));
1370 tmpvalselect = $(
"#ticketcategory_select").val();
1371 if(tmpvalselect ==
"" && $(
"#ticketcategory_select_child_id").val() >= 1){
1372 $(
"#ticketcategory_select_child_id").val($(
this).attr(
"child_id")-1);
1374 console.log($(
"#ticketcategory_select").val());
1376 $stringtoprint .= '</script>
';
1377 $stringtoprint .= ajax_combobox($htmlname);
1379 return $stringtoprint;
1396 public function selectSeveritiesTickets($selected = '
', $htmlname = 'ticketseverity
', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '')
1398 global $conf, $langs, $user;
1400 $ticketstat = new Ticket($this->db);
1402 dol_syslog(get_class($this)."::selectSeveritiesTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
1404 $filterarray = array();
1406 if ($filtertype != '' && $filtertype != '-1
') {
1407 $filterarray = explode(',
', $filtertype);
1410 $ticketstat->loadCacheSeveritiesTickets();
1412 print '<select
id=
"select'.$htmlname.'" class=
"flat minwidth100'.($morecss ? ' '.$morecss : '').'" name=
"'.$htmlname.'">
';
1414 print '<option value=
"">
'.((is_numeric($empty) || $empty == 'ifone
') ? '
' : $empty).'</option>
';
1417 $severitytickets = $conf->cache['severity_tickets
'];
1418 '@phan-var-force array<int,array{code:string,label:string,use_default:int,pos:
int}> $severitytickets
';
1419 if (is_array($severitytickets) && count($severitytickets)) {
1420 foreach ($severitytickets as $id => $arrayseverities) {
1421 // Skip if filtering on specific payment modes was requested
1422 if (count($filterarray) && !in_array($arrayseverities['code
'], $filterarray)) {
1426 // We discard empty line if showempty is on because an empty line has already been output.
1427 if ($empty && empty($arrayseverities['code
'])) {
1432 print '<option value=
"'.$id.'"';
1436 print '<option value=
"'.$arrayseverities['code'].'"';
1440 print '<option value=
"'.$arrayseverities['code'].'"';
1444 print '<option value=
"'.$id.'"';
1447 // If text is selected, we compare with code, otherwise with id
1448 if (isset($selected) && preg_match('/[a-z]/i
', $selected) && $selected == $arrayseverities['code
']) {
1449 print ' selected=
"selected"';
1450 } elseif (isset($selected) && $selected == $id) {
1451 print ' selected=
"selected"';
1452 } elseif ($arrayseverities['use_default
'] == "1" && empty($selected) && (!$empty || $empty == 'ifone
')) {
1453 print ' selected=
"selected"';
1454 } elseif (count($severitytickets) == 1 && (!$empty || $empty == 'ifone
')) { // If only 1 choice, we autoselect it
1455 print ' selected=
"selected"';
1462 $value = ($maxlength ? dol_trunc($arrayseverities['label
'], $maxlength) : $arrayseverities['label
']);
1466 $value = $arrayseverities['code
'];
1470 $value = ($maxlength ? dol_trunc($arrayseverities['label
'], $maxlength) : $arrayseverities['label
']);
1474 $value = $arrayseverities['code
'];
1477 print $value ? $value : '
';
1482 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1483 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1486 print ajax_combobox('select
'.$htmlname);
1489 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1495 public function clear_attached_files()
1498 global $conf, $user;
1499 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php
';
1501 // Set tmp user directory
1502 $vardir = $conf->user->dir_output."/".$user->id;
1503 $upload_dir = $vardir.'/temp/
'; // TODO Add $keytoavoidconflict in upload_dir path
1504 if (is_dir($upload_dir)) {
1505 dol_delete_dir_recursive($upload_dir);
1508 if (!empty($this->trackid)) { // TODO Always use trackid (ticXXX) instead of track_id (abcd123)
1509 $keytoavoidconflict = '-
'.$this->trackid;
1511 $keytoavoidconflict = empty($this->track_id) ? '' : '-
'.$this->track_id;
1513 unset($_SESSION["listofpaths".$keytoavoidconflict]);
1514 unset($_SESSION["listofnames".$keytoavoidconflict]);
1515 unset($_SESSION["listofmimes".$keytoavoidconflict]);
1525 public function showMessageForm($width = '40%
', $fromPublicInterface = 0)
1527 global $conf, $langs, $user, $hookmanager, $form;
1529 $formmail = new FormMail($this->db);
1530 $addfileaction = 'addfile
';
1532 if (!is_object($form)) {
1533 $form = new Form($this->db);
1536 // Load translation files required by the page
1537 $langs->loadLangs(array('other
', 'mails
', 'ticket
'));
1539 // Clear temp files. Must be done at beginning, before call of triggers
1540 if (GETPOST('mode
', 'alpha
') == 'init
' || (GETPOST('modelselected
') && GETPOST('modelmailselected
', 'alpha
') && GETPOST('modelmailselected
', 'alpha
') != '-1
')) {
1541 $this->clear_attached_files();
1544 // Define output language
1545 $outputlangs = $langs;
1547 if (getDolGlobalInt('MAIN_MULTILANGS
') && isset($this->param['langsmodels
'])) {
1548 $newlang = $this->param['langsmodels
'];
1550 if (!empty($newlang)) {
1551 $outputlangs = new Translate("", $conf);
1552 $outputlangs->setDefaultLang($newlang);
1553 $outputlangs->load('other
');
1556 // Get message template for $this->param["models"] into c_email_templates
1557 $arraydefaultmessage = -1;
1558 if (isset($this->param['models
']) && $this->param['models
'] != 'none
') {
1560 if (array_key_exists('models_id
', $this->param)) {
1561 $model_id = (int) $this->param["models_id"];
1564 // If $model_id is empty, preselect the first one
1565 $usedefault = ($model_id ? -1 : 1);
1566 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id, 1, '', $usedefault);
1567 if (isset($arraydefaultmessage->id) && empty($model_id)) {
1568 $model_id = $arraydefaultmessage->id;
1569 $this->param['models_id
'] = $model_id;
1573 // Define list of attached files
1574 $listofpaths = array();
1575 $listofnames = array();
1576 $listofmimes = array();
1578 if (!empty($this->trackid)) {
1579 $keytoavoidconflict = '-
'.$this->trackid;
1581 $keytoavoidconflict = empty($this->track_id) ? '' : '-
'.$this->track_id; // track_id instead of trackid
1583 //var_dump($keytoavoidconflict);
1584 if (GETPOST('mode
', 'alpha
') == 'init
' || (GETPOST('modelselected
') && GETPOST('modelmailselected
', 'alpha
') && GETPOST('modelmailselected
', 'alpha
') != '-1
')) {
1585 if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param['fileinit
']) && is_array($this->param['fileinit
'])) {
1586 foreach ($this->param['fileinit
'] as $path) {
1587 $formmail->add_attached_files($path, basename($path), dol_mimetype($path));
1591 //var_dump($_SESSION);
1592 //var_dump($_SESSION["listofpaths".$keytoavoidconflict]);
1593 if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
1594 $listofpaths = explode(';
', $_SESSION["listofpaths".$keytoavoidconflict]);
1596 if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
1597 $listofnames = explode(';
', $_SESSION["listofnames".$keytoavoidconflict]);
1599 if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
1600 $listofmimes = explode(';
', $_SESSION["listofmimes".$keytoavoidconflict]);
1603 // Define output language
1604 $outputlangs = $langs;
1606 if (getDolGlobalInt('MAIN_MULTILANGS
') && isset($this->param['langsmodels
'])) {
1607 $newlang = $this->param['langsmodels
'];
1609 if (!empty($newlang)) {
1610 $outputlangs = new Translate("", $conf);
1611 $outputlangs->setDefaultLang($newlang);
1612 $outputlangs->load('other
');
1615 print "\n<!-- Begin message_form TICKET -->\n";
1617 $send_email = GETPOSTINT('send_email
') ? GETPOSTINT('send_email
') : 0;
1619 // Example 1 : Adding jquery code
1620 print '<script nonce=
"'.getNonce().'" type=
"text/javascript">
1621 jQuery(document).ready(
function() {
1622 send_email=
'.((int) $send_email).';
1624 if (!jQuery(
"#send_msg_email").is(
":checked")) {
1625 jQuery(
"#send_msg_email").prop(
"checked",
true).trigger(
"change");
1627 jQuery(
".email_line").show();
1628 jQuery(
".not_email_line").hide();
1630 if (!jQuery(
"#private_message").is(
":checked")) {
1631 jQuery(
"#private_message").prop(
"checked",
true).trigger(
"change");
1633 jQuery(
".email_line").hide();
1634 jQuery(
".not_email_line").show();
1638 // If constant set, allow to send private messages as email
1639 if (!getDolGlobalString('TICKET_SEND_PRIVATE_EMAIL
')) {
1640 print 'jQuery(
"#send_msg_email").click(
function() {
1641 console.log(
"Click send_msg_email");
1642 if(jQuery(
this).is(
":checked")) {
1643 if (jQuery(
"#private_message").is(
":checked")) {
1644 jQuery(
"#private_message").prop(
"checked",
false).trigger(
"change");
1646 jQuery(
".email_line").show();
1647 jQuery(
".not_email_line").hide();
1650 jQuery(
".email_line").hide();
1651 jQuery(
".not_email_line").show();
1655 jQuery(
"#private_message").click(
function() {
1656 console.log(
"Click private_message");
1657 if (jQuery(
this).is(
":checked")) {
1658 if (jQuery(
"#send_msg_email").is(
":checked")) {
1659 jQuery(
"#send_msg_email").prop(
"checked",
false).trigger(
"change");
1661 jQuery(
".email_line").hide();
1662 jQuery(
".not_email_line").show();
1670 print '<form method=
"post" name=
"ticket" id=
"ticket" enctype=
"multipart/form-data" action=
"'.$this->param["returnurl
"].'">
';
1671 print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
1672 print '<input
type=
"hidden" name=
"action" value=
"'.$this->action.'">
';
1673 print '<input
type=
"hidden" name=
"actionbis" value=
"add_message">
';
1674 print '<input
type=
"hidden" name=
"backtopage" value=
"'.$this->backtopage.'">
';
1675 if (!empty($this->trackid)) {
1676 print '<input
type=
"hidden" name=
"trackid" value=
"'.$this->trackid.'">
';
1678 print '<input
type=
"hidden" name=
"trackid" value=
"'.(empty($this->track_id) ? '' : $this->track_id).'">
';
1679 $keytoavoidconflict = empty($this->track_id) ? '' : '-
'.$this->track_id; // track_id instead of trackid
1681 foreach ($this->param as $key => $value) {
1682 print '<input
type=
"hidden" name=
"'.$key.'" value=
"'.$value.'">
';
1685 // Get message template
1687 if (array_key_exists('models_id
', $this->param)) {
1688 $model_id = $this->param["models_id"];
1689 $usedefault = ($model_id ? -1 : 1);
1690 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id, 1, '', $usedefault);
1693 $result = $formmail->fetchAllEMailTemplate(!empty($this->param["models"]) ? $this->param["models"] : "", $user, $outputlangs);
1695 setEventMessages($this->error, $this->errors, 'errors
');
1697 $modelmail_array = array();
1698 foreach ($formmail->lines_model as $line) {
1699 $modelmail_array[$line->id] = $line->label;
1702 $ticketstat = new Ticket($this->db);
1703 $res = $ticketstat->fetch(0, '', $this->track_id);
1705 print '<
table class=
"border" width=
"'.$width.'">
';
1707 // External users can't send message
email
1708 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1709 print
'<tr><td class="width200"></td><td>';
1710 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : (
getDolGlobalInt(
'TICKETS_MESSAGE_FORCE_MAIL') ?
'checked' :
''));
1711 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1712 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1713 $texttooltip = $langs->trans(
"TicketMessageSendEmailHelp");
1715 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2b");
1717 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2a",
'{s1}');
1719 $texttooltip = str_replace(
'{s1}', $langs->trans(
'MarkMessageAsPrivate'), $texttooltip);
1720 print
' '.$form->textwithpicto(
'', $texttooltip, 1,
'help');
1723 if (count($modelmail_array) > 0) {
1724 print
' <span class="email_line">';
1725 print $formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], $langs->trans(
'SelectMailModel'), 0, 0,
"", 0, 0, 0,
'',
'minwidth200');
1727 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv(
"Tools").
' - '.$langs->transnoentitiesnoconv(
"EMailTemplates")), 1);
1730 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1737 if (!$user->socid) {
1738 print
'<tr><td></td><td>';
1739 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1740 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1741 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1742 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1763 print
'<tr class="email_line"><td class="width200"><span class="">'.$langs->trans(
"MailFrom");
1765 print
' <span class="opacitymedium">('.$langs->trans(
"MailReply").
')</span>';
1767 print
'</span></td>';
1768 print
'<td><span class="">'.img_picto(
'',
'email',
'class="pictofixedwidth"').$from;
1770 print
' <span class="opacitymedium">('.$replyto.
')</span>';
1772 print
'</span></td></tr>';
1775 $parameters = array();
1777 $reshook = $hookmanager->executeHooks(
'printFieldTicketEmailTo', $parameters, $this, $action);
1778 if (empty($reshook)) {
1779 print
'<tr class="email_line"><td class="fieldrequired">'.$langs->trans(
'MailRecipients');
1780 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients"), 1,
'help');
1785 print
'<input class="minwidth200" id="sendto" name="sendto" spellcheck="false" placeholder="email@domain.com" value="'.dol_escape_htmltag($sendto_free).
'" />';
1788 $contacts = $ticketstat->getInfosTicketInternalContact(1);
1789 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact(1));
1790 $seen_emails = array();
1792 if (is_array($contacts) && count($contacts) > 0) {
1793 foreach ($contacts as $info_sendto) {
1794 if ($info_sendto[
'email'] !=
'') {
1795 $email_lc = strtolower($info_sendto[
'email']);
1796 if (!in_array($email_lc, $seen_emails)) {
1797 $label_text = trim($info_sendto[
'firstname'].
' '.$info_sendto[
'lastname']).
' <'.$info_sendto[
'email'].
'>';
1798 $label_html =
dol_htmlentities(trim($info_sendto[
'firstname'].
' '.$info_sendto[
'lastname']), ENT_QUOTES,
'UTF-8')
1799 .
' <span class="opacitymedium">('.
dol_htmlentities($info_sendto[
'libelle'], ENT_QUOTES,
'UTF-8').
')</span>';
1800 $withto[$info_sendto[
'email']] = array(
1801 'id' => $info_sendto[
'email'],
1802 'label' => str_replace(array(
'<',
'>'), array(
'(',
')'), $label_text),
1803 'labelhtml' => $label_html,
1805 $seen_emails[] = $email_lc;
1811 if (!empty($ticketstat->origin_replyto) && !in_array(strtolower($ticketstat->origin_replyto), $seen_emails)) {
1812 $email = (string) $ticketstat->origin_replyto;
1813 $withto[$email] = array(
1816 'labelhtml' =>
dol_escape_htmltag($email).
' <span class="opacitymedium">('.$langs->trans(
'TicketEmailOriginIssuer').
')</span>',
1818 $seen_emails[] = strtolower($email);
1819 } elseif ($ticketstat->origin_email && !in_array(strtolower((
string) $ticketstat->origin_email), $seen_emails)) {
1820 $email = (string) $ticketstat->origin_email;
1821 $withto[$email] = array(
1824 'labelhtml' =>
dol_escape_htmltag($email).
' <span class="opacitymedium">('.$langs->trans(
'TicketEmailOriginIssuer').
')</span>',
1826 $seen_emails[] = strtolower($email);
1829 if ($ticketstat->fk_soc > 0) {
1830 $ticketstat->socid = $ticketstat->fk_soc;
1831 $ticketstat->fetch_thirdparty();
1832 if (!empty($ticketstat->thirdparty->email) && !in_array(strtolower((
string) $ticketstat->thirdparty->email), $seen_emails)) {
1833 $email = (string) $ticketstat->thirdparty->email;
1834 $withto[$email] = array(
1837 'labelhtml' =>
dol_escape_htmltag($email).
' <span class="opacitymedium">('.$langs->trans(
'Customer').
')</span>',
1839 $seen_emails[] = strtolower($email);
1845 if (!in_array(strtolower($generic_email), $seen_emails)) {
1846 $withto[$generic_email] = array(
1847 'id' => $generic_email,
1848 'label' => $generic_email,
1849 'labelhtml' =>
dol_escape_htmltag($generic_email).
' <span class="opacitymedium">(generic)</span>',
1856 $withtoselected =
GETPOST(
'receiver',
'array');
1858 $withtoselected = array_keys($withto);
1861 if (!empty($withto)) {
1862 print
' <span class="opacitymedium">'.$langs->trans(
"and").
'/'.$langs->trans(
"or").
'</span> ';
1863 print $form->multiselectarray(
'receiver', $withto, $withtoselected, 0, 0,
'inline-block minwidth500', 0, 0,
'',
'',
'', 1);
1866 print
'<input type="hidden" name="receiver_multiselect" value="1">';
1867 print
' <span class="opacitymedium"><small>'.$langs->trans(
'WarningNoEMailsAdded').
'</small></span>';
1872 print
'<tr class="email_line"><td>';
1873 print $form->textwithpicto($langs->trans(
"MailCC"), $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients"), 1,
'help');
1878 $sendtocc_free =
GETPOST(
'sendtocc',
'alphawithlgt');
1882 print
'<input class="minwidth200" id="sendtocc" name="sendtocc" spellcheck="false" value="'.dol_escape_htmltag($sendtocc_free).
'" />';
1885 if (!empty($withto)) {
1886 print
' <span class="opacitymedium">'.$langs->trans(
"and").
'/'.$langs->trans(
"or").
'</span> ';
1887 $withtocc_selected =
GETPOSTISSET(
'receivercc_multiselect') ?
GETPOST(
'receivercc',
'array') : array();
1888 print $form->multiselectarray(
'receivercc', $withto, $withtocc_selected, 0, 0,
'inline-block minwidth500', 0, 0,
'',
'',
'', 1);
1891 print
'<input type="hidden" name="receivercc_multiselect" value="1">';
1895 print $hookmanager->resPrint;
1899 $uselocalbrowser =
false;
1902 if ($this->withtitletopic) {
1903 print
'<tr class="not_email_line"><td><label for="summary"><span>'.$langs->trans(
"Summary").
'</span></label></td><td>';
1905 if ($this->withtopicreadonly && $this->topic_title) {
1906 print $langs->trans(
'Summary').
' '.$this->topic_title;
1907 } elseif (empty($this->withtopicreadonly)) {
1908 $subject = $this->topic_title;
1909 print
'<input class="text minwidth500" maxlength="42" id="summary" name="summary" placeholder="" value="'.dolPrintHTMLForAttribute($subject).
'"'.(empty($this->withemail) ?
' autofocus' :
'').
' />';
1915 foreach ($formmail->lines_model as $line) {
1916 if (!empty($this->substit) && $this->param[
'models_id'] == $line->id) {
1921 print
'<tr class="email_line"><td class="fieldrequired">'.$langs->trans(
'MailTopic').
'</td>';
1922 if (empty($topic)) {
1923 print
'<td><input type="text" class="text minwidth500" name="subject" value="['.getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
' - '.$langs->trans(
"Ticket").
' '.$ticketstat->ref.
'] '. $ticketstat->subject .
'" spellcheck="false">';
1925 print
'<td><input type="text" class="text minwidth500" name="subject" value="'.make_substitutions($topic, $this->substit).
'" spellcheck="false">';
1930 if (!empty($this->withfile)) {
1932 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
1935 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1936 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
1937 $out .=
'jQuery(document).ready(function () {';
1938 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1939 $out .=
' jQuery("#addedfile").on("change", function() {';
1940 $out .=
' if (jQuery(this).val().length) {';
1941 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", false);';
1942 $out .=
' } else {';
1943 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1946 $out .=
' jQuery(".removedfile").click(function() {';
1947 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1950 $out .=
'</script>'.
"\n";
1952 if (count($listofpaths)) {
1953 foreach ($listofpaths as $key => $val) {
1954 $out .=
'<div id="attachfile_'.$key.
'">';
1955 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1956 if (!$this->withfilereadonly) {
1957 $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.
'" />';
1959 $out .=
'<br></div>';
1964 if ($this->withfile == 2) {
1965 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1967 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1969 $out .=
"</td></tr>\n";
1975 $defaultmessage =
"";
1976 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1977 $defaultmessage = (string) $arraydefaultmessage->content;
1979 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1983 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1984 } elseif (!
dol_textishtml($defaultmessage) && isset($this->substit[
'__USER_SIGNATURE__']) &&
dol_textishtml($this->substit[
'__USER_SIGNATURE__'])) {
1985 $defaultmessage =
dol_nl2br($defaultmessage);
1988 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1992 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1993 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1997 $ckeditorenabledforticket = (
getDolGlobalString(
'FCKEDITOR_ENABLE_TICKET') >= ($fromPublicInterface ? 2 : 1))
2000 print
'<!-- Message line from showMessageForm -->';
2001 print
'<tr><td class="tdtop"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
2002 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
2003 $texttooltip = $langs->trans(
"TicketMessageHelp");
2005 $texttooltip .=
'<br><br>'.$langs->trans(
"ForEmailMessageWillBeCompletedWith").
'...';
2007 $allowedmailtags = array(
'a',
'div',
'strong',
'em',
'i',
'u',
'p',
'ul',
'ol',
'li',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'img');
2010 print
'<input type="hidden" name="mail_intro" value="'.dolPrintHTMLForAttribute($mail_intro, 0, $allowedmailtags).
'">';
2011 $texttooltip .=
'<br><u>'.$langs->trans(
"TicketMessageMailIntro").
'</u><br>'.$mail_intro;
2015 print
'<input type="hidden" name="mail_signature" value="'.dolPrintHTMLForAttribute($mail_signature, 0, $allowedmailtags).
'">';
2016 $texttooltip .=
'<br><br><u>'.$langs->trans(
"TicketMessageMailFooter").
'</u><br>'.$mail_signature;
2018 print $form->textwithpicto(
'', $texttooltip, 1,
'help');
2020 print
'</label></td>';
2021 $out =
'<td class="tdtop">';
2023 $out .=
'<div class="div-layoutai">';
2026 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
2027 $formmail =
new FormMail($this->db);
2029 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formai.class.php';
2030 $formai =
new FormAI($this->db);
2032 $formmail->withfckeditor = $ckeditorenabledforticket ? 1 : 0;
2033 $formmail->withlayout = ((string) $ckeditorenabledforticket && !$fromPublicInterface) ?
'email' :
'';
2034 $formmail->withaiprompt = (
isModEnabled(
'ai') && !$fromPublicInterface) ?
'text' :
'';
2036 $showlinktolayout = ($formmail->withfckeditor &&
getDolGlobalInt(
'MAIN_EMAIL_USE_LAYOUT')) ? $formmail->withlayout :
'';
2037 $showlinktolayoutlabel = $langs->trans(
"FillMessageWithALayout");
2038 $showlinktoai = ($formmail->withaiprompt ?
'textgenerationemail' :
'');
2039 $showlinktoailabel = $langs->trans(
"AIEnhancements");
2040 $formatforouput =
'';
2041 $htmlname =
'message';
2043 $formai->substit = $this->substit;
2047 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
2055 print
'<tr><td colspan="2">';
2057 $toolbarname =
'dolibarr_notes';
2058 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2059 $uselocalbrowser =
false;
2060 if (!$ckeditorenabledforticket) {
2064 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser, $ckeditorenabledforticket, ROWS_6,
'90%');
2065 $doleditor->Create();
2085 print
'<br><center>';
2086 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"Add").
'"';
2088 if ($this->withfile == 2 && !empty(
$conf->use_javascript_ajax)) {
2089 print
' onClick="if (document.ticket.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans(
"FileWasNotUploaded")).
'\');
return false; }
else {
return true; }
"';
2092 if (!empty($this->withcancel)) {
2093 print "
";
2094 print '<input class="button button-cancel
" type="submit
" name="cancel
" value="'.$langs->trans("Cancel").'">';
2096 print "</center>\n
";
2098 print '<input type="hidden
" name="page_y
">'."\n
";
2100 print "</form><br>\n
";
2102 // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
2103 if (getDolGlobalString('MAIN_MAILFORM_DISABLE_ENTERKEY')) {
2104 print '<script type="text/javascript
">';
2105 print 'jQuery(document).ready(function () {';
2106 print ' $(document).on("keypress
", \'#ticket\', function (e) { /* Note this is called at every key pressed ! */
2107 var code = e.keyCode || e.which;
2109 console.log("Enter was intercepted and blocked
");
2118 print "<!-- End message_form TICKET -->\n
";
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
Class to manage a WYSIWYG editor.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
treeview li table
No Email.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Class to generate the form for creating a new ticket.
$conf db name
Only used if Module[ID]Name translation string is not found.
getMaxFileSizeArray()
Return the max allowed for file upload.
if(empty( $takeposterminal)) fail($message)
Abort invoice creation with a given error message.