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>';
335 $this->
selectTypesTickets((
GETPOST(
'type_code',
'alpha') ?
GETPOST(
'type_code',
'alpha') : $this->type_code),
'type_code',
'', 2,
'ifone', 0, 0,
'minwidth200');
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,
'ifone', 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="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</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" && empty($selected) && !$multiselect) {
757 print
' selected="selected"';
758 } elseif (count($ticketstat->cache_types_tickets) == 1 && (!$empty || $empty ==
'ifone')) {
759 print
' selected="selected"';
766 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
767 } elseif ($format == 1) {
768 $value = $arraytypes[
'code'];
769 } elseif ($format == 2) {
770 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
771 } elseif ($format == 3) {
772 $value = $arraytypes[
'code'];
775 print $value ? $value :
' ';
780 if (isset($user->admin) && $user->admin && !$noadmininfo) {
781 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
802 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs =
null)
804 global $conf, $langs, $user;
806 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
808 if (is_null($outputlangs) || !is_object($outputlangs)) {
809 $outputlangs = $langs;
811 $outputlangs->load(
"ticket");
813 $publicgroups = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
815 $ticketstat =
new Ticket($this->db);
816 $ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1);
818 if ($use_multilevel <= 0) {
819 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
821 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
824 if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
825 foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
828 if (empty($arraycategories[
'public'])) {
834 if ($empty && empty($arraycategories[
'code'])) {
838 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
839 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) != (
"TicketCategoryShort".$arraycategories[
'code'])) {
840 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
841 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
842 $label = $outputlangs->trans($arraycategories[
'code']);
846 print
'<option value="'.$id.
'"';
850 print
'<option value="'.$arraycategories[
'code'].
'"';
854 print
'<option value="'.$arraycategories[
'code'].
'"';
858 print
'<option value="'.$id.
'"';
862 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
863 print
' selected="selected"';
864 } elseif (isset($selected) && $selected == $id) {
865 print
' selected="selected"';
866 } elseif ($arraycategories[
'use_default'] ==
"1" && !$selected && (!$empty || $empty ==
'ifone')) {
867 print
' selected="selected"';
868 } elseif (count($ticketstat->cache_category_tickets) == 1 && (!$empty || $empty ==
'ifone')) {
869 print
' selected="selected"';
876 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
880 $value = $arraycategories[
'code'];
884 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
888 $value = $arraycategories[
'code'];
891 print $value ? $value :
' ';
896 if (isset($user->admin) && $user->admin && !$noadmininfo) {
897 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
901 } elseif ($htmlname!=
'') {
902 $selectedgroups = array();
904 $groupticket=
GETPOST($htmlname,
'aZ09');
905 $child_id=
GETPOST($htmlname.
'_child_id',
'aZ09')?
GETPOST($htmlname.
'_child_id',
'aZ09'):0;
906 if (!empty($groupticket)) {
907 $tmpgroupticket = $groupticket;
908 $sql =
"SELECT ctc.rowid, ctc.fk_parent, ctc.code";
909 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc WHERE ctc.code = '".$this->db->escape($tmpgroupticket).
"'";
910 $resql = $this->db->query($sql);
912 $obj = $this->db->fetch_object($resql);
913 $selectedgroups[] = $obj->code;
914 while ($obj->fk_parent > 0) {
915 $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).
"'";
916 $resql = $this->db->query($sql);
918 $obj = $this->db->fetch_object($resql);
919 $selectedgroups[] = $obj->code;
925 $arrayidused = array();
926 $arrayidusedconcat = array();
927 $arraycodenotparent = array();
928 $arraycodenotparent[] =
"";
930 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
931 $stringtoprint .=
'<select id ="'.$htmlname.
'" class="minwidth500" child_id="0">';
932 $stringtoprint .=
'<option value=""> </option>';
934 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
935 $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";
936 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
937 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
938 if ($filtertype ==
'public=1') {
939 $sql .=
" AND ctc.public = 1";
941 $sql .=
" AND ctc.fk_parent = 0";
942 $sql .= $this->db->order(
'ctc.pos',
'ASC');
944 $resql = $this->db->query($sql);
946 $num_rows_level0 = $this->db->num_rows($resql);
948 while ($i < $num_rows_level0) {
949 $obj = $this->db->fetch_object($resql);
951 $label = ($obj->label !=
'-' ? $obj->label :
'');
952 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
953 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
954 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
955 $label = $outputlangs->trans($obj->code);
958 $grouprowid = $obj->rowid;
959 $groupvalue = $obj->code;
960 $grouplabel = $label;
962 $isparent = $obj->isparent;
963 if (is_array($selectedgroups)) {
964 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
966 $iselected = $groupticket == $obj->code ?
'selected':
'';
969 if ($isparent ==
'NOTPARENT') {
970 $arraycodenotparent[] = $groupvalue;
972 $arrayidused[] = $grouprowid;
973 $arrayidusedconcat[] = $grouprowid;
980 if (count($arrayidused) == 1) {
981 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
983 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400">';
984 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400">';
986 $stringtoprint .=
'</select> ';
989 while ($levelid <= $use_multilevel) {
990 $tabscript = array();
991 $stringtoprint .=
'<select id ="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
992 $stringtoprint .=
'<option value=""> </option>';
994 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
995 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
996 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
997 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
998 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(join(
',', $arrayidusedconcat)).
")";
1000 if ($filtertype ==
'public=1') {
1001 $sql .=
" AND ctc.public = 1";
1004 if (!empty($arrayidused)) {
1005 $sql .=
" AND ctc.fk_parent IN ( ";
1006 foreach ($arrayidused as $idused) {
1007 $sql .= $idused.
", ";
1009 $sql = substr($sql, 0, -2);
1012 $sql .= $this->db->order(
'ctc.pos',
'ASC');
1014 $resql = $this->db->query($sql);
1016 $num_rows = $this->db->num_rows($resql);
1018 $arrayidused=array();
1019 while ($i < $num_rows) {
1020 $obj = $this->db->fetch_object($resql);
1022 $label = ($obj->label !=
'-' ? $obj->label :
'');
1023 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
1024 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1025 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1026 $label = $outputlangs->trans($obj->code);
1029 $grouprowid = $obj->rowid;
1030 $groupvalue = $obj->code;
1031 $grouplabel = $label;
1032 $isparent = $obj->isparent;
1033 $fatherid = $obj->fk_parent;
1034 $arrayidused[] = $grouprowid;
1035 $arrayidusedconcat[] = $grouprowid;
1036 $groupcodefather = $obj->codefather;
1037 if ($isparent ==
'NOTPARENT') {
1038 $arraycodenotparent[] = $groupvalue;
1040 if (is_array($selectedgroups)) {
1041 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
1043 $iselected = $groupticket == $obj->code ?
'selected':
'';
1046 if (empty($tabscript[$groupcodefather])) {
1047 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").val() == "'.
dol_escape_js($groupcodefather).
'"){
1049 console.log("We show childs tickets of '.$groupcodefather.
' group ticket")
1052 console.log("We hide childs tickets of '.$groupcodefather.
' group ticket")
1061 $stringtoprint .=
'</select>';
1063 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1064 $stringtoprint .=
'arraynotparents = '.json_encode($arraycodenotparent).
';';
1065 $stringtoprint .=
'if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").val())){
1066 console.log("'.$htmlname.
'_child_'.$levelid.
'")
1067 if($("#'.$htmlname.
'_child_'.$levelid.
'").val() == "" && ($("#'.$htmlname.
'_child_'.$levelid.
'").attr("child_id")>'.$child_id.
')){
1068 $("#'.$htmlname.
'_child_'.$levelid.
'").hide();
1069 console.log("We hide '.$htmlname.
'_child_'.$levelid.
' input")
1071 if(arraynotparents.includes("'.$groupticket.
'") && '.$child_id.
' == 0){
1072 $("#ticketcategory_select_child_id").val($("#'.$htmlname.
'").attr("child_id"))
1073 $("#ticketcategory_select").val($("#'.$htmlname.
'").val()) ;
1074 console.log("We choose '.$htmlname.
' input and reload hidden input");
1077 $("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").change(function() {
1078 child_id = $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid:
'').
'").attr("child_id");
1080 /* Change of value to select this value*/
1081 if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.
') {
1082 $("#ticketcategory_select").val($(this).val());
1083 $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1084 console.log("We choose to select "+ $(this).val());
1086 if ($("#'.$htmlname.
'_child_'.$levelid.
' option").length <= 1) {
1087 $("#ticketcategory_select").val($(this).val());
1088 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1089 console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1091 console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1092 $("#ticketcategory_select").val("");
1093 $("#ticketcategory_select_child_id").val("");
1097 console.log("We select a new value into combo child_id="+child_id);
1099 // Hide all selected box that are child of the one modified
1100 $(".groupticketchild").each(function(){
1101 if ($(this).attr("child_id") > child_id) {
1102 console.log("hide child_id="+$(this).attr("child_id"));
1108 // Now we enable the next combo
1109 $("#'.$htmlname.
'_child_'.$levelid.
'").val("");
1110 if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.
'_child_'.$levelid.
' option").length > 1) {
1111 console.log($("#'.$htmlname.
'_child_'.$levelid.
' option").length);
1112 $("#'.$htmlname.
'_child_'.$levelid.
'").show()
1114 $("#'.$htmlname.
'_child_'.$levelid.
'").hide()
1118 foreach ($tabscript as $script) {
1119 $stringtoprint .= $script;
1121 $stringtoprint .=
'})';
1122 $stringtoprint .=
'</script>';
1124 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1125 $stringtoprint .=
'$("#'.$htmlname.
'_child_'.$use_multilevel.
'").change(function() {
1126 $("#ticketcategory_select").val($(this).val());
1127 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1128 console.log($("#ticketcategory_select").val());
1130 $stringtoprint .=
'</script>';
1133 return $stringtoprint;
1150 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
1152 global $langs, $user;
1154 $ticketstat =
new Ticket($this->db);
1156 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1158 $filterarray = array();
1160 if ($filtertype !=
'' && $filtertype !=
'-1') {
1161 $filterarray = explode(
',', $filtertype);
1164 $ticketstat->loadCacheSeveritiesTickets();
1166 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1168 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
1171 if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
1172 foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
1174 if (count($filterarray) && !in_array($arrayseverities[
'type'], $filterarray)) {
1179 if ($empty && empty($arrayseverities[
'code'])) {
1184 print
'<option value="'.$id.
'"';
1188 print
'<option value="'.$arrayseverities[
'code'].
'"';
1192 print
'<option value="'.$arrayseverities[
'code'].
'"';
1196 print
'<option value="'.$id.
'"';
1200 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
1201 print
' selected="selected"';
1202 } elseif (isset($selected) && $selected == $id) {
1203 print
' selected="selected"';
1204 } elseif ($arrayseverities[
'use_default'] ==
"1" && empty($selected) && (!$empty || $empty ==
'ifone')) {
1205 print
' selected="selected"';
1206 } elseif (count($ticketstat->cache_severity_tickets) == 1 && (!$empty || $empty ==
'ifone')) {
1207 print
' selected="selected"';
1214 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1218 $value = $arrayseverities[
'code'];
1222 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1226 $value = $arrayseverities[
'code'];
1229 print $value ? $value :
' ';
1234 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1235 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1250 global $conf, $user;
1251 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1254 $vardir = $conf->user->dir_output.
"/".$user->id;
1255 $upload_dir = $vardir.
'/temp/';
1256 if (is_dir($upload_dir)) {
1260 if (!empty($this->trackid)) {
1261 $keytoavoidconflict =
'-'.$this->trackid;
1263 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1265 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
1266 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
1267 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
1278 global $conf, $langs, $user, $hookmanager, $form, $mysoc;
1280 $formmail =
new FormMail($this->db);
1281 $addfileaction =
'addfile';
1283 if (!is_object($form)) {
1284 $form =
new Form($this->db);
1288 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
1291 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1292 $this->clear_attached_files();
1296 $outputlangs = $langs;
1298 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1299 $newlang = $this->param[
'langsmodels'];
1301 if (!empty($newlang)) {
1302 $outputlangs =
new Translate(
"", $conf);
1303 $outputlangs->setDefaultLang($newlang);
1304 $outputlangs->load(
'other');
1308 $arraydefaultmessage = -1;
1309 if (isset($this->param[
'models']) && $this->param[
'models'] !=
'none') {
1311 if (array_key_exists(
'models_id', $this->param)) {
1312 $model_id = (int) $this->param[
"models_id"];
1315 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id);
1319 $listofpaths = array();
1320 $listofnames = array();
1321 $listofmimes = array();
1323 if (!empty($this->trackid)) {
1324 $keytoavoidconflict =
'-'.$this->trackid;
1326 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1329 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1330 if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param[
'fileinit']) && is_array($this->param[
'fileinit'])) {
1331 foreach ($this->param[
'fileinit'] as $file) {
1332 $formmail->add_attached_files($file, basename($file),
dol_mimetype($file));
1338 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
1339 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
1341 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
1342 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
1344 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
1345 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
1349 $outputlangs = $langs;
1351 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1352 $newlang = $this->param[
'langsmodels'];
1354 if (!empty($newlang)) {
1355 $outputlangs =
new Translate(
"", $conf);
1356 $outputlangs->setDefaultLang($newlang);
1357 $outputlangs->load(
'other');
1360 print
"\n<!-- Begin message_form TICKET -->\n";
1362 $send_email =
GETPOST(
'send_email',
'int') ?
GETPOST(
'send_email',
'int') : 0;
1365 print
'<script nonce="'.getNonce().
'" type="text/javascript">
1366 jQuery(document).ready(function() {
1367 send_email=' . $send_email.
';
1369 if (!jQuery("#send_msg_email").is(":checked")) {
1370 jQuery("#send_msg_email").prop("checked", true).trigger("change");
1372 jQuery(".email_line").show();
1374 if (!jQuery("#private_message").is(":checked")) {
1375 jQuery("#private_message").prop("checked", true).trigger("change");
1377 jQuery(".email_line").hide();
1382 if (empty($conf->global->TICKET_SEND_PRIVATE_EMAIL)) {
1383 print
'jQuery("#send_msg_email").click(function() {
1384 console.log("Click send_msg_email");
1385 if(jQuery(this).is(":checked")) {
1386 if (jQuery("#private_message").is(":checked")) {
1387 jQuery("#private_message").prop("checked", false).trigger("change");
1389 jQuery(".email_line").show();
1392 jQuery(".email_line").hide();
1396 jQuery("#private_message").click(function() {
1397 console.log("Click private_message");
1398 if (jQuery(this).is(":checked")) {
1399 if (jQuery("#send_msg_email").is(":checked")) {
1400 jQuery("#send_msg_email").prop("checked", false).trigger("change");
1402 jQuery(".email_line").hide();
1411 print
'<form method="post" name="ticket" id="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
1412 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1413 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
1414 print
'<input type="hidden" name="actionbis" value="add_message">';
1415 print
'<input type="hidden" name="backtopage" value="'.$this->backtopage.
'">';
1416 if (!empty($this->trackid)) {
1417 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
1419 print
'<input type="hidden" name="trackid" value="'.(empty($this->track_id) ?
'' : $this->track_id).
'">';
1420 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1422 foreach ($this->param as $key => $value) {
1423 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
1428 if (array_key_exists(
'models_id', $this->param)) {
1429 $model_id = $this->param[
"models_id"];
1430 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id);
1433 $result = $formmail->fetchAllEMailTemplate(!empty($this->param[
"models"]) ? $this->param[
"models"] :
"", $user, $outputlangs);
1437 $modelmail_array = array();
1438 foreach ($formmail->lines_model as $line) {
1439 $modelmail_array[$line->id] = $line->label;
1442 print
'<table class="border" width="'.$width.
'">';
1445 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1446 $ticketstat =
new Ticket($this->db);
1447 $res = $ticketstat->fetch(
'',
'', $this->track_id);
1449 print
'<tr><td></td><td>';
1450 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : (
getDolGlobalInt(
'TICKETS_MESSAGE_FORCE_MAIL')?
'checked':
''));
1451 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1452 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1453 $texttooltip = $langs->trans(
"TicketMessageSendEmailHelp");
1454 if (empty($conf->global->TICKET_SEND_PRIVATE_EMAIL)) {
1455 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2b");
1457 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2a",
'{s1}');
1459 $texttooltip = str_replace(
'{s1}', $langs->trans(
'MarkMessageAsPrivate'), $texttooltip);
1460 print
' '.$form->textwithpicto(
'', $texttooltip, 1,
'help');
1464 if (!$user->socid) {
1465 print
'<tr><td></td><td>';
1466 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1467 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1468 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1469 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1474 if (count($modelmail_array) > 0) {
1475 print
'<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'.
"\n";
1476 print $langs->trans(
'SelectMailModel').
': '.$formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], 1, 0,
"",
"", 0, 0, 0,
'',
'minwidth200');
1478 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1481 print
'<input type="submit" class="button" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1482 print
'</div></td>';
1486 print
'<tr class="email_line"><td>'.$langs->trans(
'Subject').
'</td>';
1487 print
'<td><input type="text" class="text minwidth500" name="subject" value="['.getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
' - '.$langs->trans(
"Ticket").
' '.$ticketstat->ref.
'] '.$langs->trans(
'TicketNewMessage').
'" />';
1491 print
'<tr class="email_line"><td>'.$langs->trans(
'MailRecipients');
1492 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessageRecipientsHelp"), 1,
'help');
1496 $contacts = $ticketstat->getInfosTicketInternalContact(1);
1497 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact(1));
1502 if (is_array($contacts) && count($contacts) > 0) {
1503 foreach ($contacts as $key => $info_sendto) {
1504 if ($info_sendto[
'email'] !=
'') {
1505 $sendto[] =
dol_escape_htmltag(trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">").
' <small class="opacitymedium">('.
dol_escape_htmltag($info_sendto[
'libelle']).
")</small>";
1510 if ($ticketstat->origin_email && !in_array($ticketstat->origin_email, $sendto)) {
1511 $sendto[] =
dol_escape_htmltag($ticketstat->origin_email).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
1514 if ($ticketstat->fk_soc > 0) {
1515 $ticketstat->socid = $ticketstat->fk_soc;
1516 $ticketstat->fetch_thirdparty();
1518 if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
1519 $sendto[] = $ticketstat->thirdparty->email.
' <small class="opacitymedium">('.$langs->trans(
'Customer').
')</small>';
1524 $sendto[] =
getDolGlobalString(
'TICKET_NOTIFICATION_EMAIL_TO').
' <small class="opacitymedium">(generic email)</small>';
1528 if (is_array($sendto) && count($sendto) > 0) {
1529 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
1530 print implode(
', ', $sendto);
1532 print
'<div class="warning">'.$langs->trans(
'WarningNoEMailsAdded').
' '.$langs->trans(
'TicketGoIntoContactTab').
'</div>';
1538 $uselocalbrowser =
false;
1560 if (!empty($this->withfile)) {
1562 $out .=
'<td width="180">'.$langs->trans(
"MailFile").
'</td>';
1565 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1566 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
1567 $out .=
'jQuery(document).ready(function () {';
1568 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1569 $out .=
' jQuery("#addedfile").on("change", function() {';
1570 $out .=
' if (jQuery(this).val().length) {';
1571 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", false);';
1572 $out .=
' } else {';
1573 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1576 $out .=
' jQuery(".removedfile").click(function() {';
1577 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1580 $out .=
'</script>'.
"\n";
1582 if (count($listofpaths)) {
1583 foreach ($listofpaths as $key => $val) {
1584 $out .=
'<div id="attachfile_'.$key.
'">';
1585 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1586 if (!$this->withfilereadonly) {
1587 $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.
'" />';
1589 $out .=
'<br></div>';
1594 if ($this->withfile == 2) {
1595 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1597 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1599 $out .=
"</td></tr>\n";
1606 $defaultmessage =
"";
1607 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1608 $defaultmessage = $arraydefaultmessage->content;
1610 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1614 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1615 } elseif (!
dol_textishtml($defaultmessage) && isset($this->substit[
'__USER_SIGNATURE__']) &&
dol_textishtml($this->substit[
'__USER_SIGNATURE__'])) {
1616 $defaultmessage =
dol_nl2br($defaultmessage);
1618 if (GETPOSTISSET(
"message") && !
GETPOST(
'modelselected')) {
1619 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1623 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1624 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1627 print
'<tr><td colspan="2"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1628 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1629 $texttooltip = $langs->trans(
"TicketMessageHelp");
1631 $texttooltip .=
'<br><br>'.$langs->trans(
"ForEmailMessageWillBeCompletedWith").
'...';
1634 $texttooltip .=
'<br><u>'.$langs->trans(
"TicketMessageMailIntro").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO');
1637 $texttooltip .=
'<br><br><u>'.$langs->trans(
"TicketMessageMailFooter").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_SIGNATURE');
1639 print $form->textwithpicto(
'', $texttooltip, 1,
'help');
1641 print
'</label></td></tr>';
1644 print
'<tr><td colspan="2">';
1646 $toolbarname =
'dolibarr_notes';
1647 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1648 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, 70);
1649 $doleditor->Create();
1668 print
'<center><br>';
1669 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"Add").
'"';
1671 if ($this->withfile == 2 && !empty($conf->use_javascript_ajax)) {
1672 print
' onClick="if (document.ticket.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans(
"FileWasNotUploaded")).
'\');
return false; }
else {
return true; }
"';
1675 if (!empty($this->withcancel)) {
1676 print "
";
1677 print '<input class="button button-cancel
" type="submit
" name="cancel
" value="'.$langs->trans("Cancel").'">';
1679 print "</center>\n
";
1681 print '<input type="hidden
" name="page_y
">'."\n
";
1685 // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
1686 if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) {
1687 print '<script type="text/javascript
">';
1688 print 'jQuery(document).ready(function () {';
1689 print ' $(document).on("keypress
", \'#ticket\', function (e) { /* Note this is called at every key pressed ! */
1690 var code = e.keyCode || e.which;
1692 console.log("Enter was intercepted and blocked
");
1701 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.