Merge pull request #20013 from thomas-Ngr/develop_db_ticket_last_message_date
New : ticket add last_msg_sent field
This commit is contained in:
commit
bfa9986736
@ -279,7 +279,12 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|||||||
if ($mailfile->error) {
|
if ($mailfile->error) {
|
||||||
dol_syslog($mailfile->error, LOG_DEBUG);
|
dol_syslog($mailfile->error, LOG_DEBUG);
|
||||||
} else {
|
} else {
|
||||||
$result = $mailfile->sendfile();
|
$result = $mailfile->sendfile();
|
||||||
|
if ($result) {
|
||||||
|
// update last_msg_sent date
|
||||||
|
$object->date_last_msg_sent = dol_now();
|
||||||
|
$object->update($user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
|
||||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
||||||
|
|||||||
@ -87,6 +87,7 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value
|
|||||||
INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_MODIFY','Expense report modified','Executed when an expense report is modified','expensereport',202);
|
INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_MODIFY','Expense report modified','Executed when an expense report is modified','expensereport',202);
|
||||||
INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_MODIFY','Expense report modified','Executed when an expense report is modified','expensereport',212);
|
INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_MODIFY','Expense report modified','Executed when an expense report is modified','expensereport',212);
|
||||||
|
|
||||||
|
ALTER TABLE llx_ticket ADD COLUMN date_last_msg_sent datetime AFTER date_read;
|
||||||
|
|
||||||
CREATE TABLE llx_stock_mouvement_extrafields (
|
CREATE TABLE llx_stock_mouvement_extrafields (
|
||||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
|||||||
@ -36,6 +36,7 @@ CREATE TABLE llx_ticket
|
|||||||
severity_code varchar(32),
|
severity_code varchar(32),
|
||||||
datec datetime,
|
datec datetime,
|
||||||
date_read datetime,
|
date_read datetime,
|
||||||
|
date_last_msg_sent datetime,
|
||||||
date_close datetime,
|
date_close datetime,
|
||||||
notify_tiers_at_create tinyint,
|
notify_tiers_at_create tinyint,
|
||||||
email_msgid varchar(255), -- if ticket is created by email collector, we store here MSG ID
|
email_msgid varchar(255), -- if ticket is created by email collector, we store here MSG ID
|
||||||
|
|||||||
@ -177,6 +177,11 @@ class Ticket extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public $date_read = '';
|
public $date_read = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Last message date
|
||||||
|
*/
|
||||||
|
public $date_last_msg_sent = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Close ticket date
|
* @var int Close ticket date
|
||||||
*/
|
*/
|
||||||
@ -266,6 +271,7 @@ class Ticket extends CommonObject
|
|||||||
//'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'help'=>""), // what is this ?
|
//'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'help'=>""), // what is this ?
|
||||||
'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
|
'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
|
||||||
'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-1, 'enabled'=>1, 'position'=>501, 'notnull'=>1),
|
'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-1, 'enabled'=>1, 'position'=>501, 'notnull'=>1),
|
||||||
|
'date_last_msg_sent' => array('type'=>'datetime', 'label'=>'TicketLastMessageDate', 'visible'=>0, 'enabled'=>1, 'position'=>502, 'notnull'=>-1),
|
||||||
'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>505, 'notnull'=>1, 'css'=>'tdoverflowmax125'),
|
'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>505, 'notnull'=>1, 'css'=>'tdoverflowmax125'),
|
||||||
'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-1, 'enabled'=>1, 'position'=>510, 'notnull'=>1),
|
'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-1, 'enabled'=>1, 'position'=>510, 'notnull'=>1),
|
||||||
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>520, 'notnull'=>1),
|
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>520, 'notnull'=>1),
|
||||||
@ -568,6 +574,7 @@ class Ticket extends CommonObject
|
|||||||
$sql .= " t.severity_code,";
|
$sql .= " t.severity_code,";
|
||||||
$sql .= " t.datec,";
|
$sql .= " t.datec,";
|
||||||
$sql .= " t.date_read,";
|
$sql .= " t.date_read,";
|
||||||
|
$sql .= " t.date_last_msg_sent,";
|
||||||
$sql .= " t.date_close,";
|
$sql .= " t.date_close,";
|
||||||
$sql .= " t.tms,";
|
$sql .= " t.tms,";
|
||||||
$sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label";
|
$sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label";
|
||||||
@ -635,6 +642,7 @@ class Ticket extends CommonObject
|
|||||||
$this->date_creation = $this->db->jdate($obj->datec);
|
$this->date_creation = $this->db->jdate($obj->datec);
|
||||||
$this->date_read = $this->db->jdate($obj->date_read);
|
$this->date_read = $this->db->jdate($obj->date_read);
|
||||||
$this->date_validation = $this->db->jdate($obj->date_read);
|
$this->date_validation = $this->db->jdate($obj->date_read);
|
||||||
|
$this->date_last_msg_sent = $this->db->jdate($obj->date_last_msg_sent);
|
||||||
$this->date_close = $this->db->jdate($obj->date_close);
|
$this->date_close = $this->db->jdate($obj->date_close);
|
||||||
$this->tms = $this->db->jdate($obj->tms);
|
$this->tms = $this->db->jdate($obj->tms);
|
||||||
$this->date_modification = $this->db->jdate($obj->tms);
|
$this->date_modification = $this->db->jdate($obj->tms);
|
||||||
@ -695,6 +703,7 @@ class Ticket extends CommonObject
|
|||||||
$sql .= " t.severity_code,";
|
$sql .= " t.severity_code,";
|
||||||
$sql .= " t.datec,";
|
$sql .= " t.datec,";
|
||||||
$sql .= " t.date_read,";
|
$sql .= " t.date_read,";
|
||||||
|
$sql .= " t.date_last_msg_sent,";
|
||||||
$sql .= " t.date_close,";
|
$sql .= " t.date_close,";
|
||||||
$sql .= " t.tms";
|
$sql .= " t.tms";
|
||||||
$sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label";
|
$sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label";
|
||||||
@ -801,6 +810,7 @@ class Ticket extends CommonObject
|
|||||||
|
|
||||||
$line->datec = $this->db->jdate($obj->datec);
|
$line->datec = $this->db->jdate($obj->datec);
|
||||||
$line->date_read = $this->db->jdate($obj->date_read);
|
$line->date_read = $this->db->jdate($obj->date_read);
|
||||||
|
$line->date_last_msg_sent = $this->db->jdate($obj->date_last_msg_sent);
|
||||||
$line->date_close = $this->db->jdate($obj->date_close);
|
$line->date_close = $this->db->jdate($obj->date_close);
|
||||||
|
|
||||||
// Extra fields
|
// Extra fields
|
||||||
@ -923,6 +933,7 @@ class Ticket extends CommonObject
|
|||||||
$sql .= " severity_code=".(isset($this->severity_code) ? "'".$this->db->escape($this->severity_code)."'" : "null").",";
|
$sql .= " severity_code=".(isset($this->severity_code) ? "'".$this->db->escape($this->severity_code)."'" : "null").",";
|
||||||
$sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
|
$sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
|
||||||
$sql .= " date_read=".(dol_strlen($this->date_read) != 0 ? "'".$this->db->idate($this->date_read)."'" : 'null').",";
|
$sql .= " date_read=".(dol_strlen($this->date_read) != 0 ? "'".$this->db->idate($this->date_read)."'" : 'null').",";
|
||||||
|
$sql .= " date_last_msg_sent=".(dol_strlen($this->date_last_msg_sent) != 0 ? "'".$this->db->idate($this->date_last_msg_sent)."'" : 'null').",";
|
||||||
$sql .= " date_close=".(dol_strlen($this->date_close) != 0 ? "'".$this->db->idate($this->date_close)."'" : 'null')."";
|
$sql .= " date_close=".(dol_strlen($this->date_close) != 0 ? "'".$this->db->idate($this->date_close)."'" : 'null')."";
|
||||||
$sql .= " WHERE rowid=".((int) $this->id);
|
$sql .= " WHERE rowid=".((int) $this->id);
|
||||||
|
|
||||||
@ -1116,6 +1127,7 @@ class Ticket extends CommonObject
|
|||||||
$this->severity_code = 'SEVERITYCODE';
|
$this->severity_code = 'SEVERITYCODE';
|
||||||
$this->datec = '';
|
$this->datec = '';
|
||||||
$this->date_read = '';
|
$this->date_read = '';
|
||||||
|
$this->date_last_msg_sent = '';
|
||||||
$this->date_close = '';
|
$this->date_close = '';
|
||||||
$this->tms = '';
|
$this->tms = '';
|
||||||
return 1;
|
return 1;
|
||||||
@ -2744,7 +2756,12 @@ class Ticket extends CommonObject
|
|||||||
|
|
||||||
// altairis: dont try to send email when no recipient
|
// altairis: dont try to send email when no recipient
|
||||||
if (!empty($sendto)) {
|
if (!empty($sendto)) {
|
||||||
$this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
|
$result = $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
|
||||||
|
if ($result) {
|
||||||
|
// update last_msg_sent date
|
||||||
|
$object->date_last_msg_sent = dol_now();
|
||||||
|
$object->update($user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2755,7 +2772,6 @@ class Ticket extends CommonObject
|
|||||||
if ($object->fk_statut < 3 && !$user->socid) {
|
if ($object->fk_statut < 3 && !$user->socid) {
|
||||||
$object->setStatut(3);
|
$object->setStatut(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
@ -2778,7 +2794,7 @@ class Ticket extends CommonObject
|
|||||||
* @param array $filename_list List of files to attach (full path of filename on file system)
|
* @param array $filename_list List of files to attach (full path of filename on file system)
|
||||||
* @param array $mimetype_list List of MIME type of attached files
|
* @param array $mimetype_list List of MIME type of attached files
|
||||||
* @param array $mimefilename_list List of attached file name in message
|
* @param array $mimefilename_list List of attached file name in message
|
||||||
* @return void
|
* @return boolean True if mail sent to at least one receiver, false otherwise
|
||||||
*/
|
*/
|
||||||
public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array(), $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
|
public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array(), $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
|
||||||
{
|
{
|
||||||
@ -2786,7 +2802,7 @@ class Ticket extends CommonObject
|
|||||||
|
|
||||||
if ($conf->global->TICKET_DISABLE_ALL_MAILS) {
|
if ($conf->global->TICKET_DISABLE_ALL_MAILS) {
|
||||||
dol_syslog(get_class($this).'::sendTicketMessageByEmail: Emails are disable into ticket setup by option TICKET_DISABLE_ALL_MAILS', LOG_WARNING);
|
dol_syslog(get_class($this).'::sendTicketMessageByEmail: Emails are disable into ticket setup by option TICKET_DISABLE_ALL_MAILS', LOG_WARNING);
|
||||||
return '';
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$langs->load("mails");
|
$langs->load("mails");
|
||||||
@ -2805,6 +2821,7 @@ class Ticket extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$from = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM;
|
$from = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM;
|
||||||
|
$is_sent = false;
|
||||||
if (is_array($array_receiver) && count($array_receiver) > 0) {
|
if (is_array($array_receiver) && count($array_receiver) > 0) {
|
||||||
foreach ($array_receiver as $key => $receiver) {
|
foreach ($array_receiver as $key => $receiver) {
|
||||||
$deliveryreceipt = 0;
|
$deliveryreceipt = 0;
|
||||||
@ -2826,6 +2843,7 @@ class Ticket extends CommonObject
|
|||||||
$result = $mailfile->sendfile();
|
$result = $mailfile->sendfile();
|
||||||
if ($result) {
|
if ($result) {
|
||||||
setEventMessages($langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($receiver, 2)), null, 'mesgs');
|
setEventMessages($langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($receiver, 2)), null, 'mesgs');
|
||||||
|
$is_sent = true;
|
||||||
} else {
|
} else {
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
if ($mailfile->error) {
|
if ($mailfile->error) {
|
||||||
@ -2844,6 +2862,7 @@ class Ticket extends CommonObject
|
|||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
setEventMessages($langs->trans('ErrorMailRecipientIsEmptyForSendTicketMessage'), null, 'warnings');
|
setEventMessages($langs->trans('ErrorMailRecipientIsEmptyForSendTicketMessage'), null, 'warnings');
|
||||||
}
|
}
|
||||||
|
return $is_sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
@ -3093,6 +3112,11 @@ class TicketsLine
|
|||||||
*/
|
*/
|
||||||
public $date_read = '';
|
public $date_read = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Last message date
|
||||||
|
*/
|
||||||
|
public $date_last_msg_sent = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close ticket date
|
* Close ticket date
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user