29require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
30require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
31require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
33if (!class_exists(
'FormCompany')) {
34 include DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
65 public $fk_user_create;
81 public $withfilereadonly;
87 public $withtitletopic;
88 public $withtopicreadonly;
92 public $withfromsocid;
93 public $withfromcontactid;
94 public $withnotifytiersatcreate;
95 public $withusercreate;
96 public $withcreatereadonly;
101 public $withextrafields;
107 public $category_code;
108 public $severity_code;
115 public $substit = array();
116 public $param = array();
122 public $errors = array();
136 $this->action =
'add';
138 $this->withcompany = isModEnabled(
"societe");
139 $this->withfromsocid = 0;
140 $this->withfromcontactid = 0;
143 $this->withnotifytiersatcreate = 0;
144 $this->withusercreate = 1;
145 $this->withcreatereadonly = 1;
146 $this->withemail = 0;
148 $this->withextrafields = 0;
162 public function showForm($withdolfichehead = 0, $mode =
'edit', $public = 0,
Contact $with_contact =
null, $action =
'')
164 global $conf, $langs, $user, $hookmanager;
167 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
169 $form =
new Form($this->db);
171 $ticketstatic =
new Ticket($this->db);
174 if (!empty($this->withfromsocid) && $this->withfromsocid > 0) {
175 $soc->fetch($this->withfromsocid);
178 $ticketstat =
new Ticket($this->db);
181 $extrafields->fetch_name_optionals_label($ticketstat->table_element);
183 print
"\n<!-- Begin form TICKET -->\n";
185 if ($withdolfichehead) {
189 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']).
'">';
190 print
'<input type="hidden" name="token" value="'.newToken().
'">';
191 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
192 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
193 foreach ($this->param as $key => $value) {
194 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
196 print
'<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.
'">';
198 print
'<table class="border centpercent">';
200 if ($this->withref) {
202 $defaultref = $ticketstat->getDefaultRef();
203 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Ref").
'</span></td><td>';
204 print
'<input type="text" name="ref" value="'.dol_escape_htmltag(
GETPOST(
"ref",
'alpha') ?
GETPOST(
"ref",
'alpha') : $defaultref).
'">';
209 $email = GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alphanohtml') :
'';
210 if ($this->withemail) {
211 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"Email").
'</span></label></td><td>';
212 print
'<input class="text minwidth200" id="email" name="email" value="'.$email.
'" autofocus>';
217 $html_contact_search =
'';
218 $html_contact_search .=
'<tr id="contact_search_line">';
219 $html_contact_search .=
'<td class="titlefield">';
220 $html_contact_search .=
'<label for="contact"><span class="fieldrequired">' . $langs->trans(
'Contact') .
'</span></label>';
221 $html_contact_search .=
'<input type="hidden" id="contact_id" name="contact_id" value="" />';
222 $html_contact_search .=
'</td>';
223 $html_contact_search .=
'<td id="contact_search_result"></td>';
224 $html_contact_search .=
'</tr>';
225 print $html_contact_search;
227 $html_contact_lastname =
'';
228 $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>';
229 $html_contact_lastname .=
'<input type="text" id="contact_lastname" name="contact_lastname" value="' .
dol_escape_htmltag(GETPOSTISSET(
'contact_lastname') ?
GETPOST(
'contact_lastname',
'alphanohtml') :
'') .
'" />';
230 $html_contact_lastname .=
'</td></tr>';
231 print $html_contact_lastname;
233 $html_contact_firstname =
'';
234 $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>';
235 $html_contact_firstname .=
'<input type="text" id="contact_firstname" name="contact_firstname" value="' .
dol_escape_htmltag(GETPOSTISSET(
'contact_firstname') ?
GETPOST(
'contact_firstname',
'alphanohtml') :
'') .
'" />';
236 $html_contact_firstname .=
'</td></tr>';
237 print $html_contact_firstname;
239 $html_company_name =
'';
240 $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>';
241 $html_company_name .=
'<input type="text" id="company_name" name="company_name" value="' .
dol_escape_htmltag(GETPOSTISSET(
'company_name') ?
GETPOST(
'company_name',
'alphanohtml') :
'') .
'" />';
242 $html_company_name .=
'</td></tr>';
243 print $html_company_name;
245 $html_contact_phone =
'';
246 $html_contact_phone .=
'<tr id="contact_phone_line" class="contact_field"><td><label for="contact_phone"><span>' . $langs->trans(
'Phone') .
'</span></label></td><td>';
247 $html_contact_phone .=
'<input type="text" id="contact_phone" name="contact_phone" value="' .
dol_escape_htmltag(GETPOSTISSET(
'contact_phone') ?
GETPOST(
'contact_phone',
'alphanohtml') :
'') .
'" />';
248 $html_contact_phone .=
'</td></tr>';
249 print $html_contact_phone;
252 $langs->load(
'errors');
253 print
'<script nonce="'.getNonce().
'" type="text/javascript">
254 jQuery(document).ready(function() {
255 var contact = jQuery.parseJSON("'.
dol_escape_js(json_encode($with_contact), 2).
'");
256 jQuery("#contact_search_line").hide();
258 if (contact.id > 0) {
259 jQuery("#contact_search_line").show();
260 jQuery("#contact_id").val(contact.id);
261 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
262 jQuery(".contact_field").hide();
264 jQuery(".contact_field").show();
268 jQuery("#email").change(function() {
269 jQuery("#contact_search_line").show();
270 jQuery("#contact_search_result").html("'.
dol_escape_js($langs->trans(
'Select2SearchInProgress')).
'");
271 jQuery("#contact_id").val("");
272 jQuery("#contact_lastname").val("");
273 jQuery("#contact_firstname").val("");
274 jQuery("#company_name").val("");
275 jQuery("#contact_phone").val("");
280 action: "getContacts",
281 email: jQuery("#email").val()
284 if (response.error) {
285 jQuery("#contact_search_result").html("<span class=\"error\">"+response.error+"</span>");
287 var contact_list = response.contacts;
288 if (contact_list.length == 1) {
289 var contact = contact_list[0];
290 jQuery("#contact_id").val(contact.id);
291 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
292 jQuery(".contact_field").hide();
293 } else if (contact_list.length <= 0) {
294 jQuery("#contact_search_line").hide();
295 jQuery(".contact_field").show();
299 ).fail(function(jqxhr, textStatus, error) {
300 var error_msg = "'.
dol_escape_js($langs->trans(
'ErrorAjaxRequestFailed')).
'"+" ["+textStatus+"] : "+error;
301 jQuery("#contact_search_result").html("<span class=\"error\">"+error_msg+"</span>");
311 if (isset($this->param[
'origin']) && $this->param[
'originid'] > 0) {
313 $element = $subelement = $this->param[
'origin'];
315 if (preg_match(
'/^([^_]+)_([^_]+)/i', $this->param[
'origin'], $regs)) {
317 $subelement = $regs[2];
321 $classname = ucfirst($subelement);
322 $objectsrc =
new $classname($this->db);
323 $objectsrc->fetch(
GETPOST(
'originid',
'int'));
325 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
326 $objectsrc->fetch_lines();
329 $objectsrc->fetch_thirdparty();
330 $newclassname = $classname;
331 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td colspan="2"><input name="'.$subelement.
'id" value="'.
GETPOST(
'originid').
'" type="hidden" />'.$objectsrc->getNomUrl(1).
'</td></tr>';
335 print
'<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans(
"TicketTypeRequest").
'</span></label></td><td>';
336 $this->
selectTypesTickets((
GETPOST(
'type_code',
'alpha') ?
GETPOST(
'type_code',
'alpha') : $this->type_code),
'type_code',
'', 2,
'ifone', 0, 0,
'minwidth200');
340 print
'<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans(
"TicketCategory").
'</span></label></td><td>';
343 $filter =
'public=1';
345 $selected = (
GETPOST(
'category_code') ?
GETPOST(
'category_code') : $this->category_code);
346 $this->
selectGroupTickets($selected,
'category_code', $filter, 2,
'ifone', 0, 0,
'minwidth200');
350 print
'<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans(
"TicketSeverity").
'</span></label></td><td>';
354 if (!empty($conf->knowledgemanagement->enabled)) {
356 print
'<tr id="KWwithajax" class="hidden"><td></td></tr>';
357 print
'<!-- Script to manage change of ticket group -->
358 <script nonce="'.getNonce().
'">
359 jQuery(document).ready(function() {
360 function groupticketchange() {
361 console.log("We called groupticketchange, so we try to load list KM linked to event");
362 $("#KWwithajax").html("");
363 idgroupticket = $("#selectcategory_code").val();
365 console.log("We have selected id="+idgroupticket);
367 if (idgroupticket != "") {
368 $.ajax({ url: \''.DOL_URL_ROOT.
'/core/ajax/fetchKnowledgeRecord.php\',
369 data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.newToken().
'\', lang:\
''.$langs->defaultlang.
'\',
public:
'.($public).' },
371 success: function(response) {
373 console.log("We received response "+response);
374 if (typeof response == "object") {
375 console.log("response is already type object, no need to parse it");
377 console.log("response is type "+(typeof response));
378 response = JSON.parse(response);
380 for (key in response) {
381 answer = response[key].answer;
382 urllist += \'<li><a href="#" title="\'+response[key].title+\'" class="button_KMpopup" data-html="\'+answer+\'">\' +response[key].title+\'</a></li>\';
385 $("#KWwithajax").html(\'<td>'.$langs->trans(
"KMFoundForTicketGroup").
'</td><td><ul>\'+urllist+\'</ul></td>\');
386 $("#KWwithajax").show();
387 $(".button_KMpopup").on("click",function(){
388 console.log("Open popup with jQuery(...).dialog() with KM article")
389 var $dialog = $("<div></div>").html($(this).attr("data-html"))
393 height: (window.innerHeight - 150),
395 title: $(this).attr("title"),
397 $dialog.dialog("open");
398 console.log($dialog);
402 error : function(output) {
403 console.error("Error on Fetch of KM articles");
408 $("#selectcategory_code").on("change",function() { groupticketchange(); });
409 if ($("#selectcategory_code").val() != "") {
417 if ($this->withtitletopic) {
418 print
'<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans(
"Subject").
'</span></label></td><td>';
420 if ($this->withtopicreadonly) {
421 print $langs->trans(
'SubjectAnswerToTicket').
' '.$this->topic_title;
423 if (isset($this->withreadid) && $this->withreadid > 0) {
424 $subject = $langs->trans(
'SubjectAnswerToTicket').
' '.$this->withreadid.
' : '.$this->topic_title;
426 $subject =
GETPOST(
'subject',
'alpha');
428 print
'<input class="text minwidth500" id="subject" name="subject" value="'.$subject.
'"'.(empty($this->withemail) ?
' autofocus' :
'').
' />';
434 $msg = GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') :
'';
435 print
'<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span></label></td><td>';
438 $toolbarname =
'dolibarr_notes';
439 if ($this->ispublic) {
440 $toolbarname =
'dolibarr_details';
441 print
'<div class="warning hideonsmartphone">'.(getDolGlobalString(
"TICKET_PUBLIC_TEXT_HELP_MESSAGE", $langs->trans(
'TicketPublicPleaseBeAccuratelyDescribe'))).
'</div>';
443 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
444 $uselocalbrowser =
true;
445 $doleditor =
new DolEditor(
'message', $msg,
'100%', 230, $toolbarname,
'In',
true, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_TICKET'), ROWS_8,
'90%');
446 $doleditor->Create();
450 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
451 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td>';
452 print
'<span class="span-icon-security inline-block">';
453 print
'<input id="securitycode" placeholder="'.$langs->trans(
"SecurityCode").
'" class="flat input-icon-security width125" type="text" maxlength="5" name="code" tabindex="3" />';
455 print
'<span class="nowrap inline-block">';
456 print
'<img class="inline-block valignmiddle" src="'.DOL_URL_ROOT.
'/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />';
457 print
'<a class="inline-block valignmiddle" href="" tabindex="4" data-role="button">'.img_picto($langs->trans(
"Refresh"),
'refresh',
'id="captcha_refresh_img"').
'</a>';
463 if (isModEnabled(
'categorie')) {
464 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
465 $cate_arbo = $form->select_all_categories(Categorie::TYPE_TICKET,
'',
'parent', 64, 0, 1);
467 if (count($cate_arbo)) {
469 print
'<tr><td class="wordbreak">'.$langs->trans(
"Categories").
'</td><td>';
470 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
476 if (!empty($this->withfile)) {
478 $listofpaths = array();
479 $listofnames = array();
480 $listofmimes = array();
481 if (!empty($_SESSION[
"listofpaths"])) {
482 $listofpaths = explode(
';', $_SESSION[
"listofpaths"]);
485 if (!empty($_SESSION[
"listofnames"])) {
486 $listofnames = explode(
';', $_SESSION[
"listofnames"]);
489 if (!empty($_SESSION[
"listofmimes"])) {
490 $listofmimes = explode(
';', $_SESSION[
"listofmimes"]);
494 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
497 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
498 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
499 $out .=
'jQuery(document).ready(function () {';
500 $out .=
' jQuery(".removedfile").click(function() {';
501 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
504 $out .=
'</script>'.
"\n";
505 if (count($listofpaths)) {
506 foreach ($listofpaths as $key => $val) {
507 $out .=
'<div id="attachfile_'.$key.
'">';
508 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
509 if (!$this->withfilereadonly) {
510 $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.
'" />';
512 $out .=
'<br></div>';
515 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
517 if ($this->withfile == 2) {
519 $maxmin = $maxfilesizearray[
'maxmin'];
521 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
523 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
525 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="addfile" name="addfile" value="'.$langs->trans(
"MailingAddFile").
'" />';
527 $out .=
"</td></tr>\n";
533 if ($this->withusercreate > 0 && $this->fk_user_create) {
534 print
'<tr><td class="titlefield">'.$langs->trans(
"CreatedBy").
'</td><td>';
535 $langs->load(
"users");
536 $fuser =
new User($this->db);
538 if ($this->withcreatereadonly) {
539 if ($res = $fuser->fetch($this->fk_user_create)) {
540 print $fuser->getNomUrl(1);
544 print
"</td></tr>\n";
548 if ($this->withcompany) {
550 if (empty($user->socid)) {
552 print
'<tr><td class="titlefield">'.$langs->trans(
"ThirdParty").
'</td><td>';
554 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
555 print
img_picto(
'',
'company',
'class="paddingright"');
556 print $form->select_company($this->withfromsocid,
'socid',
'', 1, 1,
'', $events, 0,
'minwidth200');
558 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT')) {
560 print
'<script nonce="'.getNonce().
'" type="text/javascript">
561 $(document).ready(function () {
562 jQuery("#'.$htmlname.
'").change(function () {
563 var obj = '.json_encode($events).
';
564 $.each(obj, function(key,values) {
565 if (values.method.length) {
566 runJsCodeForEvent'.$htmlname.
'(values);
571 function runJsCodeForEvent'.$htmlname.
'(obj) {
572 console.log("Run runJsCodeForEvent'.$htmlname.
'");
573 var id = $("#'.$htmlname.
'").val();
574 var method = obj.method;
576 var htmlname = obj.htmlname;
577 var showempty = obj.showempty;
586 $.each(obj.params, function(key,action) {
588 var num = response.num;
590 $("#" + key).removeAttr(action);
592 $("#" + key).attr(action, action);
596 $("select#" + htmlname).html(response.value);
598 var selecthtml_str = response.value;
599 var selecthtml_dom=$.parseHTML(selecthtml_str);
600 if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
601 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
604 $("#inputautocomplete"+htmlname).val("");
606 $("select#" + htmlname).change(); /* Trigger event change */
615 print
'<tr><td>'.$langs->trans(
"Contact").
'</td><td>';
617 $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
618 print
img_picto(
'',
'contact',
'class="paddingright"');
619 print $form->selectcontacts($selectedCompany, $this->withfromcontactid,
'contactid', 3,
'',
'', 0,
'minwidth200');
621 $formcompany->selectTypeContact($ticketstatic,
'',
'type',
'external',
'', 0,
'maginleftonly');
624 print
'<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.
'"/></td>';
625 print
'<td><input type="hidden" name="contactid" value="'.$user->contact_id.
'"/></td>';
626 print
'<td><input type="hidden" name="type" value="Z"/></td></tr>';
630 if (empty($this->ispublic)) {
631 print
'<tr><td><label for="notify_tiers_at_create">'.$langs->trans(
"TicketNotifyTiersAtCreation").
'</label></td><td>';
632 print
'<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ?
' checked="checked"' :
'').
'>';
638 print $langs->trans(
"AssignedTo");
640 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
641 print $form->select_dolusers(
GETPOST(
'fk_user_assign',
'int'),
'fk_user_assign', 1);
646 if ($subelement !=
'project') {
647 if (isModEnabled(
'project') && !$this->ispublic) {
649 print
'<tr><td><label for="project"><span class="">'.$langs->trans(
"Project").
'</span></label></td><td>';
650 print
img_picto(
'',
'project').$formproject->select_projects(-1,
GETPOST(
'projectid',
'int'),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
655 if ($subelement !=
'contract') {
656 if (isModEnabled(
'contract') && !$this->ispublic) {
657 $langs->load(
'contracts');
659 print
'<tr><td><label for="contract"><span class="">'.$langs->trans(
"Contract").
'</span></label></td><td>';
661 print $formcontract->select_contract(-1,
GETPOST(
'contactid',
'int'),
'contractid', 0, 1, 1, 1);
667 $parameters = array();
668 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $ticketstat, $action);
669 if (empty($reshook)) {
670 print $ticketstat->showOptionals($extrafields,
'create');
675 if ($withdolfichehead) {
681 print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"CreateTicket"), ($this->withcancel ?
"Cancel" :
""));
693 print
'<input type="hidden" name="page_y">'.
"\n";
696 print
"<!-- End form TICKET -->\n";
713 public function selectTypesTickets($selected =
'', $htmlname =
'tickettype', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $multiselect = 0)
715 global $langs, $user;
717 $selected = is_array($selected) ? $selected : (!empty($selected) ? explode(
',', $selected) : array());
718 $ticketstat =
new Ticket($this->db);
720 dol_syslog(get_class($this) .
"::select_types_tickets " . implode(
';', $selected) .
", " . $htmlname .
", " . $filtertype .
", " . $format .
", " . $multiselect, LOG_DEBUG);
722 $filterarray = array();
724 if ($filtertype !=
'' && $filtertype !=
'-1') {
725 $filterarray = explode(
',', $filtertype);
728 $ticketstat->loadCacheTypesTickets();
730 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.($multiselect ?
'[]' :
'').
'"'.($multiselect ?
' multiple' :
'').
'>';
731 if ($empty && !$multiselect) {
732 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
735 if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
736 foreach ($ticketstat->cache_types_tickets as $id => $arraytypes) {
738 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
743 if ($empty && empty($arraytypes[
'code'])) {
748 print
'<option value="'.$id.
'"';
752 print
'<option value="'.$arraytypes[
'code'].
'"';
756 print
'<option value="'.$arraytypes[
'code'].
'"';
760 print
'<option value="'.$id.
'"';
764 if (in_array($arraytypes[
'code'], $selected)) {
765 print
' selected="selected"';
766 } elseif (in_array($id, $selected)) {
767 print
' selected="selected"';
768 } elseif ($arraytypes[
'use_default'] ==
"1" && empty($selected) && !$multiselect) {
769 print
' selected="selected"';
770 } elseif (count($ticketstat->cache_types_tickets) == 1 && (!$empty || $empty ==
'ifone')) {
771 print
' selected="selected"';
778 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
779 } elseif ($format == 1) {
780 $value = $arraytypes[
'code'];
781 } elseif ($format == 2) {
782 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
783 } elseif ($format == 3) {
784 $value = $arraytypes[
'code'];
787 print $value ? $value :
' ';
792 if (isset($user->admin) && $user->admin && !$noadmininfo) {
793 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
814 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs =
null)
816 global $conf, $langs, $user;
818 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
820 if (is_null($outputlangs) || !is_object($outputlangs)) {
821 $outputlangs = $langs;
823 $outputlangs->load(
"ticket");
825 $publicgroups = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
827 $ticketstat =
new Ticket($this->db);
828 $ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1);
830 if ($use_multilevel <= 0) {
831 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
833 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
836 if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
837 foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
840 if (empty($arraycategories[
'public'])) {
846 if ($empty && empty($arraycategories[
'code'])) {
850 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
851 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) !=
"TicketCategoryShort".$arraycategories[
'code']) {
852 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
853 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
854 $label = $outputlangs->trans($arraycategories[
'code']);
858 print
'<option value="'.$id.
'"';
862 print
'<option value="'.$arraycategories[
'code'].
'"';
866 print
'<option value="'.$arraycategories[
'code'].
'"';
870 print
'<option value="'.$id.
'"';
874 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
875 print
' selected="selected"';
876 } elseif (isset($selected) && $selected == $id) {
877 print
' selected="selected"';
878 } elseif ($arraycategories[
'use_default'] ==
"1" && !$selected && (!$empty || $empty ==
'ifone')) {
879 print
' selected="selected"';
880 } elseif (count($ticketstat->cache_category_tickets) == 1 && (!$empty || $empty ==
'ifone')) {
881 print
' selected="selected"';
888 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
892 $value = $arraycategories[
'code'];
896 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
900 $value = $arraycategories[
'code'];
903 print $value ? $value :
' ';
908 if (isset($user->admin) && $user->admin && !$noadmininfo) {
909 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
913 } elseif ($htmlname !=
'') {
914 $selectedgroups = array();
916 $groupticket=
GETPOST($htmlname,
'aZ09');
917 $child_id=
GETPOST($htmlname.
'_child_id',
'aZ09') ?
GETPOST($htmlname.
'_child_id',
'aZ09') : 0;
918 if (!empty($groupticket)) {
919 $tmpgroupticket = $groupticket;
920 $sql =
"SELECT ctc.rowid, ctc.fk_parent, ctc.code";
921 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc WHERE ctc.code = '".$this->db->escape($tmpgroupticket).
"'";
922 $resql = $this->db->query($sql);
924 $obj = $this->db->fetch_object($resql);
925 $selectedgroups[] = $obj->code;
926 while ($obj->fk_parent > 0) {
927 $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).
"'";
928 $resql = $this->db->query($sql);
930 $obj = $this->db->fetch_object($resql);
931 $selectedgroups[] = $obj->code;
937 $arrayidused = array();
938 $arrayidusedconcat = array();
939 $arraycodenotparent = array();
940 $arraycodenotparent[] =
"";
942 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
943 $stringtoprint .=
'<select id="'.$htmlname.
'" class="minwidth500" child_id="0">';
944 $stringtoprint .=
'<option value=""> </option>';
946 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
947 $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";
948 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
949 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
950 if ($filtertype ==
'public=1') {
951 $sql .=
" AND ctc.public = 1";
953 $sql .=
" AND ctc.fk_parent = 0";
954 $sql .= $this->db->order(
'ctc.pos',
'ASC');
956 $resql = $this->db->query($sql);
958 $num_rows_level0 = $this->db->num_rows($resql);
960 while ($i < $num_rows_level0) {
961 $obj = $this->db->fetch_object($resql);
963 $label = ($obj->label !=
'-' ? $obj->label :
'');
964 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code) {
965 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
966 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
967 $label = $outputlangs->trans($obj->code);
970 $grouprowid = $obj->rowid;
971 $groupvalue = $obj->code;
972 $grouplabel = $label;
974 $isparent = $obj->isparent;
975 if (is_array($selectedgroups)) {
976 $iselected = in_array($obj->code, $selectedgroups) ?
'selected' :
'';
978 $iselected = $groupticket == $obj->code ?
'selected' :
'';
981 if ($isparent ==
'NOTPARENT') {
982 $arraycodenotparent[] = $groupvalue;
984 $arrayidused[] = $grouprowid;
985 $arrayidusedconcat[] = $grouprowid;
992 if (count($arrayidused) == 1) {
993 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
995 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400">';
996 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400">';
998 $stringtoprint .=
'</select> ';
1001 while ($levelid <= $use_multilevel) {
1002 $tabscript = array();
1003 $stringtoprint .=
'<select id="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
1004 $stringtoprint .=
'<option value=""> </option>';
1006 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
1007 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
1008 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
1009 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
1010 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(join(
',', $arrayidusedconcat)).
")";
1012 if ($filtertype ==
'public=1') {
1013 $sql .=
" AND ctc.public = 1";
1016 if (!empty($arrayidused)) {
1017 $sql .=
" AND ctc.fk_parent IN ( ";
1018 foreach ($arrayidused as $idused) {
1019 $sql .= $idused.
", ";
1021 $sql = substr($sql, 0, -2);
1024 $sql .= $this->db->order(
'ctc.pos',
'ASC');
1026 $resql = $this->db->query($sql);
1028 $num_rows = $this->db->num_rows($resql);
1030 $arrayidused=array();
1031 while ($i < $num_rows) {
1032 $obj = $this->db->fetch_object($resql);
1034 $label = ($obj->label !=
'-' ? $obj->label :
'');
1035 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code) {
1036 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1037 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1038 $label = $outputlangs->trans($obj->code);
1041 $grouprowid = $obj->rowid;
1042 $groupvalue = $obj->code;
1043 $grouplabel = $label;
1044 $isparent = $obj->isparent;
1045 $fatherid = $obj->fk_parent;
1046 $arrayidused[] = $grouprowid;
1047 $arrayidusedconcat[] = $grouprowid;
1048 $groupcodefather = $obj->codefather;
1049 if ($isparent ==
'NOTPARENT') {
1050 $arraycodenotparent[] = $groupvalue;
1052 if (is_array($selectedgroups)) {
1053 $iselected = in_array($obj->code, $selectedgroups) ?
'selected' :
'';
1055 $iselected = $groupticket == $obj->code ?
'selected' :
'';
1058 if (empty($tabscript[$groupcodefather])) {
1059 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1) :
'').
'").val() == "'.
dol_escape_js($groupcodefather).
'"){
1061 console.log("We show childs tickets of '.$groupcodefather.
' group ticket")
1064 console.log("We hide childs tickets of '.$groupcodefather.
' group ticket")
1073 $stringtoprint .=
'</select>';
1075 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1076 $stringtoprint .=
'arraynotparents = '.json_encode($arraycodenotparent).
';';
1077 $stringtoprint .=
'if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1) :
'').
'").val())){
1078 console.log("'.$htmlname.
'_child_'.$levelid.
'")
1079 if($("#'.$htmlname.
'_child_'.$levelid.
'").val() == "" && ($("#'.$htmlname.
'_child_'.$levelid.
'").attr("child_id")>'.$child_id.
')){
1080 $("#'.$htmlname.
'_child_'.$levelid.
'").hide();
1081 console.log("We hide '.$htmlname.
'_child_'.$levelid.
' input")
1083 if(arraynotparents.includes("'.$groupticket.
'") && '.$child_id.
' == 0){
1084 $("#ticketcategory_select_child_id").val($("#'.$htmlname.
'").attr("child_id"))
1085 $("#ticketcategory_select").val($("#'.$htmlname.
'").val()) ;
1086 console.log("We choose '.$htmlname.
' input and reload hidden input");
1089 $("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1) :
'').
'").change(function() {
1090 child_id = $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid :
'').
'").attr("child_id");
1092 /* Change of value to select this value*/
1093 if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.
') {
1094 $("#ticketcategory_select").val($(this).val());
1095 $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1096 console.log("We choose to select "+ $(this).val());
1098 if ($("#'.$htmlname.
'_child_'.$levelid.
' option").length <= 1) {
1099 $("#ticketcategory_select").val($(this).val());
1100 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1101 console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1103 console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1104 $("#ticketcategory_select").val("");
1105 $("#ticketcategory_select_child_id").val("");
1109 console.log("We select a new value into combo child_id="+child_id);
1111 // Hide all selected box that are child of the one modified
1112 $(".groupticketchild").each(function(){
1113 if ($(this).attr("child_id") > child_id) {
1114 console.log("hide child_id="+$(this).attr("child_id"));
1120 // Now we enable the next combo
1121 $("#'.$htmlname.
'_child_'.$levelid.
'").val("");
1122 if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.
'_child_'.$levelid.
' option").length > 1) {
1123 console.log($("#'.$htmlname.
'_child_'.$levelid.
' option").length);
1124 $("#'.$htmlname.
'_child_'.$levelid.
'").show()
1126 $("#'.$htmlname.
'_child_'.$levelid.
'").hide()
1130 foreach ($tabscript as $script) {
1131 $stringtoprint .= $script;
1133 $stringtoprint .=
'})';
1134 $stringtoprint .=
'</script>';
1136 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1137 $stringtoprint .=
'$("#'.$htmlname.
'_child_'.$use_multilevel.
'").change(function() {
1138 $("#ticketcategory_select").val($(this).val());
1139 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1140 console.log($("#ticketcategory_select").val());
1142 $stringtoprint .=
'</script>';
1145 return $stringtoprint;
1162 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
1164 global $langs, $user;
1166 $ticketstat =
new Ticket($this->db);
1168 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1170 $filterarray = array();
1172 if ($filtertype !=
'' && $filtertype !=
'-1') {
1173 $filterarray = explode(
',', $filtertype);
1176 $ticketstat->loadCacheSeveritiesTickets();
1178 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1180 print
'<option value="">'.((is_numeric($empty) || $empty ==
'ifone') ?
' ' : $empty).
'</option>';
1183 if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
1184 foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
1186 if (count($filterarray) && !in_array($arrayseverities[
'type'], $filterarray)) {
1191 if ($empty && empty($arrayseverities[
'code'])) {
1196 print
'<option value="'.$id.
'"';
1200 print
'<option value="'.$arrayseverities[
'code'].
'"';
1204 print
'<option value="'.$arrayseverities[
'code'].
'"';
1208 print
'<option value="'.$id.
'"';
1212 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
1213 print
' selected="selected"';
1214 } elseif (isset($selected) && $selected == $id) {
1215 print
' selected="selected"';
1216 } elseif ($arrayseverities[
'use_default'] ==
"1" && empty($selected) && (!$empty || $empty ==
'ifone')) {
1217 print
' selected="selected"';
1218 } elseif (count($ticketstat->cache_severity_tickets) == 1 && (!$empty || $empty ==
'ifone')) {
1219 print
' selected="selected"';
1226 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1230 $value = $arrayseverities[
'code'];
1234 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1238 $value = $arrayseverities[
'code'];
1241 print $value ? $value :
' ';
1246 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1247 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1262 global $conf, $user;
1263 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1266 $vardir = $conf->user->dir_output.
"/".$user->id;
1267 $upload_dir = $vardir.
'/temp/';
1268 if (is_dir($upload_dir)) {
1272 if (!empty($this->trackid)) {
1273 $keytoavoidconflict =
'-'.$this->trackid;
1275 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1277 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
1278 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
1279 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
1290 global $conf, $langs, $user, $hookmanager, $form, $mysoc;
1292 $formmail =
new FormMail($this->db);
1293 $addfileaction =
'addfile';
1295 if (!is_object($form)) {
1296 $form =
new Form($this->db);
1300 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
1303 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1304 $this->clear_attached_files();
1308 $outputlangs = $langs;
1310 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1311 $newlang = $this->param[
'langsmodels'];
1313 if (!empty($newlang)) {
1314 $outputlangs =
new Translate(
"", $conf);
1315 $outputlangs->setDefaultLang($newlang);
1316 $outputlangs->load(
'other');
1320 $arraydefaultmessage = -1;
1321 if (isset($this->param[
'models']) && $this->param[
'models'] !=
'none') {
1323 if (array_key_exists(
'models_id', $this->param)) {
1324 $model_id = (int) $this->param[
"models_id"];
1327 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id);
1331 $listofpaths = array();
1332 $listofnames = array();
1333 $listofmimes = array();
1335 if (!empty($this->trackid)) {
1336 $keytoavoidconflict =
'-'.$this->trackid;
1338 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1341 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1342 if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param[
'fileinit']) && is_array($this->param[
'fileinit'])) {
1343 foreach ($this->param[
'fileinit'] as $file) {
1344 $formmail->add_attached_files($file, basename($file),
dol_mimetype($file));
1350 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
1351 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
1353 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
1354 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
1356 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
1357 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
1361 $outputlangs = $langs;
1363 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1364 $newlang = $this->param[
'langsmodels'];
1366 if (!empty($newlang)) {
1367 $outputlangs =
new Translate(
"", $conf);
1368 $outputlangs->setDefaultLang($newlang);
1369 $outputlangs->load(
'other');
1372 print
"\n<!-- Begin message_form TICKET -->\n";
1374 $send_email =
GETPOST(
'send_email',
'int') ?
GETPOST(
'send_email',
'int') : 0;
1377 print
'<script nonce="'.getNonce().
'" type="text/javascript">
1378 jQuery(document).ready(function() {
1379 send_email=' . $send_email.
';
1381 if (!jQuery("#send_msg_email").is(":checked")) {
1382 jQuery("#send_msg_email").prop("checked", true).trigger("change");
1384 jQuery(".email_line").show();
1386 if (!jQuery("#private_message").is(":checked")) {
1387 jQuery("#private_message").prop("checked", true).trigger("change");
1389 jQuery(".email_line").hide();
1395 print
'jQuery("#send_msg_email").click(function() {
1396 console.log("Click send_msg_email");
1397 if(jQuery(this).is(":checked")) {
1398 if (jQuery("#private_message").is(":checked")) {
1399 jQuery("#private_message").prop("checked", false).trigger("change");
1401 jQuery(".email_line").show();
1404 jQuery(".email_line").hide();
1408 jQuery("#private_message").click(function() {
1409 console.log("Click private_message");
1410 if (jQuery(this).is(":checked")) {
1411 if (jQuery("#send_msg_email").is(":checked")) {
1412 jQuery("#send_msg_email").prop("checked", false).trigger("change");
1414 jQuery(".email_line").hide();
1423 print
'<form method="post" name="ticket" id="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
1424 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1425 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
1426 print
'<input type="hidden" name="actionbis" value="add_message">';
1427 print
'<input type="hidden" name="backtopage" value="'.$this->backtopage.
'">';
1428 if (!empty($this->trackid)) {
1429 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
1431 print
'<input type="hidden" name="trackid" value="'.(empty($this->track_id) ?
'' : $this->track_id).
'">';
1432 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1434 foreach ($this->param as $key => $value) {
1435 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
1440 if (array_key_exists(
'models_id', $this->param)) {
1441 $model_id = $this->param[
"models_id"];
1442 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id);
1445 $result = $formmail->fetchAllEMailTemplate(!empty($this->param[
"models"]) ? $this->param[
"models"] :
"", $user, $outputlangs);
1449 $modelmail_array = array();
1450 foreach ($formmail->lines_model as $line) {
1451 $modelmail_array[$line->id] = $line->label;
1454 print
'<table class="border" width="'.$width.
'">';
1457 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1458 $ticketstat =
new Ticket($this->db);
1459 $res = $ticketstat->fetch(
'',
'', $this->track_id);
1461 print
'<tr><td></td><td>';
1462 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : (
getDolGlobalInt(
'TICKETS_MESSAGE_FORCE_MAIL') ?
'checked' :
''));
1463 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1464 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1465 $texttooltip = $langs->trans(
"TicketMessageSendEmailHelp");
1467 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2b");
1469 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2a",
'{s1}');
1471 $texttooltip = str_replace(
'{s1}', $langs->trans(
'MarkMessageAsPrivate'), $texttooltip);
1472 print
' '.$form->textwithpicto(
'', $texttooltip, 1,
'help');
1476 if (!$user->socid) {
1477 print
'<tr><td></td><td>';
1478 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1479 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1480 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1481 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1486 if (count($modelmail_array) > 0) {
1487 print
'<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'.
"\n";
1488 print $langs->trans(
'SelectMailModel').
': '.$formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], 1, 0,
"",
"", 0, 0, 0,
'',
'minwidth200');
1490 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1493 print
'<input type="submit" class="button" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1494 print
'</div></td>';
1498 foreach ($formmail->lines_model as $line) {
1499 if (!empty($this->substit) && $this->param[
'models_id'] == $line->id) {
1504 print
'<tr class="email_line"><td>'.$langs->trans(
'Subject').
'</td>';
1505 if (empty($topic)) {
1506 print
'<td><input type="text" class="text minwidth500" name="subject" value="['.getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
' - '.$langs->trans(
"Ticket").
' '.$ticketstat->ref.
'] '.$langs->trans(
'TicketNewMessage').
'" />';
1508 print
'<td><input type="text" class="text minwidth500" name="subject" value="['.getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
' - '.$langs->trans(
"Ticket").
' '.$ticketstat->ref.
'] '.$topic.
'" />';
1513 print
'<tr class="email_line"><td>'.$langs->trans(
'MailRecipients');
1514 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessageRecipientsHelp"), 1,
'help');
1518 $contacts = $ticketstat->getInfosTicketInternalContact(1);
1519 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact(1));
1524 if (is_array($contacts) && count($contacts) > 0) {
1525 foreach ($contacts as $key => $info_sendto) {
1526 if ($info_sendto[
'email'] !=
'') {
1527 $sendto[] =
dol_escape_htmltag(trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">").
' <small class="opacitymedium">('.
dol_escape_htmltag($info_sendto[
'libelle']).
")</small>";
1532 if ($ticketstat->origin_email && !in_array($ticketstat->origin_email, $sendto)) {
1533 $sendto[] =
dol_escape_htmltag($ticketstat->origin_email).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
1536 if ($ticketstat->fk_soc > 0) {
1537 $ticketstat->socid = $ticketstat->fk_soc;
1538 $ticketstat->fetch_thirdparty();
1540 if (!empty($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
1541 $sendto[] = $ticketstat->thirdparty->email.
' <small class="opacitymedium">('.$langs->trans(
'Customer').
')</small>';
1546 $sendto[] =
getDolGlobalString(
'TICKET_NOTIFICATION_EMAIL_TO').
' <small class="opacitymedium">(generic email)</small>';
1550 if (is_array($sendto) && count($sendto) > 0) {
1551 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
1552 print implode(
', ', $sendto);
1554 print
'<div class="warning">'.$langs->trans(
'WarningNoEMailsAdded').
' '.$langs->trans(
'TicketGoIntoContactTab').
'</div>';
1560 $uselocalbrowser =
false;
1582 if (!empty($this->withfile)) {
1584 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
1587 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1588 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
1589 $out .=
'jQuery(document).ready(function () {';
1590 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1591 $out .=
' jQuery("#addedfile").on("change", function() {';
1592 $out .=
' if (jQuery(this).val().length) {';
1593 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", false);';
1594 $out .=
' } else {';
1595 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1598 $out .=
' jQuery(".removedfile").click(function() {';
1599 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1602 $out .=
'</script>'.
"\n";
1604 if (count($listofpaths)) {
1605 foreach ($listofpaths as $key => $val) {
1606 $out .=
'<div id="attachfile_'.$key.
'">';
1607 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1608 if (!$this->withfilereadonly) {
1609 $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.
'" />';
1611 $out .=
'<br></div>';
1616 if ($this->withfile == 2) {
1617 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1619 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1621 $out .=
"</td></tr>\n";
1628 $defaultmessage =
"";
1629 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1630 $defaultmessage = $arraydefaultmessage->content;
1632 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1636 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1637 } elseif (!
dol_textishtml($defaultmessage) && isset($this->substit[
'__USER_SIGNATURE__']) &&
dol_textishtml($this->substit[
'__USER_SIGNATURE__'])) {
1638 $defaultmessage =
dol_nl2br($defaultmessage);
1640 if (GETPOSTISSET(
"message") && !
GETPOST(
'modelselected')) {
1641 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1645 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1646 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1649 print
'<tr><td colspan="2"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1650 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1651 $texttooltip = $langs->trans(
"TicketMessageHelp");
1653 $texttooltip .=
'<br><br>'.$langs->trans(
"ForEmailMessageWillBeCompletedWith").
'...';
1656 $texttooltip .=
'<br><u>'.$langs->trans(
"TicketMessageMailIntro").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO');
1659 $texttooltip .=
'<br><br><u>'.$langs->trans(
"TicketMessageMailFooter").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_SIGNATURE');
1661 print $form->textwithpicto(
'', $texttooltip, 1,
'help');
1663 print
'</label></td></tr>';
1666 print
'<tr><td colspan="2">';
1668 $toolbarname =
'dolibarr_notes';
1669 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1670 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_TICKET'), ROWS_5,
'90%');
1671 $doleditor->Create();
1690 print
'<br><center>';
1691 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"Add").
'"';
1693 if ($this->withfile == 2 && !empty($conf->use_javascript_ajax)) {
1694 print
' onClick="if (document.ticket.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans(
"FileWasNotUploaded")).
'\');
return false; }
else {
return true; }
"';
1697 if (!empty($this->withcancel)) {
1698 print "
";
1699 print '<input class="button button-cancel
" type="submit
" name="cancel
" value="'.$langs->trans("Cancel").'">';
1701 print "</center>\n
";
1703 print '<input type="hidden
" name="page_y
">'."\n
";
1705 print "</form><br>\n
";
1707 // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
1708 if (getDolGlobalString('MAIN_MAILFORM_DISABLE_ENTERKEY')) {
1709 print '<script type="text/javascript
">';
1710 print 'jQuery(document).ready(function () {';
1711 print ' $(document).on("keypress
", \'#ticket\', function (e) { /* Note this is called at every key pressed ! */
1712 var code = e.keyCode || e.which;
1714 console.log("Enter was intercepted and blocked
");
1723 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 a 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.