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>';
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, 1, 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' :
'').
'>';
732 print
'<option value=""> </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)) {
769 print
' selected="selected"';
776 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
777 } elseif ($format == 1) {
778 $value = $arraytypes[
'code'];
779 } elseif ($format == 2) {
780 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
781 } elseif ($format == 3) {
782 $value = $arraytypes[
'code'];
785 print $value ? $value :
' ';
790 if (isset($user->admin) && $user->admin && !$noadmininfo) {
791 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
812 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs =
null)
814 global $conf, $langs, $user;
816 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
818 if (is_null($outputlangs) || !is_object($outputlangs)) {
819 $outputlangs = $langs;
821 $outputlangs->load(
"ticket");
823 $publicgroups = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
825 $ticketstat =
new Ticket($this->db);
826 $ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1);
828 if ($use_multilevel <= 0) {
829 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
831 print
'<option value=""> </option>';
834 if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
835 foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
838 if (empty($arraycategories[
'public'])) {
844 if ($empty && empty($arraycategories[
'code'])) {
848 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
849 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) !=
"TicketCategoryShort".$arraycategories[
'code']) {
850 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
851 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
852 $label = $outputlangs->trans($arraycategories[
'code']);
856 print
'<option value="'.$id.
'"';
860 print
'<option value="'.$arraycategories[
'code'].
'"';
864 print
'<option value="'.$arraycategories[
'code'].
'"';
868 print
'<option value="'.$id.
'"';
872 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
873 print
' selected="selected"';
874 } elseif (isset($selected) && $selected == $id) {
875 print
' selected="selected"';
876 } elseif ($arraycategories[
'use_default'] ==
"1" && !$selected && !$empty) {
877 print
' selected="selected"';
878 } elseif (count($ticketstat->cache_category_tickets) == 1) {
879 print
' selected="selected"';
886 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
890 $value = $arraycategories[
'code'];
894 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
898 $value = $arraycategories[
'code'];
901 print $value ? $value :
' ';
906 if (isset($user->admin) && $user->admin && !$noadmininfo) {
907 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
911 } elseif ($htmlname !=
'') {
912 $selectedgroups = array();
914 $groupticket=
GETPOST($htmlname,
'aZ09');
915 $child_id=
GETPOST($htmlname.
'_child_id',
'aZ09') ?
GETPOST($htmlname.
'_child_id',
'aZ09') : 0;
916 if (!empty($groupticket)) {
917 $tmpgroupticket = $groupticket;
918 $sql =
"SELECT ctc.rowid, ctc.fk_parent, ctc.code";
919 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc WHERE ctc.code = '".$this->db->escape($tmpgroupticket).
"'";
920 $resql = $this->db->query($sql);
922 $obj = $this->db->fetch_object($resql);
923 $selectedgroups[] = $obj->code;
924 while ($obj->fk_parent > 0) {
925 $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).
"'";
926 $resql = $this->db->query($sql);
928 $obj = $this->db->fetch_object($resql);
929 $selectedgroups[] = $obj->code;
935 $arrayidused = array();
936 $arrayidusedconcat = array();
937 $arraycodenotparent = array();
938 $arraycodenotparent[] =
"";
940 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
941 $stringtoprint .=
'<select id="'.$htmlname.
'" class="minwidth500" child_id="0">';
942 $stringtoprint .=
'<option value=""> </option>';
944 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
945 $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";
946 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
947 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
948 if ($filtertype ==
'public=1') {
949 $sql .=
" AND ctc.public = 1";
951 $sql .=
" AND ctc.fk_parent = 0";
952 $sql .= $this->db->order(
'ctc.pos',
'ASC');
954 $resql = $this->db->query($sql);
956 $num_rows_level0 = $this->db->num_rows($resql);
958 while ($i < $num_rows_level0) {
959 $obj = $this->db->fetch_object($resql);
961 $label = ($obj->label !=
'-' ? $obj->label :
'');
962 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code) {
963 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
964 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
965 $label = $outputlangs->trans($obj->code);
968 $grouprowid = $obj->rowid;
969 $groupvalue = $obj->code;
970 $grouplabel = $label;
972 $isparent = $obj->isparent;
973 if (is_array($selectedgroups)) {
974 $iselected = in_array($obj->code, $selectedgroups) ?
'selected' :
'';
976 $iselected = $groupticket == $obj->code ?
'selected' :
'';
979 if ($isparent ==
'NOTPARENT') {
980 $arraycodenotparent[] = $groupvalue;
982 $arrayidused[] = $grouprowid;
983 $arrayidusedconcat[] = $grouprowid;
990 if (count($arrayidused) == 1) {
991 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
993 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400">';
994 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400">';
996 $stringtoprint .=
'</select> ';
999 while ($levelid <= $use_multilevel) {
1000 $tabscript = array();
1001 $stringtoprint .=
'<select id="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
1002 $stringtoprint .=
'<option value=""> </option>';
1004 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
1005 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
1006 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
1007 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
1008 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(join(
',', $arrayidusedconcat)).
")";
1010 if ($filtertype ==
'public=1') {
1011 $sql .=
" AND ctc.public = 1";
1014 if (!empty($arrayidused)) {
1015 $sql .=
" AND ctc.fk_parent IN ( ";
1016 foreach ($arrayidused as $idused) {
1017 $sql .= $idused.
", ";
1019 $sql = substr($sql, 0, -2);
1022 $sql .= $this->db->order(
'ctc.pos',
'ASC');
1024 $resql = $this->db->query($sql);
1026 $num_rows = $this->db->num_rows($resql);
1028 $arrayidused=array();
1029 while ($i < $num_rows) {
1030 $obj = $this->db->fetch_object($resql);
1032 $label = ($obj->label !=
'-' ? $obj->label :
'');
1033 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code) {
1034 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1035 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1036 $label = $outputlangs->trans($obj->code);
1039 $grouprowid = $obj->rowid;
1040 $groupvalue = $obj->code;
1041 $grouplabel = $label;
1042 $isparent = $obj->isparent;
1043 $fatherid = $obj->fk_parent;
1044 $arrayidused[] = $grouprowid;
1045 $arrayidusedconcat[] = $grouprowid;
1046 $groupcodefather = $obj->codefather;
1047 if ($isparent ==
'NOTPARENT') {
1048 $arraycodenotparent[] = $groupvalue;
1050 if (is_array($selectedgroups)) {
1051 $iselected = in_array($obj->code, $selectedgroups) ?
'selected' :
'';
1053 $iselected = $groupticket == $obj->code ?
'selected' :
'';
1056 if (empty($tabscript[$groupcodefather])) {
1057 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1) :
'').
'").val() == "'.
dol_escape_js($groupcodefather).
'"){
1059 console.log("We show childs tickets of '.$groupcodefather.
' group ticket")
1062 console.log("We hide childs tickets of '.$groupcodefather.
' group ticket")
1071 $stringtoprint .=
'</select>';
1073 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1074 $stringtoprint .=
'arraynotparents = '.json_encode($arraycodenotparent).
';';
1075 $stringtoprint .=
'if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1) :
'').
'").val())){
1076 console.log("'.$htmlname.
'_child_'.$levelid.
'")
1077 if($("#'.$htmlname.
'_child_'.$levelid.
'").val() == "" && ($("#'.$htmlname.
'_child_'.$levelid.
'").attr("child_id")>'.$child_id.
')){
1078 $("#'.$htmlname.
'_child_'.$levelid.
'").hide();
1079 console.log("We hide '.$htmlname.
'_child_'.$levelid.
' input")
1081 if(arraynotparents.includes("'.$groupticket.
'") && '.$child_id.
' == 0){
1082 $("#ticketcategory_select_child_id").val($("#'.$htmlname.
'").attr("child_id"))
1083 $("#ticketcategory_select").val($("#'.$htmlname.
'").val()) ;
1084 console.log("We choose '.$htmlname.
' input and reload hidden input");
1087 $("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1) :
'').
'").change(function() {
1088 child_id = $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid :
'').
'").attr("child_id");
1090 /* Change of value to select this value*/
1091 if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.
') {
1092 $("#ticketcategory_select").val($(this).val());
1093 $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1094 console.log("We choose to select "+ $(this).val());
1096 if ($("#'.$htmlname.
'_child_'.$levelid.
' option").length <= 1) {
1097 $("#ticketcategory_select").val($(this).val());
1098 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1099 console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1101 console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1102 $("#ticketcategory_select").val("");
1103 $("#ticketcategory_select_child_id").val("");
1107 console.log("We select a new value into combo child_id="+child_id);
1109 // Hide all selected box that are child of the one modified
1110 $(".groupticketchild").each(function(){
1111 if ($(this).attr("child_id") > child_id) {
1112 console.log("hide child_id="+$(this).attr("child_id"));
1118 // Now we enable the next combo
1119 $("#'.$htmlname.
'_child_'.$levelid.
'").val("");
1120 if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.
'_child_'.$levelid.
' option").length > 1) {
1121 console.log($("#'.$htmlname.
'_child_'.$levelid.
' option").length);
1122 $("#'.$htmlname.
'_child_'.$levelid.
'").show()
1124 $("#'.$htmlname.
'_child_'.$levelid.
'").hide()
1128 foreach ($tabscript as $script) {
1129 $stringtoprint .= $script;
1131 $stringtoprint .=
'})';
1132 $stringtoprint .=
'</script>';
1134 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1135 $stringtoprint .=
'$("#'.$htmlname.
'_child_'.$use_multilevel.
'").change(function() {
1136 $("#ticketcategory_select").val($(this).val());
1137 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1138 console.log($("#ticketcategory_select").val());
1140 $stringtoprint .=
'</script>';
1143 return $stringtoprint;
1160 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
1162 global $langs, $user;
1164 $ticketstat =
new Ticket($this->db);
1166 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1168 $filterarray = array();
1170 if ($filtertype !=
'' && $filtertype !=
'-1') {
1171 $filterarray = explode(
',', $filtertype);
1174 $ticketstat->loadCacheSeveritiesTickets();
1176 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1178 print
'<option value=""> </option>';
1181 if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
1182 foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
1184 if (count($filterarray) && !in_array($arrayseverities[
'type'], $filterarray)) {
1189 if ($empty && empty($arrayseverities[
'code'])) {
1194 print
'<option value="'.$id.
'"';
1198 print
'<option value="'.$arrayseverities[
'code'].
'"';
1202 print
'<option value="'.$arrayseverities[
'code'].
'"';
1206 print
'<option value="'.$id.
'"';
1210 if (isset($selected) && preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
1211 print
' selected="selected"';
1212 } elseif (isset($selected) && $selected == $id) {
1213 print
' selected="selected"';
1214 } elseif ($arrayseverities[
'use_default'] ==
"1" && empty($selected)) {
1215 print
' selected="selected"';
1222 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1226 $value = $arrayseverities[
'code'];
1230 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1234 $value = $arrayseverities[
'code'];
1237 print $value ? $value :
' ';
1242 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1243 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1258 global $conf, $user;
1259 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1262 $vardir = $conf->user->dir_output.
"/".$user->id;
1263 $upload_dir = $vardir.
'/temp/';
1264 if (is_dir($upload_dir)) {
1268 if (!empty($this->trackid)) {
1269 $keytoavoidconflict =
'-'.$this->trackid;
1271 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1273 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
1274 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
1275 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
1286 global $conf, $langs, $user, $hookmanager, $form, $mysoc;
1288 $formmail =
new FormMail($this->db);
1289 $addfileaction =
'addfile';
1291 if (!is_object($form)) {
1292 $form =
new Form($this->db);
1296 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
1299 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1300 $this->clear_attached_files();
1304 $outputlangs = $langs;
1306 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1307 $newlang = $this->param[
'langsmodels'];
1309 if (!empty($newlang)) {
1310 $outputlangs =
new Translate(
"", $conf);
1311 $outputlangs->setDefaultLang($newlang);
1312 $outputlangs->load(
'other');
1316 $arraydefaultmessage = -1;
1317 if (isset($this->param[
'models']) && $this->param[
'models'] !=
'none') {
1319 if (array_key_exists(
'models_id', $this->param)) {
1320 $model_id = (int) $this->param[
"models_id"];
1323 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id);
1327 $listofpaths = array();
1328 $listofnames = array();
1329 $listofmimes = array();
1331 if (!empty($this->trackid)) {
1332 $keytoavoidconflict =
'-'.$this->trackid;
1334 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1337 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1338 if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param[
'fileinit']) && is_array($this->param[
'fileinit'])) {
1339 foreach ($this->param[
'fileinit'] as $file) {
1340 $formmail->add_attached_files($file, basename($file),
dol_mimetype($file));
1346 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
1347 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
1349 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
1350 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
1352 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
1353 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
1357 $outputlangs = $langs;
1359 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1360 $newlang = $this->param[
'langsmodels'];
1362 if (!empty($newlang)) {
1363 $outputlangs =
new Translate(
"", $conf);
1364 $outputlangs->setDefaultLang($newlang);
1365 $outputlangs->load(
'other');
1368 print
"\n<!-- Begin message_form TICKET -->\n";
1370 $send_email =
GETPOST(
'send_email',
'int') ?
GETPOST(
'send_email',
'int') : 0;
1373 print
'<script nonce="'.getNonce().
'" type="text/javascript">
1374 jQuery(document).ready(function() {
1375 send_email=' . $send_email.
';
1377 if (!jQuery("#send_msg_email").is(":checked")) {
1378 jQuery("#send_msg_email").prop("checked", true).trigger("change");
1380 jQuery(".email_line").show();
1382 if (!jQuery("#private_message").is(":checked")) {
1383 jQuery("#private_message").prop("checked", true).trigger("change");
1385 jQuery(".email_line").hide();
1391 print
'jQuery("#send_msg_email").click(function() {
1392 console.log("Click send_msg_email");
1393 if(jQuery(this).is(":checked")) {
1394 if (jQuery("#private_message").is(":checked")) {
1395 jQuery("#private_message").prop("checked", false).trigger("change");
1397 jQuery(".email_line").show();
1400 jQuery(".email_line").hide();
1404 jQuery("#private_message").click(function() {
1405 console.log("Click private_message");
1406 if (jQuery(this).is(":checked")) {
1407 if (jQuery("#send_msg_email").is(":checked")) {
1408 jQuery("#send_msg_email").prop("checked", false).trigger("change");
1410 jQuery(".email_line").hide();
1419 print
'<form method="post" name="ticket" id="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
1420 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1421 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
1422 print
'<input type="hidden" name="actionbis" value="add_message">';
1423 print
'<input type="hidden" name="backtopage" value="'.$this->backtopage.
'">';
1424 if (!empty($this->trackid)) {
1425 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
1427 print
'<input type="hidden" name="trackid" value="'.(empty($this->track_id) ?
'' : $this->track_id).
'">';
1428 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1430 foreach ($this->param as $key => $value) {
1431 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
1436 if (array_key_exists(
'models_id', $this->param)) {
1437 $model_id = $this->param[
"models_id"];
1438 $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param[
"models"], $user, $outputlangs, $model_id);
1441 $result = $formmail->fetchAllEMailTemplate(!empty($this->param[
"models"]) ? $this->param[
"models"] :
"", $user, $outputlangs);
1445 $modelmail_array = array();
1446 foreach ($formmail->lines_model as $line) {
1447 $modelmail_array[$line->id] = $line->label;
1450 print
'<table class="border" width="'.$width.
'">';
1453 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1454 $ticketstat =
new Ticket($this->db);
1455 $res = $ticketstat->fetch(
'',
'', $this->track_id);
1457 print
'<tr><td></td><td>';
1458 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : (
getDolGlobalInt(
'TICKETS_MESSAGE_FORCE_MAIL') ?
'checked' :
''));
1459 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1460 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1461 $texttooltip = $langs->trans(
"TicketMessageSendEmailHelp");
1463 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2b");
1465 $texttooltip .=
' '.$langs->trans(
"TicketMessageSendEmailHelp2a",
'{s1}');
1467 $texttooltip = str_replace(
'{s1}', $langs->trans(
'MarkMessageAsPrivate'), $texttooltip);
1468 print
' '.$form->textwithpicto(
'', $texttooltip, 1,
'help');
1472 if (!$user->socid) {
1473 print
'<tr><td></td><td>';
1474 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1475 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1476 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1477 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1482 if (count($modelmail_array) > 0) {
1483 print
'<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'.
"\n";
1484 print $langs->trans(
'SelectMailModel').
': '.$formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], 1, 0,
"",
"", 0, 0, 0,
'',
'minwidth200');
1486 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1489 print
'<input type="submit" class="button" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1490 print
'</div></td>';
1494 foreach ($formmail->lines_model as $line) {
1495 if (!empty($this->substit) && $this->param[
'models_id'] == $line->id) {
1500 print
'<tr class="email_line"><td>'.$langs->trans(
'Subject').
'</td>';
1501 if (empty($topic)) {
1502 print
'<td><input type="text" class="text minwidth500" name="subject" value="['.getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
' - '.$langs->trans(
"Ticket").
' '.$ticketstat->ref.
'] '.$langs->trans(
'TicketNewMessage').
'" />';
1504 print
'<td><input type="text" class="text minwidth500" name="subject" value="['.getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
' - '.$langs->trans(
"Ticket").
' '.$ticketstat->ref.
'] '.$topic.
'" />';
1509 print
'<tr class="email_line"><td>'.$langs->trans(
'MailRecipients');
1510 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessageRecipientsHelp"), 1,
'help');
1514 $contacts = $ticketstat->getInfosTicketInternalContact(1);
1515 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact(1));
1520 if (is_array($contacts) && count($contacts) > 0) {
1521 foreach ($contacts as $key => $info_sendto) {
1522 if ($info_sendto[
'email'] !=
'') {
1523 $sendto[] =
dol_escape_htmltag(trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">").
' <small class="opacitymedium">('.
dol_escape_htmltag($info_sendto[
'libelle']).
")</small>";
1528 if ($ticketstat->origin_email && !in_array($ticketstat->origin_email, $sendto)) {
1529 $sendto[] =
dol_escape_htmltag($ticketstat->origin_email).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
1532 if ($ticketstat->fk_soc > 0) {
1533 $ticketstat->socid = $ticketstat->fk_soc;
1534 $ticketstat->fetch_thirdparty();
1536 if (!empty($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
1537 $sendto[] = $ticketstat->thirdparty->email.
' <small class="opacitymedium">('.$langs->trans(
'Customer').
')</small>';
1542 $sendto[] =
getDolGlobalString(
'TICKET_NOTIFICATION_EMAIL_TO').
' <small class="opacitymedium">(generic email)</small>';
1546 if (is_array($sendto) && count($sendto) > 0) {
1547 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
1548 print implode(
', ', $sendto);
1550 print
'<div class="warning">'.$langs->trans(
'WarningNoEMailsAdded').
' '.$langs->trans(
'TicketGoIntoContactTab').
'</div>';
1556 $uselocalbrowser =
false;
1578 if (!empty($this->withfile)) {
1580 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
1583 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1584 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
1585 $out .=
'jQuery(document).ready(function () {';
1586 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1587 $out .=
' jQuery("#addedfile").on("change", function() {';
1588 $out .=
' if (jQuery(this).val().length) {';
1589 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", false);';
1590 $out .=
' } else {';
1591 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1594 $out .=
' jQuery(".removedfile").click(function() {';
1595 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1598 $out .=
'</script>'.
"\n";
1600 if (count($listofpaths)) {
1601 foreach ($listofpaths as $key => $val) {
1602 $out .=
'<div id="attachfile_'.$key.
'">';
1603 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1604 if (!$this->withfilereadonly) {
1605 $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.
'" />';
1607 $out .=
'<br></div>';
1612 if ($this->withfile == 2) {
1613 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1615 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1617 $out .=
"</td></tr>\n";
1624 $defaultmessage =
"";
1625 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1626 $defaultmessage = $arraydefaultmessage->content;
1628 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1632 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1633 } elseif (!
dol_textishtml($defaultmessage) && isset($this->substit[
'__USER_SIGNATURE__']) &&
dol_textishtml($this->substit[
'__USER_SIGNATURE__'])) {
1634 $defaultmessage =
dol_nl2br($defaultmessage);
1636 if (GETPOSTISSET(
"message") && !
GETPOST(
'modelselected')) {
1637 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1641 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1642 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1645 print
'<tr><td colspan="2"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1646 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1647 $texttooltip = $langs->trans(
"TicketMessageHelp");
1649 $texttooltip .=
'<br><br>'.$langs->trans(
"ForEmailMessageWillBeCompletedWith").
'...';
1652 $texttooltip .=
'<br><u>'.$langs->trans(
"TicketMessageMailIntro").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO');
1655 $texttooltip .=
'<br><br><u>'.$langs->trans(
"TicketMessageMailFooter").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_SIGNATURE');
1657 print $form->textwithpicto(
'', $texttooltip, 1,
'help');
1659 print
'</label></td></tr>';
1662 print
'<tr><td colspan="2">';
1664 $toolbarname =
'dolibarr_notes';
1665 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1666 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_TICKET'), ROWS_5,
'90%');
1667 $doleditor->Create();
1686 print
'<br><center>';
1687 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"Add").
'"';
1689 if ($this->withfile == 2 && !empty($conf->use_javascript_ajax)) {
1690 print
' onClick="if (document.ticket.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans(
"FileWasNotUploaded")).
'\');
return false; }
else {
return true; }
"';
1693 if (!empty($this->withcancel)) {
1694 print "
";
1695 print '<input class="button button-cancel
" type="submit
" name="cancel
" value="'.$langs->trans("Cancel").'">';
1697 print "</center>\n
";
1699 print '<input type="hidden
" name="page_y
">'."\n
";
1701 print "</form><br>\n
";
1703 // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
1704 if (getDolGlobalString('MAIN_MAILFORM_DISABLE_ENTERKEY')) {
1705 print '<script type="text/javascript
">';
1706 print 'jQuery(document).ready(function () {';
1707 print ' $(document).on("keypress
", \'#ticket\', function (e) { /* Note this is called at every key pressed ! */
1708 var code = e.keyCode || e.which;
1710 console.log("Enter was intercepted and blocked
");
1719 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.