Mail queue & tickets

- Allow cancelling emails
- Adjust wording of ticket scheduling emails
This commit is contained in:
Marcus Hill
2024-02-24 11:06:55 +00:00
parent da54b125c3
commit 1e8fbddcbd
4 changed files with 45 additions and 25 deletions

View File

@@ -151,7 +151,7 @@ if (isset($_POST['test_email_smtp'])) {
validateCSRFToken($_POST['csrf_token']);
validateAdminRole();
$test_email = intval($_POST['test_email']);
if($test_email == 1) {
$email_from = sanitizeInput($config_mail_from_email);
@@ -328,7 +328,7 @@ if (isset($_POST['edit_theme_settings'])) {
if (isset($_POST['edit_favicon_settings'])) {
validateCSRFToken($_POST['csrf_token']);
validateAdminRole();
// Check to see if a file is attached
@@ -451,7 +451,7 @@ if (isset($_POST['edit_integrations_settings'])) {
if (isset($_POST['edit_ai_settings'])) {
validateCSRFToken($_POST['csrf_token']);
validateAdminRole();
$provider = sanitizeInput($_POST['provider']);
@@ -538,10 +538,10 @@ if (isset($_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
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";
@@ -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'])) {
validateCSRFToken($_GET['csrf_token']);

View File

@@ -1473,10 +1473,10 @@ if (isset($_POST['edit_ticket_schedule'])) {
mysqli_query(
$mysqli,
"UPDATE tickets SET
ticket_schedule = '$schedule',
ticket_onsite = '$onsite',
ticket_status = 'Scheduled'
WHERE ticket_id = $ticket_id"
ticket_schedule = '$schedule',
ticket_onsite = '$onsite',
ticket_status = 'Scheduled'
WHERE ticket_id = $ticket_id"
);
@@ -1499,7 +1499,6 @@ if (isset($_POST['edit_ticket_schedule'])) {
WHERE ticket_id = $ticket_id
");
$row = mysqli_fetch_array($sql);
$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'>
Hello,
</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>
<a href='https://$config_base_url/portal/ticket.php?id=$ticket_id' class='link-button'>$ticket_link</a>
<br><br>
@@ -1585,7 +1584,7 @@ if (isset($_POST['edit_ticket_schedule'])) {
<br><br>
<strong>Ticket:</strong> $ticket_prefix$ticket_number<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>
<div class='footer'>
~<br>
@@ -1630,7 +1629,6 @@ if (isset($_POST['edit_ticket_schedule'])) {
header("Location: calendar_events.php");
}
exit;
}
if (isset($_GET['cancel_ticket_schedule'])) {
@@ -1686,7 +1684,7 @@ if (isset($_GET['cancel_ticket_schedule'])) {
'body' => mysqli_escape_string($mysqli, "<div class='header'>
Hello, $contact_name
</div>
Your ticket regarding $ticket_subject has been cancelled.
Scheduled work for your ticket regarding $ticket_subject has been cancelled.
<br><br>
<a href='https://$config_base_url/portal/ticket.php?id=$ticket_id' class='link-button'>Access your ticket here</a>
<br><br>
@@ -1713,7 +1711,7 @@ if (isset($_GET['cancel_ticket_schedule'])) {
'recipient' => $user_email,
'recipient_name' => $user_name,
'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
]
];
@@ -1731,7 +1729,7 @@ if (isset($_GET['cancel_ticket_schedule'])) {
'body' => mysqli_escape_string($mysqli, nullable_htmlentities("<div class='header'>
Hello,
</div>
Your ticket regarding $ticket_subject has been cancelled.
Scheduled work for the ticket regarding $ticket_subject has been cancelled.
<br><br>
<a href='https://$config_base_url/portal/ticket.php?id=$ticket_id' class='link-button'>$ticket_link</a>
<br><br>
@@ -1739,7 +1737,7 @@ if (isset($_GET['cancel_ticket_schedule'])) {
<br><br>
<strong>Ticket:</strong> $ticket_prefix$ticket_number<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>
<div class='footer'>
~<br>