* Copyright (C) 2016 Christophe Battarel * Copyright (C) 2019 Frédéric France * Copyright (C) 2021 Juanjo Menent * Copyright (C) 2021 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/core/class/html.formticket.class.php * \ingroup ticket * \brief File of class to generate the form for creating a new ticket. */ require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; if (!class_exists('FormCompany')) { include DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; } /** * Class to generate the form for creating a new ticket. * Usage: $formticket = new FormTicket($db) * $formticket->proprietes = 1 or string or array of values * $formticket->show_form() shows the form * * @package Ticket */ class FormTicket { /** * @var DoliDB Database handler. */ public $db; /** * @var string The track_id of the ticket. Used also for the $keytoavoidconflict to name session vars to upload files. */ public $track_id; /** * @var int ID */ public $fk_user_create; public $message; public $topic_title; public $action; public $withtopic; public $withemail; /** * @var int $withsubstit Show substitution array */ public $withsubstit; public $withfile; public $withfilereadonly; public $backtopage; public $ispublic; // to show information or not into public form public $withtitletopic; public $withtopicreadonly; public $withreadid; public $withcompany; // to show company drop-down list public $withfromsocid; public $withfromcontactid; public $withnotifytiersatcreate; public $withusercreate; // to show name of creating user in form public $withcreatereadonly; public $withref; // to show ref field public $withcancel; public $type_code; public $category_code; public $severity_code; /** * * @var array $substit Substitutions */ public $substit = array(); public $param = array(); /** * @var string Error code (or message) */ public $error; public $errors = array(); /** * Constructor * * @param DoliDB $db Database handler */ public function __construct($db) { global $conf; $this->db = $db; $this->action = 'add'; $this->withcompany = isModEnabled("societe"); $this->withfromsocid = 0; $this->withfromcontactid = 0; $this->withreadid=0; //$this->withtitletopic=''; $this->withnotifytiersatcreate = 0; $this->withusercreate = 1; $this->withcreatereadonly = 1; $this->withemail = 0; $this->withref = 0; $this->withextrafields = 0; // to show extrafields or not //$this->withtopicreadonly=0; } /** * Show the form to input ticket * * @param int $withdolfichehead With dol_get_fiche_head() and dol_get_fiche_end() * @param string $mode Mode ('create' or 'edit') * @param int $public 1=If we show the form for the public interface * @param Contact|null $with_contact [=NULL] Contact to link to this ticket if it exists * @param string $action [=''] Action in card * @return void */ public function showForm($withdolfichehead = 0, $mode = 'edit', $public = 0, Contact $with_contact = null, $action = '') { global $conf, $langs, $user, $hookmanager; // Load translation files required by the page $langs->loadLangs(array('other', 'mails', 'ticket')); $form = new Form($this->db); $formcompany = new FormCompany($this->db); $ticketstatic = new Ticket($this->db); $soc = new Societe($this->db); if (!empty($this->withfromsocid) && $this->withfromsocid > 0) { $soc->fetch($this->withfromsocid); } $ticketstat = new Ticket($this->db); $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($ticketstat->table_element); print "\n\n"; if ($withdolfichehead) { print dol_get_fiche_head(null, 'card', '', 0, ''); } print '
param["returnurl"] : $_SERVER['PHP_SELF']).'">'; print ''; print ''; print ''; foreach ($this->param as $key => $value) { print ''; } print ''; print ''; if ($this->withref) { // Ref $defaultref = $ticketstat->getDefaultRef(); print ''; } // TITLE $email = GETPOSTISSET('email') ? GETPOST('email', 'alphanohtml') : ''; if ($this->withemail) { print ''; if ($with_contact) { // contact search and result $html_contact_search = ''; $html_contact_search .= ''; $html_contact_search .= ''; $html_contact_search .= ''; $html_contact_search .= ''; print $html_contact_search; // contact lastname $html_contact_lastname = ''; $html_contact_lastname .= ''; print $html_contact_lastname; // contact firstname $html_contact_firstname = ''; $html_contact_firstname .= ''; print $html_contact_firstname; // company name $html_company_name = ''; $html_company_name .= ''; print $html_company_name; // contact phone $html_contact_phone = ''; $html_contact_phone .= ''; print $html_contact_phone; // search contact form email $langs->load('errors'); print ''; } } // If ticket created from another object $subelement = ''; if (isset($this->param['origin']) && $this->param['originid'] > 0) { // Parse element/subelement (ex: project_task) $element = $subelement = $this->param['origin']; $regs = array(); if (preg_match('/^([^_]+)_([^_]+)/i', $this->param['origin'], $regs)) { $element = $regs[1]; $subelement = $regs[2]; } dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($this->db); $objectsrc->fetch(GETPOST('originid', 'int')); if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { $objectsrc->fetch_lines(); } $objectsrc->fetch_thirdparty(); $newclassname = $classname; print ''; } // Type of Ticket print ''; // Group => Category print ''; // Severity => Priority print ''; if (!empty($conf->knowledgemanagement->enabled)) { // KM Articles print ''; print ''."\n"; } // Subject if ($this->withtitletopic) { print ''; } // MESSAGE $msg = GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ''; print ''; if ($public && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; print ''; } // Categories if (isModEnabled('categorie')) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $cate_arbo = $form->select_all_categories(Categorie::TYPE_TICKET, '', 'parent', 64, 0, 1); if (count($cate_arbo)) { // Categories print '"; } } // Attached files if (!empty($this->withfile)) { // Define list of attached files $listofpaths = array(); $listofnames = array(); $listofmimes = array(); if (!empty($_SESSION["listofpaths"])) { $listofpaths = explode(';', $_SESSION["listofpaths"]); } if (!empty($_SESSION["listofnames"])) { $listofnames = explode(';', $_SESSION["listofnames"]); } if (!empty($_SESSION["listofmimes"])) { $listofmimes = explode(';', $_SESSION["listofmimes"]); } $out = ''; $out .= ''; $out .= '\n"; print $out; } // User of creation if ($this->withusercreate > 0 && $this->fk_user_create) { print '\n"; } // Customer or supplier if ($this->withcompany) { // altairis: force company and contact id for external user if (empty($user->socid)) { // Company print ''; if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) { $htmlname = 'socid'; print ''; } // Contact and type print ''; } else { print ''; print ''; print ''; } // Notify thirdparty at creation if (empty($this->ispublic)) { print ''; } // User assigned print ''; print ''; } if ($subelement != 'project') { if (isModEnabled('project') && !$this->ispublic) { $formproject = new FormProjets($this->db); print ''; } } // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { print $ticketstat->showOptionals($extrafields, 'create'); } print '
'.$langs->trans("Ref").''; print ''; print '
'; print ''; print '
'; $html_contact_search .= ''; $html_contact_search .= ''; $html_contact_search .= '
'; $html_contact_lastname .= ''; $html_contact_lastname .= '
'; $html_contact_firstname .= ''; $html_contact_firstname .= '
'; $html_company_name .= ''; $html_company_name .= '
'; $html_contact_phone .= ''; $html_contact_phone .= '
'.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
'; $this->selectTypesTickets((GETPOST('type_code', 'alpha') ? GETPOST('type_code', 'alpha') : $this->type_code), 'type_code', '', 2, 1, 0, 0, 'minwidth200'); print '
'; $filter = ''; if ($public) { $filter = 'public=1'; } $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', $filter, 2, 1, 0, 0, 'minwidth200'); print '
'; $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 1); print '
'; // Answer to a ticket : display of the thread title in readonly if ($this->withtopicreadonly) { print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title; } else { if (isset($this->withreadid) && $this->withreadid > 0) { $subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withreadid.' : '.$this->topic_title; } else { $subject = GETPOST('subject', 'alpha'); } print 'withemail)?' autofocus':'').' />'; } print '
'; // If public form, display more information $toolbarname = 'dolibarr_notes'; if ($this->ispublic) { $toolbarname = 'dolibarr_details'; print '
'.(getDolGlobalString("TICKET_PUBLIC_TEXT_HELP_MESSAGE", $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'))).'
'; } include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $uselocalbrowser = true; $doleditor = new DolEditor('message', $msg, '100%', 230, $toolbarname, 'In', true, $uselocalbrowser, getDolGlobalInt('FCKEDITOR_ENABLE_TICKET'), ROWS_8, '90%'); $doleditor->Create(); print '
'; print ''; print ''; print ''; print ''; print ''; print ''.img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"').''; print ''; print '
'.$langs->trans("Categories").''; print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print "
'.$langs->trans("MailFile").''; // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript $out .= ''."\n"; $out .= ''."\n"; if (count($listofpaths)) { foreach ($listofpaths as $key => $val) { $out .= '
'; $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; if (!$this->withfilereadonly) { $out .= ' '; } $out .= '
'; } } else { $out .= $langs->trans("NoAttachedFiles").'
'; } if ($this->withfile == 2) { // Can add other files $maxfilesizearray = getMaxFileSizeArray(); $maxmin = $maxfilesizearray['maxmin']; if ($maxmin > 0) { $out .= ''; // MAX_FILE_SIZE must precede the field type=file } $out .= ''; $out .= ' '; $out .= ''; } $out .= "
'.$langs->trans("CreatedBy").''; $langs->load("users"); $fuser = new User($this->db); if ($this->withcreatereadonly) { if ($res = $fuser->fetch($this->fk_user_create)) { print $fuser->getNomUrl(1); } } print '   '; print "
'.$langs->trans("ThirdParty").''; $events = array(); $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); print img_picto('', 'company', 'class="paddingright"'); print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events, 0, 'minwidth200'); print '
'.$langs->trans("Contact").''; // If no socid, set to -1 to avoid full contacts list $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1; print img_picto('', 'contact', 'class="paddingright"'); print $form->selectcontacts($selectedCompany, $this->withfromcontactid, 'contactid', 3, '', '', 0, 'minwidth200'); print ' '; $formcompany->selectTypeContact($ticketstatic, '', 'type', 'external', '', 0, 'maginleftonly'); print '
'; print 'withnotifytiersatcreate ? ' checked="checked"' : '').'>'; print '
'; print $langs->trans("AssignedTo"); print ''; print img_picto('', 'user', 'class="pictofixedwidth"'); print $form->select_dolusers(GETPOST('fk_user_assign', 'int'), 'fk_user_assign', 1); print '
'; print img_picto('', 'project').$formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); print '
'; if ($withdolfichehead) { print dol_get_fiche_end(); } print '

'; print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ? "SendResponse" : "CreateTicket"), ($this->withcancel ? "Cancel" : "")); /* print '
'; print ''; if ($this->withcancel) { print "      "; print ''; } print '
'; */ print ''."\n"; print "
\n"; print "\n"; } /** * Return html list of tickets type * * @param string|array $selected Id of preselected field or array of Ids * @param string $htmlname Nom de la zone select * @param string $filtertype To filter on field type in llx_c_ticket_type (array('code'=>xx,'label'=>zz)) * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code * @param int $empty 1=peut etre vide, 0 sinon * @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $maxlength Max length of label * @param string $morecss More CSS * @param int $multiselect Is multiselect ? * @return void */ public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '', $multiselect = 0) { global $langs, $user; $selected = is_array($selected) ? $selected : (!empty($selected) ? explode(',', $selected) : array()); $ticketstat = new Ticket($this->db); dol_syslog(get_class($this) . "::select_types_tickets " . implode(';', $selected) . ", " . $htmlname . ", " . $filtertype . ", " . $format . ", " . $multiselect, LOG_DEBUG); $filterarray = array(); if ($filtertype != '' && $filtertype != '-1') { $filterarray = explode(',', $filtertype); } $ticketstat->loadCacheTypesTickets(); print ''; if (isset($user->admin) && $user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } print ajax_combobox('select'.$htmlname); } /** * Return html list of ticket anaytic codes * * @param string $selected Id pre-selected category * @param string $htmlname Name of select component * @param string $filtertype To filter on some properties in llx_c_ticket_category ('public = 1'). This parameter must not come from input of users. * @param int $format 0 = id+label, 1 = code+code, 2 = code+label, 3 = id+code * @param int $empty 1 = can be empty, 0 = or not * @param int $noadmininfo 0 = ddd admin info, 1 = disable admin info * @param int $maxlength Max length of label * @param string $morecss More CSS * @param int $use_multilevel If > 0 create a multilevel select which use $htmlname example: $use_multilevel = 1 permit to have 2 select boxes. * @param Translate $outputlangs Output language * @return void */ public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '', $use_multilevel = 0, $outputlangs = null) { global $conf, $langs, $user; dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); if (is_null($outputlangs) || !is_object($outputlangs)) { $outputlangs = $langs; } $outputlangs->load("ticket"); $ticketstat = new Ticket($this->db); $ticketstat->loadCacheCategoriesTickets(); if ($use_multilevel <= 0) { print ''; if (isset($user->admin) && $user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } print ajax_combobox('select'.$htmlname); } elseif ($htmlname!='') { $selectedgroups = array(); $groupvalue = ""; $groupticket=GETPOST($htmlname, 'aZ09'); $child_id=GETPOST($htmlname.'_child_id', 'aZ09')?GETPOST($htmlname.'_child_id', 'aZ09'):0; if (!empty($groupticket)) { $tmpgroupticket = $groupticket; $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)."'"; $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); $selectedgroups[] = $obj->code; while ($obj->fk_parent > 0) { $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)."'"; $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); $selectedgroups[] = $obj->code; } } } } $arrayidused = array(); $arrayidusedconcat = array(); $arraycodenotparent = array(); $arraycodenotparent[] = ""; $stringtoprint = ''.$langs->trans("GroupOfTicket").' '; $stringtoprint .= ''; } else { $stringtoprint .= ''; $stringtoprint .= ''; } $stringtoprint .= ' '; $levelid = 1; // The first combobox while ($levelid <= $use_multilevel) { // Loop to take the child of the combo $tabscript = array(); $stringtoprint .= ''; $stringtoprint .=''; } $stringtoprint .=''; $stringtoprint .= ajax_combobox($htmlname); return $stringtoprint; } } /** * Return html list of ticket severitys (priorities) * * @param string $selected Id severity pre-selected * @param string $htmlname Name of the select area * @param string $filtertype To filter on field type in llx_c_ticket_severity (array('code'=>xx,'label'=>zz)) * @param int $format 0 = id+label, 1 = code+code, 2 = code+label, 3 = id+code * @param int $empty 1 = can be empty, 0 = or not * @param int $noadmininfo 0 = add admin info, 1 = disable admin info * @param int $maxlength Max length of label * @param string $morecss More CSS * @return void */ public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketseverity', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '') { global $langs, $user; $ticketstat = new Ticket($this->db); dol_syslog(get_class($this)."::selectSeveritiesTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); $filterarray = array(); if ($filtertype != '' && $filtertype != '-1') { $filterarray = explode(',', $filtertype); } $ticketstat->loadCacheSeveritiesTickets(); print ''; if (isset($user->admin) && $user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } print ajax_combobox('select'.$htmlname); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Clear list of attached files in send mail form (also stored in session) * * @return void */ public function clear_attached_files() { // phpcs:enable global $conf, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Set tmp user directory $vardir = $conf->user->dir_output."/".$user->id; $upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path if (is_dir($upload_dir)) { dol_delete_dir_recursive($upload_dir); } if (!empty($this->trackid)) { // TODO Always use trackid (ticXXX) instead of track_id (abcd123) $keytoavoidconflict = '-'.$this->trackid; } else { $keytoavoidconflict = empty($this->track_id) ? '' : '-'.$this->track_id; } unset($_SESSION["listofpaths".$keytoavoidconflict]); unset($_SESSION["listofnames".$keytoavoidconflict]); unset($_SESSION["listofmimes".$keytoavoidconflict]); } /** * Show the form to add message on ticket * * @param string $width Width of form * @return void */ public function showMessageForm($width = '40%') { global $conf, $langs, $user, $hookmanager, $form, $mysoc; $formmail = new FormMail($this->db); $addfileaction = 'addfile'; if (!is_object($form)) { $form = new Form($this->db); } // Load translation files required by the page $langs->loadLangs(array('other', 'mails')); // Clear temp files. Must be done at beginning, before call of triggers if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelselected') && GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) { $this->clear_attached_files(); } // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->param['langsmodels'])) { $newlang = $this->param['langsmodels']; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('other'); } // Get message template for $this->param["models"] into c_email_templates $arraydefaultmessage = -1; if (isset($this->param['models']) && $this->param['models'] != 'none') { $model_id = 0; if (array_key_exists('models_id', $this->param)) { $model_id = (int) $this->param["models_id"]; } $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); // If $model_id is empty, preselect the first one } // Define list of attached files $listofpaths = array(); $listofnames = array(); $listofmimes = array(); if (!empty($this->trackid)) { $keytoavoidconflict = '-'.$this->trackid; } else { $keytoavoidconflict = empty($this->track_id) ? '' : '-'.$this->track_id; // track_id instead of trackid } //var_dump($keytoavoidconflict); if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelselected') && GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) { if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param['fileinit']) && is_array($this->param['fileinit'])) { foreach ($this->param['fileinit'] as $file) { $formmail->add_attached_files($file, basename($file), dol_mimetype($file)); } } } //var_dump($_SESSION); //var_dump($_SESSION["listofpaths".$keytoavoidconflict]); if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) { $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); } if (!empty($_SESSION["listofnames".$keytoavoidconflict])) { $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); } if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) { $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); } // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->param['langsmodels'])) { $newlang = $this->param['langsmodels']; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('other'); } print "\n\n"; $send_email = GETPOST('send_email', 'int') ? GETPOST('send_email', 'int') : 0; // Example 1 : Adding jquery code print ''; print '
'; print ''; print ''; print ''; print ''; if (!empty($this->trackid)) { print ''; } else { print ''; $keytoavoidconflict = empty($this->track_id) ? '' : '-'.$this->track_id; // track_id instead of trackid } foreach ($this->param as $key => $value) { print ''; } // Get message template $model_id = 0; if (array_key_exists('models_id', $this->param)) { $model_id = $this->param["models_id"]; $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); } $result = $formmail->fetchAllEMailTemplate(!empty($this->param["models"]) ? $this->param["models"] : "", $user, $outputlangs); if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); } $modelmail_array = array(); foreach ($formmail->lines_model as $line) { $modelmail_array[$line->id] = $line->label; } print ''; // External users can't send message email if ($user->hasRight("ticket", "write") && !$user->socid) { $ticketstat = new Ticket($this->db); $res = $ticketstat->fetch('', '', $this->track_id); print ''; // Private message (not visible by customer/external user) if (!$user->socid) { print ''; } // Zone to select its email template if (count($modelmail_array) > 0) { print ''; } // Subject print ''; print ''; // Recipients / adressed-to print ''; } $uselocalbrowser = false; // Intro // External users can't send message email /* if ($user->rights->ticket->write && !$user->socid && !empty($conf->global->TICKET_MESSAGE_MAIL_INTRO)) { $mail_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO; print ''; } */ // Attached files if (!empty($this->withfile)) { $out = ''; $out .= ''; $out .= '\n"; print $out; } // MESSAGE $defaultmessage = ""; if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) { $defaultmessage = $arraydefaultmessage->content; } $defaultmessage = str_replace('\n', "\n", $defaultmessage); // Deal with format differences between message and signature (text / HTML) if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) { $this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']); } elseif (!dol_textishtml($defaultmessage) && isset($this->substit['__USER_SIGNATURE__']) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) { $defaultmessage = dol_nl2br($defaultmessage); } if (GETPOSTISSET("message") && !GETPOST('modelselected')) { $defaultmessage = GETPOST('message', 'restricthtml'); } else { $defaultmessage = make_substitutions($defaultmessage, $this->substit); // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty) $defaultmessage = preg_replace("/^(
)+/", "", $defaultmessage); $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage); } print ''; print ''; // Footer // External users can't send message email /*if ($user->rights->ticket->write && !$user->socid && !empty($conf->global->TICKET_MESSAGE_MAIL_SIGNATURE)) { $mail_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; print ''; } */ print '
'; $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : (getDolGlobalInt('TICKETS_MESSAGE_FORCE_MAIL')?'checked':'')); print ' '; print ''; $texttooltip = $langs->trans("TicketMessageSendEmailHelp", '{s1}'); $texttooltip = str_replace('{s1}', $langs->trans('MarkMessageAsPrivate'), $texttooltip); print ' '.$form->textwithpicto('', $texttooltip, 1, 'help'); print '
'; $checkbox_selected = (GETPOST('private_message', 'alpha') == "1" ? ' checked' : ''); print ' '; print ''; print ' '.$form->textwithpicto('', $langs->trans("TicketMessagePrivateHelp"), 1, 'help'); print '
'.$langs->trans("MailFile").''; // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript $out .= ''."\n"; $out .= ''."\n"; if (count($listofpaths)) { foreach ($listofpaths as $key => $val) { $out .= '
'; $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; if (!$this->withfilereadonly) { $out .= ' '; } $out .= '
'; } } else { //$out .= $langs->trans("NoAttachedFiles").'
'; } if ($this->withfile == 2) { // Can add other files $out .= ''; $out .= ' '; $out .= ''; } $out .= "
'; //$toolbarname = 'dolibarr_details'; $toolbarname = 'dolibarr_notes'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('message', $defaultmessage, '100%', 200, $toolbarname, '', false, $uselocalbrowser, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, 70); $doleditor->Create(); print '
'; print '

'; print ''; if ($this->withcancel) { print "     "; print ''; } print "
\n"; print ''."\n"; print "
\n"; print "\n"; } }