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') {
270 $ref = GETPOSTISSET(
"ref") ?
GETPOST(
"ref",
'alpha') :
'';
271 $type_code = GETPOSTISSET(
'type_code') ?
GETPOST(
'type_code',
'alpha') :
'';
272 $category_code = GETPOSTISSET(
'category_code') ?
GETPOST(
'category_code',
'alpha') :
'';
273 $severity_code = GETPOSTISSET(
'severity_code') ?
GETPOST(
'severity_code',
'alpha') :
'';
274 $subject = GETPOSTISSET(
'subject') ?
GETPOST(
'subject',
'alpha') :
'';
275 $email = GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') :
'';
276 $msg = GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') :
'';
277 $projectid = GETPOSTISSET(
'projectid') ?
GETPOSTINT(
'projectid') : 0;
278 $user_assign = GETPOSTISSET(
'fk_user_assign') ?
GETPOSTINT(
'fk_user_assign') : $this->fk_user_create;
281 $type_code = GETPOSTISSET(
'type_code') ?
GETPOST(
'type_code',
'alpha') :
$object->type_code;
282 $category_code = GETPOSTISSET(
'category_code') ?
GETPOST(
'category_code',
'alpha') :
$object->category_code;
283 $severity_code = GETPOSTISSET(
'severity_code') ?
GETPOST(
'severity_code',
'alpha') :
$object->severity_code;
284 $subject = GETPOSTISSET(
'subject') ?
GETPOST(
'subject',
'alpha') :
$object->subject;
285 $email = GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') :
$object->email_from;
286 $msg = GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') :
$object->message;
287 $projectid = GETPOSTISSET(
'projectid') ?
GETPOSTINT(
'projectid') : (int)
$object->fk_project;
288 $user_assign = GETPOSTISSET(
'fk_user_assign') ?
GETPOSTINT(
'fk_user_assign') :
$object->fk_user_assign;
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>';
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",
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"></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"]);
610 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
611 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
612 $out .=
'jQuery(document).ready(function () {';
613 $out .=
' jQuery(".removedfile").click(function() {';
614 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
617 $out .=
'</script>'.
"\n";
618 if (count($listofpaths)) {
619 foreach ($listofpaths as $key => $val) {
620 $out .=
'<div id="attachfile_'.$key.
'">';
621 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
622 if (!$this->withfilereadonly) {
623 $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.
'" />';
625 $out .=
'<br></div>';
628 if ($this->withfile == 2) {
630 $maxmin = $maxfilesizearray[
'maxmin'];
632 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
634 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
636 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="addfile" name="addfile" value="'.$langs->trans(
"MailingAddFile").
'" />';
638 $out .=
"</td></tr>\n";
641 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">
642 jQuery(document).ready(function () {
643 jQuery("#addedfile").on("change", function() {
644 // Dispara el clic automáticamente al seleccionar archivo
645 jQuery("#addfile").click();
647 // Oculta el botón redundante si JS está activo
648 jQuery("#addfile").hide();
656 if ($this->withusercreate > 0 && $this->fk_user_create) {
657 print
'<tr><td class="titlefield">'.$langs->trans(
"CreatedBy").
'</td><td>';
658 $langs->load(
"users");
659 $fuser =
new User($this->db);
661 if ($this->withcreatereadonly) {
662 if ($res = $fuser->fetch($this->fk_user_create)) {
663 print $fuser->getNomUrl(1);
667 print
"</td></tr>\n";
671 if ($this->withcompany) {
673 if (empty($user->socid)) {
675 print
'<tr><td class="titlefield">'.$langs->trans(
"ThirdParty").
'</td><td>';
677 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
678 print
img_picto(
'',
'company',
'class="paddingright"');
679 print $form->select_company($this->withfromsocid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth200');
683 print
'<script nonce="'.getNonce().
'" type="text/javascript">
684 $(document).ready(function () {
685 jQuery("#'.$htmlname.
'").change(function () {
686 var obj = '.json_encode($events).
';
687 $.each(obj, function(key,values) {
688 if (values.method.length) {
689 runJsCodeForEvent'.$htmlname.
'(values);
694 function runJsCodeForEvent'.$htmlname.
'(obj) {
695 console.log("Run runJsCodeForEvent'.$htmlname.
'");
696 var id = $("#'.$htmlname.
'").val();
697 var method = obj.method;
699 var htmlname = obj.htmlname;
700 var showempty = obj.showempty;
709 $.each(obj.params, function(key,action) {
711 var num = response.num;
713 $("#" + key).removeAttr(action);
715 $("#" + key).attr(action, action);
719 $("select#" + htmlname).html(response.value);
721 var selecthtml_str = response.value;
722 var selecthtml_dom=$.parseHTML(selecthtml_str);
723 if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
724 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
727 $("#inputautocomplete"+htmlname).val("");
729 $("select#" + htmlname).change(); /* Trigger event change */
736 if ($mode ==
'create') {
738 print
'<tr><td>'.$langs->trans(
"Contact").
'</td><td>';
740 $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
741 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
743 print $form->select_contact($selectedCompany, $this->withfromcontactid,
'contactid', 3,
'',
'', 1,
'maxwidth300 widthcentpercentminusx',
true);
746 $formcompany->selectTypeContact($ticketstatic,
'',
'type',
'external',
'', 0,
'maginleftonly maxwidth200');
750 print
'<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.
'"/></td>';
751 print
'<td><input type="hidden" name="contactid" value="'.$user->contact_id.
'"/></td>';
752 print
'<td><input type="hidden" name="type" value="Z"/></td></tr>';
756 if (empty($this->ispublic) && ($action ==
'create' || $action ==
'presend')) {
757 print
'<tr><td><label for="notify_tiers_at_create">'.$langs->trans(
"TicketNotifyTiersAtCreation").
'</label></td><td>';
758 print
'<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ?
' checked="checked"' :
'').
'>';
764 print $langs->trans(
"AssignedTo");
766 if ($permissiontomanage) {
767 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
768 print $form->select_dolusers($user_assign,
'fk_user_assign', 1);
770 $userstat =
new User($this->db);
771 $userstat->fetch($user_assign);
772 print $userstat->getNomUrl(-1);
778 if ($subelement !=
'project') {
781 print
'<tr><td><label for="project"><span class="">'.$langs->trans(
"Project").
'</span></label></td><td>';
782 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects(-1, $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
787 if ($subelement !=
'contract' && $subelement !=
'contrat') {
794 $langs->load(
'contracts');
796 print
'<tr><td><label for="contract"><span class="">'.$langs->trans(
"Contract").
'</span></label></td><td>';
797 print
img_picto(
'',
'contract',
'class="pictofixedwidth"');
799 print $formcontract->select_contract($user->socid ?? -1,
GETPOSTINT(
'contractid'),
'contractid', 0, 1, 1, 1);
807 $parameters = array();
808 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $ticketstat, $action);
809 if (empty($reshook)) {
810 if ($mode ==
'create') {
811 print
$object->showOptionals($extrafields,
'create');
813 print
$object->showOptionals($extrafields,
'edit');
820 print
'<tr><td class="titlefield"></td><td><br>';
822 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
826 $dirModCaptcha = array_merge(array(
'main' =>
'/core/modules/security/captcha/'), is_array(
$conf->modules_parts[
'captcha']) ?
$conf->modules_parts[
'captcha'] : array());
828 $fullpathclassfile =
'';
829 foreach ($dirModCaptcha as $dir) {
830 $fullpathclassfile =
dol_buildpath($dir.
"modCaptcha".ucfirst($captcha).
'.class.php', 0, 2);
831 if ($fullpathclassfile) {
836 if ($fullpathclassfile) {
837 include_once $fullpathclassfile;
841 $classname =
"modCaptcha".ucfirst($captcha);
842 if (class_exists($classname)) {
844 $captchaobj =
new $classname($this->db,
$conf, $langs, $user);
845 '@phan-var-force ModeleCaptcha $captchaobj';
847 if (is_object($captchaobj) && method_exists($captchaobj,
'getCaptchaCodeForForm')) {
848 print $captchaobj->getCaptchaCodeForForm(
'');
850 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method getCaptchaCodeForForm()';
853 print
'Error, the captcha handler class '.$classname.
' was not found after the include';
856 print
'Error, the captcha handler '.$captcha.
' has no class file found modCaptcha'.ucfirst($captcha);
859 print
'<br></td></tr>';
864 if ($withdolfichehead) {
870 if ($mode ==
'create') {
871 print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"CreateTicket"), ($this->withcancel ?
"Cancel" :
""));
873 print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"Save"), ($this->withcancel ?
"Cancel" :
""));
888 print
'<input type="hidden" name="page_y">'.
"\n";
891 print
"<!-- End form TICKET -->\n";
909 public function selectTypesTickets($selected =
'', $htmlname =
'tickettype', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $multiselect = 0, $disabledefault = 0)
911 global $langs, $user;
913 $selected = is_array($selected) ? $selected : (!empty($selected) ? explode(
',', $selected) : array());
914 $ticketstat =
new Ticket($this->db);
916 dol_syslog(get_class($this) .
"::select_types_tickets " . implode(
';', $selected) .
", " . $htmlname .
", " . $filtertype .
", " . $format .
", " . $multiselect, LOG_DEBUG);
918 $filterarray = array();
920 if ($filtertype !=
'' && $filtertype !=
'-1') {
921 $filterarray = explode(
',', $filtertype);
924 $ticketstat->loadCacheTypesTickets();
926 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.($multiselect ?
'[]' :
'').
'"'.($multiselect ?
' multiple' :
'').
'>';
927 if ($empty && !$multiselect) {
928 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
931 if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
932 foreach ($ticketstat->cache_types_tickets as
$id => $arraytypes) {
934 if (count($filterarray) && !in_array($arraytypes[
'code'], $filterarray)) {
939 if ($empty && empty($arraytypes[
'code'])) {
944 print
'<option value="'.$id.
'"';
948 print
'<option value="'.$arraytypes[
'code'].
'"';
952 print
'<option value="'.$arraytypes[
'code'].
'"';
956 print
'<option value="'.$id.
'"';
960 if (in_array($arraytypes[
'code'], $selected)) {
961 print
' selected="selected"';
962 } elseif (in_array(
$id, $selected)) {
963 print
' selected="selected"';
964 } elseif ($arraytypes[
'use_default'] ==
"1" && empty($disabledefault) && empty($selected) && !$multiselect) {
965 print
' selected="selected"';
966 } elseif (count($ticketstat->cache_types_tickets) == 1 && (!$empty || $empty ==
'ifone')) {
967 print
' selected="selected"';
974 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
975 } elseif ($format == 1) {
976 $value = $arraytypes[
'code'];
977 } elseif ($format == 2) {
978 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
979 } elseif ($format == 3) {
980 $value = $arraytypes[
'code'];
983 print $value ? $value :
' ';
988 if (isset($user->admin) && $user->admin && !$noadmininfo) {
989 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1010 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs =
null)
1012 global
$conf, $langs, $user;
1014 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1016 if (is_null($outputlangs) || !is_object($outputlangs)) {
1017 $outputlangs = $langs;
1019 $outputlangs->load(
"ticket");
1021 $publicgroups = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
1023 $ticketstat =
new Ticket($this->db);
1024 $ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1);
1026 if ($use_multilevel <= 0) {
1027 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1029 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
1032 $categorytickets =
$conf->cache[
'category_tickets'];
1033 '@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';
1034 if (is_array($categorytickets) && count($categorytickets)) {
1035 foreach ($categorytickets as
$id => $arraycategories) {
1037 if ($publicgroups) {
1038 if (empty($arraycategories[
'public'])) {
1044 if ($empty && empty($arraycategories[
'code'])) {
1048 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
1049 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) !=
"TicketCategoryShort".$arraycategories[
'code']) {
1050 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
1051 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
1052 $label = $outputlangs->trans($arraycategories[
'code']);
1056 print
'<option value="'.$id.
'"';
1060 print
'<option value="'.$arraycategories[
'code'].
'"';
1064 print
'<option value="'.$arraycategories[
'code'].
'"';
1068 print
'<option value="'.$id.
'"';
1072 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
1073 print
' selected="selected"';
1074 } elseif (isset($selected) && $selected ==
$id) {
1075 print
' selected="selected"';
1076 } elseif ($arraycategories[
'use_default'] ==
"1" && empty($selected) && (!$empty || $empty ==
'ifone')) {
1077 print
' selected="selected"';
1078 } elseif (count($categorytickets) == 1 && (!$empty || $empty ==
'ifone')) {
1079 print
' selected="selected"';
1086 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
1090 $value = $arraycategories[
'code'];
1094 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
1098 $value = $arraycategories[
'code'];
1101 print $value ? $value :
' ';
1106 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1107 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1111 } elseif ($htmlname !=
'') {
1112 $selectedgroups = array();
1114 $groupticket =
GETPOST($htmlname,
'aZ09');
1115 $child_id =
GETPOST($htmlname.
'_child_id',
'aZ09') ?
GETPOST($htmlname.
'_child_id',
'aZ09') : 0;
1116 if (!empty($groupticket)) {
1117 $tmpgroupticket = $groupticket;
1118 $sql =
"SELECT ctc.rowid, ctc.fk_parent, ctc.code";
1119 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc WHERE ctc.code = '".$this->db->escape($tmpgroupticket).
"'";
1120 $resql = $this->db->query($sql);
1122 $obj = $this->db->fetch_object($resql);
1123 $selectedgroups[] = $obj->code;
1124 while ($obj->fk_parent > 0) {
1125 $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).
"'";
1126 $resql = $this->db->query($sql);
1128 $obj = $this->db->fetch_object($resql);
1129 $selectedgroups[] = $obj->code;
1135 $arrayidused = array();
1136 $arrayidusedconcat = array();
1137 $arraycodenotparent = array();
1138 $arraycodenotparent[] =
"";
1140 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
1141 $stringtoprint .=
'<select id="'.$htmlname.
'" class="minwidth500" child_id="0">';
1142 $stringtoprint .=
'<option value=""> </option>';
1144 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
1145 $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";
1146 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
1147 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int)
$conf->entity);
1148 $public = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
1150 $sql .=
" AND ctc.public = 1";
1152 $sql .=
" AND ctc.fk_parent = 0";
1153 $sql .= $this->db->order(
'ctc.pos',
'ASC');
1155 $resql = $this->db->query($sql);
1157 $num_rows_level0 = $this->db->num_rows($resql);
1159 while ($i < $num_rows_level0) {
1160 $obj = $this->db->fetch_object($resql);
1162 $label = ($obj->label !=
'-' ? $obj->label :
'');
1163 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code) {
1164 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1165 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1166 $label = $outputlangs->trans($obj->code);
1169 $grouprowid = $obj->rowid;
1170 $groupvalue = $obj->code;
1171 $grouplabel = $label;
1173 $isparent = $obj->isparent;
1174 if (is_array($selectedgroups)) {
1175 $iselected = in_array($obj->code, $selectedgroups) ?
'selected' :
'';
1177 $iselected = $groupticket == $obj->code ?
'selected' :
'';
1180 if ($isparent ==
'NOTPARENT') {
1181 $arraycodenotparent[] = $groupvalue;
1183 $arrayidused[] = $grouprowid;
1184 $arrayidusedconcat[] = $grouprowid;
1191 if (count($arrayidused) == 1) {
1192 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
1194 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400" value="'.
GETPOST($htmlname).
'">';
1195 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400" '.
GETPOST($htmlname).
' value="'.
GETPOST($htmlname.
"_child_id").
'">';
1197 $stringtoprint .=
'</select> ';
1200 while ($levelid <= $use_multilevel) {
1201 $tabscript = array();
1202 $stringtoprint .=
'<select id="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
1203 $stringtoprint .=
'<option value=""> </option>';
1205 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
1206 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
1207 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
1208 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int)
$conf->entity);
1209 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(implode(
',', $arrayidusedconcat)).
")";
1211 $public = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
1213 $sql .=
" AND ctc.public = 1";
1216 if (!empty($arrayidused)) {
1217 $sql .=
" AND ctc.fk_parent IN ( ";
1218 foreach ($arrayidused as $idused) {
1219 $sql .= ((int) $idused).
", ";
1221 $sql = substr($sql, 0, -2);
1224 $sql .= $this->db->order(
'ctc.pos',
'ASC');
1226 $resql = $this->db->query($sql);
1228 $num_rows = $this->db->num_rows($resql);
1230 $arrayidused = array();
1231 while ($i < $num_rows) {
1232 $obj = $this->db->fetch_object($resql);
1234 $label = ($obj->label !=
'-' ? $obj->label :
'');
1235 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code) {
1236 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1237 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1238 $label = $outputlangs->trans($obj->code);
1241 $grouprowid = $obj->rowid;
1242 $groupvalue = $obj->code;
1243 $grouplabel = $label;
1244 $isparent = $obj->isparent;
1245 $fatherid = $obj->fk_parent;
1246 $arrayidused[] = $grouprowid;
1247 $arrayidusedconcat[] = $grouprowid;
1248 $groupcodefather = $obj->codefather;
1249 if ($isparent ==
'NOTPARENT') {
1250 $arraycodenotparent[] = $groupvalue;
1252 if (is_array($selectedgroups)) {
1253 $iselected = in_array($obj->code, $selectedgroups) ?
'selected' :
'';
1255 $iselected = $groupticket == $obj->code ?
'selected' :
'';
1258 if (empty($tabscript[$groupcodefather])) {
1259 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid - 1) :
'').
'").val() == "'.
dol_escape_js($groupcodefather).
'"){
1261 console.log("We show child tickets of '.$groupcodefather.
' group ticket")
1264 console.log("We hide child tickets of '.$groupcodefather.
' group ticket")
1273 $stringtoprint .=
'</select>';
1275 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1276 $stringtoprint .=
'arraynotparents = '.json_encode($arraycodenotparent).
';';
1277 $stringtoprint .=
'if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid - 1) :
'').
'").val())){
1278 console.log("'.$htmlname.
'_child_'.$levelid.
'")
1279 if($("#'.$htmlname.
'_child_'.$levelid.
'").val() == "" && ($("#'.$htmlname.
'_child_'.$levelid.
'").attr("child_id")>'.$child_id.
')){
1280 $("#'.$htmlname.
'_child_'.$levelid.
'").hide();
1281 console.log("We hide '.$htmlname.
'_child_'.$levelid.
' input")
1283 if(arraynotparents.includes("'.$groupticket.
'") && '.$child_id.
' == 0){
1284 $("#ticketcategory_select_child_id").val($("#'.$htmlname.
'").attr("child_id"))
1285 $("#ticketcategory_select").val($("#'.$htmlname.
'").val()) ;
1286 console.log("We choose '.$htmlname.
' input and reload hidden input");
1289 $("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid - 1) :
'').
'").change(function() {
1290 child_id = $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid :
'').
'").attr("child_id");
1292 /* Change of value to select this value*/
1293 if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.
') {
1294 $("#ticketcategory_select").val($(this).val());
1295 $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1296 console.log("We choose to select "+ $(this).val());
1298 if ($("#'.$htmlname.
'_child_'.$levelid.
' option").length <= 1) {
1299 $("#ticketcategory_select").val($(this).val());
1300 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1301 console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1303 console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1304 $("#ticketcategory_select").val("");
1305 $("#ticketcategory_select_child_id").val("");
1309 console.log("We select a new value into combo child_id="+child_id);
1311 // Hide all selected box that are child of the one modified
1312 $(".groupticketchild").each(function(){
1313 if ($(this).attr("child_id") > child_id) {
1314 console.log("hide child_id="+$(this).attr("child_id"));
1320 // Now we enable the next combo
1321 $("#'.$htmlname.
'_child_'.$levelid.
'").val("");
1322 if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.
'_child_'.$levelid.
' option").length > 1) {
1323 console.log($("#'.$htmlname.
'_child_'.$levelid.
' option").length);
1324 $("#'.$htmlname.
'_child_'.$levelid.
'").show()
1326 $("#'.$htmlname.
'_child_'.$levelid.
'").hide()
1330 foreach ($tabscript as $script) {
1331 $stringtoprint .= $script;
1333 $stringtoprint .=
'})';
1334 $stringtoprint .=
'</script>';
1336 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1337 $stringtoprint .=
'$("#'.$htmlname.
'_child_'.$use_multilevel.
'").change(function() {
1338 $("#ticketcategory_select").val($(this).val());
1339 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1340 tmpvalselect = $("#ticketcategory_select").val();
1341 if(tmpvalselect == "" && $("#ticketcategory_select_child_id").val() >= 1){
1342 $("#ticketcategory_select_child_id").val($(this).attr("child_id")-1);
1344 console.log($("#ticketcategory_select").val());
1346 $stringtoprint .=
'</script>';
1349 return $stringtoprint;
1366 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
1368 global
$conf, $langs, $user;
1370 $ticketstat =
new Ticket($this->db);
1372 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1374 $filterarray = array();
1376 if ($filtertype !=
'' && $filtertype !=
'-1') {
1377 $filterarray = explode(
',', $filtertype);
1380 $ticketstat->loadCacheSeveritiesTickets();
1382 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1384 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
1387 $severitytickets =
$conf->cache[
'severity_tickets'];
1388 '@phan-var-force array<int,array{code:string,label:string,use_default:int,pos:int}> $severitytickets';
1389 if (is_array($severitytickets) && count($severitytickets)) {
1390 foreach ($severitytickets as
$id => $arrayseverities) {
1392 if (count($filterarray) && !in_array($arrayseverities[
'code'], $filterarray)) {
1397 if ($empty && empty($arrayseverities[
'code'])) {
1402 print
'<option value="'.$id.
'"';
1406 print
'<option value="'.$arrayseverities[
'code'].
'"';
1410 print
'<option value="'.$arrayseverities[
'code'].
'"';
1414 print
'<option value="'.$id.
'"';
1418 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
1419 print
' selected="selected"';
1420 } elseif (isset($selected) && $selected ==
$id) {
1421 print
' selected="selected"';
1422 } elseif ($arrayseverities[
'use_default'] ==
"1" && empty($selected) && (!$empty || $empty ==
'ifone')) {
1423 print
' selected="selected"';
1424 } elseif (count($severitytickets) == 1 && (!$empty || $empty ==
'ifone')) {
1425 print
' selected="selected"';
1432 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1436 $value = $arrayseverities[
'code'];
1440 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1444 $value = $arrayseverities[
'code'];
1447 print $value ? $value :
' ';
1452 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1453 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1468 global
$conf, $user;
1469 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1472 $vardir =
$conf->user->dir_output.
"/".$user->id;
1473 $upload_dir = $vardir.
'/temp/';
1474 if (is_dir($upload_dir)) {
1478 if (!empty($this->trackid)) {
1479 $keytoavoidconflict =
'-'.$this->trackid;
1481 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1483 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
1484 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
1485 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
1497 global
$conf, $langs, $user, $hookmanager, $form;
1499 $formmail =
new FormMail($this->db);
1500 $addfileaction =
'addfile';
1502 if (!is_object($form)) {
1503 $form =
new Form($this->db);
1507 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
1510 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1511 $this->clear_attached_files();
1515 $outputlangs = $langs;
1517 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1518 $newlang = $this->param[
'langsmodels'];
1520 if (!empty($newlang)) {
1522 $outputlangs->setDefaultLang($newlang);
1523 $outputlangs->load(
'other');
1527 $arraydefaultmessage = -1;
1528 if (isset($this->param[
'models']) && $this->param[
'models'] !=
'none') {
1530 if (array_key_exists(
'models_id', $this->param)) {
1531 $model_id = (int) $this->param[
"models_id"];
1535 $usedefault = ($model_id ? -1 : 1);
1536 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id, 1,
'', $usedefault);
1537 if (isset($arraydefaultmessage->id) && empty($model_id)) {
1538 $model_id = $arraydefaultmessage->id;
1539 $this->param[
'models_id'] = $model_id;
1544 $listofpaths = array();
1545 $listofnames = array();
1546 $listofmimes = array();
1548 if (!empty($this->trackid)) {
1549 $keytoavoidconflict =
'-'.$this->trackid;
1551 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1554 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1555 if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param[
'fileinit']) && is_array($this->param[
'fileinit'])) {
1556 foreach ($this->param[
'fileinit'] as $path) {
1557 $formmail->add_attached_files($path, basename($path),
dol_mimetype($path));
1563 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
1564 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
1566 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
1567 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
1569 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
1570 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
1574 $outputlangs = $langs;
1576 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1577 $newlang = $this->param[
'langsmodels'];
1579 if (!empty($newlang)) {
1581 $outputlangs->setDefaultLang($newlang);
1582 $outputlangs->load(
'other');
1585 print
"\n<!-- Begin message_form TICKET -->\n";
1590 print
'<script nonce="'.getNonce().
'" type="text/javascript">
1591 jQuery(document).ready(function() {
1592 send_email='.((int) $send_email).
';
1594 if (!jQuery("#send_msg_email").is(":checked")) {
1595 jQuery("#send_msg_email").prop("checked", true).trigger("change");
1597 jQuery(".email_line").show();
1598 jQuery(".not_email_line").hide();
1600 if (!jQuery("#private_message").is(":checked")) {
1601 jQuery("#private_message").prop("checked", true).trigger("change");
1603 jQuery(".email_line").hide();
1604 jQuery(".not_email_line").show();
1610 print
'jQuery("#send_msg_email").click(function() {
1611 console.log("Click send_msg_email");
1612 if(jQuery(this).is(":checked")) {
1613 if (jQuery("#private_message").is(":checked")) {
1614 jQuery("#private_message").prop("checked", false).trigger("change");
1616 jQuery(".email_line").show();
1617 jQuery(".not_email_line").hide();
1620 jQuery(".email_line").hide();
1621 jQuery(".not_email_line").show();
1625 jQuery("#private_message").click(function() {
1626 console.log("Click private_message");
1627 if (jQuery(this).is(":checked")) {
1628 if (jQuery("#send_msg_email").is(":checked")) {
1629 jQuery("#send_msg_email").prop("checked", false).trigger("change");
1631 jQuery(".email_line").hide();
1632 jQuery(".not_email_line").show();
1640 print
'<form method="post" name="ticket" id="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
1641 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1642 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
1643 print
'<input type="hidden" name="actionbis" value="add_message">';
1644 print
'<input type="hidden" name="backtopage" value="'.$this->backtopage.
'">';
1645 if (!empty($this->trackid)) {
1646 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
1648 print
'<input type="hidden" name="trackid" value="'.(empty($this->track_id) ?
'' : $this->track_id).
'">';
1649 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1651 foreach ($this->param as $key => $value) {
1652 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
1657 if (array_key_exists(
'models_id', $this->param)) {
1658 $model_id = $this->param[
"models_id"];
1659 $usedefault = ($model_id ? -1 : 1);
1660 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id, 1,
'', $usedefault);
1663 $result = $formmail->fetchAllEMailTemplate(!empty($this->param[
"models"]) ? $this->param[
"models"] :
"", $user, $outputlangs);
1667 $modelmail_array = array();
1668 foreach ($formmail->lines_model as $line) {
1669 $modelmail_array[$line->id] = $line->label;
1672 $ticketstat =
new Ticket($this->db);
1673 $res = $ticketstat->fetch(0,
'', $this->track_id);
1675 print
'<table class="border" width="'.$width.
'">';
1678 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1679 print
'<tr><td class="width200"></td><td>';
1680 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : (
getDolGlobalInt(
'TICKETS_MESSAGE_FORCE_MAIL') ?
'checked' :
''));
1681 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1682 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1683 $texttooltip = $langs->trans(
"TicketMessageSendEmailHelp");
1685 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2b");
1687 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2a",
'{s1}');
1689 $texttooltip = str_replace(
'{s1}', $langs->trans(
'MarkMessageAsPrivate'), $texttooltip);
1690 print
' '.$form->textwithpicto(
'', $texttooltip, 1,
'help');
1693 if (count($modelmail_array) > 0) {
1694 print
' <span class="email_line">';
1695 print $formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], $langs->trans(
'SelectMailModel'), 0, 0,
"", 0, 0, 0,
'',
'minwidth200');
1697 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv(
"Tools").
' - '.$langs->transnoentitiesnoconv(
"EMailTemplates")), 1);
1700 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1707 if (!$user->socid) {
1708 print
'<tr><td></td><td>';
1709 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1710 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1711 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1712 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1733 print
'<tr class="email_line"><td class="width200"><span class="">'.$langs->trans(
"MailFrom");
1735 print
' <span class="opacitymedium">('.$langs->trans(
"MailReply").
')</span>';
1737 print
'</span></td>';
1738 print
'<td><span class="">'.img_picto(
'',
'email',
'class="pictofixedwidth"').$from;
1740 print
' <span class="opacitymedium">('.$replyto.
')</span>';
1742 print
'</span></td></tr>';
1745 $parameters = array();
1747 $reshook = $hookmanager->executeHooks(
'printFieldTicketEmailTo', $parameters, $this, $action);
1748 if (empty($reshook)) {
1749 print
'<tr class="email_line"><td class="fieldrequired">'.$langs->trans(
'MailRecipients');
1750 print
' '.$form->textwithpicto(
'', $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients"), 1,
'help');
1754 $sendto_free = GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'alphawithlgt') :
'';
1755 print
'<input class="minwidth200" id="sendto" name="sendto" spellcheck="false" placeholder="email@domain.com" value="'.dol_escape_htmltag($sendto_free).
'" />';
1758 $contacts = $ticketstat->getInfosTicketInternalContact(1);
1759 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact(1));
1760 $seen_emails = array();
1762 if (is_array($contacts) && count($contacts) > 0) {
1763 foreach ($contacts as $info_sendto) {
1764 if ($info_sendto[
'email'] !=
'') {
1765 $email_lc = strtolower($info_sendto[
'email']);
1766 if (!in_array($email_lc, $seen_emails)) {
1767 $label_text = trim($info_sendto[
'firstname'].
' '.$info_sendto[
'lastname']).
' <'.$info_sendto[
'email'].
'>';
1768 $label_html =
dol_htmlentities(trim($info_sendto[
'firstname'].
' '.$info_sendto[
'lastname']), ENT_QUOTES,
'UTF-8')
1769 .
' <span class="opacitymedium">('.
dol_htmlentities($info_sendto[
'libelle'], ENT_QUOTES,
'UTF-8').
')</span>';
1770 $withto[$info_sendto[
'email']] = array(
1771 'id' => $info_sendto[
'email'],
1772 'label' => str_replace(array(
'<',
'>'), array(
'(',
')'), $label_text),
1773 'labelhtml' => $label_html,
1775 $seen_emails[] = $email_lc;
1781 if (!empty($ticketstat->origin_replyto) && !in_array(strtolower($ticketstat->origin_replyto), $seen_emails)) {
1782 $email = (
string) $ticketstat->origin_replyto;
1783 $withto[$email] = array(
1786 'labelhtml' =>
dol_escape_htmltag($email).
' <span class="opacitymedium">('.$langs->trans(
'TicketEmailOriginIssuer').
')</span>',
1788 $seen_emails[] = strtolower($email);
1789 } elseif ($ticketstat->origin_email && !in_array(strtolower((
string) $ticketstat->origin_email), $seen_emails)) {
1790 $email = (
string) $ticketstat->origin_email;
1791 $withto[$email] = array(
1794 'labelhtml' =>
dol_escape_htmltag($email).
' <span class="opacitymedium">('.$langs->trans(
'TicketEmailOriginIssuer').
')</span>',
1796 $seen_emails[] = strtolower($email);
1799 if ($ticketstat->fk_soc > 0) {
1800 $ticketstat->socid = $ticketstat->fk_soc;
1801 $ticketstat->fetch_thirdparty();
1802 if (!empty($ticketstat->thirdparty->email) && !in_array(strtolower((
string) $ticketstat->thirdparty->email), $seen_emails)) {
1803 $email = (
string) $ticketstat->thirdparty->email;
1804 $withto[$email] = array(
1807 'labelhtml' =>
dol_escape_htmltag($email).
' <span class="opacitymedium">('.$langs->trans(
'Customer').
')</span>',
1809 $seen_emails[] = strtolower($email);
1815 if (!in_array(strtolower($generic_email), $seen_emails)) {
1816 $withto[$generic_email] = array(
1817 'id' => $generic_email,
1818 'label' => $generic_email,
1819 'labelhtml' =>
dol_escape_htmltag($generic_email).
' <span class="opacitymedium">(generic)</span>',
1825 if (GETPOSTISSET(
'receiver_multiselect')) {
1826 $withtoselected =
GETPOST(
'receiver',
'array');
1828 $withtoselected = array_keys($withto);
1831 if (!empty($withto)) {
1832 print
' <span class="opacitymedium">'.$langs->trans(
"and").
'/'.$langs->trans(
"or").
'</span> ';
1833 print $form->multiselectarray(
'receiver', $withto, $withtoselected, 0, 0,
'inline-block minwidth500', 0, 0,
'',
'',
'', 1);
1836 print
'<input type="hidden" name="receiver_multiselect" value="1">';
1837 print
' <span class="opacitymedium"><small>'.$langs->trans(
'WarningNoEMailsAdded').
'</small></span>';
1842 print
'<tr class="email_line"><td>';
1843 print $form->textwithpicto($langs->trans(
"MailCC"), $langs->trans(
"YouCanUseCommaSeparatorForSeveralRecipients"), 1,
'help');
1847 if (GETPOSTISSET(
'receivercc_multiselect')) {
1848 $sendtocc_free =
GETPOST(
'sendtocc',
'alphawithlgt');
1852 print
'<input class="minwidth200" id="sendtocc" name="sendtocc" spellcheck="false" value="'.dol_escape_htmltag($sendtocc_free).
'" />';
1855 if (!empty($withto)) {
1856 print
' <span class="opacitymedium">'.$langs->trans(
"and").
'/'.$langs->trans(
"or").
'</span> ';
1857 $withtocc_selected = GETPOSTISSET(
'receivercc_multiselect') ?
GETPOST(
'receivercc',
'array') : array();
1858 print $form->multiselectarray(
'receivercc', $withto, $withtocc_selected, 0, 0,
'inline-block minwidth500', 0, 0,
'',
'',
'', 1);
1861 print
'<input type="hidden" name="receivercc_multiselect" value="1">';
1865 print $hookmanager->resPrint;
1869 $uselocalbrowser =
false;
1872 if ($this->withtitletopic) {
1873 print
'<tr class="not_email_line"><td><label for="summary"><span>'.$langs->trans(
"Summary").
'</span></label></td><td>';
1875 if ($this->withtopicreadonly && $this->topic_title) {
1876 print $langs->trans(
'Summary').
' '.$this->topic_title;
1877 } elseif (empty($this->withtopicreadonly)) {
1878 $subject = $this->topic_title;
1879 print
'<input class="text minwidth500" maxlength="42" id="summary" name="summary" placeholder="" value="'.dolPrintHTMLForAttribute($subject).
'"'.(empty($this->withemail) ?
' autofocus' :
'').
' />';
1885 foreach ($formmail->lines_model as $line) {
1886 if (!empty($this->substit) && $this->param[
'models_id'] == $line->id) {
1891 print
'<tr class="email_line"><td class="fieldrequired">'.$langs->trans(
'MailTopic').
'</td>';
1892 if (empty($topic)) {
1893 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">';
1895 print
'<td><input type="text" class="text minwidth500" name="subject" value="'.make_substitutions($topic, $this->substit).
'" spellcheck="false">';
1900 if (!empty($this->withfile)) {
1902 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
1905 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1906 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
1907 $out .=
'jQuery(document).ready(function () {';
1908 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1909 $out .=
' jQuery("#addedfile").on("change", function() {';
1910 $out .=
' if (jQuery(this).val().length) {';
1911 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", false);';
1912 $out .=
' } else {';
1913 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1916 $out .=
' jQuery(".removedfile").click(function() {';
1917 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1920 $out .=
'</script>'.
"\n";
1922 if (count($listofpaths)) {
1923 foreach ($listofpaths as $key => $val) {
1924 $out .=
'<div id="attachfile_'.$key.
'">';
1925 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1926 if (!$this->withfilereadonly) {
1927 $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.
'" />';
1929 $out .=
'<br></div>';
1934 if ($this->withfile == 2) {
1935 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1937 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1939 $out .=
"</td></tr>\n";
1945 $defaultmessage =
"";
1946 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1947 $defaultmessage = (
string) $arraydefaultmessage->content;
1949 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1953 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1954 } elseif (!
dol_textishtml($defaultmessage) && isset($this->substit[
'__USER_SIGNATURE__']) &&
dol_textishtml($this->substit[
'__USER_SIGNATURE__'])) {
1955 $defaultmessage =
dol_nl2br($defaultmessage);
1957 if (GETPOSTISSET(
"message") && !
GETPOST(
'modelselected')) {
1958 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1962 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1963 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1967 $ckeditorenabledforticket = (
getDolGlobalString(
'FCKEDITOR_ENABLE_TICKET') >= ($fromPublicInterface ? 2 : 1))
1970 print
'<!-- Message line from showMessageForm -->';
1971 print
'<tr><td class="tdtop"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1972 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1973 $texttooltip = $langs->trans(
"TicketMessageHelp");
1975 $texttooltip .=
'<br><br>'.$langs->trans(
"ForEmailMessageWillBeCompletedWith").
'...';
1977 $allowedmailtags = array(
'a',
'div',
'strong',
'em',
'i',
'u',
'p',
'ul',
'ol',
'li',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'img');
1980 print
'<input type="hidden" name="mail_intro" value="'.dolPrintHTMLForAttribute($mail_intro, 0, $allowedmailtags).
'">';
1981 $texttooltip .=
'<br><u>'.$langs->trans(
"TicketMessageMailIntro").
'</u><br>'.$mail_intro;
1985 print
'<input type="hidden" name="mail_signature" value="'.dolPrintHTMLForAttribute($mail_signature, 0, $allowedmailtags).
'">';
1986 $texttooltip .=
'<br><br><u>'.$langs->trans(
"TicketMessageMailFooter").
'</u><br>'.$mail_signature;
1988 print $form->textwithpicto(
'', $texttooltip, 1,
'help');
1990 print
'</label></td>';
1991 $out =
'<td class="tdtop">';
1993 $out .=
'<div class="div-layoutai">';
1996 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1997 $formmail =
new FormMail($this->db);
1999 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formai.class.php';
2000 $formai =
new FormAI($this->db);
2002 $formmail->withfckeditor = $ckeditorenabledforticket ? 1 : 0;
2003 $formmail->withlayout = ((
string) $ckeditorenabledforticket && !$fromPublicInterface) ?
'email' :
'';
2004 $formmail->withaiprompt = (
isModEnabled(
'ai') && !$fromPublicInterface) ?
'text' :
'';
2006 $showlinktolayout = ($formmail->withfckeditor &&
getDolGlobalInt(
'MAIN_EMAIL_USE_LAYOUT')) ? $formmail->withlayout :
'';
2007 $showlinktolayoutlabel = $langs->trans(
"FillMessageWithALayout");
2008 $showlinktoai = ($formmail->withaiprompt ?
'textgenerationemail' :
'');
2009 $showlinktoailabel = $langs->trans(
"AIEnhancements");
2010 $formatforouput =
'';
2011 $htmlname =
'message';
2013 $formai->substit = $this->substit;
2017 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
2025 print
'<tr><td colspan="2">';
2027 $toolbarname =
'dolibarr_notes';
2028 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2029 $uselocalbrowser =
false;
2030 if (!$ckeditorenabledforticket) {
2034 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser, $ckeditorenabledforticket, ROWS_6,
'90%');
2035 $doleditor->Create();
2055 print
'<br><center>';
2056 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"Add").
'"';
2058 if ($this->withfile == 2 && !empty(
$conf->use_javascript_ajax)) {
2059 print
' onClick="if (document.ticket.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans(
"FileWasNotUploaded")).
'\');
return false; }
else {
return true; }
"';
2062 if (!empty($this->withcancel)) {
2063 print "
";
2064 print '<input class="button button-cancel
" type="submit
" name="cancel
" value="'.$langs->trans("Cancel").'">';
2066 print "</center>\n
";
2068 print '<input type="hidden
" name="page_y
">'."\n
";
2070 print "</form><br>\n
";
2072 // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
2073 if (getDolGlobalString('MAIN_MAILFORM_DISABLE_ENTERKEY')) {
2074 print '<script type="text/javascript
">';
2075 print 'jQuery(document).ready(function () {';
2076 print ' $(document).on("keypress
", \'#ticket\', function (e) { /* Note this is called at every key pressed ! */
2077 var code = e.keyCode || e.which;
2079 console.log("Enter was intercepted and blocked
");
2088 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)
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
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_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.
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.
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.
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
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_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.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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...
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
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.