From 13cf4df473d214e9402bf6a5ebd0fb8a6960f601 Mon Sep 17 00:00:00 2001 From: o-psi Date: Thu, 18 Jan 2024 19:50:01 +0000 Subject: [PATCH 1/7] Scheduled Tickets --- calendar_events.php | 11 +++++ post/ticket.php | 78 ++++++++++++++++++++++++++++++++++ ticket.php | 33 +++++++++++--- ticket_edit_schedule_modal.php | 40 +++++++++++++++++ 4 files changed, 156 insertions(+), 6 deletions(-) create mode 100644 ticket_edit_schedule_modal.php 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 From 53ad94cc067874244a29963488df26ccb9ef325c Mon Sep 17 00:00:00 2001 From: o-psi Date: Thu, 18 Jan 2024 22:48:20 +0000 Subject: [PATCH 2/7] Update Database to match --- database_updates.php | 15 ++++++++++++--- database_version.php | 2 +- db.sql | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/database_updates.php b/database_updates.php index cabf8b15..01bc7589 100644 --- a/database_updates.php +++ b/database_updates.php @@ -1559,14 +1559,23 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.2'"); } + + if (CURRENT_DATABASE_VERSION == '1.0.2') { + //Insert queries here required to update to DB version 1.0.3 + mysqli_query($mysqli, "ALTER TABLE `tickets` ADD `ticket_schedule` DATETIME DEFAULT NULL AFTER `ticket_billable`"); + + //Then, update the database to the next sequential version + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.3'"); + } + // Be sure to change database_version.php to reflect the version you are updating to here // Please add this same comment block to the bottom of this file, and update the version number. // Uncomment Below Lines, to add additional database updates // - // if (CURRENT_DATABASE_VERSION == '1.0.2') { - // // Insert queries here required to update to DB version 1.0.3 + // if (CURRENT_DATABASE_VERSION == '1.0.3') { + // // Insert queries here required to update to DB version 1.0.4 // // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.3'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.4'"); // } } else { diff --git a/database_version.php b/database_version.php index c3d5aa31..6ede6e49 100644 --- a/database_version.php +++ b/database_version.php @@ -5,5 +5,5 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "1.0.2"); +DEFINE("LATEST_DATABASE_VERSION", "1.0.3"); diff --git a/db.sql b/db.sql index 15d7a5f5..3b449279 100644 --- a/db.sql +++ b/db.sql @@ -1565,6 +1565,7 @@ CREATE TABLE `tickets` ( `ticket_priority` varchar(200) DEFAULT NULL, `ticket_status` varchar(200) NOT NULL, `ticket_billable` tinyint(1) NOT NULL DEFAULT 0, + `ticket_schedule` DATETIME DEFAULT NULL, `ticket_vendor_ticket_number` varchar(255) DEFAULT NULL, `ticket_feedback` varchar(200) DEFAULT NULL, `ticket_created_at` datetime NOT NULL DEFAULT current_timestamp(), From 03d3b04bdb6c56df47d50614d8f13c81b9b3d85b Mon Sep 17 00:00:00 2001 From: o-psi Date: Fri, 2 Feb 2024 14:38:25 +0000 Subject: [PATCH 3/7] Update side_nav.php: Changed label from "Scheduled Tickets" to "Recurring Tickets" --- side_nav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/side_nav.php b/side_nav.php index e59d0abe..9912450b 100644 --- a/side_nav.php +++ b/side_nav.php @@ -39,7 +39,7 @@ From a6f105e660caf2a65bcd0fe514a9f13bf23db9b5 Mon Sep 17 00:00:00 2001 From: o-psi Date: Fri, 2 Feb 2024 14:40:24 +0000 Subject: [PATCH 4/7] Update side_nav.php with recurring tickets link --- side_nav.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/side_nav.php b/side_nav.php index 9912450b..53c13cf2 100644 --- a/side_nav.php +++ b/side_nav.php @@ -37,8 +37,8 @@ From 0ac36f91ebcf976653b37a79e0c1960b52ec6c7e Mon Sep 17 00:00:00 2001 From: o-psi Date: Fri, 2 Feb 2024 14:40:35 +0000 Subject: [PATCH 5/7] Update recurring expenses icon --- side_nav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/side_nav.php b/side_nav.php index 53c13cf2..c1dd3f0b 100644 --- a/side_nav.php +++ b/side_nav.php @@ -111,7 +111,7 @@ From f71d3d9b1964600a3c93ad9df6ce37706b96a8c7 Mon Sep 17 00:00:00 2001 From: o-psi Date: Fri, 2 Feb 2024 15:08:44 +0000 Subject: [PATCH 6/7] finish rename scheduled tickets to recurring tickets in UI --- js/scheduled_tickets_edit_modal.js | 2 +- scheduled_ticket_add_modal.php | 2 +- scheduled_tickets.php | 4 ++-- side_nav.php | 6 ------ tickets.php | 9 +++++++++ 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/js/scheduled_tickets_edit_modal.js b/js/scheduled_tickets_edit_modal.js index f934cf27..67525ad6 100644 --- a/js/scheduled_tickets_edit_modal.js +++ b/js/scheduled_tickets_edit_modal.js @@ -15,7 +15,7 @@ function populateScheduledTicketEditModal(client_id, ticket_id) { const assets = response.assets; // Populate the scheduled ticket modal fields - document.getElementById("editHeader").innerText = " Edit Scheduled ticket: " + ticket.scheduled_ticket_subject; + document.getElementById("editHeader").innerText = " Edit Recurring ticket: " + ticket.scheduled_ticket_subject; document.getElementById("editTicketId").value = ticket_id; document.getElementById("editClientId").value = client_id; document.getElementById("editTicketSubject").value = ticket.scheduled_ticket_subject; diff --git a/scheduled_ticket_add_modal.php b/scheduled_ticket_add_modal.php index 918df9bc..199d4b0c 100644 --- a/scheduled_ticket_add_modal.php +++ b/scheduled_ticket_add_modal.php @@ -2,7 +2,7 @@