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') {
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>';
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>';
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>';
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",
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>");
441 if (isset($this->param[
'origin']) && $this->param[
'originid'] > 0) {
443 $element = $subelement = $this->param[
'origin'];
445 if (preg_match(
'/^([^_]+)_([^_]+)/i', $this->param[
'origin'], $regs)) {
447 $subelement = $regs[2];
451 $classname = ucfirst($subelement);
452 $objectsrc =
new $classname($this->db);
453 '@phan-var-force CommonObject $objectsrc';
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');
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');
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><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span></label></td><td>';
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));
573 if (!$ckeditorenabledforticket) {
576 $doleditor =
new DolEditor(
'message', $msg,
'100%', 230, $toolbarname,
'In',
true, $uselocalbrowser, $ckeditorenabledforticket, ROWS_8,
'90%');
577 $doleditor->Create();
583 print
'<tr><td class="wordbreak">'.$langs->trans(
"Categories").
'</td><td>';
584 print $form->selectCategories(Categorie::TYPE_TICKET,
'categories',
$object);
589 if (!empty($this->withfile)) {
591 $listofpaths = array();
592 $listofnames = array();
593 $listofmimes = array();
594 if (!empty($_SESSION[
"listofpaths"])) {
595 $listofpaths = explode(
';', $_SESSION[
"listofpaths"]);
598 if (!empty($_SESSION[
"listofnames"])) {
599 $listofnames = explode(
';', $_SESSION[
"listofnames"]);
602 if (!empty($_SESSION[
"listofmimes"])) {
603 $listofmimes = explode(
';', $_SESSION[
"listofmimes"]);
608 $out .= $langs->trans(
"LinkedFiles");
612 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
613 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
614 $out .=
'jQuery(document).ready(function () {';
615 $out .=
' jQuery(".removedfile").click(function() {';
616 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
619 $out .=
'</script>'.
"\n";
620 if (count($listofpaths)) {
621 foreach ($listofpaths as $key => $val) {
622 $out .=
'<div id="attachfile_'.$key.
'">';
623 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
624 if (!$this->withfilereadonly) {
625 $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.
'" />';
627 $out .=
'<br></div>';
630 if ($this->withfile == 2) {
632 $maxmin = $maxfilesizearray[
'maxmin'];
634 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
636 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
638 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="addfile" name="addfile" value="'.$langs->trans(
"MailingAddFile").
'" />';
640 $out .=
"</td></tr>\n";
643 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">
644 jQuery(document).ready(function () {
645 jQuery("#addedfile").on("change", function() {
646 // Dispara el clic automáticamente al seleccionar archivo
647 jQuery("#addfile").click();
649 // Oculta el botón redundante si JS está activo
650 jQuery("#addfile").hide();
658 if ($this->withusercreate > 0 && $this->fk_user_create) {
659 print
'<tr><td class="titlefield">'.$langs->trans(
"CreatedBy").
'</td><td>';
660 $langs->load(
"users");
661 $fuser =
new User($this->db);
663 if ($this->withcreatereadonly) {
664 if ($res = $fuser->fetch($this->fk_user_create)) {
665 print $fuser->getNomUrl(1);
669 print
"</td></tr>\n";
673 if ($this->withcompany) {
675 if (empty($user->socid)) {
677 print
'<tr><td class="titlefield">'.$langs->trans(
"ThirdParty").
'</td><td>';
679 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
680 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
681 print $form->select_company($this->withfromsocid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth200');
685 print
'<script nonce="'.getNonce().
'" type="text/javascript">
686 $(document).ready(function () {
687 jQuery("#'.$htmlname.
'").change(function () {
688 var obj = '.json_encode($events).
';
689 $.each(obj, function(key,values) {
690 if (values.method.length) {
691 runJsCodeForEvent'.$htmlname.
'(values);
696 function runJsCodeForEvent'.$htmlname.
'(obj) {
697 console.log("Run runJsCodeForEvent'.$htmlname.
'");
698 var id = $("#'.$htmlname.
'").val();
699 var method = obj.method;
701 var htmlname = obj.htmlname;
702 var showempty = obj.showempty;
711 $.each(obj.params, function(key,action) {
713 var num = response.num;
715 $("#" + key).removeAttr(action);
717 $("#" + key).attr(action, action);
721 $("select#" + htmlname).html(response.value);
723 var selecthtml_str = response.value;
724 var selecthtml_dom=$.parseHTML(selecthtml_str);
725 if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
726 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
729 $("#inputautocomplete"+htmlname).val("");
731 $("select#" + htmlname).change(); /* Trigger event change */
738 if ($mode ==
'create') {
740 print
'<tr><td>'.$langs->trans(
"Contact").
'</td><td>';
742 $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
743 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
745 print $form->select_contact($selectedCompany, $this->withfromcontactid,
'contactid', 3,
'',
'', 1,
'maxwidth300 widthcentpercentminusx',
true);
748 $formcompany->selectTypeContact($ticketstatic,
'',
'type',
'external',
'', 0,
'maginleftonly maxwidth200');
752 print
'<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.
'"/></td>';
753 print
'<td><input type="hidden" name="contactid" value="'.$user->contact_id.
'"/></td>';
754 print
'<td><input type="hidden" name="type" value="Z"/></td></tr>';
758 if (empty($this->ispublic) && ($action ==
'create' || $action ==
'presend')) {
759 print
'<tr><td><label for="notify_tiers_at_create">'.$langs->trans(
"TicketNotifyTiersAtCreation").
'</label></td><td>';
760 print
'<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ?
' checked="checked"' :
'').
'>';
766 print $langs->trans(
"AssignedTo");
768 if ($permissiontomanage) {
769 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
770 print $form->select_dolusers($user_assign,
'fk_user_assign', 1);
772 $userstat =
new User($this->db);
773 $userstat->fetch($user_assign);
774 print $userstat->getNomUrl(-1);
780 if ($subelement !=
'project') {
783 print
'<tr><td><label for="project"><span class="">'.$langs->trans(
"Project").
'</span></label></td><td>';
784 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects(-1, $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
789 if ($subelement !=
'contract' && $subelement !=
'contrat') {
796 $langs->load(
'contracts');
798 print
'<tr><td><label for="contract"><span class="">'.$langs->trans(
"Contract").
'</span></label></td><td>';
799 print
img_picto(
'',
'contract',
'class="pictofixedwidth"');
801 print $formcontract->select_contract($user->socid ?? -1,
GETPOSTINT(
'contractid'),
'contractid', 0, 1, 1, 1);
809 $parameters = array();
810 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $ticketstat, $action);
811 if (empty($reshook)) {
812 if ($mode ==
'create') {
813 print
$object->showOptionals($extrafields,
'create');
815 print
$object->showOptionals($extrafields,
'edit');
822 print
'<tr><td class="titlefield"></td><td><br>';
824 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
828 $dirModCaptcha = array_merge(array(
'main' =>
'/core/modules/security/captcha/'), is_array(
$conf->modules_parts[
'captcha']) ?
$conf->modules_parts[
'captcha'] : array());
830 $fullpathclassfile =
'';
831 foreach ($dirModCaptcha as $dir) {
832 $fullpathclassfile =
dol_buildpath($dir.
"modCaptcha".ucfirst($captcha).
'.class.php', 0, 2);
833 if ($fullpathclassfile) {
838 if ($fullpathclassfile) {
839 include_once $fullpathclassfile;
843 $classname =
"modCaptcha".ucfirst($captcha);
844 if (class_exists($classname)) {
846 $captchaobj =
new $classname($this->db,
$conf, $langs, $user);
847 '@phan-var-force ModeleCaptcha $captchaobj';
849 if (is_object($captchaobj) && method_exists($captchaobj,
'getCaptchaCodeForForm')) {
850 print $captchaobj->getCaptchaCodeForForm(
'');
852 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method getCaptchaCodeForForm()';
855 print
'Error, the captcha handler class '.$classname.
' was not found after the include';
858 print
'Error, the captcha handler '.$captcha.
' has no class file found modCaptcha'.ucfirst($captcha);
861 print
'<br></td></tr>';
866 if ($withdolfichehead) {
872 if ($mode ==
'create') {
873 print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"CreateTicket"), ($this->withcancel ?
"Cancel" :
""));
875 print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"Save"), ($this->withcancel ?
"Cancel" :
""));
890 print
'<input type="hidden" name="page_y">'.
"\n";
893 print
"<!-- End form TICKET -->\n";
911 public function selectTypesTickets($selected =
'', $htmlname =
'tickettype', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $multiselect = 0, $disabledefault = 0)
913 global $langs, $user;
915 $selected = is_array($selected) ? $selected : (!empty($selected) ? explode(
',', $selected) : array());
916 $ticketstat =
new Ticket($this->db);
918 dol_syslog(get_class($this) .
"::select_types_tickets " . implode(
';', $selected) .
", " . $htmlname .
", " . $filtertype .
", " . $format .
", " . $multiselect, LOG_DEBUG);
920 $filterarray = array();
922 if ($filtertype !=
'' && $filtertype !=
'-1') {
923 $filterarray = explode(
',', $filtertype);
926 $ticketstat->loadCacheTypesTickets();
928 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.($multiselect ?
'[]' :
'').
'"'.($multiselect ?
' multiple' :
'').
'>';
929 if ($empty && !$multiselect) {
930 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
933 if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
934 foreach ($ticketstat->cache_types_tickets as
$id => $arraytypes) {
936 if (count($filterarray) && !in_array($arraytypes[
'code'], $filterarray)) {
941 if ($empty && empty($arraytypes[
'code'])) {
946 print
'<option value="'.$id.
'"';
950 print
'<option value="'.$arraytypes[
'code'].
'"';
954 print
'<option value="'.$arraytypes[
'code'].
'"';
958 print
'<option value="'.$id.
'"';
962 if (in_array($arraytypes[
'code'], $selected)) {
963 print
' selected="selected"';
964 } elseif (in_array(
$id, $selected)) {
965 print
' selected="selected"';
966 } elseif ($arraytypes[
'use_default'] ==
"1" && empty($disabledefault) && empty($selected) && !$multiselect) {
967 print
' selected="selected"';
968 } elseif (count($ticketstat->cache_types_tickets) == 1 && (!$empty || $empty ==
'ifone')) {
969 print
' selected="selected"';
976 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
977 } elseif ($format == 1) {
978 $value = $arraytypes[
'code'];
979 } elseif ($format == 2) {
980 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
981 } elseif ($format == 3) {
982 $value = $arraytypes[
'code'];
985 print $value ? $value :
' ';
990 if (isset($user->admin) && $user->admin && !$noadmininfo) {
991 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1012 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs =
null)
1014 global
$conf, $langs, $user;
1016 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1018 if (is_null($outputlangs) || !is_object($outputlangs)) {
1019 $outputlangs = $langs;
1021 $outputlangs->load(
"ticket");
1023 $publicgroups = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
1025 $ticketstat =
new Ticket($this->db);
1026 $ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1);
1028 if ($use_multilevel <= 0) {
1029 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1031 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
1034 $categorytickets =
$conf->cache[
'category_tickets'];
1035 '@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';
1036 if (is_array($categorytickets) && count($categorytickets)) {
1037 foreach ($categorytickets as
$id => $arraycategories) {
1039 if ($publicgroups) {
1040 if (empty($arraycategories[
'public'])) {
1046 if ($empty && empty($arraycategories[
'code'])) {
1050 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
1051 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) !=
"TicketCategoryShort".$arraycategories[
'code']) {
1052 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
1053 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
1054 $label = $outputlangs->trans($arraycategories[
'code']);
1058 print
'<option value="'.$id.
'"';
1062 print
'<option value="'.$arraycategories[
'code'].
'"';
1066 print
'<option value="'.$arraycategories[
'code'].
'"';
1070 print
'<option value="'.$id.
'"';
1074 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
1075 print
' selected="selected"';
1076 } elseif (isset($selected) && $selected ==
$id) {
1077 print
' selected="selected"';
1078 } elseif ($arraycategories[
'use_default'] ==
"1" && empty($selected) && (!$empty || $empty ==
'ifone')) {
1079 print
' selected="selected"';
1080 } elseif (count($categorytickets) == 1 && (!$empty || $empty ==
'ifone')) {
1081 print
' selected="selected"';
1088 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
1092 $value = $arraycategories[
'code'];
1096 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
1100 $value = $arraycategories[
'code'];
1103 print $value ? $value :
' ';
1108 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1109 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1113 } elseif ($htmlname !=
'') {
1114 $selectedgroups = array();
1116 $groupticket =
GETPOST($htmlname,
'aZ09');
1117 $child_id =
GETPOST($htmlname.
'_child_id',
'aZ09') ?
GETPOST($htmlname.
'_child_id',
'aZ09') : 0;
1118 if (!empty($groupticket)) {
1119 $tmpgroupticket = $groupticket;
1120 $sql =
"SELECT ctc.rowid, ctc.fk_parent, ctc.code";
1121 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc WHERE ctc.code = '".$this->db->escape($tmpgroupticket).
"'";
1122 $resql = $this->db->query($sql);
1124 $obj = $this->db->fetch_object($resql);
1125 $selectedgroups[] = $obj->code;
1126 while ($obj->fk_parent > 0) {
1127 $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).
"'";
1128 $resql = $this->db->query($sql);
1130 $obj = $this->db->fetch_object($resql);
1131 $selectedgroups[] = $obj->code;
1137 $arrayidused = array();
1138 $arrayidusedconcat = array();
1139 $arraycodenotparent = array();
1140 $arraycodenotparent[] =
"";
1142 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
1143 $stringtoprint .=
'<select id="'.$htmlname.
'" class="minwidth500" child_id="0">';
1144 $stringtoprint .=
'<option value=""> </option>';
1146 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
1147 $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";
1148 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
1149 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int)
$conf->entity);
1150 $public = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
1152 $sql .=
" AND ctc.public = 1";
1154 $sql .=
" AND ctc.fk_parent = 0";
1155 $sql .= $this->db->order(
'ctc.pos',
'ASC');
1157 $resql = $this->db->query($sql);
1159 $num_rows_level0 = $this->db->num_rows($resql);
1161 while ($i < $num_rows_level0) {
1162 $obj = $this->db->fetch_object($resql);
1164 $label = ($obj->label !=
'-' ? $obj->label :
'');
1165 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code) {
1166 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1167 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1168 $label = $outputlangs->trans($obj->code);
1171 $grouprowid = $obj->rowid;
1172 $groupvalue = $obj->code;
1173 $grouplabel = $label;
1175 $isparent = $obj->isparent;
1176 if (is_array($selectedgroups)) {
1177 $iselected = in_array($obj->code, $selectedgroups) ?
'selected' :
'';
1179 $iselected = $groupticket == $obj->code ?
'selected' :
'';
1182 if ($isparent ==
'NOTPARENT') {
1183 $arraycodenotparent[] = $groupvalue;
1185 $arrayidused[] = $grouprowid;
1186 $arrayidusedconcat[] = $grouprowid;
1193 if (count($arrayidused) == 1) {
1194 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
1196 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400" value="'.
GETPOST($htmlname).
'">';
1197 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400" '.
GETPOST($htmlname).
' value="'.
GETPOST($htmlname.
"_child_id").
'">';
1199 $stringtoprint .=
'</select> ';
1202 while ($levelid <= $use_multilevel) {
1203 $tabscript = array();
1204 $stringtoprint .=
'<select id="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
1205 $stringtoprint .=
'<option value=""> </option>';
1207 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
1208 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
1209 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
1210 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int)
$conf->entity);
1211 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(implode(
',', $arrayidusedconcat)).
")";
1213 $public = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
1215 $sql .=
" AND ctc.public = 1";
1218 if (!empty($arrayidused)) {
1219 $sql .=
" AND ctc.fk_parent IN ( ";
1220 foreach ($arrayidused as $idused) {
1221 $sql .= ((int) $idused).
", ";
1223 $sql = substr($sql, 0, -2);
1226 $sql .= $this->db->order(
'ctc.pos',
'ASC');
1228 $resql = $this->db->query($sql);
1230 $num_rows = $this->db->num_rows($resql);
1232 $arrayidused = array();
1233 while ($i < $num_rows) {
1234 $obj = $this->db->fetch_object($resql);
1236 $label = ($obj->label !=
'-' ? $obj->label :
'');
1237 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code) {
1238 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1239 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1240 $label = $outputlangs->trans($obj->code);
1243 $grouprowid = $obj->rowid;
1244 $groupvalue = $obj->code;
1245 $grouplabel = $label;
1246 $isparent = $obj->isparent;
1247 $fatherid = $obj->fk_parent;
1248 $arrayidused[] = $grouprowid;
1249 $arrayidusedconcat[] = $grouprowid;
1250 $groupcodefather = $obj->codefather;
1251 if ($isparent ==
'NOTPARENT') {
1252 $arraycodenotparent[] = $groupvalue;
1254 if (is_array($selectedgroups)) {
1255 $iselected = in_array($obj->code, $selectedgroups) ?
'selected' :
'';
1257 $iselected = $groupticket == $obj->code ?
'selected' :
'';
1260 if (empty($tabscript[$groupcodefather])) {
1261 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid - 1) :
'').
'").val() == "'.
dol_escape_js($groupcodefather).
'"){
1263 console.log("We show child tickets of '.$groupcodefather.
' group ticket")
1266 console.log("We hide child tickets of '.$groupcodefather.
' group ticket")
1275 $stringtoprint .=
'</select>';
1277 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1278 $stringtoprint .=
'arraynotparents = '.json_encode($arraycodenotparent).
';';
1279 $stringtoprint .=
'if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid - 1) :
'').
'").val())){
1280 console.log("'.$htmlname.
'_child_'.$levelid.
'")
1281 if($("#'.$htmlname.
'_child_'.$levelid.
'").val() == "" && ($("#'.$htmlname.
'_child_'.$levelid.
'").attr("child_id")>'.$child_id.
')){
1282 $("#'.$htmlname.
'_child_'.$levelid.
'").hide();
1283 console.log("We hide '.$htmlname.
'_child_'.$levelid.
' input")
1285 if(arraynotparents.includes("'.$groupticket.
'") && '.$child_id.
' == 0){
1286 $("#ticketcategory_select_child_id").val($("#'.$htmlname.
'").attr("child_id"))
1287 $("#ticketcategory_select").val($("#'.$htmlname.
'").val()) ;
1288 console.log("We choose '.$htmlname.
' input and reload hidden input");
1291 $("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid - 1) :
'').
'").change(function() {
1292 child_id = $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid :
'').
'").attr("child_id");
1294 /* Change of value to select this value*/
1295 if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.
') {
1296 $("#ticketcategory_select").val($(this).val());
1297 $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1298 console.log("We choose to select "+ $(this).val());
1300 if ($("#'.$htmlname.
'_child_'.$levelid.
' option").length <= 1) {
1301 $("#ticketcategory_select").val($(this).val());
1302 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1303 console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1305 console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1306 $("#ticketcategory_select").val("");
1307 $("#ticketcategory_select_child_id").val("");
1311 console.log("We select a new value into combo child_id="+child_id);
1313 // Hide all selected box that are child of the one modified
1314 $(".groupticketchild").each(function(){
1315 if ($(this).attr("child_id") > child_id) {
1316 console.log("hide child_id="+$(this).attr("child_id"));
1322 // Now we enable the next combo
1323 $("#'.$htmlname.
'_child_'.$levelid.
'").val("");
1324 if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.
'_child_'.$levelid.
' option").length > 1) {
1325 console.log($("#'.$htmlname.
'_child_'.$levelid.
' option").length);
1326 $("#'.$htmlname.
'_child_'.$levelid.
'").show()
1328 $("#'.$htmlname.
'_child_'.$levelid.
'").hide()
1332 foreach ($tabscript as $script) {
1333 $stringtoprint .= $script;
1335 $stringtoprint .=
'})';
1336 $stringtoprint .=
'</script>';
1338 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1339 $stringtoprint .=
'$("#'.$htmlname.
'_child_'.$use_multilevel.
'").change(function() {
1340 $("#ticketcategory_select").val($(this).val());
1341 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1342 tmpvalselect = $("#ticketcategory_select").val();
1343 if(tmpvalselect == "" && $("#ticketcategory_select_child_id").val() >= 1){
1344 $("#ticketcategory_select_child_id").val($(this).attr("child_id")-1);
1346 console.log($("#ticketcategory_select").val());
1348 $stringtoprint .=
'</script>';
1351 return $stringtoprint;
1368 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
1370 global
$conf, $langs, $user;
1372 $ticketstat =
new Ticket($this->db);
1374 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1376 $filterarray = array();
1378 if ($filtertype !=
'' && $filtertype !=
'-1') {
1379 $filterarray = explode(
',', $filtertype);
1382 $ticketstat->loadCacheSeveritiesTickets();
1384 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1386 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
1389 $severitytickets =
$conf->cache[
'severity_tickets'];
1390 '@phan-var-force array<int,array{code:string,label:string,use_default:int,pos:int}> $severitytickets';
1391 if (is_array($severitytickets) && count($severitytickets)) {
1392 foreach ($severitytickets as
$id => $arrayseverities) {
1394 if (count($filterarray) && !in_array($arrayseverities[
'code'], $filterarray)) {
1399 if ($empty && empty($arrayseverities[
'code'])) {
1404 print
'<option value="'.$id.
'"';
1408 print
'<option value="'.$arrayseverities[
'code'].
'"';
1412 print
'<option value="'.$arrayseverities[
'code'].
'"';
1416 print
'<option value="'.$id.
'"';
1420 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
1421 print
' selected="selected"';
1422 } elseif (isset($selected) && $selected ==
$id) {
1423 print
' selected="selected"';
1424 } elseif ($arrayseverities[
'use_default'] ==
"1" && empty($selected) && (!$empty || $empty ==
'ifone')) {
1425 print
' selected="selected"';
1426 } elseif (count($severitytickets) == 1 && (!$empty || $empty ==
'ifone')) {
1427 print
' selected="selected"';
1434 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1438 $value = $arrayseverities[
'code'];
1442 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1446 $value = $arrayseverities[
'code'];
1449 print $value ? $value :
' ';
1454 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1455 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1470 global
$conf, $user;
1471 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1474 $vardir =
$conf->user->dir_output.
"/".$user->id;
1475 $upload_dir = $vardir.
'/temp/';
1476 if (is_dir($upload_dir)) {
1480 if (!empty($this->trackid)) {
1481 $keytoavoidconflict =
'-'.$this->trackid;
1483 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1485 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
1486 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
1487 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
1499 global
$conf, $langs, $user, $hookmanager, $form;
1501 $formmail =
new FormMail($this->db);
1502 $addfileaction =
'addfile';
1504 if (!is_object($form)) {
1505 $form =
new Form($this->db);
1509 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
1512 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1513 $this->clear_attached_files();
1517 $outputlangs = $langs;
1519 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1520 $newlang = $this->param[
'langsmodels'];
1522 if (!empty($newlang)) {
1524 $outputlangs->setDefaultLang($newlang);
1525 $outputlangs->load(
'other');
1529 $arraydefaultmessage = -1;
1530 if (isset($this->param[
'models']) && $this->param[
'models'] !=
'none') {
1532 if (array_key_exists(
'models_id', $this->param)) {
1533 $model_id = (int) $this->param[
"models_id"];
1537 $usedefault = ($model_id ? -1 : 1);
1538 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id, 1,
'', $usedefault);
1539 if (isset($arraydefaultmessage->id) && empty($model_id)) {
1540 $model_id = $arraydefaultmessage->id;
1541 $this->param[
'models_id'] = $model_id;
1546 $listofpaths = array();
1547 $listofnames = array();
1548 $listofmimes = array();
1550 if (!empty($this->trackid)) {
1551 $keytoavoidconflict =
'-'.$this->trackid;
1553 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1556 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1557 if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param[
'fileinit']) && is_array($this->param[
'fileinit'])) {
1558 foreach ($this->param[
'fileinit'] as $path) {
1559 $formmail->add_attached_files($path, basename($path),
dol_mimetype($path));
1565 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
1566 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
1568 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
1569 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
1571 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
1572 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
1576 $outputlangs = $langs;
1578 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1579 $newlang = $this->param[
'langsmodels'];
1581 if (!empty($newlang)) {
1583 $outputlangs->setDefaultLang($newlang);
1584 $outputlangs->load(
'other');
1587 print
"\n<!-- Begin message_form TICKET -->\n";
1592 print
'<script nonce="'.getNonce().
'" type="text/javascript">
1593 jQuery(document).ready(function() {
1594 send_email='.((int) $send_email).
';
1596 if (!jQuery("#send_msg_email").is(":checked")) {
1597 jQuery("#send_msg_email").prop("checked", true).trigger("change");
1599 jQuery(".email_line").show();
1600 jQuery(".not_email_line").hide();
1602 if (!jQuery("#private_message").is(":checked")) {
1603 jQuery("#private_message").prop("checked", true).trigger("change");
1605 jQuery(".email_line").hide();
1606 jQuery(".not_email_line").show();
1612 print
'jQuery("#send_msg_email").click(function() {
1613 console.log("Click send_msg_email");
1614 if(jQuery(this).is(":checked")) {
1615 if (jQuery("#private_message").is(":checked")) {
1616 jQuery("#private_message").prop("checked", false).trigger("change");
1618 jQuery(".email_line").show();
1619 jQuery(".not_email_line").hide();
1622 jQuery(".email_line").hide();
1623 jQuery(".not_email_line").show();
1627 jQuery("#private_message").click(function() {
1628 console.log("Click private_message");
1629 if (jQuery(this).is(":checked")) {
1630 if (jQuery("#send_msg_email").is(":checked")) {
1631 jQuery("#send_msg_email").prop("checked", false).trigger("change");
1633 jQuery(".email_line").hide();
1634 jQuery(".not_email_line").show();
1642 print
'<form method="post" name="ticket" id="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
1643 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1644 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
1645 print
'<input type="hidden" name="actionbis" value="add_message">';
1646 print
'<input type="hidden" name="backtopage" value="'.$this->backtopage.
'">';
1647 if (!empty($this->trackid)) {
1648 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
1650 print
'<input type="hidden" name="trackid" value="'.(empty($this->track_id) ?
'' : $this->track_id).
'">';
1651 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1653 foreach ($this->param as $key => $value) {
1654 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
1659 if (array_key_exists(
'models_id', $this->param)) {
1660 $model_id = $this->param[
"models_id"];
1661 $usedefault = ($model_id ? -1 : 1);
1662 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id, 1,
'', $usedefault);
1665 $result = $formmail->fetchAllEMailTemplate(!empty($this->param[
"models"]) ? $this->param[
"models"] :
"", $user, $outputlangs);
1669 $modelmail_array = array();
1670 foreach ($formmail->lines_model as $line) {
1671 $modelmail_array[$line->id] = $line->label;
1674 $ticketstat =
new Ticket($this->db);
1675 $res = $ticketstat->fetch(0,
'', $this->track_id);
1677 print
'<table class="border" width="'.$width.
'">';
1680 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1681 print
'<tr><td class="width200"></td><td>';
1682 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : (
getDolGlobalInt(
'TICKETS_MESSAGE_FORCE_MAIL') ?
'checked' :
''));
1683 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1684 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1685 $texttooltip = $langs->trans(
"TicketMessageSendEmailHelp");
1687 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2b");
1689 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2a",
'{s1}');
1691 $texttooltip = str_replace(
'{s1}', $langs->trans(
'MarkMessageAsPrivate'), $texttooltip);
1692 print
' '.$form->textwithpicto(
'', $texttooltip, 1,
'help');
1695 if (count($modelmail_array) > 0) {
1696 print
' <span class="email_line">';
1697 print $formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], $langs->trans(
'SelectMailModel'), 0, 0,
"", 0, 0, 0,
'',
'minwidth200');
1699 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv(
"Tools").
' - '.$langs->transnoentitiesnoconv(
"EMailTemplates")), 1);
1702 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1709 if (!$user->socid) {
1710 print
'<tr><td></td><td>';
1711 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1712 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1713 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1714 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1735 print
'<tr class="email_line"><td class="width200"><span class="">'.$langs->trans(
"MailFrom");
1737 print
' <span class="opacitymedium">('.$langs->trans(
"MailReply").
')</span>';
1739 print
'</span></td>';
1740 print
'<td><span class="">'.img_picto(
'',
'email',
'class="pictofixedwidth"').$from;
1742 print
' <span class="opacitymedium">('.$replyto.
')</span>';
1744 print
'</span></td></tr>';
1747 $parameters = array();
1749 $reshook = $hookmanager->executeHooks(
'printFieldTicketEmailTo', $parameters, $this, $action);
1750 if (empty($reshook)) {
1751 print
'<tr class="email_line"><td>'.$langs->trans(
'MailRecipients');
1752 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessageRecipientsHelp"), 1,
'help');
1756 $contacts = $ticketstat->getInfosTicketInternalContact(1);
1757 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact(1));
1762 if (is_array($contacts) && count($contacts) > 0) {
1763 foreach ($contacts as $key => $info_sendto) {
1764 if ($info_sendto[
'email'] !=
'') {
1765 $sendto[] =
dol_escape_htmltag(trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">").
' <small class="opacitymedium">('.
dol_escape_htmltag($info_sendto[
'libelle']).
")</small>";
1770 if (!empty($ticketstat->origin_replyto) && !in_array($ticketstat->origin_replyto, $sendto)) {
1771 $sendto[] =
dol_escape_htmltag((
string) $ticketstat->origin_replyto).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
1772 } elseif ($ticketstat->origin_email && !in_array($ticketstat->origin_email, $sendto)) {
1773 $sendto[] =
dol_escape_htmltag((
string) $ticketstat->origin_email).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
1776 if ($ticketstat->fk_soc > 0) {
1777 $ticketstat->socid = $ticketstat->fk_soc;
1778 $ticketstat->fetch_thirdparty();
1780 if (!empty($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
1781 $sendto[] = $ticketstat->thirdparty->email.
' <small class="opacitymedium">('.$langs->trans(
'Customer').
')</small>';
1786 $sendto[] =
getDolGlobalString(
'TICKET_NOTIFICATION_EMAIL_TO').
' <small class="opacitymedium">(generic email)</small>';
1790 if (is_array($sendto) && count($sendto) > 0) {
1791 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
1792 print implode(
', ', $sendto);
1794 print
'<div class="warning">'.$langs->trans(
'WarningNoEMailsAdded').
' '.$langs->trans(
'TicketGoIntoContactTab').
'</div>';
1799 print $hookmanager->resPrint;
1804 print
'<tr class="email_line"><td><span class="">'.$langs->trans(
"MailCC").
'</span></td>';
1805 print
'<td><span class="">'.img_picto(
'',
'email',
'class="pictofixedwidth"').$sendtocc.
'</span></td></tr>';
1809 $uselocalbrowser =
false;
1812 if ($this->withtitletopic) {
1813 print
'<tr class="not_email_line"><td><label for="summary"><span>'.$langs->trans(
"Summary").
'</span></label></td><td>';
1815 if ($this->withtopicreadonly && $this->topic_title) {
1816 print $langs->trans(
'Summary').
' '.$this->topic_title;
1817 } elseif (empty($this->withtopicreadonly)) {
1818 $subject = $this->topic_title;
1819 print
'<input class="text minwidth500" maxlength="42" id="summary" name="summary" placeholder="" value="'.dolPrintHTMLForAttribute($subject).
'"'.(empty($this->withemail) ?
' autofocus' :
'').
' />';
1825 foreach ($formmail->lines_model as $line) {
1826 if (!empty($this->substit) && $this->param[
'models_id'] == $line->id) {
1831 print
'<tr class="email_line"><td class="fieldrequired">'.$langs->trans(
'MailTopic').
'</td>';
1832 if (empty($topic)) {
1833 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">';
1835 print
'<td><input type="text" class="text minwidth500" name="subject" value="'.make_substitutions($topic, $this->substit).
'" spellcheck="false">';
1840 if (!empty($this->withfile)) {
1842 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
1845 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1846 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
1847 $out .=
'jQuery(document).ready(function () {';
1848 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1849 $out .=
' jQuery("#addedfile").on("change", function() {';
1850 $out .=
' if (jQuery(this).val().length) {';
1851 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", false);';
1852 $out .=
' } else {';
1853 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1856 $out .=
' jQuery(".removedfile").click(function() {';
1857 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1860 $out .=
'</script>'.
"\n";
1862 if (count($listofpaths)) {
1863 foreach ($listofpaths as $key => $val) {
1864 $out .=
'<div id="attachfile_'.$key.
'">';
1865 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1866 if (!$this->withfilereadonly) {
1867 $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.
'" />';
1869 $out .=
'<br></div>';
1874 if ($this->withfile == 2) {
1875 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1877 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1879 $out .=
"</td></tr>\n";
1885 $defaultmessage =
"";
1886 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1887 $defaultmessage = (
string) $arraydefaultmessage->content;
1889 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1893 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1894 } elseif (!
dol_textishtml($defaultmessage) && isset($this->substit[
'__USER_SIGNATURE__']) &&
dol_textishtml($this->substit[
'__USER_SIGNATURE__'])) {
1895 $defaultmessage =
dol_nl2br($defaultmessage);
1898 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1902 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1903 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1906 $ckeditorenabledforticket = (
getDolGlobalString(
'FCKEDITOR_ENABLE_TICKET') >= ($fromPublicInterface ? 2 : 1));
1908 print
'<!-- Message line from showMessageForm -->';
1909 print
'<tr><td class="tdtop"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1910 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1911 $texttooltip = $langs->trans(
"TicketMessageHelp");
1913 $texttooltip .=
'<br><br>'.$langs->trans(
"ForEmailMessageWillBeCompletedWith").
'...';
1915 $allowedmailtags = array(
'a',
'div',
'strong',
'em',
'i',
'u',
'p',
'ul',
'ol',
'li',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'img');
1918 print
'<input type="hidden" name="mail_intro" value="'.dolPrintHTMLForAttribute($mail_intro, 0, $allowedmailtags).
'">';
1919 $texttooltip .=
'<br><u>'.$langs->trans(
"TicketMessageMailIntro").
'</u><br>'.$mail_intro;
1923 print
'<input type="hidden" name="mail_signature" value="'.dolPrintHTMLForAttribute($mail_signature, 0, $allowedmailtags).
'">';
1924 $texttooltip .=
'<br><br><u>'.$langs->trans(
"TicketMessageMailFooter").
'</u><br>'.$mail_signature;
1926 print $form->textwithpicto(
'', $texttooltip, 1,
'help');
1928 print
'</label></td>';
1929 $out =
'<td class="tdtop">';
1931 $out .=
'<div class="div-layoutai">';
1934 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1935 $formmail =
new FormMail($this->db);
1937 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formai.class.php';
1938 $formai =
new FormAI($this->db);
1940 $formmail->withfckeditor = $ckeditorenabledforticket ? 1 : 0;
1941 $formmail->withlayout = ((
string) $ckeditorenabledforticket && !$fromPublicInterface) ?
'email' :
'';
1942 $formmail->withaiprompt = (
isModEnabled(
'ai') && !$fromPublicInterface) ?
'text' :
'';
1944 $showlinktolayout = ($formmail->withfckeditor &&
getDolGlobalInt(
'MAIN_EMAIL_USE_LAYOUT')) ? $formmail->withlayout :
'';
1945 $showlinktolayoutlabel = $langs->trans(
"FillMessageWithALayout");
1946 $showlinktoai = ($formmail->withaiprompt ?
'textgenerationemail' :
'');
1947 $showlinktoailabel = $langs->trans(
"AIEnhancements");
1948 $formatforouput =
'';
1949 $htmlname =
'message';
1951 $formai->substit = $this->substit;
1955 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
1963 print
'<tr><td colspan="2">';
1965 $toolbarname =
'dolibarr_notes';
1966 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1967 $uselocalbrowser =
false;
1968 if (!$ckeditorenabledforticket) {
1972 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser, $ckeditorenabledforticket, ROWS_6,
'90%');
1973 $doleditor->Create();
1993 print
'<br><center>';
1994 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"Add").
'"';
1996 if ($this->withfile == 2 && !empty(
$conf->use_javascript_ajax)) {
1997 print
' onClick="if (document.ticket.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans(
"FileWasNotUploaded")).
'\');
return false; }
else {
return true; }
"';
2000 if (!empty($this->withcancel)) {
2001 print "
";
2002 print '<input class="button button-cancel
" type="submit
" name="cancel
" value="'.$langs->trans("Cancel").'">';
2004 print "</center>\n
";
2006 print '<input type="hidden
" name="page_y
">'."\n
";
2008 print "</form><br>\n
";
2010 // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
2011 if (getDolGlobalString('MAIN_MAILFORM_DISABLE_ENTERKEY')) {
2012 print '<script type="text/javascript
">';
2013 print 'jQuery(document).ready(function () {';
2014 print ' $(document).on("keypress
", \'#ticket\', function (e) { /* Note this is called at every key pressed ! */
2015 var code = e.keyCode || e.which;
2017 console.log("Enter was intercepted and blocked
");
2026 print "<!-- End message_form TICKET -->\n
";
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
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 translations.
Class to manage Dolibarr users.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
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_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
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.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dolPrintHTMLForAttributeUrl($s)
Return a string ready to be output on a href attribute (this one need a special because we need conte...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
Class to generate the form for creating a new ticket.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
getMaxFileSizeArray()
Return the max allowed for file upload.