Update ticket scheduled post actions.
This commit is contained in:
+21
-6
@@ -1510,8 +1510,19 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
|||||||
WHERE ticket_id = $ticket_id"
|
WHERE ticket_id = $ticket_id"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Check for other conflicting scheduled items based on 2 hr window
|
||||||
|
$start = date('Y-m-d H:i:s', strtotime($schedule) - 7200);
|
||||||
|
$end = date('Y-m-d H:i:s', strtotime($schedule) + 7200);
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_schedule BETWEEN '$start' AND '$end' AND ticket_id != $ticket_id AND ticket_status = 'Scheduled'");
|
||||||
|
if (mysqli_num_rows($sql) > 0) {
|
||||||
|
$conflicting_tickets = [];
|
||||||
|
while ($row = mysqli_fetch_array($sql)) {
|
||||||
|
$conflicting_tickets[] = $row['ticket_id'] . " - " . $row['ticket_subject'] . " @ " . $row['ticket_schedule'];
|
||||||
|
}
|
||||||
|
$_SESSION['alert_message'] = "Ticket scheduled, but there are other tickets scheduled within 2 hours of this time. Please check the schedule for tickets: " . implode(", ", $conflicting_tickets);
|
||||||
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
|
||||||
|
}else {
|
||||||
//Send email to client and assigned user
|
//Send email to client and assigned user
|
||||||
|
|
||||||
$sql = mysqli_query($mysqli,"SELECT * FROM tickets
|
$sql = mysqli_query($mysqli,"SELECT * FROM tickets
|
||||||
@@ -1525,14 +1536,18 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
|||||||
|
|
||||||
$client_id = intval($row['ticket_client_id']);
|
$client_id = intval($row['ticket_client_id']);
|
||||||
$client_name = sanitizeInput($row['client_name']);
|
$client_name = sanitizeInput($row['client_name']);
|
||||||
|
$ticket_details = sanitizeInput($row['ticket_details']);
|
||||||
$contact_name = sanitizeInput($row['contact_name']);
|
$contact_name = sanitizeInput($row['contact_name']);
|
||||||
$contact_email = sanitizeInput($row['contact_email']);
|
$contact_email = sanitizeInput($row['contact_email']);
|
||||||
$ticket_prefix = sanitizeInput($row['ticket_prefix']);
|
$ticket_prefix = sanitizeInput($row['ticket_prefix']);
|
||||||
$ticket_number = intval($row['ticket_number']);
|
$ticket_number = intval($row['ticket_number']);
|
||||||
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
||||||
$cal_str = createCalendarEvent($schedule, $ticket_subject, $ticket_link, $config_base_url);
|
|
||||||
|
|
||||||
|
|
||||||
|
$cal_subject = $ticket_number . ": " .$client_name . " - " . $ticket_subject;
|
||||||
|
$cal_description = $ticket_details . " - " . $full_ticket_url;
|
||||||
|
|
||||||
|
$cal_str = createCalendarEvent($schedule, $cal_subject, $cal_description, $cal_location);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
[
|
[
|
||||||
@@ -1554,9 +1569,7 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
|||||||
'cal_str' => $cal_str
|
'cal_str' => $cal_str
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
//Send all watchers an email
|
//Send all watchers an email
|
||||||
|
|
||||||
$sql_watchers = mysqli_query($mysqli, "SELECT watcher_email FROM ticket_watchers WHERE watcher_ticket_id = $ticket_id");
|
$sql_watchers = mysqli_query($mysqli, "SELECT watcher_email FROM ticket_watchers WHERE watcher_ticket_id = $ticket_id");
|
||||||
|
|
||||||
while ($row = mysqli_fetch_array($sql_watchers)) {
|
while ($row = mysqli_fetch_array($sql_watchers)) {
|
||||||
@@ -1571,15 +1584,15 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
|||||||
'cal_str' => $cal_str
|
'cal_str' => $cal_str
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = addToMailQueue($mysqli, $data);
|
$response = addToMailQueue($mysqli, $data);
|
||||||
|
|
||||||
// if response is not empty, then there was an error
|
// if response is not empty, then there was an error
|
||||||
if (!empty($response)) {
|
if (!empty($response)) {
|
||||||
$_SESSION['alert_message'] = "Error sending email: " . $response;
|
$_SESSION['alert_message'] = "Error sending email: " . $response;
|
||||||
} else {
|
} else {
|
||||||
$_SESSION['alert_message'] = "Ticket scheduled";
|
$_SESSION['alert_message'] = "Ticket scheduled";
|
||||||
}
|
}
|
||||||
|
// Update ticket reply
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_replies SET ticket_reply = 'Ticket scheduled for $schedule', ticket_reply_type = 'Internal', ticket_reply_time_worked = '00:05:00', ticket_reply_by = $session_user_id, ticket_reply_ticket_id = $ticket_id");
|
||||||
|
|
||||||
//Logging
|
//Logging
|
||||||
mysqli_query(
|
mysqli_query(
|
||||||
@@ -1598,4 +1611,6 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
|||||||
|
|
||||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user