Do not Resolved Tickets in Bulk that have Open tasks, display warning and count of ticket not resolved because of open tasks
This commit is contained in:
+19
-2
@@ -1012,12 +1012,21 @@ if (isset($_POST['bulk_resolve_tickets'])) {
|
||||
// Resolve Selected Tickets
|
||||
if (isset($_POST['ticket_ids'])) {
|
||||
|
||||
// Get a Ticket Count
|
||||
$ticket_count = count($_POST['ticket_ids']);
|
||||
// Intitialze the counts before the loop
|
||||
$ticket_count = 0;
|
||||
$skipped_count = 0;
|
||||
|
||||
foreach ($_POST['ticket_ids'] as $ticket_id) {
|
||||
$ticket_id = intval($ticket_id);
|
||||
|
||||
// Check to make sure Tasks are complete before resolving
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('task_id') AS num FROM tasks WHERE task_completed_at IS NULL AND task_ticket_id = $ticket_id"));
|
||||
$num_of_open_tasks = $row['num'];
|
||||
|
||||
if ($num_of_open_tasks == 0) {
|
||||
// Count the Ticket Loop
|
||||
$ticket_count++;
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = $ticket_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
||||
@@ -1105,11 +1114,19 @@ if (isset($_POST['bulk_resolve_tickets'])) {
|
||||
}
|
||||
addToMailQueue($data);
|
||||
} // End Mail IF
|
||||
} else {
|
||||
$skipped_count++;
|
||||
} // End Task Check
|
||||
} // End Loop
|
||||
} // End Array Empty Check
|
||||
|
||||
$_SESSION['alert_message'] = "Resolved <strong>$ticket_count</strong> Tickets";
|
||||
|
||||
if ($skipped_count > 0) {
|
||||
$_SESSION['alert_type'] = "info";
|
||||
$_SESSION['alert_message'] .= " <strong>$skipped_count</strong> ticket(s) could not be resolved because they have open tasks.";
|
||||
}
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user