diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php
index 216644876ba..d5484f31829 100644
--- a/htdocs/core/class/html.formticket.class.php
+++ b/htdocs/core/class/html.formticket.class.php
@@ -670,7 +670,7 @@ class FormTicket
/**
* Return html list of tickets type
*
- * @param string|array $selected Id du type pre-selectionne
+ * @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
@@ -685,7 +685,7 @@ class FormTicket
{
global $langs, $user;
- $selected = is_array($selected) ? $selected : (!empty($selected) ? implode(',', $selected) : array());
+ $selected = is_array($selected) ? $selected : (!empty($selected) ? array($selected) : array());
$ticketstat = new Ticket($this->db);
dol_syslog(get_class($this) . "::select_types_tickets " . implode(';', $selected) . ", " . $htmlname . ", " . $filtertype . ", " . $format . ", " . $multiselect, LOG_DEBUG);
diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php
index 1290a9a9a9b..c9ca9b6622f 100755
--- a/htdocs/ticket/card.php
+++ b/htdocs/ticket/card.php
@@ -126,6 +126,8 @@ $permissiontoadd = $user->rights->ticket->write;
$actionobject = new ActionsTicket($db);
+$upload_dir = $conf->ticket->dir_output;
+
$now = dol_now();
@@ -682,7 +684,6 @@ if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
// Actions to build doc
- $upload_dir = $conf->ticket->dir_output;
$permissiontoadd = $user->rights->ticket->write;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
//var_dump($action);exit;
diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php
index 35e01a74f0d..e7930569bdd 100644
--- a/htdocs/ticket/class/api_tickets.class.php
+++ b/htdocs/ticket/class/api_tickets.class.php
@@ -181,36 +181,6 @@ class Tickets extends DolibarrApi
$this->ticket->messages = $messages;
}
- // History
- $history = array();
- $this->ticket->loadCacheLogsTicket();
- if (is_array($this->ticket->cache_logs_ticket) && count($this->ticket->cache_logs_ticket) > 0) {
- $num = count($this->ticket->cache_logs_ticket);
- $i = 0;
- $user_action = new User($this->db);
-
- while ($i < $num) {
- $userstring = '';
- if ($this->ticket->cache_logs_ticket[$i]['fk_user_create'] > 0) {
- $user_action->fetch($this->ticket->cache_logs_ticket[$i]['fk_user_create']);
-
- $userstring = dolGetFirstLastname($user_action->firstname, $user_action->lastname);
- }
-
- // Now define messages
- $history[] = array(
- 'id' => $this->ticket->cache_logs_ticket[$i]['id'],
- 'fk_user_author' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'],
- 'fk_user_action' => $this->ticket->cache_logs_ticket[$i]['fk_user_create'],
- 'fk_user_action_string' => $userstring,
- 'message' => $this->ticket->cache_logs_ticket[$i]['message'],
- 'datec' => $this->ticket->cache_logs_ticket[$i]['datec'],
- );
- $i++;
- }
- $this->ticket->history = $history;
- }
-
if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php
index 4a03098b57c..276196bc035 100644
--- a/htdocs/ticket/class/ticket.class.php
+++ b/htdocs/ticket/class/ticket.class.php
@@ -1580,144 +1580,6 @@ class Ticket extends CommonObject
}
}
-
- /**
- * Send notification of changes by email
- *
- * @param User $user User that create
- * @param string $message Log message
- * @return int <0 if KO, >0 if OK (number of emails sent)
- */
- private function sendLogByEmail($user, $message)
- {
- global $conf, $langs;
-
- $nb_sent = 0;
-
- $langs->load('ticket');
-
- // Retrieve email of all contacts (internal and external)
- $contacts = $this->listeContact(-1, 'internal');
- $contacts = array_merge($contacts, $this->listeContact(-1, 'external'));
-
- /* If origin_email and no socid, we add email to the list * */
- if (!empty($this->origin_email) && empty($this->fk_soc)) {
- $array_ext = array(array('firstname' => '', 'lastname' => '', 'email' => $this->origin_email, 'libelle' => $langs->transnoentities('TicketEmailOriginIssuer'), 'socid' => "-1"));
- $contacts = array_merge($contacts, $array_ext);
- }
-
- if (!empty($this->fk_soc)) {
- $this->fetch_thirdparty($this->fk_soc);
- $array_company = array(array('firstname' => '', 'lastname' => $this->client->name, 'email' => $this->client->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $this->client->id));
- $contacts = array_merge($contacts, $array_company);
- }
-
- // foreach contact send email with notification message
- if (count($contacts) > 0) {
- foreach ($contacts as $key => $info_sendto) {
- $tmpmessage = '';
- $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNotificationEmailSubject', $this->track_id);
- $tmpmessage .= $langs->transnoentities('TicketNotificationEmailBody', $this->track_id)."\n\n";
- $tmpmessage .= $langs->transnoentities('Title').' : '.$this->subject."\n";
-
- $recipient_name = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1');
- $recipient = (!empty($recipient_name) ? $recipient_name : $info_sendto['email']).' ('.strtolower($info_sendto['libelle']).')';
- $tmpmessage .= $langs->transnoentities('TicketNotificationRecipient').' : '.$recipient."\n";
- $tmpmessage .= "\n";
- $tmpmessage .= '* '.$langs->transnoentities('TicketNotificationLogMessage').' *'."\n";
- $tmpmessage .= dol_html_entity_decode($message, ENT_QUOTES | ENT_HTML5)."\n";
-
- if ($info_sendto['source'] == 'internal') {
- $url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$this->track_id;
- $tmpmessage .= "\n".$langs->transnoentities('TicketNotificationEmailBodyInfosTrackUrlinternal').' : '.$this->track_id.''."\n";
- } else {
- $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/view.php' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$this->track_id;
- $tmpmessage .= "\n".$langs->transnoentities('TicketNewEmailBodyInfosTrackUrlCustomer').' : '.$this->track_id.''."\n";
- }
-
- $tmpmessage .= "\n";
- $tmpmessage .= $langs->transnoentities('TicketEmailPleaseDoNotReplyToThisEmail')."\n";
-
- $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
- $replyto = $from;
-
- // Init to avoid errors
- $filepath = array();
- $filename = array();
- $mimetype = array();
-
- $tmpmessage = dol_nl2br($tmpmessage);
-
- if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
- $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
- $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
- }
- include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
- $sendtocc = '';
- $deliveryreceipt = 0;
- $mailfile = new CMailFile($subject, $info_sendto['email'], $from, $tmpmessage, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, 0);
- if ($mailfile->error || !empty($mailfile->errors)) {
- setEventMessages($mailfile->error, $mailfile->errors, 'errors');
- } else {
- $result = $mailfile->sendfile();
- if ($result > 0) {
- $nb_sent++;
- }
- }
- if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
- $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
- }
- }
-
- setEventMessages($langs->trans('TicketNotificationNumberEmailSent', $nb_sent), null, 'mesgs');
- }
-
- return $nb_sent;
- }
-
- /**
- * Charge la liste des actions sur le ticket
- *
- * @return int Number of lines loaded, 0 if already loaded, <0 if KO
- */
- public function loadCacheLogsTicket()
- {
- global $langs;
-
- if (is_array($this->cache_logs_ticket) && count($this->cache_logs_ticket)) {
- return 0;
- }
- // Cache deja charge
-
- // TODO Read the table llx_actioncomm
- /*
- $sql = "SELECT rowid, fk_user_create, datec, message";
- $sql .= " FROM " . MAIN_DB_PREFIX . "ticket_logs";
- $sql .= " WHERE fk_track_id ='" . $this->db->escape($this->track_id) . "'";
- $sql .= " ORDER BY datec DESC";
-
- $resql = $this->db->query($sql);
- if ($resql) {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num) {
- $obj = $this->db->fetch_object($resql);
- $this->cache_logs_ticket[$i]['id'] = $obj->rowid;
- $this->cache_logs_ticket[$i]['fk_user_create'] = $obj->fk_user_create;
- $this->cache_logs_ticket[$i]['datec'] = $this->db->jdate($obj->datec);
- $this->cache_logs_ticket[$i]['message'] = $obj->message;
- $i++;
- }
- return $num;
- } else {
- $this->error = "Error " . $this->db->lasterror();
- dol_syslog(get_class($this) . "::loadCacheLogsTicket " . $this->error, LOG_ERR);
- return -1;
- }*/
-
- return 0;
- }
-
/**
* Add message into database
*
@@ -2869,9 +2731,11 @@ class Ticket extends CommonObject
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
+ $upload_dir_tmp = $conf->user->dir_output."/".$user->id;
+
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$trackid = "tic".$this->id;
- $mailfile = new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid, '', 'ticket');
+ $mailfile = new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid, '', 'ticket', '', $upload_dir_tmp);
if ($mailfile->error) {
setEventMessages($mailfile->error, null, 'errors');
} else {