mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Mail queue & tickets
- Allow cancelling emails - Adjust wording of ticket scheduling emails
This commit is contained in:
@@ -133,11 +133,16 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
<td>
|
<td>
|
||||||
<button class="btn btn-sm btn-secondary" data-toggle="modal" data-target="#viewEmailModal<?php echo $email_id; ?>"><i class="fas fa-fw fa-eye"></i></button>
|
<button class="btn btn-sm btn-secondary" data-toggle="modal" data-target="#viewEmailModal<?php echo $email_id; ?>"><i class="fas fa-fw fa-eye"></i></button>
|
||||||
|
|
||||||
<?php if($email_attempts > 3 && $email_status == 2) { ?>
|
<!-- Show force resend if all retries have failed -->
|
||||||
|
<?php if ($email_status == 2 && $email_attempts > 3) { ?>
|
||||||
<a class="btn btn-sm btn-success" href="post.php?send_failed_mail=<?php echo $email_id; ?>"><i class="fas fa-fw fa-paper-plane"></i></a>
|
<a class="btn btn-sm btn-success" href="post.php?send_failed_mail=<?php echo $email_id; ?>"><i class="fas fa-fw fa-paper-plane"></i></a>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
<!-- Allow cancelling a message if it hasn't yet been picked up (e.g. stuck/bugged) -->
|
||||||
|
<?php if ($email_status == 0) { ?>
|
||||||
|
<a class="btn btn-sm btn-danger confirm-link" href="post.php?cancel_mail=<?php echo $email_id; ?>"><i class="fas fa-fw fa-trash"></i></a>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ file_put_contents($lock_file_path, "Locked");
|
|||||||
|
|
||||||
// Process Mail Queue
|
// Process Mail Queue
|
||||||
|
|
||||||
// Email Status:
|
// Email Status:
|
||||||
// 0 Queued
|
// 0 Queued
|
||||||
// 1 Sending
|
// 1 Sending
|
||||||
// 2 Failed
|
// 2 Failed
|
||||||
@@ -102,20 +102,20 @@ if (mysqli_num_rows($sql_queue) > 0) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($mail !== true) {
|
if ($mail !== true) {
|
||||||
// Update Message
|
// Update Message - Failure
|
||||||
mysqli_query($mysqli, "UPDATE email_queue SET email_status = 2, email_failed_at = NOW(), email_attempts = 1 WHERE email_id = $email_id");
|
mysqli_query($mysqli, "UPDATE email_queue SET email_status = 2, email_failed_at = NOW(), email_attempts = 1 WHERE email_id = $email_id");
|
||||||
|
|
||||||
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $email_recipient_logging'");
|
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $email_recipient_logging'");
|
||||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Mail', log_action = 'Error', log_description = 'Failed to send email to $email_recipient_logging regarding $email_subject_logging. $mail'");
|
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Mail', log_action = 'Error', log_description = 'Failed to send email to $email_recipient_logging regarding $email_subject_logging. $mail'");
|
||||||
} else {
|
} else {
|
||||||
// Update Message
|
// Update Message - Success
|
||||||
mysqli_query($mysqli, "UPDATE email_queue SET email_status = 3, email_sent_at = NOW(), email_attempts = 1 WHERE email_id = $email_id");
|
mysqli_query($mysqli, "UPDATE email_queue SET email_status = 3, email_sent_at = NOW(), email_attempts = 1 WHERE email_id = $email_id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
// Get Mail that failed to send and attempt to send Failed Mail up to 4 times every 30 mins
|
// Get Mail that failed to send and attempt to send Failed Mail up to 4 times every 30 mins
|
||||||
$sql_failed_queue = mysqli_query($mysqli, "SELECT * FROM email_queue WHERE email_status = 2 AND email_attempts < 4 AND email_failed_at < NOW() + INTERVAL 30 MINUTE");
|
$sql_failed_queue = mysqli_query($mysqli, "SELECT * FROM email_queue WHERE email_status = 2 AND email_attempts < 4 AND email_failed_at < NOW() + INTERVAL 30 MINUTE");
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ if (isset($_POST['test_email_smtp'])) {
|
|||||||
|
|
||||||
validateCSRFToken($_POST['csrf_token']);
|
validateCSRFToken($_POST['csrf_token']);
|
||||||
validateAdminRole();
|
validateAdminRole();
|
||||||
|
|
||||||
$test_email = intval($_POST['test_email']);
|
$test_email = intval($_POST['test_email']);
|
||||||
if($test_email == 1) {
|
if($test_email == 1) {
|
||||||
$email_from = sanitizeInput($config_mail_from_email);
|
$email_from = sanitizeInput($config_mail_from_email);
|
||||||
@@ -328,7 +328,7 @@ if (isset($_POST['edit_theme_settings'])) {
|
|||||||
if (isset($_POST['edit_favicon_settings'])) {
|
if (isset($_POST['edit_favicon_settings'])) {
|
||||||
|
|
||||||
validateCSRFToken($_POST['csrf_token']);
|
validateCSRFToken($_POST['csrf_token']);
|
||||||
|
|
||||||
validateAdminRole();
|
validateAdminRole();
|
||||||
|
|
||||||
// Check to see if a file is attached
|
// Check to see if a file is attached
|
||||||
@@ -451,7 +451,7 @@ if (isset($_POST['edit_integrations_settings'])) {
|
|||||||
if (isset($_POST['edit_ai_settings'])) {
|
if (isset($_POST['edit_ai_settings'])) {
|
||||||
|
|
||||||
validateCSRFToken($_POST['csrf_token']);
|
validateCSRFToken($_POST['csrf_token']);
|
||||||
|
|
||||||
validateAdminRole();
|
validateAdminRole();
|
||||||
|
|
||||||
$provider = sanitizeInput($_POST['provider']);
|
$provider = sanitizeInput($_POST['provider']);
|
||||||
@@ -538,10 +538,10 @@ if (isset($_GET['send_failed_mail'])) {
|
|||||||
|
|
||||||
$email_id = intval($_GET['send_failed_mail']);
|
$email_id = intval($_GET['send_failed_mail']);
|
||||||
|
|
||||||
mysqli_query($mysqli,"UPDATE email_queue SET email_attempts = 3 WHERE email_id = $email_id");
|
mysqli_query($mysqli,"UPDATE email_queue SET email_status = 0, email_attempts = 3 WHERE email_id = $email_id");
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Email', log_action = 'Send', log_description = '$session_name attempted to force send email queue id: $email_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Email', log_action = 'Send', log_description = '$session_name attempted to force send email queue id: $email_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, log_entity_id = $email_id");
|
||||||
|
|
||||||
$_SESSION['alert_message'] = "Email Force Sent, give it a minute to resend";
|
$_SESSION['alert_message'] = "Email Force Sent, give it a minute to resend";
|
||||||
|
|
||||||
@@ -549,6 +549,23 @@ if (isset($_GET['send_failed_mail'])) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['cancel_mail'])) {
|
||||||
|
|
||||||
|
validateTechRole();
|
||||||
|
|
||||||
|
$email_id = intval($_GET['cancel_mail']);
|
||||||
|
|
||||||
|
mysqli_query($mysqli,"UPDATE email_queue SET email_status = 2, email_attempts = 99, email_failed_at = NOW() WHERE email_id = $email_id");
|
||||||
|
|
||||||
|
// Logging
|
||||||
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Email', log_action = 'Cancel', log_description = '$session_name canceled send email queue id: $email_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, log_entity_id = $email_id");
|
||||||
|
|
||||||
|
$_SESSION['alert_message'] = "Email cancelled and marked as failed.";
|
||||||
|
|
||||||
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_GET['download_database'])) {
|
if (isset($_GET['download_database'])) {
|
||||||
|
|
||||||
validateCSRFToken($_GET['csrf_token']);
|
validateCSRFToken($_GET['csrf_token']);
|
||||||
|
|||||||
@@ -1473,10 +1473,10 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
|||||||
mysqli_query(
|
mysqli_query(
|
||||||
$mysqli,
|
$mysqli,
|
||||||
"UPDATE tickets SET
|
"UPDATE tickets SET
|
||||||
ticket_schedule = '$schedule',
|
ticket_schedule = '$schedule',
|
||||||
ticket_onsite = '$onsite',
|
ticket_onsite = '$onsite',
|
||||||
ticket_status = 'Scheduled'
|
ticket_status = 'Scheduled'
|
||||||
WHERE ticket_id = $ticket_id"
|
WHERE ticket_id = $ticket_id"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -1499,7 +1499,6 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
|||||||
WHERE ticket_id = $ticket_id
|
WHERE ticket_id = $ticket_id
|
||||||
");
|
");
|
||||||
|
|
||||||
|
|
||||||
$row = mysqli_fetch_array($sql);
|
$row = mysqli_fetch_array($sql);
|
||||||
|
|
||||||
$client_id = intval($row['ticket_client_id']);
|
$client_id = intval($row['ticket_client_id']);
|
||||||
@@ -1577,7 +1576,7 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
|||||||
'body' => mysqli_escape_string($mysqli, nullable_htmlentities("<div class='header'>
|
'body' => mysqli_escape_string($mysqli, nullable_htmlentities("<div class='header'>
|
||||||
Hello,
|
Hello,
|
||||||
</div>
|
</div>
|
||||||
Your ticket regarding $ticket_subject has been scheduled for $email_datetime.
|
The ticket regarding $ticket_subject has been scheduled for $email_datetime.
|
||||||
<br><br>
|
<br><br>
|
||||||
<a href='https://$config_base_url/portal/ticket.php?id=$ticket_id' class='link-button'>$ticket_link</a>
|
<a href='https://$config_base_url/portal/ticket.php?id=$ticket_id' class='link-button'>$ticket_link</a>
|
||||||
<br><br>
|
<br><br>
|
||||||
@@ -1585,7 +1584,7 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
|||||||
<br><br>
|
<br><br>
|
||||||
<strong>Ticket:</strong> $ticket_prefix$ticket_number<br>
|
<strong>Ticket:</strong> $ticket_prefix$ticket_number<br>
|
||||||
<strong>Subject:</strong> $ticket_subject<br>
|
<strong>Subject:</strong> $ticket_subject<br>
|
||||||
<strong>Portal:</strong> <a href='https://$config_base_url/portal/ticket.php?id=$ticket_id'>Access your ticket here</a>
|
<strong>Portal:</strong> <a href='https://$config_base_url/portal/ticket.php?id=$ticket_id'>Access the ticket here</a>
|
||||||
<br><br>
|
<br><br>
|
||||||
<div class='footer'>
|
<div class='footer'>
|
||||||
~<br>
|
~<br>
|
||||||
@@ -1630,7 +1629,6 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
|||||||
header("Location: calendar_events.php");
|
header("Location: calendar_events.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['cancel_ticket_schedule'])) {
|
if (isset($_GET['cancel_ticket_schedule'])) {
|
||||||
@@ -1686,7 +1684,7 @@ if (isset($_GET['cancel_ticket_schedule'])) {
|
|||||||
'body' => mysqli_escape_string($mysqli, "<div class='header'>
|
'body' => mysqli_escape_string($mysqli, "<div class='header'>
|
||||||
Hello, $contact_name
|
Hello, $contact_name
|
||||||
</div>
|
</div>
|
||||||
Your ticket regarding $ticket_subject has been cancelled.
|
Scheduled work for your ticket regarding $ticket_subject has been cancelled.
|
||||||
<br><br>
|
<br><br>
|
||||||
<a href='https://$config_base_url/portal/ticket.php?id=$ticket_id' class='link-button'>Access your ticket here</a>
|
<a href='https://$config_base_url/portal/ticket.php?id=$ticket_id' class='link-button'>Access your ticket here</a>
|
||||||
<br><br>
|
<br><br>
|
||||||
@@ -1713,7 +1711,7 @@ if (isset($_GET['cancel_ticket_schedule'])) {
|
|||||||
'recipient' => $user_email,
|
'recipient' => $user_email,
|
||||||
'recipient_name' => $user_name,
|
'recipient_name' => $user_name,
|
||||||
'subject' => "Ticket Schedule Cancelled - [$ticket_prefix$ticket_number] - $ticket_subject",
|
'subject' => "Ticket Schedule Cancelled - [$ticket_prefix$ticket_number] - $ticket_subject",
|
||||||
'body' => "Hello, " . $user_name . "<br><br>The ticket regarding $ticket_subject has been cancelled.<br><br>--------------------------------<br><a href=\"https://$config_base_url/ticket.php?id=$ticket_id\">$ticket_link</a><br>--------------------------------<br><br>Please do not reply to this email. <br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Portal: https://$config_base_url/ticket.php?id=$ticket_id<br><br>~<br>$session_company_name<br>Support Department<br>$config_ticket_from_email",
|
'body' => "Hello, " . $user_name . "<br><br>Scheduled work for the ticket regarding $ticket_subject has been cancelled.<br><br>--------------------------------<br><a href=\"https://$config_base_url/ticket.php?id=$ticket_id\">$ticket_link</a><br>--------------------------------<br><br>Please do not reply to this email. <br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Portal: https://$config_base_url/ticket.php?id=$ticket_id<br><br>~<br>$session_company_name<br>Support Department<br>$config_ticket_from_email",
|
||||||
'cal_str' => $cal_str
|
'cal_str' => $cal_str
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
@@ -1731,7 +1729,7 @@ if (isset($_GET['cancel_ticket_schedule'])) {
|
|||||||
'body' => mysqli_escape_string($mysqli, nullable_htmlentities("<div class='header'>
|
'body' => mysqli_escape_string($mysqli, nullable_htmlentities("<div class='header'>
|
||||||
Hello,
|
Hello,
|
||||||
</div>
|
</div>
|
||||||
Your ticket regarding $ticket_subject has been cancelled.
|
Scheduled work for the ticket regarding $ticket_subject has been cancelled.
|
||||||
<br><br>
|
<br><br>
|
||||||
<a href='https://$config_base_url/portal/ticket.php?id=$ticket_id' class='link-button'>$ticket_link</a>
|
<a href='https://$config_base_url/portal/ticket.php?id=$ticket_id' class='link-button'>$ticket_link</a>
|
||||||
<br><br>
|
<br><br>
|
||||||
@@ -1739,7 +1737,7 @@ if (isset($_GET['cancel_ticket_schedule'])) {
|
|||||||
<br><br>
|
<br><br>
|
||||||
<strong>Ticket:</strong> $ticket_prefix$ticket_number<br>
|
<strong>Ticket:</strong> $ticket_prefix$ticket_number<br>
|
||||||
<strong>Subject:</strong> $ticket_subject<br>
|
<strong>Subject:</strong> $ticket_subject<br>
|
||||||
<strong>Portal:</strong> <a href='https://$config_base_url/portal/ticket.php?id=$ticket_id'>Access your ticket here</a>
|
<strong>Portal:</strong> <a href='https://$config_base_url/portal/ticket.php?id=$ticket_id'>Access the ticket here</a>
|
||||||
<br><br>
|
<br><br>
|
||||||
<div class='footer'>
|
<div class='footer'>
|
||||||
~<br>
|
~<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user