Add support for emails for users who want emails sent for overdue tickets not assigned to them
This commit is contained in:
parent
dd0481b452
commit
a47068c83b
@ -234,7 +234,8 @@ function update_profile()
|
||||
$_SESSION['new']['autorefresh'] = isset($_POST['autorefresh']) ? $_POST['autorefresh'] : 0;
|
||||
|
||||
/* Notifications */
|
||||
if ($_SESSION[$session_array]['isadmin'] || (isset($_SESSION[$session_array]['heskprivileges']) && strpos($_SESSION[$session_array]['heskprivileges'], 'can_change_notification_settings') !== false)) {
|
||||
if (!(!$_SESSION[$session_array]['isadmin'] && isset($_SESSION[$session_array]['heskprivileges'])
|
||||
&& strpos($_SESSION[$session_array]['heskprivileges'], 'can_change_notification_settings') === false)) {
|
||||
$_SESSION['new']['notify_new_unassigned'] = empty($_POST['notify_new_unassigned']) || !$can_view_unassigned ? 0 : 1;
|
||||
$_SESSION['new']['notify_new_my'] = empty($_POST['notify_new_my']) ? 0 : 1;
|
||||
$_SESSION['new']['notify_reply_unassigned'] = empty($_POST['notify_reply_unassigned']) || !$can_view_unassigned ? 0 : 1;
|
||||
@ -275,6 +276,7 @@ function update_profile()
|
||||
`notify_note_unassigned`='" . intval($_SESSION['new']['notify_note_unassigned']) . "',
|
||||
`notify_customer_new`='" . $_SESSION['new']['notify_customer_new'] . "',
|
||||
`notify_customer_reply`='" . $_SESSION['new']['notify_customer_reply'] . "',
|
||||
`notify_overdue_unassigned`='" . $_SESSION['new']['notify_overdue_unassigned'] . "',
|
||||
`show_suggested`='" . $_SESSION['new']['show_suggested'] . "'
|
||||
WHERE `id`='" . intval($_SESSION['id']) . "' LIMIT 1"
|
||||
);
|
||||
|
@ -126,7 +126,6 @@ $sql = "SELECT `ticket`.`id` AS `id`, `ticket`.`trackid` AS `trackid`, `ticket`.
|
||||
WHERE `due_date` IS NOT NULL
|
||||
AND `due_date` <= NOW()
|
||||
AND `overdue_email_sent` = '0'";
|
||||
//AND `owner` <> 0";
|
||||
|
||||
$successful_emails = 0;
|
||||
$failed_emails = 0;
|
||||
@ -137,9 +136,19 @@ if (hesk_dbNumRows($rs) > 0 && !$included_email_functions) {
|
||||
$included_email_functions = true;
|
||||
}
|
||||
|
||||
$user_rs = hesk_dbQuery("SELECT `id`, `isadmin`, `categories`, `email`,
|
||||
CASE WHEN `heskprivileges` LIKE '%can_view_unassigned%' THEN 1 ELSE 0 END AS `can_view_unassigned`
|
||||
FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE `notify_overdue_unassigned` = '1'
|
||||
AND (`heskprivileges` LIKE '%can_view_tickets%' OR `isadmin` = '1')");
|
||||
|
||||
$users = [];
|
||||
while ($row = hesk_dbFetchAssoc($user_rs)) {
|
||||
$users[] = $row;
|
||||
}
|
||||
|
||||
$tickets_to_flag = [];
|
||||
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||
if (mfh_sendOverdueTicketReminder($row, $modsForHesk_settings)) {
|
||||
if (mfh_sendOverdueTicketReminder($row, $users, $modsForHesk_settings)) {
|
||||
$tickets_to_flag[] = $row['id'];
|
||||
$successful_emails++;
|
||||
|
||||
|
@ -313,7 +313,7 @@ function mfh_processCalendarTemplate($message, $reminder_data) {
|
||||
}
|
||||
|
||||
|
||||
function mfh_sendOverdueTicketReminder($ticket, $modsForHesk_settings) {
|
||||
function mfh_sendOverdueTicketReminder($ticket, $users, $modsForHesk_settings) {
|
||||
global $hesk_settings, $hesklang;
|
||||
|
||||
if (defined('HESK_DEMO')) {
|
||||
@ -338,7 +338,18 @@ function mfh_sendOverdueTicketReminder($ticket, $modsForHesk_settings) {
|
||||
$htmlMessage = hesk_getHtmlMessage('overdue_ticket', NULL, $modsForHesk_settings, 1, 0, 1);
|
||||
$htmlMessage = hesk_processMessage($htmlMessage, $ticket, 1, 1, 0, $modsForHesk_settings, 1);
|
||||
|
||||
hesk_mail($ticket['user_email'], $subject, $message, $htmlMessage, $modsForHesk_settings);
|
||||
$emails = [];
|
||||
$emails[] = $ticket['user_email'];
|
||||
foreach ($users as $user) {
|
||||
if ($user['email'] != $ticket['user_email']
|
||||
&& ($user['isadmin'] || strpos($user['categories'], $ticket['category']) !== false)) {
|
||||
$emails[] = $user['email'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($emails as $email) {
|
||||
hesk_mail($email, $subject, $message, $htmlMessage, $modsForHesk_settings);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user