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 foreach ($this->param as $key => $value) {
183 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
185 print
'<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.
'">';
187 print
'<table class="border centpercent">';
189 if ($this->withref) {
191 $defaultref = $ticketstat->getDefaultRef();
192 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Ref").
'</span></td><td>';
193 print
'<input type="text" name="ref" value="'.dol_escape_htmltag(
GETPOST(
"ref",
'alpha') ?
GETPOST(
"ref",
'alpha') : $defaultref).
'">';
199 if ($this->withemail) {
200 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"Email").
'</span></label></td><td>';
201 print
'<input class="text minwidth200" id="email" name="email" value="'.$email.
'" autofocus>';
206 $html_contact_search =
'';
207 $html_contact_search .=
'<tr id="contact_search_line">';
208 $html_contact_search .=
'<td class="titlefield">';
209 $html_contact_search .=
'<label for="contact"><span class="fieldrequired">' . $langs->trans(
'Contact') .
'</span></label>';
210 $html_contact_search .=
'<input type="hidden" id="contact_id" name="contact_id" value="" />';
211 $html_contact_search .=
'</td>';
212 $html_contact_search .=
'<td id="contact_search_result"></td>';
213 $html_contact_search .=
'</tr>';
214 print $html_contact_search;
216 $html_contact_lastname =
'';
217 $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>';
218 $html_contact_lastname .=
'<input type="text" id="contact_lastname" name="contact_lastname" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_lastname') ?
GETPOST(
'contact_lastname',
'alphanohtml') :
'') .
'" />';
219 $html_contact_lastname .=
'</td></tr>';
220 print $html_contact_lastname;
222 $html_contact_firstname =
'';
223 $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>';
224 $html_contact_firstname .=
'<input type="text" id="contact_firstname" name="contact_firstname" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_firstname') ?
GETPOST(
'contact_firstname',
'alphanohtml') :
'') .
'" />';
225 $html_contact_firstname .=
'</td></tr>';
226 print $html_contact_firstname;
228 $html_company_name =
'';
229 $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>';
230 $html_company_name .=
'<input type="text" id="company_name" name="company_name" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'company_name') ?
GETPOST(
'company_name',
'alphanohtml') :
'') .
'" />';
231 $html_company_name .=
'</td></tr>';
232 print $html_company_name;
234 $html_contact_phone =
'';
235 $html_contact_phone .=
'<tr id="contact_phone_line" class="contact_field"><td><label for="contact_phone"><span>' . $langs->trans(
'Phone') .
'</span></label></td><td>';
236 $html_contact_phone .=
'<input type="text" id="contact_phone" name="contact_phone" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_phone') ?
GETPOST(
'contact_phone',
'alphanohtml') :
'') .
'" />';
237 $html_contact_phone .=
'</td></tr>';
238 print $html_contact_phone;
241 $langs->load(
'errors');
242 print
'<script type="text/javascript">
243 jQuery(document).ready(function() {
244 var contact = jQuery.parseJSON("'.dol_escape_js(json_encode($with_contact), 2).
'");
245 jQuery("#contact_search_line").hide();
247 if (contact.id > 0) {
248 jQuery("#contact_search_line").show();
249 jQuery("#contact_id").val(contact.id);
250 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
251 jQuery(".contact_field").hide();
253 jQuery(".contact_field").show();
257 jQuery("#email").change(function() {
258 jQuery("#contact_search_line").show();
259 jQuery("#contact_search_result").html("'.
dol_escape_js($langs->trans(
'Select2SearchInProgress')).
'");
260 jQuery("#contact_id").val("");
261 jQuery("#contact_lastname").val("");
262 jQuery("#contact_firstname").val("");
263 jQuery("#company_name").val("");
264 jQuery("#contact_phone").val("");
269 action: "getContacts",
270 email: jQuery("#email").val()
273 if (response.error) {
274 jQuery("#contact_search_result").html("<span class=\"error\">"+response.error+"</span>");
276 var contact_list = response.contacts;
277 if (contact_list.length == 1) {
278 var contact = contact_list[0];
279 jQuery("#contact_id").val(contact.id);
280 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
281 jQuery(".contact_field").hide();
282 } else if (contact_list.length <= 0) {
283 jQuery("#contact_search_line").hide();
284 jQuery(".contact_field").show();
288 ).fail(function(jqxhr, textStatus, error) {
289 var error_msg = "'.
dol_escape_js($langs->trans(
'ErrorAjaxRequestFailed')).
'"+" ["+textStatus+"] : "+error;
290 jQuery("#contact_search_result").html("<span class=\"error\">"+error_msg+"</span>");
300 if (isset($this->param[
'origin']) && $this->param[
'originid'] > 0) {
302 $element = $subelement = $this->param[
'origin'];
304 if (preg_match(
'/^([^_]+)_([^_]+)/i', $this->param[
'origin'], $regs)) {
306 $subelement = $regs[2];
310 $classname = ucfirst($subelement);
311 $objectsrc =
new $classname($this->
db);
312 $objectsrc->fetch(
GETPOST(
'originid',
'int'));
314 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
315 $objectsrc->fetch_lines();
318 $objectsrc->fetch_thirdparty();
319 $newclassname = $classname;
320 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td colspan="2"><input name="'.$subelement.
'id" value="'.
GETPOST(
'originid').
'" type="hidden" />'.$objectsrc->getNomUrl(1).
'</td></tr>';
324 print
'<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans(
"TicketTypeRequest").
'</span></label></td><td>';
329 print
'<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans(
"TicketCategory").
'</span></label></td><td>';
332 $filter =
'public=1';
334 $this->
selectGroupTickets((
GETPOST(
'category_code') ?
GETPOST(
'category_code') : $this->category_code),
'category_code', $filter, 2, 1, 0, 0,
'minwidth200');
338 print
'<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans(
"TicketSeverity").
'</span></label></td><td>';
343 if ($this->withtitletopic) {
344 print
'<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans(
"Subject").
'</span></label></td><td>';
346 if ($this->withtopicreadonly) {
347 print $langs->trans(
'SubjectAnswerToTicket').
' '.$this->topic_title;
349 if (isset($this->withreadid) && $this->withreadid > 0) {
350 $subject = $langs->trans(
'SubjectAnswerToTicket').
' '.$this->withreadid.
' : '.$this->topic_title;
352 $subject =
GETPOST(
'subject',
'alpha');
354 print
'<input class="text minwidth500" id="subject" name="subject" value="'.$subject.
'" autofocus />';
359 if (!empty($conf->knowledgemanagement->enabled)) {
361 print
'<tr id="KWwithajax"></tr>';
362 print
'<!-- Script to manage change of ticket group -->
364 jQuery(document).ready(function() {
365 function groupticketchange() {
366 console.log("We called groupticketchange, so we try to load list KM linked to event");
367 $("#KWwithajax").html("");
368 idgroupticket = $("#selectcategory_code").val();
370 console.log("We have selected id="+idgroupticket);
372 if (idgroupticket != "") {
373 $.ajax({ url: \''.DOL_URL_ROOT.
'/core/ajax/fetchKnowledgeRecord.php\',
374 data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.
newToken().
'\', lang:\
''.$langs->defaultlang.
'\'},
376 success: function(response) {
378 console.log("We received response "+response);
379 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() != "") {
418 print
'<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span></label></td><td>';
421 $toolbarname =
'dolibarr_notes';
422 if ($this->ispublic) {
423 $toolbarname =
'dolibarr_details';
424 print
'<div class="warning">'.(getDolGlobalString(
"TICKET_PUBLIC_TEXT_HELP_MESSAGE", $langs->trans(
'TicketPublicPleaseBeAccuratelyDescribe'))).
'</div>';
426 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
427 $uselocalbrowser =
true;
428 $doleditor =
new DolEditor(
'message', $msg,
'100%', 230, $toolbarname,
'In',
true, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_TICKET'), ROWS_8,
'90%');
429 $doleditor->Create();
432 if ($public && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
433 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
434 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td>';
435 print
'<span class="span-icon-security inline-block">';
436 print
'<input id="securitycode" placeholder="'.$langs->trans(
"SecurityCode").
'" class="flat input-icon-security width125" type="text" maxlength="5" name="code" tabindex="3" />';
438 print
'<span class="nowrap inline-block">';
439 print
'<img class="inline-block valignmiddle" src="'.DOL_URL_ROOT.
'/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />';
440 print
'<a class="inline-block valignmiddle" href="" tabindex="4" data-role="button">'.img_picto($langs->trans(
"Refresh"),
'refresh',
'id="captcha_refresh_img"').
'</a>';
447 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
448 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_TICKET,
'',
'parent', 64, 0, 1);
450 if (count($cate_arbo)) {
452 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
453 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
459 if (!empty($this->withfile)) {
461 $listofpaths = array();
462 $listofnames = array();
463 $listofmimes = array();
464 if (!empty($_SESSION[
"listofpaths"])) {
465 $listofpaths = explode(
';', $_SESSION[
"listofpaths"]);
468 if (!empty($_SESSION[
"listofnames"])) {
469 $listofnames = explode(
';', $_SESSION[
"listofnames"]);
472 if (!empty($_SESSION[
"listofmimes"])) {
473 $listofmimes = explode(
';', $_SESSION[
"listofmimes"]);
477 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
480 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
481 $out .=
'<script type="text/javascript">';
482 $out .=
'jQuery(document).ready(function () {';
483 $out .=
' jQuery(".removedfile").click(function() {';
484 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
487 $out .=
'</script>'.
"\n";
488 if (count($listofpaths)) {
489 foreach ($listofpaths as $key => $val) {
490 $out .=
'<div id="attachfile_'.$key.
'">';
491 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
492 if (!$this->withfilereadonly) {
493 $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.
'" />';
495 $out .=
'<br></div>';
498 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
500 if ($this->withfile == 2) {
502 $maxmin = $maxfilesizearray[
'maxmin'];
504 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
506 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
508 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="addfile" name="addfile" value="'.$langs->trans(
"MailingAddFile").
'" />';
510 $out .=
"</td></tr>\n";
516 if ($this->withusercreate > 0 && $this->fk_user_create) {
517 print
'<tr><td class="titlefield">'.$langs->trans(
"CreatedBy").
'</td><td>';
518 $langs->load(
"users");
519 $fuser =
new User($this->
db);
521 if ($this->withcreatereadonly) {
522 if ($res = $fuser->fetch($this->fk_user_create)) {
523 print $fuser->getNomUrl(1);
527 print
"</td></tr>\n";
531 if ($this->withcompany) {
533 if (empty($user->socid)) {
535 print
'<tr><td class="titlefield">'.$langs->trans(
"ThirdParty").
'</td><td>';
537 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
538 print
img_picto(
'',
'company',
'class="paddingright"');
539 print
$form->select_company($this->withfromsocid,
'socid',
'', 1, 1,
'', $events, 0,
'minwidth200');
541 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
543 print
'<script type="text/javascript">
544 $(document).ready(function () {
545 jQuery("#'.$htmlname.
'").change(function () {
546 var obj = '.json_encode($events).
';
547 $.each(obj, function(key,values) {
548 if (values.method.length) {
549 runJsCodeForEvent'.$htmlname.
'(values);
554 function runJsCodeForEvent'.$htmlname.
'(obj) {
555 console.log("Run runJsCodeForEvent'.$htmlname.
'");
556 var id = $("#'.$htmlname.
'").val();
557 var method = obj.method;
559 var htmlname = obj.htmlname;
560 var showempty = obj.showempty;
569 $.each(obj.params, function(key,action) {
571 var num = response.num;
573 $("#" + key).removeAttr(action);
575 $("#" + key).attr(action, action);
579 $("select#" + htmlname).html(response.value);
581 var selecthtml_str = response.value;
582 var selecthtml_dom=$.parseHTML(selecthtml_str);
583 if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
584 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
587 $("#inputautocomplete"+htmlname).val("");
589 $("select#" + htmlname).change(); /* Trigger event change */
598 print
'<tr><td>'.$langs->trans(
"Contact").
'</td><td>';
600 $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
601 print
img_picto(
'',
'contact',
'class="paddingright"');
602 print
$form->selectcontacts($selectedCompany, $this->withfromcontactid,
'contactid', 3,
'',
'', 0,
'minwidth200');
604 $formcompany->selectTypeContact($ticketstatic,
'',
'type',
'external',
'', 0,
'maginleftonly');
607 print
'<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.
'"/></td>';
608 print
'<td><input type="hidden" name="contactid" value="'.$user->contact_id.
'"/></td>';
609 print
'<td><input type="hidden" name="type" value="Z"/></td></tr>';
613 if (empty($this->ispublic)) {
614 print
'<tr><td><label for="notify_tiers_at_create">'.$langs->trans(
"TicketNotifyTiersAtCreation").
'</label></td><td>';
615 print
'<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ?
' checked="checked"' :
'').
'>';
621 print $langs->trans(
"AssignedTo");
623 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
624 print
$form->select_dolusers(
GETPOST(
'fk_user_assign',
'int'),
'fk_user_assign', 1);
629 if ($subelement !=
'project') {
632 print
'<tr><td><label for="project"><span class="">'.$langs->trans(
"Project").
'</span></label></td><td>';
633 print
img_picto(
'',
'project').$formproject->select_projects(-1,
GETPOST(
'projectid',
'int'),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
639 $parameters = array();
640 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $ticketstat, $action);
641 if (empty($reshook)) {
642 print $ticketstat->showOptionals($extrafields,
'create');
647 if ($withdolfichehead) {
653 print
$form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"CreateTicket"), ($this->withcancel ?
"Cancel" :
""));
665 print
'<input type="hidden" name="page_y">'.
"\n";
668 print
"<!-- End form TICKET -->\n";
685 public function selectTypesTickets($selected =
'', $htmlname =
'tickettype', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $multiselect = 0)
687 global $langs, $user;
689 $selected = is_array($selected) ? $selected : (!empty($selected) ? array($selected) : array());
690 $ticketstat =
new Ticket($this->
db);
692 dol_syslog(get_class($this) .
"::select_types_tickets " . implode(
';', $selected) .
", " . $htmlname .
", " . $filtertype .
", " . $format .
", " . $multiselect, LOG_DEBUG);
694 $filterarray = array();
696 if ($filtertype !=
'' && $filtertype !=
'-1') {
697 $filterarray = explode(
',', $filtertype);
700 $ticketstat->loadCacheTypesTickets();
702 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.($multiselect?
'[]':
'').
'"'.($multiselect?
' multiple':
'').
'>';
704 print
'<option value=""> </option>';
707 if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
708 foreach ($ticketstat->cache_types_tickets as $id => $arraytypes) {
710 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
715 if ($empty && empty($arraytypes[
'code'])) {
720 print
'<option value="'.$id.
'"';
724 print
'<option value="'.$arraytypes[
'code'].
'"';
728 print
'<option value="'.$arraytypes[
'code'].
'"';
732 print
'<option value="'.$id.
'"';
736 if (in_array($arraytypes[
'code'], $selected)) {
737 print
' selected="selected"';
738 } elseif (in_array($id, $selected)) {
739 print
' selected="selected"';
740 } elseif ($arraytypes[
'use_default'] ==
"1" && !$selected && !$empty) {
741 print
' selected="selected"';
748 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
749 } elseif ($format == 1) {
750 $value = $arraytypes[
'code'];
751 } elseif ($format == 2) {
752 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
753 } elseif ($format == 3) {
754 $value = $arraytypes[
'code'];
757 print $value ? $value :
' ';
762 if (isset($user->admin) && $user->admin && !$noadmininfo) {
763 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
784 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs =
null)
786 global $conf, $langs, $user;
788 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
790 if (is_null($outputlangs) || !is_object($outputlangs)) {
791 $outputlangs = $langs;
793 $outputlangs->load(
"ticket");
795 $ticketstat =
new Ticket($this->
db);
796 $ticketstat->loadCacheCategoriesTickets();
798 if ($use_multilevel <= 0) {
799 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
801 print
'<option value=""> </option>';
804 if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
805 foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
807 if ($filtertype ==
'public=1') {
808 if (empty($arraycategories[
'public'])) {
814 if ($empty && empty($arraycategories[
'code'])) {
818 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
819 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) != (
"TicketCategoryShort".$arraycategories[
'code'])) {
820 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
821 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
822 $label = $outputlangs->trans($arraycategories[
'code']);
826 print
'<option value="'.$id.
'"';
830 print
'<option value="'.$arraycategories[
'code'].
'"';
834 print
'<option value="'.$arraycategories[
'code'].
'"';
838 print
'<option value="'.$id.
'"';
842 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
843 print
' selected="selected"';
844 } elseif ($selected == $id) {
845 print
' selected="selected"';
846 } elseif ($arraycategories[
'use_default'] ==
"1" && !$selected && !$empty) {
847 print
' selected="selected"';
854 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
858 $value = $arraycategories[
'code'];
862 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
866 $value = $arraycategories[
'code'];
869 print $value ? $value :
' ';
874 if (isset($user->admin) && $user->admin && !$noadmininfo) {
875 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
879 } elseif ($htmlname!=
'') {
880 $selectedgroups = array();
882 $groupticket=
GETPOST($htmlname,
'aZ09');
883 $child_id=
GETPOST($htmlname.
'_child_id',
'aZ09')?
GETPOST($htmlname.
'_child_id',
'aZ09'):0;
884 if (!empty($groupticket)) {
885 $tmpgroupticket = $groupticket;
886 $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).
"'";
889 $obj = $this->
db->fetch_object(
$resql);
890 $selectedgroups[] = $obj->code;
891 while ($obj->fk_parent > 0) {
892 $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).
"'";
895 $obj = $this->
db->fetch_object(
$resql);
896 $selectedgroups[] = $obj->code;
902 $arrayidused = array();
903 $arrayidusedconcat = array();
904 $arraycodenotparent = array();
905 $arraycodenotparent[] =
"";
907 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
908 $stringtoprint .=
'<select id ="'.$htmlname.
'" class="minwidth500" child_id="0">';
909 $stringtoprint .=
'<option value=""> </option>';
911 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
912 $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";
913 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
914 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
915 if ($filtertype ==
'public=1') {
916 $sql .=
" AND ctc.public = 1";
918 $sql .=
" AND ctc.fk_parent = 0";
919 $sql .= $this->
db->order(
'ctc.pos',
'ASC');
923 $num_rows_level0 = $this->
db->num_rows(
$resql);
925 while ($i < $num_rows_level0) {
926 $obj = $this->
db->fetch_object(
$resql);
928 $label = ($obj->label !=
'-' ? $obj->label :
'');
929 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
930 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
931 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
932 $label = $outputlangs->trans($obj->code);
935 $grouprowid = $obj->rowid;
936 $groupvalue = $obj->code;
937 $grouplabel = $label;
939 $isparent = $obj->isparent;
940 if (is_array($selectedgroups)) {
941 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
943 $iselected = $groupticket == $obj->code ?
'selected':
'';
946 if ($isparent ==
'NOTPARENT') {
947 $arraycodenotparent[] = $groupvalue;
949 $arrayidused[] = $grouprowid;
950 $arrayidusedconcat[] = $grouprowid;
957 if (count($arrayidused) == 1) {
958 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
960 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400">';
961 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400">';
963 $stringtoprint .=
'</select> ';
966 while ($levelid <= $use_multilevel) {
967 $tabscript = array();
968 $stringtoprint .=
'<select id ="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
969 $stringtoprint .=
'<option value=""> </option>';
971 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
972 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
973 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
974 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
975 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(join(
',', $arrayidusedconcat)).
")";
977 if ($filtertype ==
'public=1') {
978 $sql .=
" AND ctc.public = 1";
981 if (!empty($arrayidused)) {
982 $sql .=
" AND ctc.fk_parent IN ( ";
983 foreach ($arrayidused as $idused) {
984 $sql .= $idused.
", ";
986 $sql = substr($sql, 0, -2);
989 $sql .= $this->
db->order(
'ctc.pos',
'ASC');
993 $num_rows = $this->
db->num_rows(
$resql);
995 $arrayidused=array();
996 while ($i < $num_rows) {
997 $obj = $this->
db->fetch_object(
$resql);
999 $label = ($obj->label !=
'-' ? $obj->label :
'');
1000 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
1001 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1002 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1003 $label = $outputlangs->trans($obj->code);
1006 $grouprowid = $obj->rowid;
1007 $groupvalue = $obj->code;
1008 $grouplabel = $label;
1009 $isparent = $obj->isparent;
1010 $fatherid = $obj->fk_parent;
1011 $arrayidused[] = $grouprowid;
1012 $arrayidusedconcat[] = $grouprowid;
1013 $groupcodefather = $obj->codefather;
1014 if ($isparent ==
'NOTPARENT') {
1015 $arraycodenotparent[] = $groupvalue;
1017 if (is_array($selectedgroups)) {
1018 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
1020 $iselected = $groupticket == $obj->code ?
'selected':
'';
1023 if (empty($tabscript[$groupcodefather])) {
1024 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").val() == "'.
dol_escape_js($groupcodefather).
'"){
1026 console.log("We show childs tickets of '.$groupcodefather.
' group ticket")
1029 console.log("We hide childs tickets of '.$groupcodefather.
' group ticket")
1038 $stringtoprint .=
'</select>';
1040 $stringtoprint .=
'<script>';
1041 $stringtoprint .=
'arraynotparents = '.json_encode($arraycodenotparent).
';';
1042 $stringtoprint .=
'if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").val())){
1043 console.log("'.$htmlname.
'_child_'.$levelid.
'")
1044 if($("#'.$htmlname.
'_child_'.$levelid.
'").val() == "" && ($("#'.$htmlname.
'_child_'.$levelid.
'").attr("child_id")>'.$child_id.
')){
1045 $("#'.$htmlname.
'_child_'.$levelid.
'").hide();
1046 console.log("We hide '.$htmlname.
'_child_'.$levelid.
' input")
1048 if(arraynotparents.includes("'.$groupticket.
'") && '.$child_id.
' == 0){
1049 $("#ticketcategory_select_child_id").val($("#'.$htmlname.
'").attr("child_id"))
1050 $("#ticketcategory_select").val($("#'.$htmlname.
'").val()) ;
1051 console.log("We choose '.$htmlname.
' input and reload hidden input");
1054 $("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").change(function() {
1055 child_id = $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid:
'').
'").attr("child_id");
1057 /* Change of value to select this value*/
1058 if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.
') {
1059 $("#ticketcategory_select").val($(this).val());
1060 $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1061 console.log("We choose to select "+ $(this).val());
1063 if ($("#'.$htmlname.
'_child_'.$levelid.
' option").length <= 1) {
1064 $("#ticketcategory_select").val($(this).val());
1065 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1066 console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1068 console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1069 $("#ticketcategory_select").val("");
1070 $("#ticketcategory_select_child_id").val("");
1074 console.log("We select a new value into combo child_id="+child_id);
1076 // Hide all selected box that are child of the one modified
1077 $(".groupticketchild").each(function(){
1078 if ($(this).attr("child_id") > child_id) {
1079 console.log("hide child_id="+$(this).attr("child_id"));
1085 // Now we enable the next combo
1086 $("#'.$htmlname.
'_child_'.$levelid.
'").val("");
1087 if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.
'_child_'.$levelid.
' option").length > 1) {
1088 console.log($("#'.$htmlname.
'_child_'.$levelid.
' option").length);
1089 $("#'.$htmlname.
'_child_'.$levelid.
'").show()
1091 $("#'.$htmlname.
'_child_'.$levelid.
'").hide()
1095 foreach ($tabscript as $script) {
1096 $stringtoprint .= $script;
1098 $stringtoprint .=
'})';
1099 $stringtoprint .=
'</script>';
1101 $stringtoprint .=
'<script>';
1102 $stringtoprint .=
'$("#'.$htmlname.
'_child_'.$use_multilevel.
'").change(function() {
1103 $("#ticketcategory_select").val($(this).val());
1104 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1105 console.log($("#ticketcategory_select").val());
1107 $stringtoprint .=
'</script>';
1110 return $stringtoprint;
1127 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
1129 global $langs, $user;
1131 $ticketstat =
new Ticket($this->
db);
1133 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1135 $filterarray = array();
1137 if ($filtertype !=
'' && $filtertype !=
'-1') {
1138 $filterarray = explode(
',', $filtertype);
1141 $ticketstat->loadCacheSeveritiesTickets();
1143 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1145 print
'<option value=""> </option>';
1148 if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
1149 foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
1151 if (count($filterarray) && !in_array($arrayseverities[
'type'], $filterarray)) {
1156 if ($empty && empty($arrayseverities[
'code'])) {
1161 print
'<option value="'.$id.
'"';
1165 print
'<option value="'.$arrayseverities[
'code'].
'"';
1169 print
'<option value="'.$arrayseverities[
'code'].
'"';
1173 print
'<option value="'.$id.
'"';
1177 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
1178 print
' selected="selected"';
1179 } elseif ($selected == $id) {
1180 print
' selected="selected"';
1181 } elseif ($arrayseverities[
'use_default'] ==
"1" && !$selected && !$empty) {
1182 print
' selected="selected"';
1189 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1193 $value = $arrayseverities[
'code'];
1197 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1201 $value = $arrayseverities[
'code'];
1204 print $value ? $value :
' ';
1209 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1210 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1225 global $conf, $user;
1226 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1229 $vardir = $conf->user->dir_output.
"/".$user->id;
1230 $upload_dir = $vardir.
'/temp/';
1231 if (is_dir($upload_dir)) {
1235 if (!empty($this->trackid)) {
1236 $keytoavoidconflict =
'-'.$this->trackid;
1238 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1240 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
1241 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
1242 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
1253 global $conf, $langs, $user, $hookmanager,
$form, $mysoc;
1256 $addfileaction =
'addfile';
1258 if (!is_object(
$form)) {
1263 $langs->loadLangs(array(
'other',
'mails'));
1266 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1267 $this->clear_attached_files();
1271 $outputlangs = $langs;
1273 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1274 $newlang = $this->param[
'langsmodels'];
1276 if (!empty($newlang)) {
1277 $outputlangs =
new Translate(
"", $conf);
1278 $outputlangs->setDefaultLang($newlang);
1279 $outputlangs->load(
'other');
1283 $arraydefaultmessage = -1;
1284 if (isset($this->param[
'models']) && $this->param[
'models'] !=
'none') {
1286 if (array_key_exists(
'models_id', $this->param)) {
1287 $model_id = (int) $this->param[
"models_id"];
1290 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
1294 $listofpaths = array();
1295 $listofnames = array();
1296 $listofmimes = array();
1298 if (!empty($this->trackid)) {
1299 $keytoavoidconflict =
'-'.$this->trackid;
1301 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1304 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1305 if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param[
'fileinit'])) {
1306 foreach ($this->param[
'fileinit'] as $file) {
1307 $formmail->add_attached_files($file, basename($file),
dol_mimetype($file));
1313 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
1314 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
1316 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
1317 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
1319 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
1320 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
1324 $outputlangs = $langs;
1326 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1327 $newlang = $this->param[
'langsmodels'];
1329 if (!empty($newlang)) {
1330 $outputlangs =
new Translate(
"", $conf);
1331 $outputlangs->setDefaultLang($newlang);
1332 $outputlangs->load(
'other');
1335 print
"\n<!-- Begin message_form TICKET -->\n";
1337 $send_email =
GETPOST(
'send_email',
'int') ?
GETPOST(
'send_email',
'int') : 0;
1340 print
'<script type="text/javascript">
1341 jQuery(document).ready(function() {
1342 send_email=' . $send_email.
';
1344 if (!jQuery("#send_msg_email").is(":checked")) {
1345 jQuery("#send_msg_email").prop("checked", true).trigger("change");
1347 jQuery(".email_line").show();
1349 if (!jQuery("#private_message").is(":checked")) {
1350 jQuery("#private_message").prop("checked", true).trigger("change");
1352 jQuery(".email_line").hide();
1355 jQuery("#send_msg_email").click(function() {
1356 if(jQuery(this).is(":checked")) {
1357 if (jQuery("#private_message").is(":checked")) {
1358 jQuery("#private_message").prop("checked", false).trigger("change");
1360 jQuery(".email_line").show();
1363 jQuery(".email_line").hide();
1367 jQuery("#private_message").click(function() {
1368 if (jQuery(this).is(":checked")) {
1369 if (jQuery("#send_msg_email").is(":checked")) {
1370 jQuery("#send_msg_email").prop("checked", false).trigger("change");
1372 jQuery(".email_line").hide();
1378 print
'<form method="post" name="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
1379 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1380 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
1381 print
'<input type="hidden" name="actionbis" value="add_message">';
1382 print
'<input type="hidden" name="backtopage" value="'.$this->backtopage.
'">';
1383 if (!empty($this->trackid)) {
1384 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
1386 print
'<input type="hidden" name="trackid" value="'.(empty($this->track_id) ?
'' : $this->track_id).
'">';
1387 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1389 foreach ($this->param as $key => $value) {
1390 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
1395 if (array_key_exists(
'models_id', $this->param)) {
1396 $model_id = $this->param[
"models_id"];
1397 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
1400 $result = $formmail->fetchAllEMailTemplate(!empty($this->param[
"models"]) ? $this->param[
"models"] :
"", $user, $outputlangs);
1404 $modelmail_array = array();
1405 foreach ($formmail->lines_model as $line) {
1406 $modelmail_array[$line->id] = $line->label;
1409 print
'<table class="border" width="'.$width.
'">';
1412 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1413 $ticketstat =
new Ticket($this->
db);
1414 $res = $ticketstat->fetch(
'',
'', $this->track_id);
1416 print
'<tr><td></td><td>';
1417 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : ($conf->global->TICKETS_MESSAGE_FORCE_MAIL?
'checked':
''));
1418 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1419 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1420 $texttooltip = $langs->trans(
"TicketMessageSendEmailHelp",
'{s1}');
1421 $texttooltip = str_replace(
'{s1}', $langs->trans(
'MarkMessageAsPrivate'), $texttooltip);
1422 print
' '.$form->textwithpicto(
'', $texttooltip, 1,
'help');
1426 if (!$user->socid) {
1427 print
'<tr><td></td><td>';
1428 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1429 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1430 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1431 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1436 if (count($modelmail_array) > 0) {
1437 print
'<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'.
"\n";
1438 print $langs->trans(
'SelectMailModel').
': '.$formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], 1, 0,
"",
"", 0, 0, 0,
'',
'minwidth200');
1440 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1443 print
'<input type="submit" class="button" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1444 print
'</div></td>';
1448 print
'<tr class="email_line"><td>'.$langs->trans(
'Subject').
'</td>';
1449 print
'<td><input type="text" class="text minwidth500" name="subject" value="['.$conf->global->MAIN_INFO_SOCIETE_NOM.
' - '.$langs->trans(
"Ticket").
' '.$ticketstat->ref.
'] '.$langs->trans(
'TicketNewMessage').
'" />';
1453 print
'<tr class="email_line"><td>'.$langs->trans(
'MailRecipients').
'</td><td>';
1456 $contacts = $ticketstat->getInfosTicketInternalContact();
1457 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact());
1462 if (is_array($contacts) && count($contacts) > 0) {
1463 foreach ($contacts as $key => $info_sendto) {
1464 if ($info_sendto[
'email'] !=
'') {
1465 $sendto[] =
dol_escape_htmltag(trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">").
' <small class="opacitymedium">('.
dol_escape_htmltag($info_sendto[
'libelle']).
")</small>";
1470 if ($ticketstat->origin_email && !in_array($ticketstat->origin_email, $sendto)) {
1471 $sendto[] =
dol_escape_htmltag($ticketstat->origin_email).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
1474 if ($ticketstat->fk_soc > 0) {
1475 $ticketstat->socid = $ticketstat->fk_soc;
1476 $ticketstat->fetch_thirdparty();
1478 if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
1479 $sendto[] = $ticketstat->thirdparty->email.
' <small class="opacitymedium">('.$langs->trans(
'Customer').
')</small>';
1483 if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) {
1484 $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO.
' <small class="opacitymedium">(generic email)</small>';
1488 if (is_array($sendto) && count($sendto) > 0) {
1489 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
1490 print implode(
', ', $sendto);
1492 print
'<div class="warning">'.$langs->trans(
'WarningNoEMailsAdded').
' '.$langs->trans(
'TicketGoIntoContactTab').
'</div>';
1498 $uselocalbrowser =
false;
1520 if (!empty($this->withfile)) {
1522 $out .=
'<td width="180">'.$langs->trans(
"MailFile").
'</td>';
1525 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1526 $out .=
'<script type="text/javascript">';
1527 $out .=
'jQuery(document).ready(function () {';
1528 $out .=
' jQuery(".removedfile").click(function() {';
1529 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1532 $out .=
'</script>'.
"\n";
1534 if (count($listofpaths)) {
1535 foreach ($listofpaths as $key => $val) {
1536 $out .=
'<div id="attachfile_'.$key.
'">';
1537 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1538 if (!$this->withfilereadonly) {
1539 $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.
'" />';
1541 $out .=
'<br></div>';
1546 if ($this->withfile == 2) {
1547 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1549 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1551 $out .=
"</td></tr>\n";
1558 $defaultmessage =
"";
1559 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1560 $defaultmessage = $arraydefaultmessage->content;
1562 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1566 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1567 } elseif (!
dol_textishtml($defaultmessage) && isset($this->substit[
'__USER_SIGNATURE__']) &&
dol_textishtml($this->substit[
'__USER_SIGNATURE__'])) {
1568 $defaultmessage =
dol_nl2br($defaultmessage);
1571 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1575 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1576 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1579 print
'<tr><td colspan="2"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1580 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1581 $texttooltip = $langs->trans(
"TicketMessageHelp");
1583 $texttooltip .=
'<br><br>'.$langs->trans(
"ForEmailMessageWillBeCompletedWith").
'...';
1586 $texttooltip .=
'<br><u>'.$langs->trans(
"TicketMessageMailIntro").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO');
1589 $texttooltip .=
'<br><br><u>'.$langs->trans(
"TicketMessageMailFooter").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_SIGNATURE');
1591 print
$form->textwithpicto(
'', $texttooltip, 1,
'help');
1593 print
'</label></td></tr>';
1596 print
'<tr><td colspan="2">';
1598 $toolbarname =
'dolibarr_notes';
1599 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1600 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, 70);
1601 $doleditor->Create();
1620 print
'<center><br>';
1621 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"Add").
'" />';
1622 if ($this->withcancel) {
1623 print
" ";
1624 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1626 print
"</center>\n";
1628 print
'<input type="hidden" name="page_y">'.
"\n";
1631 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'))
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.