28 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
29 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
30 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
32 if (!class_exists(
'FormCompany')) {
33 include DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
59 public $fk_user_create;
75 public $withfilereadonly;
81 public $withtitletopic;
82 public $withtopicreadonly;
86 public $withfromsocid;
87 public $withfromcontactid;
88 public $withnotifytiersatcreate;
89 public $withusercreate;
90 public $withcreatereadonly;
97 public $category_code;
98 public $severity_code;
105 public $substit = array();
106 public $param = array();
112 public $errors = array();
126 $this->action =
'add';
129 $this->withfromsocid = 0;
130 $this->withfromcontactid = 0;
133 $this->withnotifytiersatcreate = 0;
134 $this->withusercreate = 1;
135 $this->withcreatereadonly = 1;
136 $this->withemail = 0;
138 $this->withextrafields = 0;
152 public function showForm($withdolfichehead = 0, $mode =
'edit', $public = 0,
Contact $with_contact =
null, $action =
'')
154 global $conf, $langs, $user, $hookmanager;
157 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
161 $ticketstatic =
new Ticket($this->
db);
164 if (!empty($this->withfromsocid) && $this->withfromsocid > 0) {
165 $soc->fetch($this->withfromsocid);
168 $ticketstat =
new Ticket($this->
db);
171 $extrafields->fetch_name_optionals_label($ticketstat->table_element);
173 print
"\n<!-- Begin form TICKET -->\n";
175 if ($withdolfichehead) {
179 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']).
'">';
180 print
'<input type="hidden" name="token" value="'.newToken().
'">';
181 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
182 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
183 foreach ($this->param as $key => $value) {
184 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
186 print
'<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.
'">';
188 print
'<table class="border centpercent">';
190 if ($this->withref) {
192 $defaultref = $ticketstat->getDefaultRef();
193 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Ref").
'</span></td><td>';
194 print
'<input type="text" name="ref" value="'.dol_escape_htmltag(
GETPOST(
"ref",
'alpha') ?
GETPOST(
"ref",
'alpha') : $defaultref).
'">';
200 if ($this->withemail) {
201 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"Email").
'</span></label></td><td>';
202 print
'<input class="text minwidth200" id="email" name="email" value="'.$email.
'" autofocus>';
207 $html_contact_search =
'';
208 $html_contact_search .=
'<tr id="contact_search_line">';
209 $html_contact_search .=
'<td class="titlefield">';
210 $html_contact_search .=
'<label for="contact"><span class="fieldrequired">' . $langs->trans(
'Contact') .
'</span></label>';
211 $html_contact_search .=
'<input type="hidden" id="contact_id" name="contact_id" value="" />';
212 $html_contact_search .=
'</td>';
213 $html_contact_search .=
'<td id="contact_search_result"></td>';
214 $html_contact_search .=
'</tr>';
215 print $html_contact_search;
217 $html_contact_lastname =
'';
218 $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>';
219 $html_contact_lastname .=
'<input type="text" id="contact_lastname" name="contact_lastname" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_lastname') ?
GETPOST(
'contact_lastname',
'alphanohtml') :
'') .
'" />';
220 $html_contact_lastname .=
'</td></tr>';
221 print $html_contact_lastname;
223 $html_contact_firstname =
'';
224 $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>';
225 $html_contact_firstname .=
'<input type="text" id="contact_firstname" name="contact_firstname" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_firstname') ?
GETPOST(
'contact_firstname',
'alphanohtml') :
'') .
'" />';
226 $html_contact_firstname .=
'</td></tr>';
227 print $html_contact_firstname;
229 $html_company_name =
'';
230 $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>';
231 $html_company_name .=
'<input type="text" id="company_name" name="company_name" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'company_name') ?
GETPOST(
'company_name',
'alphanohtml') :
'') .
'" />';
232 $html_company_name .=
'</td></tr>';
233 print $html_company_name;
235 $html_contact_phone =
'';
236 $html_contact_phone .=
'<tr id="contact_phone_line" class="contact_field"><td><label for="contact_phone"><span>' . $langs->trans(
'Phone') .
'</span></label></td><td>';
237 $html_contact_phone .=
'<input type="text" id="contact_phone" name="contact_phone" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_phone') ?
GETPOST(
'contact_phone',
'alphanohtml') :
'') .
'" />';
238 $html_contact_phone .=
'</td></tr>';
239 print $html_contact_phone;
242 $langs->load(
'errors');
243 print
'<script type="text/javascript">
244 jQuery(document).ready(function() {
245 var contact = jQuery.parseJSON("'.dol_escape_js(json_encode($with_contact), 2).
'");
246 jQuery("#contact_search_line").hide();
248 if (contact.id > 0) {
249 jQuery("#contact_search_line").show();
250 jQuery("#contact_id").val(contact.id);
251 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
252 jQuery(".contact_field").hide();
254 jQuery(".contact_field").show();
258 jQuery("#email").change(function() {
259 jQuery("#contact_search_line").show();
260 jQuery("#contact_search_result").html("'.
dol_escape_js($langs->trans(
'Select2SearchInProgress')).
'");
261 jQuery("#contact_id").val("");
262 jQuery("#contact_lastname").val("");
263 jQuery("#contact_firstname").val("");
264 jQuery("#company_name").val("");
265 jQuery("#contact_phone").val("");
270 action: "getContacts",
271 email: jQuery("#email").val()
274 if (response.error) {
275 jQuery("#contact_search_result").html("<span class=\"error\">"+response.error+"</span>");
277 var contact_list = response.contacts;
278 if (contact_list.length == 1) {
279 var contact = contact_list[0];
280 jQuery("#contact_id").val(contact.id);
281 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
282 jQuery(".contact_field").hide();
283 } else if (contact_list.length <= 0) {
284 jQuery("#contact_search_line").hide();
285 jQuery(".contact_field").show();
289 ).fail(function(jqxhr, textStatus, error) {
290 var error_msg = "'.
dol_escape_js($langs->trans(
'ErrorAjaxRequestFailed')).
'"+" ["+textStatus+"] : "+error;
291 jQuery("#contact_search_result").html("<span class=\"error\">"+error_msg+"</span>");
301 if (isset($this->param[
'origin']) && $this->param[
'originid'] > 0) {
303 $element = $subelement = $this->param[
'origin'];
305 if (preg_match(
'/^([^_]+)_([^_]+)/i', $this->param[
'origin'], $regs)) {
307 $subelement = $regs[2];
311 $classname = ucfirst($subelement);
312 $objectsrc =
new $classname($this->
db);
313 $objectsrc->fetch(
GETPOST(
'originid',
'int'));
315 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
316 $objectsrc->fetch_lines();
319 $objectsrc->fetch_thirdparty();
320 $newclassname = $classname;
321 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td colspan="2"><input name="'.$subelement.
'id" value="'.
GETPOST(
'originid').
'" type="hidden" />'.$objectsrc->getNomUrl(1).
'</td></tr>';
325 print
'<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans(
"TicketTypeRequest").
'</span></label></td><td>';
330 print
'<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans(
"TicketCategory").
'</span></label></td><td>';
333 $filter =
'public=1';
335 $selected = (
GETPOST(
'category_code') ?
GETPOST(
'category_code') : $this->category_code);
336 $this->
selectGroupTickets($selected,
'category_code', $filter, 2, 1, 0, 0,
'minwidth200');
340 print
'<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans(
"TicketSeverity").
'</span></label></td><td>';
344 if (!empty($conf->knowledgemanagement->enabled)) {
346 print
'<tr id="KWwithajax" class="hidden"><td></td></tr>';
347 print
'<!-- Script to manage change of ticket group -->
349 jQuery(document).ready(function() {
350 function groupticketchange(){
351 console.log("We called groupticketchange, so we try to load list KM linked to event");
352 $("#KWwithajax").html("");
353 idgroupticket = $("#selectcategory_code").val();
355 console.log("We have selected id="+idgroupticket);
357 if (idgroupticket != "") {
358 $.ajax({ url: \''.DOL_URL_ROOT.
'/core/ajax/fetchKnowledgeRecord.php\',
359 data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.
newToken().
'\', lang:\
''.$langs->defaultlang.
'\',
public:
'.($public).' },
361 success: function(response) {
363 console.log("We received response "+response);
364 if (typeof response == "object") {
365 console.log("response is already type object, no need to parse it");
367 console.log("response is type "+(typeof response));
368 response = JSON.parse(response);
370 for (key in response) {
371 answer = response[key].answer;
372 urllist += \'<li><a href="#" title="\'+response[key].title+\'" class="button_KMpopup" data-html="\'+answer+\'">\' +response[key].title+\'</a></li>\';
375 $("#KWwithajax").html(\'<td>'.$langs->trans(
"KMFoundForTicketGroup").
'</td><td><ul>\'+urllist+\'</ul></td>\');
376 $("#KWwithajax").show();
377 $(".button_KMpopup").on("click",function(){
378 console.log("Open popup with jQuery(...).dialog() with KM article")
379 var $dialog = $("<div></div>").html($(this).attr("data-html"))
383 height: (window.innerHeight - 150),
385 title: $(this).attr("title"),
387 $dialog.dialog("open");
388 console.log($dialog);
392 error : function(output) {
393 console.error("Error on Fetch of KM articles");
398 $("#selectcategory_code").on("change",function() { groupticketchange(); });
399 if ($("#selectcategory_code").val() != "") {
407 if ($this->withtitletopic) {
408 print
'<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans(
"Subject").
'</span></label></td><td>';
410 if ($this->withtopicreadonly) {
411 print $langs->trans(
'SubjectAnswerToTicket').
' '.$this->topic_title;
413 if (isset($this->withreadid) && $this->withreadid > 0) {
414 $subject = $langs->trans(
'SubjectAnswerToTicket').
' '.$this->withreadid.
' : '.$this->topic_title;
416 $subject =
GETPOST(
'subject',
'alpha');
418 print
'<input class="text minwidth500" id="subject" name="subject" value="'.$subject.
'"'.(empty($this->withemail)?
' autofocus':
'').
' />';
425 print
'<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span></label></td><td>';
428 $toolbarname =
'dolibarr_notes';
429 if ($this->ispublic) {
430 $toolbarname =
'dolibarr_details';
431 print
'<div class="warning hideonsmartphone">'.(getDolGlobalString(
"TICKET_PUBLIC_TEXT_HELP_MESSAGE", $langs->trans(
'TicketPublicPleaseBeAccuratelyDescribe'))).
'</div>';
433 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
434 $uselocalbrowser =
true;
435 $doleditor =
new DolEditor(
'message', $msg,
'100%', 230, $toolbarname,
'In',
true, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_TICKET'), ROWS_8,
'90%');
436 $doleditor->Create();
439 if ($public && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
440 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
441 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td>';
442 print
'<span class="span-icon-security inline-block">';
443 print
'<input id="securitycode" placeholder="'.$langs->trans(
"SecurityCode").
'" class="flat input-icon-security width125" type="text" maxlength="5" name="code" tabindex="3" />';
445 print
'<span class="nowrap inline-block">';
446 print
'<img class="inline-block valignmiddle" src="'.DOL_URL_ROOT.
'/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />';
447 print
'<a class="inline-block valignmiddle" href="" tabindex="4" data-role="button">'.img_picto($langs->trans(
"Refresh"),
'refresh',
'id="captcha_refresh_img"').
'</a>';
454 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
455 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_TICKET,
'',
'parent', 64, 0, 1);
457 if (count($cate_arbo)) {
459 print
'<tr><td class="wordbreak">'.$langs->trans(
"Categories").
'</td><td>';
460 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
466 if (!empty($this->withfile)) {
468 $listofpaths = array();
469 $listofnames = array();
470 $listofmimes = array();
471 if (!empty($_SESSION[
"listofpaths"])) {
472 $listofpaths = explode(
';', $_SESSION[
"listofpaths"]);
475 if (!empty($_SESSION[
"listofnames"])) {
476 $listofnames = explode(
';', $_SESSION[
"listofnames"]);
479 if (!empty($_SESSION[
"listofmimes"])) {
480 $listofmimes = explode(
';', $_SESSION[
"listofmimes"]);
484 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
487 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
488 $out .=
'<script type="text/javascript">';
489 $out .=
'jQuery(document).ready(function () {';
490 $out .=
' jQuery(".removedfile").click(function() {';
491 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
494 $out .=
'</script>'.
"\n";
495 if (count($listofpaths)) {
496 foreach ($listofpaths as $key => $val) {
497 $out .=
'<div id="attachfile_'.$key.
'">';
498 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
499 if (!$this->withfilereadonly) {
500 $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.
'" />';
502 $out .=
'<br></div>';
505 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
507 if ($this->withfile == 2) {
509 $maxmin = $maxfilesizearray[
'maxmin'];
511 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
513 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
515 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="addfile" name="addfile" value="'.$langs->trans(
"MailingAddFile").
'" />';
517 $out .=
"</td></tr>\n";
523 if ($this->withusercreate > 0 && $this->fk_user_create) {
524 print
'<tr><td class="titlefield">'.$langs->trans(
"CreatedBy").
'</td><td>';
525 $langs->load(
"users");
526 $fuser =
new User($this->
db);
528 if ($this->withcreatereadonly) {
529 if ($res = $fuser->fetch($this->fk_user_create)) {
530 print $fuser->getNomUrl(1);
534 print
"</td></tr>\n";
538 if ($this->withcompany) {
540 if (empty($user->socid)) {
542 print
'<tr><td class="titlefield">'.$langs->trans(
"ThirdParty").
'</td><td>';
544 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
545 print
img_picto(
'',
'company',
'class="paddingright"');
546 print
$form->select_company($this->withfromsocid,
'socid',
'', 1, 1,
'', $events, 0,
'minwidth200');
548 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
550 print
'<script type="text/javascript">
551 $(document).ready(function () {
552 jQuery("#'.$htmlname.
'").change(function () {
553 var obj = '.json_encode($events).
';
554 $.each(obj, function(key,values) {
555 if (values.method.length) {
556 runJsCodeForEvent'.$htmlname.
'(values);
561 function runJsCodeForEvent'.$htmlname.
'(obj) {
562 console.log("Run runJsCodeForEvent'.$htmlname.
'");
563 var id = $("#'.$htmlname.
'").val();
564 var method = obj.method;
566 var htmlname = obj.htmlname;
567 var showempty = obj.showempty;
576 $.each(obj.params, function(key,action) {
578 var num = response.num;
580 $("#" + key).removeAttr(action);
582 $("#" + key).attr(action, action);
586 $("select#" + htmlname).html(response.value);
588 var selecthtml_str = response.value;
589 var selecthtml_dom=$.parseHTML(selecthtml_str);
590 if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
591 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
594 $("#inputautocomplete"+htmlname).val("");
596 $("select#" + htmlname).change(); /* Trigger event change */
605 print
'<tr><td>'.$langs->trans(
"Contact").
'</td><td>';
607 $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
608 print
img_picto(
'',
'contact',
'class="paddingright"');
609 print
$form->selectcontacts($selectedCompany, $this->withfromcontactid,
'contactid', 3,
'',
'', 0,
'minwidth200');
611 $formcompany->selectTypeContact($ticketstatic,
'',
'type',
'external',
'', 0,
'maginleftonly');
614 print
'<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.
'"/></td>';
615 print
'<td><input type="hidden" name="contactid" value="'.$user->contact_id.
'"/></td>';
616 print
'<td><input type="hidden" name="type" value="Z"/></td></tr>';
620 if (empty($this->ispublic)) {
621 print
'<tr><td><label for="notify_tiers_at_create">'.$langs->trans(
"TicketNotifyTiersAtCreation").
'</label></td><td>';
622 print
'<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ?
' checked="checked"' :
'').
'>';
628 print $langs->trans(
"AssignedTo");
630 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
631 print
$form->select_dolusers(
GETPOST(
'fk_user_assign',
'int'),
'fk_user_assign', 1);
636 if ($subelement !=
'project') {
639 print
'<tr><td><label for="project"><span class="">'.$langs->trans(
"Project").
'</span></label></td><td>';
640 print
img_picto(
'',
'project').$formproject->select_projects(-1,
GETPOST(
'projectid',
'int'),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
646 $parameters = array();
647 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $ticketstat, $action);
648 if (empty($reshook)) {
649 print $ticketstat->showOptionals($extrafields,
'create');
654 if ($withdolfichehead) {
660 print
$form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"CreateTicket"), ($this->withcancel ?
"Cancel" :
""));
672 print
'<input type="hidden" name="page_y">'.
"\n";
675 print
"<!-- End form TICKET -->\n";
692 public function selectTypesTickets($selected =
'', $htmlname =
'tickettype', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $multiselect = 0)
694 global $langs, $user;
696 $selected = is_array($selected) ? $selected : (!empty($selected) ? explode(
',', $selected) : array());
697 $ticketstat =
new Ticket($this->
db);
699 dol_syslog(get_class($this) .
"::select_types_tickets " . implode(
';', $selected) .
", " . $htmlname .
", " . $filtertype .
", " . $format .
", " . $multiselect, LOG_DEBUG);
701 $filterarray = array();
703 if ($filtertype !=
'' && $filtertype !=
'-1') {
704 $filterarray = explode(
',', $filtertype);
707 $ticketstat->loadCacheTypesTickets();
709 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.($multiselect?
'[]':
'').
'"'.($multiselect?
' multiple':
'').
'>';
711 print
'<option value=""> </option>';
714 if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
715 foreach ($ticketstat->cache_types_tickets as $id => $arraytypes) {
717 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
722 if ($empty && empty($arraytypes[
'code'])) {
727 print
'<option value="'.$id.
'"';
731 print
'<option value="'.$arraytypes[
'code'].
'"';
735 print
'<option value="'.$arraytypes[
'code'].
'"';
739 print
'<option value="'.$id.
'"';
743 if (in_array($arraytypes[
'code'], $selected)) {
744 print
' selected="selected"';
745 } elseif (in_array($id, $selected)) {
746 print
' selected="selected"';
747 } elseif ($arraytypes[
'use_default'] ==
"1" && !$selected && !$empty) {
748 print
' selected="selected"';
755 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
756 } elseif ($format == 1) {
757 $value = $arraytypes[
'code'];
758 } elseif ($format == 2) {
759 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
760 } elseif ($format == 3) {
761 $value = $arraytypes[
'code'];
764 print $value ? $value :
' ';
769 if (isset($user->admin) && $user->admin && !$noadmininfo) {
770 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
791 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs =
null)
793 global $conf, $langs, $user;
795 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
797 if (is_null($outputlangs) || !is_object($outputlangs)) {
798 $outputlangs = $langs;
800 $outputlangs->load(
"ticket");
802 $publicgroups = ($filtertype ==
'public=1' || $filtertype ==
'(public:=:1)');
804 $ticketstat =
new Ticket($this->
db);
805 $ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1);
807 if ($use_multilevel <= 0) {
808 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
810 print
'<option value=""> </option>';
813 if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
814 foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
817 if (empty($arraycategories[
'public'])) {
823 if ($empty && empty($arraycategories[
'code'])) {
827 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
828 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) != (
"TicketCategoryShort".$arraycategories[
'code'])) {
829 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
830 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
831 $label = $outputlangs->trans($arraycategories[
'code']);
835 print
'<option value="'.$id.
'"';
839 print
'<option value="'.$arraycategories[
'code'].
'"';
843 print
'<option value="'.$arraycategories[
'code'].
'"';
847 print
'<option value="'.$id.
'"';
851 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
852 print
' selected="selected"';
853 } elseif ($selected == $id) {
854 print
' selected="selected"';
855 } elseif ($arraycategories[
'use_default'] ==
"1" && !$selected && !$empty) {
856 print
' selected="selected"';
857 } elseif (count($ticketstat->cache_category_tickets) == 1) {
858 print
' selected="selected"';
865 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
869 $value = $arraycategories[
'code'];
873 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
877 $value = $arraycategories[
'code'];
880 print $value ? $value :
' ';
885 if (isset($user->admin) && $user->admin && !$noadmininfo) {
886 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
890 } elseif ($htmlname!=
'') {
891 $selectedgroups = array();
893 $groupticket=
GETPOST($htmlname,
'aZ09');
894 $child_id=
GETPOST($htmlname.
'_child_id',
'aZ09')?
GETPOST($htmlname.
'_child_id',
'aZ09'):0;
895 if (!empty($groupticket)) {
896 $tmpgroupticket = $groupticket;
897 $sql =
"SELECT ctc.rowid, ctc.fk_parent, ctc.code FROM ".$this->db->prefix().
"c_ticket_category as ctc WHERE ctc.code = '".$this->
db->escape($tmpgroupticket).
"'";
900 $obj = $this->
db->fetch_object(
$resql);
901 $selectedgroups[] = $obj->code;
902 while ($obj->fk_parent > 0) {
903 $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).
"'";
906 $obj = $this->
db->fetch_object(
$resql);
907 $selectedgroups[] = $obj->code;
913 $arrayidused = array();
914 $arrayidusedconcat = array();
915 $arraycodenotparent = array();
916 $arraycodenotparent[] =
"";
918 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
919 $stringtoprint .=
'<select id ="'.$htmlname.
'" class="minwidth500" child_id="0">';
920 $stringtoprint .=
'<option value=""> </option>';
922 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
923 $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";
924 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
925 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
926 if ($filtertype ==
'public=1') {
927 $sql .=
" AND ctc.public = 1";
929 $sql .=
" AND ctc.fk_parent = 0";
930 $sql .= $this->
db->order(
'ctc.pos',
'ASC');
934 $num_rows_level0 = $this->
db->num_rows(
$resql);
936 while ($i < $num_rows_level0) {
937 $obj = $this->
db->fetch_object(
$resql);
939 $label = ($obj->label !=
'-' ? $obj->label :
'');
940 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
941 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
942 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
943 $label = $outputlangs->trans($obj->code);
946 $grouprowid = $obj->rowid;
947 $groupvalue = $obj->code;
948 $grouplabel = $label;
950 $isparent = $obj->isparent;
951 if (is_array($selectedgroups)) {
952 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
954 $iselected = $groupticket == $obj->code ?
'selected':
'';
957 if ($isparent ==
'NOTPARENT') {
958 $arraycodenotparent[] = $groupvalue;
960 $arrayidused[] = $grouprowid;
961 $arrayidusedconcat[] = $grouprowid;
968 if (count($arrayidused) == 1) {
969 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
971 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400">';
972 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400">';
974 $stringtoprint .=
'</select> ';
977 while ($levelid <= $use_multilevel) {
978 $tabscript = array();
979 $stringtoprint .=
'<select id ="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
980 $stringtoprint .=
'<option value=""> </option>';
982 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
983 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
984 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
985 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
986 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(join(
',', $arrayidusedconcat)).
")";
988 if ($filtertype ==
'public=1') {
989 $sql .=
" AND ctc.public = 1";
992 if (!empty($arrayidused)) {
993 $sql .=
" AND ctc.fk_parent IN ( ";
994 foreach ($arrayidused as $idused) {
995 $sql .= $idused.
", ";
997 $sql = substr($sql, 0, -2);
1001 $sql .= $this->
db->order(
'ctc.pos',
'ASC');
1005 $num_rows = $this->
db->num_rows(
$resql);
1007 $arrayidused=array();
1008 while ($i < $num_rows) {
1009 $obj = $this->
db->fetch_object(
$resql);
1011 $label = ($obj->label !=
'-' ? $obj->label :
'');
1012 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
1013 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1014 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1015 $label = $outputlangs->trans($obj->code);
1018 $grouprowid = $obj->rowid;
1019 $groupvalue = $obj->code;
1020 $grouplabel = $label;
1021 $isparent = $obj->isparent;
1022 $fatherid = $obj->fk_parent;
1023 $arrayidused[] = $grouprowid;
1024 $arrayidusedconcat[] = $grouprowid;
1025 $groupcodefather = $obj->codefather;
1026 if ($isparent ==
'NOTPARENT') {
1027 $arraycodenotparent[] = $groupvalue;
1029 if (is_array($selectedgroups)) {
1030 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
1032 $iselected = $groupticket == $obj->code ?
'selected':
'';
1035 if (empty($tabscript[$groupcodefather])) {
1036 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid-1:
'').
'").val() == "'.
dol_escape_js($groupcodefather).
'"){
1038 console.log("We show childs tickets of '.$groupcodefather.
' group ticket")
1041 console.log("We hide childs tickets of '.$groupcodefather.
' group ticket")
1050 $stringtoprint .=
'</select>';
1052 $stringtoprint .=
'<script>';
1053 $stringtoprint .=
'arraynotparents = '.json_encode($arraycodenotparent).
';';
1054 $stringtoprint .=
'if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid-1:
'').
'").val())){
1055 console.log("'.$htmlname.
'_child_'.$levelid.
'")
1056 if($("#'.$htmlname.
'_child_'.$levelid.
'").val() == "" && ($("#'.$htmlname.
'_child_'.$levelid.
'").attr("child_id")>'.$child_id.
')){
1057 $("#'.$htmlname.
'_child_'.$levelid.
'").hide();
1058 console.log("We hide '.$htmlname.
'_child_'.$levelid.
' input")
1060 if(arraynotparents.includes("'.$groupticket.
'") && '.$child_id.
' == 0){
1061 $("#ticketcategory_select_child_id").val($("#'.$htmlname.
'").attr("child_id"))
1062 $("#ticketcategory_select").val($("#'.$htmlname.
'").val()) ;
1063 console.log("We choose '.$htmlname.
' input and reload hidden input");
1066 $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid-1:
'').
'").change(function() {
1067 child_id = $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid:
'').
'").attr("child_id");
1069 /* Change of value to select this value*/
1070 if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.
') {
1071 $("#ticketcategory_select").val($(this).val());
1072 $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1073 console.log("We choose to select "+ $(this).val());
1075 if ($("#'.$htmlname.
'_child_'.$levelid.
' option").length <= 1) {
1076 $("#ticketcategory_select").val($(this).val());
1077 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1078 console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1080 console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1081 $("#ticketcategory_select").val("");
1082 $("#ticketcategory_select_child_id").val("");
1086 console.log("We select a new value into combo child_id="+child_id);
1088 // Hide all selected box that are child of the one modified
1089 $(".groupticketchild").each(function(){
1090 if ($(this).attr("child_id") > child_id) {
1091 console.log("hide child_id="+$(this).attr("child_id"));
1097 // Now we enable the next combo
1098 $("#'.$htmlname.
'_child_'.$levelid.
'").val("");
1099 if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.
'_child_'.$levelid.
' option").length > 1) {
1100 console.log($("#'.$htmlname.
'_child_'.$levelid.
' option").length);
1101 $("#'.$htmlname.
'_child_'.$levelid.
'").show()
1103 $("#'.$htmlname.
'_child_'.$levelid.
'").hide()
1107 foreach ($tabscript as $script) {
1108 $stringtoprint .= $script;
1110 $stringtoprint .=
'})';
1111 $stringtoprint .=
'</script>';
1113 $stringtoprint .=
'<script>';
1114 $stringtoprint .=
'$("#'.$htmlname.
'_child_'.$use_multilevel.
'").change(function() {
1115 $("#ticketcategory_select").val($(this).val());
1116 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1117 console.log($("#ticketcategory_select").val());
1119 $stringtoprint .=
'</script>';
1122 return $stringtoprint;
1139 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
1141 global $langs, $user;
1143 $ticketstat =
new Ticket($this->
db);
1145 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1147 $filterarray = array();
1149 if ($filtertype !=
'' && $filtertype !=
'-1') {
1150 $filterarray = explode(
',', $filtertype);
1153 $ticketstat->loadCacheSeveritiesTickets();
1155 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1157 print
'<option value=""> </option>';
1160 if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
1161 foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
1163 if (count($filterarray) && !in_array($arrayseverities[
'type'], $filterarray)) {
1168 if ($empty && empty($arrayseverities[
'code'])) {
1173 print
'<option value="'.$id.
'"';
1177 print
'<option value="'.$arrayseverities[
'code'].
'"';
1181 print
'<option value="'.$arrayseverities[
'code'].
'"';
1185 print
'<option value="'.$id.
'"';
1189 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
1190 print
' selected="selected"';
1191 } elseif ($selected == $id) {
1192 print
' selected="selected"';
1193 } elseif ($arrayseverities[
'use_default'] ==
"1" && !$selected && !$empty) {
1194 print
' selected="selected"';
1201 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1205 $value = $arrayseverities[
'code'];
1209 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1213 $value = $arrayseverities[
'code'];
1216 print $value ? $value :
' ';
1221 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1222 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1237 global $conf, $user;
1238 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1241 $vardir = $conf->user->dir_output.
"/".$user->id;
1242 $upload_dir = $vardir.
'/temp/';
1243 if (is_dir($upload_dir)) {
1247 if (!empty($this->trackid)) {
1248 $keytoavoidconflict =
'-'.$this->trackid;
1250 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1252 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
1253 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
1254 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
1265 global $conf, $langs, $user, $hookmanager,
$form, $mysoc;
1268 $addfileaction =
'addfile';
1270 if (!is_object(
$form)) {
1275 $langs->loadLangs(array(
'other',
'mails'));
1278 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1279 $this->clear_attached_files();
1283 $outputlangs = $langs;
1285 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1286 $newlang = $this->param[
'langsmodels'];
1288 if (!empty($newlang)) {
1289 $outputlangs =
new Translate(
"", $conf);
1290 $outputlangs->setDefaultLang($newlang);
1291 $outputlangs->load(
'other');
1295 $arraydefaultmessage = -1;
1296 if (isset($this->param[
'models']) && $this->param[
'models'] !=
'none') {
1298 if (array_key_exists(
'models_id', $this->param)) {
1299 $model_id = (int) $this->param[
"models_id"];
1302 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
1306 $listofpaths = array();
1307 $listofnames = array();
1308 $listofmimes = array();
1310 if (!empty($this->trackid)) {
1311 $keytoavoidconflict =
'-'.$this->trackid;
1313 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1316 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1317 if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param[
'fileinit']) && is_array($this->param[
'fileinit'])) {
1318 foreach ($this->param[
'fileinit'] as $file) {
1319 $formmail->add_attached_files($file, basename($file),
dol_mimetype($file));
1325 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
1326 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
1328 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
1329 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
1331 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
1332 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
1336 $outputlangs = $langs;
1338 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1339 $newlang = $this->param[
'langsmodels'];
1341 if (!empty($newlang)) {
1342 $outputlangs =
new Translate(
"", $conf);
1343 $outputlangs->setDefaultLang($newlang);
1344 $outputlangs->load(
'other');
1347 print
"\n<!-- Begin message_form TICKET -->\n";
1349 $send_email =
GETPOST(
'send_email',
'int') ?
GETPOST(
'send_email',
'int') : 0;
1353 print
'<script type="text/javascript">
1354 jQuery(document).ready(function() {
1355 send_email=' . $send_email.
';
1357 if (!jQuery("#send_msg_email").is(":checked")) {
1358 jQuery("#send_msg_email").prop("checked", true).trigger("change");
1360 jQuery(".email_line").show();
1362 if (!jQuery("#private_message").is(":checked")) {
1363 jQuery("#private_message").prop("checked", true).trigger("change");
1365 jQuery(".email_line").hide();
1369 if (empty($conf->global->TICKET_SEND_PRIVATE_EMAIL)) {
1370 print
'jQuery("#send_msg_email").click(function() {
1371 if(jQuery(this).is(":checked")) {
1372 if (jQuery("#private_message").is(":checked")) {
1373 jQuery("#private_message").prop("checked", false).trigger("change");
1375 jQuery(".email_line").show();
1378 jQuery(".email_line").hide();
1382 jQuery("#private_message").click(function() {
1383 if (jQuery(this).is(":checked")) {
1384 if (jQuery("#send_msg_email").is(":checked")) {
1385 jQuery("#send_msg_email").prop("checked", false).trigger("change");
1387 jQuery(".email_line").hide();
1397 print
'<form method="post" name="ticket" id="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
1398 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1399 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
1400 print
'<input type="hidden" name="actionbis" value="add_message">';
1401 print
'<input type="hidden" name="backtopage" value="'.$this->backtopage.
'">';
1402 if (!empty($this->trackid)) {
1403 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
1405 print
'<input type="hidden" name="trackid" value="'.(empty($this->track_id) ?
'' : $this->track_id).
'">';
1406 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1408 foreach ($this->param as $key => $value) {
1409 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
1414 if (array_key_exists(
'models_id', $this->param)) {
1415 $model_id = $this->param[
"models_id"];
1416 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
1419 $result = $formmail->fetchAllEMailTemplate(!empty($this->param[
"models"]) ? $this->param[
"models"] :
"", $user, $outputlangs);
1423 $modelmail_array = array();
1424 foreach ($formmail->lines_model as $line) {
1425 $modelmail_array[$line->id] = $line->label;
1428 print
'<table class="border" width="'.$width.
'">';
1431 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1432 $ticketstat =
new Ticket($this->
db);
1433 $res = $ticketstat->fetch(
'',
'', $this->track_id);
1435 print
'<tr><td></td><td>';
1436 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : (
getDolGlobalInt(
'TICKETS_MESSAGE_FORCE_MAIL')?
'checked':
''));
1437 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1438 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1439 $texttooltip = $langs->trans(
"TicketMessageSendEmailHelp",
'{s1}');
1440 $texttooltip = str_replace(
'{s1}', $langs->trans(
'MarkMessageAsPrivate'), $texttooltip);
1441 print
' '.$form->textwithpicto(
'', $texttooltip, 1,
'help');
1445 if (!$user->socid) {
1446 print
'<tr><td></td><td>';
1447 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1448 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1449 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1450 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1455 if (count($modelmail_array) > 0) {
1456 print
'<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'.
"\n";
1457 print $langs->trans(
'SelectMailModel').
': '.$formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], 1, 0,
"",
"", 0, 0, 0,
'',
'minwidth200');
1459 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1462 print
'<input type="submit" class="button" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1463 print
'</div></td>';
1467 print
'<tr class="email_line"><td>'.$langs->trans(
'Subject').
'</td>';
1468 print
'<td><input type="text" class="text minwidth500" name="subject" value="['.getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
' - '.$langs->trans(
"Ticket").
' '.$ticketstat->ref.
'] '.$langs->trans(
'TicketNewMessage').
'" />';
1472 print
'<tr class="email_line"><td>'.$langs->trans(
'MailRecipients').
'</td><td>';
1475 $contacts = $ticketstat->getInfosTicketInternalContact();
1476 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact());
1481 if (is_array($contacts) && count($contacts) > 0) {
1482 foreach ($contacts as $key => $info_sendto) {
1483 if ($info_sendto[
'email'] !=
'') {
1484 $sendto[] =
dol_escape_htmltag(trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">").
' <small class="opacitymedium">('.
dol_escape_htmltag($info_sendto[
'libelle']).
")</small>";
1489 if ($ticketstat->origin_email && !in_array($ticketstat->origin_email, $sendto)) {
1490 $sendto[] =
dol_escape_htmltag($ticketstat->origin_email).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
1493 if ($ticketstat->fk_soc > 0) {
1494 $ticketstat->socid = $ticketstat->fk_soc;
1495 $ticketstat->fetch_thirdparty();
1497 if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
1498 $sendto[] = $ticketstat->thirdparty->email.
' <small class="opacitymedium">('.$langs->trans(
'Customer').
')</small>';
1503 $sendto[] =
getDolGlobalString(
'TICKET_NOTIFICATION_EMAIL_TO').
' <small class="opacitymedium">(generic email)</small>';
1507 if (is_array($sendto) && count($sendto) > 0) {
1508 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
1509 print implode(
', ', $sendto);
1511 print
'<div class="warning">'.$langs->trans(
'WarningNoEMailsAdded').
' '.$langs->trans(
'TicketGoIntoContactTab').
'</div>';
1517 $uselocalbrowser =
false;
1539 if (!empty($this->withfile)) {
1541 $out .=
'<td width="180">'.$langs->trans(
"MailFile").
'</td>';
1544 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1545 $out .=
'<script type="text/javascript">';
1546 $out .=
'jQuery(document).ready(function () {';
1547 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1548 $out .=
' jQuery("#addedfile").on("change", function() {';
1549 $out .=
' if (jQuery(this).val().length) {';
1550 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", false);';
1551 $out .=
' } else {';
1552 $out .=
' jQuery("#'.$addfileaction.
'").prop("disabled", true);';
1555 $out .=
' jQuery(".removedfile").click(function() {';
1556 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1559 $out .=
'</script>'.
"\n";
1561 if (count($listofpaths)) {
1562 foreach ($listofpaths as $key => $val) {
1563 $out .=
'<div id="attachfile_'.$key.
'">';
1564 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1565 if (!$this->withfilereadonly) {
1566 $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.
'" />';
1568 $out .=
'<br></div>';
1573 if ($this->withfile == 2) {
1574 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1576 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1578 $out .=
"</td></tr>\n";
1585 $defaultmessage =
"";
1586 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1587 $defaultmessage = $arraydefaultmessage->content;
1589 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1593 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1594 } elseif (!
dol_textishtml($defaultmessage) && isset($this->substit[
'__USER_SIGNATURE__']) &&
dol_textishtml($this->substit[
'__USER_SIGNATURE__'])) {
1595 $defaultmessage =
dol_nl2br($defaultmessage);
1598 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1602 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1603 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1606 print
'<tr><td colspan="2"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1607 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1608 $texttooltip = $langs->trans(
"TicketMessageHelp");
1610 $texttooltip .=
'<br><br>'.$langs->trans(
"ForEmailMessageWillBeCompletedWith").
'...';
1613 $texttooltip .=
'<br><u>'.$langs->trans(
"TicketMessageMailIntro").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO');
1616 $texttooltip .=
'<br><br><u>'.$langs->trans(
"TicketMessageMailFooter").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_SIGNATURE');
1618 print
$form->textwithpicto(
'', $texttooltip, 1,
'help');
1620 print
'</label></td></tr>';
1623 print
'<tr><td colspan="2">';
1625 $toolbarname =
'dolibarr_notes';
1626 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1627 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, 70);
1628 $doleditor->Create();
1647 print
'<center><br>';
1648 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"Add").
'"';
1650 if ($this->withfile == 2 && !empty($conf->use_javascript_ajax)) {
1651 print
' onClick="if (document.ticket.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans(
"FileWasNotUploaded")).
'\');
return false; }
else {
return true; }
"';
1654 if (!empty($this->withcancel)) {
1655 print "
";
1656 print '<input class="button button-cancel
" type="submit
" name="cancel
" value="'.$langs->trans("Cancel").'">';
1658 print "</center>\n
";
1660 print '<input type="hidden
" name="page_y
">'."\n
";
1664 // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
1665 if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) {
1666 print '<script type="text/javascript
">';
1667 print 'jQuery(document).ready(function () {';
1668 print ' $(document).on("keypress
", \'#ticket\', function (e) { /* Note this is called at every key pressed ! */
1669 var code = e.keyCode || e.which;
1671 console.log("Enter was intercepted and blocked
");
1680 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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
table tableforfield 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.
$conf db
API class for accounts.