28require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
29require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
30require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
32if (!class_exists(
'FormCompany')) {
33 include DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
64 public $fk_user_create;
80 public $withfilereadonly;
86 public $withtitletopic;
87 public $withtopicreadonly;
91 public $withfromsocid;
92 public $withfromcontactid;
93 public $withnotifytiersatcreate;
94 public $withusercreate;
95 public $withcreatereadonly;
100 public $withextrafields;
106 public $category_code;
107 public $severity_code;
114 public $substit = array();
115 public $param = array();
121 public $errors = array();
135 $this->action =
'add';
137 $this->withcompany = isModEnabled(
"societe");
138 $this->withfromsocid = 0;
139 $this->withfromcontactid = 0;
142 $this->withnotifytiersatcreate = 0;
143 $this->withusercreate = 1;
144 $this->withcreatereadonly = 1;
145 $this->withemail = 0;
147 $this->withextrafields = 0;
161 public function showForm($withdolfichehead = 0, $mode =
'edit', $public = 0,
Contact $with_contact =
null, $action =
'')
163 global $conf, $langs, $user, $hookmanager;
166 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
168 $form =
new Form($this->db);
170 $ticketstatic =
new Ticket($this->db);
173 if (!empty($this->withfromsocid) && $this->withfromsocid > 0) {
174 $soc->fetch($this->withfromsocid);
177 $ticketstat =
new Ticket($this->db);
180 $extrafields->fetch_name_optionals_label($ticketstat->table_element);
182 print
"\n<!-- Begin form TICKET -->\n";
184 if ($withdolfichehead) {
188 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']).
'">';
189 print
'<input type="hidden" name="token" value="'.newToken().
'">';
190 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
191 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
192 foreach ($this->param as $key => $value) {
193 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
195 print
'<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.
'">';
197 print
'<table class="border centpercent">';
199 if ($this->withref) {
201 $defaultref = $ticketstat->getDefaultRef();
202 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Ref").
'</span></td><td>';
203 print
'<input type="text" name="ref" value="'.dol_escape_htmltag(
GETPOST(
"ref",
'alpha') ?
GETPOST(
"ref",
'alpha') : $defaultref).
'">';
208 $email = GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alphanohtml') :
'';
209 if ($this->withemail) {
210 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"Email").
'</span></label></td><td>';
211 print
'<input class="text minwidth200" id="email" name="email" value="'.$email.
'" autofocus>';
216 $html_contact_search =
'';
217 $html_contact_search .=
'<tr id="contact_search_line">';
218 $html_contact_search .=
'<td class="titlefield">';
219 $html_contact_search .=
'<label for="contact"><span class="fieldrequired">' . $langs->trans(
'Contact') .
'</span></label>';
220 $html_contact_search .=
'<input type="hidden" id="contact_id" name="contact_id" value="" />';
221 $html_contact_search .=
'</td>';
222 $html_contact_search .=
'<td id="contact_search_result"></td>';
223 $html_contact_search .=
'</tr>';
224 print $html_contact_search;
226 $html_contact_lastname =
'';
227 $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>';
228 $html_contact_lastname .=
'<input type="text" id="contact_lastname" name="contact_lastname" value="' .
dol_escape_htmltag(GETPOSTISSET(
'contact_lastname') ?
GETPOST(
'contact_lastname',
'alphanohtml') :
'') .
'" />';
229 $html_contact_lastname .=
'</td></tr>';
230 print $html_contact_lastname;
232 $html_contact_firstname =
'';
233 $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>';
234 $html_contact_firstname .=
'<input type="text" id="contact_firstname" name="contact_firstname" value="' .
dol_escape_htmltag(GETPOSTISSET(
'contact_firstname') ?
GETPOST(
'contact_firstname',
'alphanohtml') :
'') .
'" />';
235 $html_contact_firstname .=
'</td></tr>';
236 print $html_contact_firstname;
238 $html_company_name =
'';
239 $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>';
240 $html_company_name .=
'<input type="text" id="company_name" name="company_name" value="' .
dol_escape_htmltag(GETPOSTISSET(
'company_name') ?
GETPOST(
'company_name',
'alphanohtml') :
'') .
'" />';
241 $html_company_name .=
'</td></tr>';
242 print $html_company_name;
244 $html_contact_phone =
'';
245 $html_contact_phone .=
'<tr id="contact_phone_line" class="contact_field"><td><label for="contact_phone"><span>' . $langs->trans(
'Phone') .
'</span></label></td><td>';
246 $html_contact_phone .=
'<input type="text" id="contact_phone" name="contact_phone" value="' .
dol_escape_htmltag(GETPOSTISSET(
'contact_phone') ?
GETPOST(
'contact_phone',
'alphanohtml') :
'') .
'" />';
247 $html_contact_phone .=
'</td></tr>';
248 print $html_contact_phone;
251 $langs->load(
'errors');
252 print
'<script nonce="'.getNonce().
'" type="text/javascript">
253 jQuery(document).ready(function() {
254 var contact = jQuery.parseJSON("'.
dol_escape_js(json_encode($with_contact), 2).
'");
255 jQuery("#contact_search_line").hide();
257 if (contact.id > 0) {
258 jQuery("#contact_search_line").show();
259 jQuery("#contact_id").val(contact.id);
260 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
261 jQuery(".contact_field").hide();
263 jQuery(".contact_field").show();
267 jQuery("#email").change(function() {
268 jQuery("#contact_search_line").show();
269 jQuery("#contact_search_result").html("'.
dol_escape_js($langs->trans(
'Select2SearchInProgress')).
'");
270 jQuery("#contact_id").val("");
271 jQuery("#contact_lastname").val("");
272 jQuery("#contact_firstname").val("");
273 jQuery("#company_name").val("");
274 jQuery("#contact_phone").val("");
279 action: "getContacts",
280 email: jQuery("#email").val()
283 if (response.error) {
284 jQuery("#contact_search_result").html("<span class=\"error\">"+response.error+"</span>");
286 var contact_list = response.contacts;
287 if (contact_list.length == 1) {
288 var contact = contact_list[0];
289 jQuery("#contact_id").val(contact.id);
290 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
291 jQuery(".contact_field").hide();
292 } else if (contact_list.length <= 0) {
293 jQuery("#contact_search_line").hide();
294 jQuery(".contact_field").show();
298 ).fail(function(jqxhr, textStatus, error) {
299 var error_msg = "'.
dol_escape_js($langs->trans(
'ErrorAjaxRequestFailed')).
'"+" ["+textStatus+"] : "+error;
300 jQuery("#contact_search_result").html("<span class=\"error\">"+error_msg+"</span>");
310 if (isset($this->param[
'origin']) && $this->param[
'originid'] > 0) {
312 $element = $subelement = $this->param[
'origin'];
314 if (preg_match(
'/^([^_]+)_([^_]+)/i', $this->param[
'origin'], $regs)) {
316 $subelement = $regs[2];
320 $classname = ucfirst($subelement);
321 $objectsrc =
new $classname($this->db);
322 $objectsrc->fetch(
GETPOST(
'originid',
'int'));
324 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
325 $objectsrc->fetch_lines();
328 $objectsrc->fetch_thirdparty();
329 $newclassname = $classname;
330 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td colspan="2"><input name="'.$subelement.
'id" value="'.
GETPOST(
'originid').
'" type="hidden" />'.$objectsrc->getNomUrl(1).
'</td></tr>';
334 print
'<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans(
"TicketTypeRequest").
'</span></label></td><td>';
339 print
'<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans(
"TicketCategory").
'</span></label></td><td>';
342 $filter =
'public=1';
344 $selected = (
GETPOST(
'category_code') ?
GETPOST(
'category_code') : $this->category_code);
345 $this->
selectGroupTickets($selected,
'category_code', $filter, 2, 1, 0, 0,
'minwidth200');
349 print
'<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans(
"TicketSeverity").
'</span></label></td><td>';
353 if (!empty($conf->knowledgemanagement->enabled)) {
355 print
'<tr id="KWwithajax" class="hidden"><td></td></tr>';
356 print
'<!-- Script to manage change of ticket group -->
357 <script nonce="'.getNonce().
'">
358 jQuery(document).ready(function() {
359 function groupticketchange() {
360 console.log("We called groupticketchange, so we try to load list KM linked to event");
361 $("#KWwithajax").html("");
362 idgroupticket = $("#selectcategory_code").val();
364 console.log("We have selected id="+idgroupticket);
366 if (idgroupticket != "") {
367 $.ajax({ url: \''.DOL_URL_ROOT.
'/core/ajax/fetchKnowledgeRecord.php\',
368 data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.newToken().
'\', lang:\
''.$langs->defaultlang.
'\',
public:
'.($public).' },
370 success: function(response) {
372 console.log("We received response "+response);
373 if (typeof response == "object") {
374 console.log("response is already type object, no need to parse it");
376 console.log("response is type "+(typeof response));
377 response = JSON.parse(response);
379 for (key in response) {
380 answer = response[key].answer;
381 urllist += \'<li><a href="#" title="\'+response[key].title+\'" class="button_KMpopup" data-html="\'+answer+\'">\' +response[key].title+\'</a></li>\';
384 $("#KWwithajax").html(\'<td>'.$langs->trans(
"KMFoundForTicketGroup").
'</td><td><ul>\'+urllist+\'</ul></td>\');
385 $("#KWwithajax").show();
386 $(".button_KMpopup").on("click",function(){
387 console.log("Open popup with jQuery(...).dialog() with KM article")
388 var $dialog = $("<div></div>").html($(this).attr("data-html"))
392 height: (window.innerHeight - 150),
394 title: $(this).attr("title"),
396 $dialog.dialog("open");
397 console.log($dialog);
401 error : function(output) {
402 console.error("Error on Fetch of KM articles");
407 $("#selectcategory_code").on("change",function() { groupticketchange(); });
408 if ($("#selectcategory_code").val() != "") {
416 if ($this->withtitletopic) {
417 print
'<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans(
"Subject").
'</span></label></td><td>';
419 if ($this->withtopicreadonly) {
420 print $langs->trans(
'SubjectAnswerToTicket').
' '.$this->topic_title;
422 if (isset($this->withreadid) && $this->withreadid > 0) {
423 $subject = $langs->trans(
'SubjectAnswerToTicket').
' '.$this->withreadid.
' : '.$this->topic_title;
425 $subject =
GETPOST(
'subject',
'alpha');
427 print
'<input class="text minwidth500" id="subject" name="subject" value="'.$subject.
'"'.(empty($this->withemail)?
' autofocus':
'').
' />';
433 $msg = GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') :
'';
434 print
'<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span></label></td><td>';
437 $toolbarname =
'dolibarr_notes';
438 if ($this->ispublic) {
439 $toolbarname =
'dolibarr_details';
440 print
'<div class="warning hideonsmartphone">'.(getDolGlobalString(
"TICKET_PUBLIC_TEXT_HELP_MESSAGE", $langs->trans(
'TicketPublicPleaseBeAccuratelyDescribe'))).
'</div>';
442 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
443 $uselocalbrowser =
true;
444 $doleditor =
new DolEditor(
'message', $msg,
'100%', 230, $toolbarname,
'In',
true, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_TICKET'), ROWS_8,
'90%');
445 $doleditor->Create();
448 if ($public && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
449 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
450 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td>';
451 print
'<span class="span-icon-security inline-block">';
452 print
'<input id="securitycode" placeholder="'.$langs->trans(
"SecurityCode").
'" class="flat input-icon-security width125" type="text" maxlength="5" name="code" tabindex="3" />';
454 print
'<span class="nowrap inline-block">';
455 print
'<img class="inline-block valignmiddle" src="'.DOL_URL_ROOT.
'/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />';
456 print
'<a class="inline-block valignmiddle" href="" tabindex="4" data-role="button">'.img_picto($langs->trans(
"Refresh"),
'refresh',
'id="captcha_refresh_img"').
'</a>';
462 if (isModEnabled(
'categorie')) {
463 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
464 $cate_arbo = $form->select_all_categories(Categorie::TYPE_TICKET,
'',
'parent', 64, 0, 1);
466 if (count($cate_arbo)) {
468 print
'<tr><td class="wordbreak">'.$langs->trans(
"Categories").
'</td><td>';
469 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
475 if (!empty($this->withfile)) {
477 $listofpaths = array();
478 $listofnames = array();
479 $listofmimes = array();
480 if (!empty($_SESSION[
"listofpaths"])) {
481 $listofpaths = explode(
';', $_SESSION[
"listofpaths"]);
484 if (!empty($_SESSION[
"listofnames"])) {
485 $listofnames = explode(
';', $_SESSION[
"listofnames"]);
488 if (!empty($_SESSION[
"listofmimes"])) {
489 $listofmimes = explode(
';', $_SESSION[
"listofmimes"]);
493 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
496 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
497 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
498 $out .=
'jQuery(document).ready(function () {';
499 $out .=
' jQuery(".removedfile").click(function() {';
500 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
503 $out .=
'</script>'.
"\n";
504 if (count($listofpaths)) {
505 foreach ($listofpaths as $key => $val) {
506 $out .=
'<div id="attachfile_'.$key.
'">';
507 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
508 if (!$this->withfilereadonly) {
509 $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.
'" />';
511 $out .=
'<br></div>';
514 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
516 if ($this->withfile == 2) {
518 $maxmin = $maxfilesizearray[
'maxmin'];
520 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
522 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
524 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="addfile" name="addfile" value="'.$langs->trans(
"MailingAddFile").
'" />';
526 $out .=
"</td></tr>\n";
532 if ($this->withusercreate > 0 && $this->fk_user_create) {
533 print
'<tr><td class="titlefield">'.$langs->trans(
"CreatedBy").
'</td><td>';
534 $langs->load(
"users");
535 $fuser =
new User($this->db);
537 if ($this->withcreatereadonly) {
538 if ($res = $fuser->fetch($this->fk_user_create)) {
539 print $fuser->getNomUrl(1);
543 print
"</td></tr>\n";
547 if ($this->withcompany) {
549 if (empty($user->socid)) {
551 print
'<tr><td class="titlefield">'.$langs->trans(
"ThirdParty").
'</td><td>';
553 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
554 print
img_picto(
'',
'company',
'class="paddingright"');
555 print $form->select_company($this->withfromsocid,
'socid',
'', 1, 1,
'', $events, 0,
'minwidth200');
557 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
559 print
'<script nonce="'.getNonce().
'" type="text/javascript">
560 $(document).ready(function () {
561 jQuery("#'.$htmlname.
'").change(function () {
562 var obj = '.json_encode($events).
';
563 $.each(obj, function(key,values) {
564 if (values.method.length) {
565 runJsCodeForEvent'.$htmlname.
'(values);
570 function runJsCodeForEvent'.$htmlname.
'(obj) {
571 console.log("Run runJsCodeForEvent'.$htmlname.
'");
572 var id = $("#'.$htmlname.
'").val();
573 var method = obj.method;
575 var htmlname = obj.htmlname;
576 var showempty = obj.showempty;
585 $.each(obj.params, function(key,action) {
587 var num = response.num;
589 $("#" + key).removeAttr(action);
591 $("#" + key).attr(action, action);
595 $("select#" + htmlname).html(response.value);
597 var selecthtml_str = response.value;
598 var selecthtml_dom=$.parseHTML(selecthtml_str);
599 if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
600 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
603 $("#inputautocomplete"+htmlname).val("");
605 $("select#" + htmlname).change(); /* Trigger event change */
614 print
'<tr><td>'.$langs->trans(
"Contact").
'</td><td>';
616 $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
617 print
img_picto(
'',
'contact',
'class="paddingright"');
618 print $form->selectcontacts($selectedCompany, $this->withfromcontactid,
'contactid', 3,
'',
'', 0,
'minwidth200');
620 $formcompany->selectTypeContact($ticketstatic,
'',
'type',
'external',
'', 0,
'maginleftonly');
623 print
'<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.
'"/></td>';
624 print
'<td><input type="hidden" name="contactid" value="'.$user->contact_id.
'"/></td>';
625 print
'<td><input type="hidden" name="type" value="Z"/></td></tr>';
629 if (empty($this->ispublic)) {
630 print
'<tr><td><label for="notify_tiers_at_create">'.$langs->trans(
"TicketNotifyTiersAtCreation").
'</label></td><td>';
631 print
'<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ?
' checked="checked"' :
'').
'>';
637 print $langs->trans(
"AssignedTo");
639 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
640 print $form->select_dolusers(
GETPOST(
'fk_user_assign',
'int'),
'fk_user_assign', 1);
645 if ($subelement !=
'project') {
646 if (isModEnabled(
'project') && !$this->ispublic) {
648 print
'<tr><td><label for="project"><span class="">'.$langs->trans(
"Project").
'</span></label></td><td>';
649 print
img_picto(
'',
'project').$formproject->select_projects(-1,
GETPOST(
'projectid',
'int'),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
655 $parameters = array();
656 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $ticketstat, $action);
657 if (empty($reshook)) {
658 print $ticketstat->showOptionals($extrafields,
'create');
663 if ($withdolfichehead) {
669 print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"CreateTicket"), ($this->withcancel ?
"Cancel" :
""));
681 print
'<input type="hidden" name="page_y">'.
"\n";
684 print
"<!-- End form TICKET -->\n";
701 public function selectTypesTickets($selected =
'', $htmlname =
'tickettype', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $multiselect = 0)
703 global $langs, $user;
705 $selected = is_array($selected) ? $selected : (!empty($selected) ? explode(
',', $selected) : array());
706 $ticketstat =
new Ticket($this->db);
708 dol_syslog(get_class($this) .
"::select_types_tickets " . implode(
';', $selected) .
", " . $htmlname .
", " . $filtertype .
", " . $format .
", " . $multiselect, LOG_DEBUG);
710 $filterarray = array();
712 if ($filtertype !=
'' && $filtertype !=
'-1') {
713 $filterarray = explode(
',', $filtertype);
716 $ticketstat->loadCacheTypesTickets();
718 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.($multiselect?
'[]':
'').
'"'.($multiselect?
' multiple':
'').
'>';
720 print
'<option value=""> </option>';
723 if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
724 foreach ($ticketstat->cache_types_tickets as $id => $arraytypes) {
726 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
731 if ($empty && empty($arraytypes[
'code'])) {
736 print
'<option value="'.$id.
'"';
740 print
'<option value="'.$arraytypes[
'code'].
'"';
744 print
'<option value="'.$arraytypes[
'code'].
'"';
748 print
'<option value="'.$id.
'"';
752 if (in_array($arraytypes[
'code'], $selected)) {
753 print
' selected="selected"';
754 } elseif (in_array($id, $selected)) {
755 print
' selected="selected"';
756 } elseif ($arraytypes[
'use_default'] ==
"1" && !$selected && !$empty) {
757 print
' selected="selected"';
764 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
765 } elseif ($format == 1) {
766 $value = $arraytypes[
'code'];
767 } elseif ($format == 2) {
768 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
769 } elseif ($format == 3) {
770 $value = $arraytypes[
'code'];
773 print $value ? $value :
' ';
778 if (isset($user->admin) && $user->admin && !$noadmininfo) {
779 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
800 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs =
null)
802 global $conf, $langs, $user;
804 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
806 if (is_null($outputlangs) || !is_object($outputlangs)) {
807 $outputlangs = $langs;
809 $outputlangs->load(
"ticket");
811 $publicgroups = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
813 $ticketstat =
new Ticket($this->db);
814 $ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1);
816 if ($use_multilevel <= 0) {
817 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
819 print
'<option value=""> </option>';
822 if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
823 foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
826 if (empty($arraycategories[
'public'])) {
832 if ($empty && empty($arraycategories[
'code'])) {
836 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
837 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) != (
"TicketCategoryShort".$arraycategories[
'code'])) {
838 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
839 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
840 $label = $outputlangs->trans($arraycategories[
'code']);
844 print
'<option value="'.$id.
'"';
848 print
'<option value="'.$arraycategories[
'code'].
'"';
852 print
'<option value="'.$arraycategories[
'code'].
'"';
856 print
'<option value="'.$id.
'"';
860 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
861 print
' selected="selected"';
862 } elseif (isset($selected) && $selected == $id) {
863 print
' selected="selected"';
864 } elseif ($arraycategories[
'use_default'] ==
"1" && !$selected && !$empty) {
865 print
' selected="selected"';
866 } elseif (count($ticketstat->cache_category_tickets) == 1) {
867 print
' selected="selected"';
874 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
878 $value = $arraycategories[
'code'];
882 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
886 $value = $arraycategories[
'code'];
889 print $value ? $value :
' ';
894 if (isset($user->admin) && $user->admin && !$noadmininfo) {
895 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
899 } elseif ($htmlname!=
'') {
900 $selectedgroups = array();
902 $groupticket=
GETPOST($htmlname,
'aZ09');
903 $child_id=
GETPOST($htmlname.
'_child_id',
'aZ09')?
GETPOST($htmlname.
'_child_id',
'aZ09'):0;
904 if (!empty($groupticket)) {
905 $tmpgroupticket = $groupticket;
906 $sql =
"SELECT ctc.rowid, ctc.fk_parent, ctc.code";
907 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc WHERE ctc.code = '".$this->db->escape($tmpgroupticket).
"'";
908 $resql = $this->db->query($sql);
910 $obj = $this->db->fetch_object($resql);
911 $selectedgroups[] = $obj->code;
912 while ($obj->fk_parent > 0) {
913 $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).
"'";
914 $resql = $this->db->query($sql);
916 $obj = $this->db->fetch_object($resql);
917 $selectedgroups[] = $obj->code;
923 $arrayidused = array();
924 $arrayidusedconcat = array();
925 $arraycodenotparent = array();
926 $arraycodenotparent[] =
"";
928 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
929 $stringtoprint .=
'<select id ="'.$htmlname.
'" class="minwidth500" child_id="0">';
930 $stringtoprint .=
'<option value=""> </option>';
932 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
933 $sql .= $this->db->ifsql(
"ctc.rowid NOT IN (SELECT ctcfather.rowid FROM llx_c_ticket_category as ctcfather JOIN llx_c_ticket_category as ctcjoin ON ctcfather.rowid = ctcjoin.fk_parent)",
"'NOTPARENT'",
"'PARENT'").
" as isparent";
934 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
935 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
936 if ($filtertype ==
'public=1') {
937 $sql .=
" AND ctc.public = 1";
939 $sql .=
" AND ctc.fk_parent = 0";
940 $sql .= $this->db->order(
'ctc.pos',
'ASC');
942 $resql = $this->db->query($sql);
944 $num_rows_level0 = $this->db->num_rows($resql);
946 while ($i < $num_rows_level0) {
947 $obj = $this->db->fetch_object($resql);
949 $label = ($obj->label !=
'-' ? $obj->label :
'');
950 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
951 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
952 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
953 $label = $outputlangs->trans($obj->code);
956 $grouprowid = $obj->rowid;
957 $groupvalue = $obj->code;
958 $grouplabel = $label;
960 $isparent = $obj->isparent;
961 if (is_array($selectedgroups)) {
962 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
964 $iselected = $groupticket == $obj->code ?
'selected':
'';
967 if ($isparent ==
'NOTPARENT') {
968 $arraycodenotparent[] = $groupvalue;
970 $arrayidused[] = $grouprowid;
971 $arrayidusedconcat[] = $grouprowid;
978 if (count($arrayidused) == 1) {
979 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
981 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400">';
982 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400">';
984 $stringtoprint .=
'</select> ';
987 while ($levelid <= $use_multilevel) {
988 $tabscript = array();
989 $stringtoprint .=
'<select id ="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
990 $stringtoprint .=
'<option value=""> </option>';
992 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
993 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
994 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
995 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
996 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(join(
',', $arrayidusedconcat)).
")";
998 if ($filtertype ==
'public=1') {
999 $sql .=
" AND ctc.public = 1";
1002 if (!empty($arrayidused)) {
1003 $sql .=
" AND ctc.fk_parent IN ( ";
1004 foreach ($arrayidused as $idused) {
1005 $sql .= $idused.
", ";
1007 $sql = substr($sql, 0, -2);
1010 $sql .= $this->db->order(
'ctc.pos',
'ASC');
1012 $resql = $this->db->query($sql);
1014 $num_rows = $this->db->num_rows($resql);
1016 $arrayidused=array();
1017 while ($i < $num_rows) {
1018 $obj = $this->db->fetch_object($resql);
1020 $label = ($obj->label !=
'-' ? $obj->label :
'');
1021 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
1022 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1023 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1024 $label = $outputlangs->trans($obj->code);
1027 $grouprowid = $obj->rowid;
1028 $groupvalue = $obj->code;
1029 $grouplabel = $label;
1030 $isparent = $obj->isparent;
1031 $fatherid = $obj->fk_parent;
1032 $arrayidused[] = $grouprowid;
1033 $arrayidusedconcat[] = $grouprowid;
1034 $groupcodefather = $obj->codefather;
1035 if ($isparent ==
'NOTPARENT') {
1036 $arraycodenotparent[] = $groupvalue;
1038 if (is_array($selectedgroups)) {
1039 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
1041 $iselected = $groupticket == $obj->code ?
'selected':
'';
1044 if (empty($tabscript[$groupcodefather])) {
1045 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").val() == "'.
dol_escape_js($groupcodefather).
'"){
1047 console.log("We show childs tickets of '.$groupcodefather.
' group ticket")
1050 console.log("We hide childs tickets of '.$groupcodefather.
' group ticket")
1059 $stringtoprint .=
'</select>';
1061 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1062 $stringtoprint .=
'arraynotparents = '.json_encode($arraycodenotparent).
';';
1063 $stringtoprint .=
'if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").val())){
1064 console.log("'.$htmlname.
'_child_'.$levelid.
'")
1065 if($("#'.$htmlname.
'_child_'.$levelid.
'").val() == "" && ($("#'.$htmlname.
'_child_'.$levelid.
'").attr("child_id")>'.$child_id.
')){
1066 $("#'.$htmlname.
'_child_'.$levelid.
'").hide();
1067 console.log("We hide '.$htmlname.
'_child_'.$levelid.
' input")
1069 if(arraynotparents.includes("'.$groupticket.
'") && '.$child_id.
' == 0){
1070 $("#ticketcategory_select_child_id").val($("#'.$htmlname.
'").attr("child_id"))
1071 $("#ticketcategory_select").val($("#'.$htmlname.
'").val()) ;
1072 console.log("We choose '.$htmlname.
' input and reload hidden input");
1075 $("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").change(function() {
1076 child_id = $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid:
'').
'").attr("child_id");
1078 /* Change of value to select this value*/
1079 if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.
') {
1080 $("#ticketcategory_select").val($(this).val());
1081 $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1082 console.log("We choose to select "+ $(this).val());
1084 if ($("#'.$htmlname.
'_child_'.$levelid.
' option").length <= 1) {
1085 $("#ticketcategory_select").val($(this).val());
1086 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1087 console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1089 console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1090 $("#ticketcategory_select").val("");
1091 $("#ticketcategory_select_child_id").val("");
1095 console.log("We select a new value into combo child_id="+child_id);
1097 // Hide all selected box that are child of the one modified
1098 $(".groupticketchild").each(function(){
1099 if ($(this).attr("child_id") > child_id) {
1100 console.log("hide child_id="+$(this).attr("child_id"));
1106 // Now we enable the next combo
1107 $("#'.$htmlname.
'_child_'.$levelid.
'").val("");
1108 if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.
'_child_'.$levelid.
' option").length > 1) {
1109 console.log($("#'.$htmlname.
'_child_'.$levelid.
' option").length);
1110 $("#'.$htmlname.
'_child_'.$levelid.
'").show()
1112 $("#'.$htmlname.
'_child_'.$levelid.
'").hide()
1116 foreach ($tabscript as $script) {
1117 $stringtoprint .= $script;
1119 $stringtoprint .=
'})';
1120 $stringtoprint .=
'</script>';
1122 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1123 $stringtoprint .=
'$("#'.$htmlname.
'_child_'.$use_multilevel.
'").change(function() {
1124 $("#ticketcategory_select").val($(this).val());
1125 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1126 console.log($("#ticketcategory_select").val());
1128 $stringtoprint .=
'</script>';
1131 return $stringtoprint;
1148 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
1150 global $langs, $user;
1152 $ticketstat =
new Ticket($this->db);
1154 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1156 $filterarray = array();
1158 if ($filtertype !=
'' && $filtertype !=
'-1') {
1159 $filterarray = explode(
',', $filtertype);
1162 $ticketstat->loadCacheSeveritiesTickets();
1164 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1166 print
'<option value=""> </option>';
1169 if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
1170 foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
1172 if (count($filterarray) && !in_array($arrayseverities[
'type'], $filterarray)) {
1177 if ($empty && empty($arrayseverities[
'code'])) {
1182 print
'<option value="'.$id.
'"';
1186 print
'<option value="'.$arrayseverities[
'code'].
'"';
1190 print
'<option value="'.$arrayseverities[
'code'].
'"';
1194 print
'<option value="'.$id.
'"';
1198 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
1199 print
' selected="selected"';
1200 } elseif (isset($selected) && $selected == $id) {
1201 print
' selected="selected"';
1202 } elseif ($arrayseverities[
'use_default'] ==
"1" && !$selected && !$empty) {
1203 print
' selected="selected"';
1210 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1214 $value = $arrayseverities[
'code'];
1218 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1222 $value = $arrayseverities[
'code'];
1225 print $value ? $value :
' ';
1230 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1231 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1246 global $conf, $user;
1247 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1250 $vardir = $conf->user->dir_output.
"/".$user->id;
1251 $upload_dir = $vardir.
'/temp/';
1252 if (is_dir($upload_dir)) {
1256 if (!empty($this->trackid)) {
1257 $keytoavoidconflict =
'-'.$this->trackid;
1259 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1261 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
1262 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
1263 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
1274 global $conf, $langs, $user, $hookmanager, $form, $mysoc;
1276 $formmail =
new FormMail($this->db);
1277 $addfileaction =
'addfile';
1279 if (!is_object($form)) {
1280 $form =
new Form($this->db);
1284 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
1287 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1288 $this->clear_attached_files();
1292 $outputlangs = $langs;
1294 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1295 $newlang = $this->param[
'langsmodels'];
1297 if (!empty($newlang)) {
1298 $outputlangs =
new Translate(
"", $conf);
1299 $outputlangs->setDefaultLang($newlang);
1300 $outputlangs->load(
'other');
1304 $arraydefaultmessage = -1;
1305 if (isset($this->param[
'models']) && $this->param[
'models'] !=
'none') {
1307 if (array_key_exists(
'models_id', $this->param)) {
1308 $model_id = (int) $this->param[
"models_id"];
1311 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id);
1315 $listofpaths = array();
1316 $listofnames = array();
1317 $listofmimes = array();
1319 if (!empty($this->trackid)) {
1320 $keytoavoidconflict =
'-'.$this->trackid;
1322 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1325 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1326 if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param[
'fileinit']) && is_array($this->param[
'fileinit'])) {
1327 foreach ($this->param[
'fileinit'] as $file) {
1328 $formmail->add_attached_files($file, basename($file),
dol_mimetype($file));
1334 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
1335 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
1337 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
1338 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
1340 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
1341 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
1345 $outputlangs = $langs;
1347 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1348 $newlang = $this->param[
'langsmodels'];
1350 if (!empty($newlang)) {
1351 $outputlangs =
new Translate(
"", $conf);
1352 $outputlangs->setDefaultLang($newlang);
1353 $outputlangs->load(
'other');
1356 print
"\n<!-- Begin message_form TICKET -->\n";
1358 $send_email =
GETPOST(
'send_email',
'int') ?
GETPOST(
'send_email',
'int') : 0;
1361 print
'<script nonce="'.getNonce().
'" type="text/javascript">
1362 jQuery(document).ready(function() {
1363 send_email=' . $send_email.
';
1365 if (!jQuery("#send_msg_email").is(":checked")) {
1366 jQuery("#send_msg_email").prop("checked", true).trigger("change");
1368 jQuery(".email_line").show();
1370 if (!jQuery("#private_message").is(":checked")) {
1371 jQuery("#private_message").prop("checked", true).trigger("change");
1373 jQuery(".email_line").hide();
1378 if (empty($conf->global->TICKET_SEND_PRIVATE_EMAIL)) {
1379 print
'jQuery("#send_msg_email").click(function() {
1380 console.log("Click send_msg_email");
1381 if(jQuery(this).is(":checked")) {
1382 if (jQuery("#private_message").is(":checked")) {
1383 jQuery("#private_message").prop("checked", false).trigger("change");
1385 jQuery(".email_line").show();
1388 jQuery(".email_line").hide();
1392 jQuery("#private_message").click(function() {
1393 console.log("Click private_message");
1394 if (jQuery(this).is(":checked")) {
1395 if (jQuery("#send_msg_email").is(":checked")) {
1396 jQuery("#send_msg_email").prop("checked", false).trigger("change");
1398 jQuery(".email_line").hide();
1407 print
'<form method="post" name="ticket" id="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
1408 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1409 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
1410 print
'<input type="hidden" name="actionbis" value="add_message">';
1411 print
'<input type="hidden" name="backtopage" value="'.$this->backtopage.
'">';
1412 if (!empty($this->trackid)) {
1413 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
1415 print
'<input type="hidden" name="trackid" value="'.(empty($this->track_id) ?
'' : $this->track_id).
'">';
1416 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1418 foreach ($this->param as $key => $value) {
1419 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
1424 if (array_key_exists(
'models_id', $this->param)) {
1425 $model_id = $this->param[
"models_id"];
1426 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id);
1429 $result = $formmail->fetchAllEMailTemplate(!empty($this->param[
"models"]) ? $this->param[
"models"] :
"", $user, $outputlangs);
1433 $modelmail_array = array();
1434 foreach ($formmail->lines_model as $line) {
1435 $modelmail_array[$line->id] = $line->label;
1438 print
'<table class="border" width="'.$width.
'">';
1441 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1442 $ticketstat =
new Ticket($this->db);
1443 $res = $ticketstat->fetch(
'',
'', $this->track_id);
1445 print
'<tr><td></td><td>';
1446 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : (
getDolGlobalInt(
'TICKETS_MESSAGE_FORCE_MAIL')?
'checked':
''));
1447 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1448 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1449 $texttooltip = $langs->trans(
"TicketMessageSendEmailHelp");
1450 if (empty($conf->global->TICKET_SEND_PRIVATE_EMAIL)) {
1451 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2b");
1453 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2a",
'{s1}');
1455 $texttooltip = str_replace(
'{s1}', $langs->trans(
'MarkMessageAsPrivate'), $texttooltip);
1456 print
' '.$form->textwithpicto(
'', $texttooltip, 1,
'help');
1460 if (!$user->socid) {
1461 print
'<tr><td></td><td>';
1462 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1463 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1464 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1465 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1470 if (count($modelmail_array) > 0) {
1471 print
'<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'.
"\n";
1472 print $langs->trans(
'SelectMailModel').
': '.$formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], 1, 0,
"",
"", 0, 0, 0,
'',
'minwidth200');
1474 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1477 print
'<input type="submit" class="button" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1478 print
'</div></td>';
1482 print
'<tr class="email_line"><td>'.$langs->trans(
'Subject').
'</td>';
1483 print
'<td><input type="text" class="text minwidth500" name="subject" value="['.getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
' - '.$langs->trans(
"Ticket").
' '.$ticketstat->ref.
'] '.$langs->trans(
'TicketNewMessage').
'" />';
1487 print
'<tr class="email_line"><td>'.$langs->trans(
'MailRecipients');
1488 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessageRecipientsHelp"), 1,
'help');
1492 $contacts = $ticketstat->getInfosTicketInternalContact(1);
1493 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact(1));
1498 if (is_array($contacts) && count($contacts) > 0) {
1499 foreach ($contacts as $key => $info_sendto) {
1500 if ($info_sendto[
'email'] !=
'') {
1501 $sendto[] =
dol_escape_htmltag(trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">").
' <small class="opacitymedium">('.
dol_escape_htmltag($info_sendto[
'libelle']).
")</small>";
1506 if ($ticketstat->origin_email && !in_array($ticketstat->origin_email, $sendto)) {
1507 $sendto[] =
dol_escape_htmltag($ticketstat->origin_email).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
1510 if ($ticketstat->fk_soc > 0) {
1511 $ticketstat->socid = $ticketstat->fk_soc;
1512 $ticketstat->fetch_thirdparty();
1514 if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
1515 $sendto[] = $ticketstat->thirdparty->email.
' <small class="opacitymedium">('.$langs->trans(
'Customer').
')</small>';
1520 $sendto[] =
getDolGlobalString(
'TICKET_NOTIFICATION_EMAIL_TO').
' <small class="opacitymedium">(generic email)</small>';
1524 if (is_array($sendto) && count($sendto) > 0) {
1525 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
1526 print implode(
', ', $sendto);
1528 print
'<div class="warning">'.$langs->trans(
'WarningNoEMailsAdded').
' '.$langs->trans(
'TicketGoIntoContactTab').
'</div>';
1534 $uselocalbrowser =
false;
1556 if (!empty($this->withfile)) {
1558 $out .=
'<td width="180">'.$langs->trans(
"MailFile").
'</td>';
1561 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1562 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
1563 $out .=
'jQuery(document).ready(function () {';
1564 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1565 $out .=
' jQuery("#addedfile").on("change", function() {';
1566 $out .=
' if (jQuery(this).val().length) {';
1567 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", false);';
1568 $out .=
' } else {';
1569 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1572 $out .=
' jQuery(".removedfile").click(function() {';
1573 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1576 $out .=
'</script>'.
"\n";
1578 if (count($listofpaths)) {
1579 foreach ($listofpaths as $key => $val) {
1580 $out .=
'<div id="attachfile_'.$key.
'">';
1581 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1582 if (!$this->withfilereadonly) {
1583 $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.
'" />';
1585 $out .=
'<br></div>';
1590 if ($this->withfile == 2) {
1591 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1593 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1595 $out .=
"</td></tr>\n";
1602 $defaultmessage =
"";
1603 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1604 $defaultmessage = $arraydefaultmessage->content;
1606 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1610 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1611 } elseif (!
dol_textishtml($defaultmessage) && isset($this->substit[
'__USER_SIGNATURE__']) &&
dol_textishtml($this->substit[
'__USER_SIGNATURE__'])) {
1612 $defaultmessage =
dol_nl2br($defaultmessage);
1614 if (GETPOSTISSET(
"message") && !
GETPOST(
'modelselected')) {
1615 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1619 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1620 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1623 print
'<tr><td colspan="2"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1624 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1625 $texttooltip = $langs->trans(
"TicketMessageHelp");
1627 $texttooltip .=
'<br><br>'.$langs->trans(
"ForEmailMessageWillBeCompletedWith").
'...';
1630 $texttooltip .=
'<br><u>'.$langs->trans(
"TicketMessageMailIntro").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO');
1633 $texttooltip .=
'<br><br><u>'.$langs->trans(
"TicketMessageMailFooter").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_SIGNATURE');
1635 print $form->textwithpicto(
'', $texttooltip, 1,
'help');
1637 print
'</label></td></tr>';
1640 print
'<tr><td colspan="2">';
1642 $toolbarname =
'dolibarr_notes';
1643 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1644 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, 70);
1645 $doleditor->Create();
1664 print
'<center><br>';
1665 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"Add").
'"';
1667 if ($this->withfile == 2 && !empty($conf->use_javascript_ajax)) {
1668 print
' onClick="if (document.ticket.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans(
"FileWasNotUploaded")).
'\');
return false; }
else {
return true; }
"';
1671 if (!empty($this->withcancel)) {
1672 print "
";
1673 print '<input class="button button-cancel
" type="submit
" name="cancel
" value="'.$langs->trans("Cancel").'">';
1675 print "</center>\n
";
1677 print '<input type="hidden
" name="page_y
">'."\n
";
1681 // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
1682 if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) {
1683 print '<script type="text/javascript
">';
1684 print 'jQuery(document).ready(function () {';
1685 print ' $(document).on("keypress
", \'#ticket\', function (e) { /* Note this is called at every key pressed ! */
1686 var code = e.keyCode || e.which;
1688 console.log("Enter was intercepted and blocked
");
1697 print "<!-- End form TICKET -->\n
";
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)
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_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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 dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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...
ui dialog ui datepicker calendar ui widget content ui state ui datepicker calendar ui widget header ui state ui datepicker calendar ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
Class to generate the form for creating a new ticket.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
getMaxFileSizeArray()
Return the max allowed for file upload.