diff --git a/calendar_events.php b/calendar_events.php index ad1a2370..73625e5b 100644 --- a/calendar_events.php +++ b/calendar_events.php @@ -25,6 +25,7 @@ require_once "calendar_event_add_modal.php"; require_once "calendar_add_modal.php"; + //loop through IDs and create a modal for each $sql = mysqli_query($mysqli, "SELECT * FROM events LEFT JOIN calendars ON event_calendar_id = calendar_id"); while ($row = mysqli_fetch_array($sql)) { @@ -123,6 +124,16 @@ while ($row = mysqli_fetch_array($sql)) { } + //Tickets Scheduled + $sql = mysqli_query($mysqli, "SELECT * FROM clients LEFT JOIN tickets ON client_id = ticket_client_id WHERE ticket_schedule IS NOT NULL"); + while ($row = mysqli_fetch_array($sql)) { + $event_id = intval($row['ticket_id']); + $event_title = json_encode($row['ticket_prefix'] . $row['ticket_number'] . " " . $row['ticket_subject']); + $event_start = json_encode($row['ticket_schedule']); + + echo "{ id: $event_id, title: $event_title, start: $event_start, color: 'red', url: 'ticket.php?ticket_id=$event_id' },"; + } + //Vendors Added Created $sql = mysqli_query($mysqli, "SELECT * FROM clients LEFT JOIN vendors ON client_id = vendor_client_id WHERE vendor_template = 0"); while ($row = mysqli_fetch_array($sql)) { diff --git a/post/ticket.php b/post/ticket.php index 9b42986f..c81e2d9e 100644 --- a/post/ticket.php +++ b/post/ticket.php @@ -1143,4 +1143,82 @@ if(isset($_POST['set_billable_status'])) { header("Location: " . $_SERVER["HTTP_REFERER"]); +} + +if (isset($_POST['edit_ticket_schedule'])) { + + validateTechRole(); + + $ticket_id = intval($_POST['ticket_id']); + $schedule = sanitizeInput($_POST['scheduled_date_time']); + $ticket_link = "ticket.php?ticket_id=$ticket_id"; + $full_ticket_url = "https://$config_base_url/portal/ticket.php?ticket_id=$ticket_id"; + $ticket_link_html = "$ticket_link"; + + mysqli_query($mysqli, + "UPDATE tickets SET + ticket_schedule = '$schedule', + ticket_status = 'Scheduled' + WHERE ticket_id = $ticket_id" + ); + + + + //Send email to client and assigned user + + $sql = mysqli_query($mysqli,"SELECT * FROM tickets + LEFT JOIN clients ON ticket_client_id = client_id + LEFT JOIN contacts ON ticket_contact_id = contact_id + LEFT JOIN users ON ticket_assigned_to = user_id + WHERE ticket_id = $ticket_id + "); + + $row = mysqli_fetch_array($sql); + + $client_id = intval($row['ticket_client_id']); + $client_name = sanitizeInput($row['client_name']); + $contact_name = sanitizeInput($row['contact_name']); + $contact_email = sanitizeInput($row['contact_email']); + $ticket_prefix = sanitizeInput($row['ticket_prefix']); + $ticket_number = intval($row['ticket_number']); + $ticket_subject = sanitizeInput($row['ticket_subject']); + + $data = [ + [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, + 'recipient' => $contact_email, + 'recipient_name' => $contact_name, + 'subject' => "Ticket Scheduled - [$ticket_prefix$ticket_number] - $ticket_subject", + 'body' => "Hello, $contact_name

Your ticket regarding $ticket_subject has been scheduled for $schedule.

--------------------------------
$ticket_link
--------------------------------

We hope the issue was resolved to your satisfaction. If you need further assistance, please raise a new ticket using the below details. Please do not reply to this email.

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id

~
$session_company_name
Support Department
$config_ticket_from_email
$company_phone", + ], + [ + 'from' => $config_ticket_from_email, + 'from_name' => $config_ticket_from_name, + 'recipient' => $row['user_email'], + 'recipient_name' => $row['user_first_name'] . ' ' . $row['user_last_name'], + 'subject' => "Ticket Scheduled - [$ticket_prefix$ticket_number] - $ticket_subject", + 'body' => "Hello, " . $row['user_first_name'] . "

The ticket regarding $ticket_subject has been scheduled for $schedule.

--------------------------------
$ticket_link
--------------------------------

We hope the issue was resolved to your satisfaction. If you need further assistance, please raise a new ticket using the below details. Please do not reply to this email.

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id

~
$session_company_name
Support Department
$config_ticket_from_email
$company_phone", + ] + ]; + $response = addToMailQueue($mysqli, $data); + + + //Logging + mysqli_query( + $mysqli, + "INSERT INTO logs SET + log_type = 'Ticket', + log_action = 'Modify', + log_description = '$session_name modified ticket schedule', + log_ip = '$session_ip', + log_user_agent = '$session_user_agent', + log_user_id = $session_user_id, + log_entity_id = $ticket_id" + ); + + $_SESSION['alert_message'] = "Ticket schedule updated"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + } \ No newline at end of file diff --git a/ticket.php b/ticket.php index 431ed96e..ec6896a1 100644 --- a/ticket.php +++ b/ticket.php @@ -58,6 +58,7 @@ if (isset($_GET['ticket_id'])) { $ticket_details = $purifier->purify($row['ticket_details']); $ticket_priority = nullable_htmlentities($row['ticket_priority']); $ticket_billable = intval($row['ticket_billable']); + $ticket_scheduled_for = nullable_htmlentities($row['ticket_schedule']); //Set Ticket Bage Color based of priority if ($ticket_priority == "High") { @@ -314,7 +315,6 @@ if (isset($_GET['ticket_id'])) { - @@ -322,6 +322,8 @@ if (isset($_GET['ticket_id'])) { + +
@@ -642,15 +644,25 @@ if (isset($_GET['ticket_id'])) {
Feedback:
- + + if (!empty($ticket_scheduled_for)) { ?> +
+ Scheduled for: +
+ +
+ Scheduled for: Add +
+
Total time worked:
- + + if ($config_module_enable_accounting) { ?>
Billable: @@ -874,6 +886,8 @@ if (isset($_GET['ticket_id'])) { require_once "ticket_change_client_modal.php"; + require_once "ticket_edit_schedule_modal.php"; + require_once "ticket_merge_modal.php"; if ($config_module_enable_accounting) { @@ -885,9 +899,16 @@ if (isset($_GET['ticket_id'])) { } + + require_once "footer.php"; -?> + + + + + diff --git a/ticket_edit_schedule_modal.php b/ticket_edit_schedule_modal.php new file mode 100644 index 00000000..2f510ddd --- /dev/null +++ b/ticket_edit_schedule_modal.php @@ -0,0 +1,40 @@ + \ No newline at end of file