Skip to content

Commit

Permalink
Add scheduled ticket end date field
Browse files Browse the repository at this point in the history
  • Loading branch information
o-psi committed Nov 22, 2023
1 parent b3c37b6 commit d81a04a
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 3 deletions.
18 changes: 18 additions & 0 deletions database_updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,24 @@
// Then, update the database to the next sequential version
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.6'");
}

if (CURRENT_DATABASE_VERSION == '0.9.6') {
mysqli_query($mysqli, "ALTER TABLE `scheduled_tickets` ADD `scheduled_ticket_end_date` DATE NOT NULL AFTER `scheduled_ticket_next_run`");

mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.7'");
}

// 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 == '0.9.7') {
// // Insert queries here required to update to DB version 0.9.8
//
// // Then, update the database to the next sequential version
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.8'");
// }

} else {
// Up-to-date
}
2 changes: 1 addition & 1 deletion database_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
* It is used in conjunction with database_updates.php
*/

DEFINE("LATEST_DATABASE_VERSION", "0.9.6");
DEFINE("LATEST_DATABASE_VERSION", "0.9.7");

1 change: 1 addition & 0 deletions db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,7 @@ CREATE TABLE `scheduled_tickets` (
`scheduled_ticket_frequency` varchar(10) NOT NULL,
`scheduled_ticket_start_date` date NOT NULL,
`scheduled_ticket_next_run` date NOT NULL,
`scheduled_ticket_end_date` date NOT NULL,
`scheduled_ticket_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`scheduled_ticket_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
`scheduled_ticket_created_by` int(11) NOT NULL DEFAULT 0,
Expand Down
1 change: 1 addition & 0 deletions js/scheduled_tickets_edit_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function populateScheduledTicketEditModal(client_id, ticket_id) {
document.getElementById("editClientId").value = client_id;
document.getElementById("editTicketSubject").value = ticket.scheduled_ticket_subject;
document.getElementById("editTicketNextRun").value = ticket.scheduled_ticket_next_run;
document.getElementById("editTicketEndDate").value = ticket.scheduled_ticket_end_date;
tinyMCE.get('editTicketDetails').setContent(ticket.scheduled_ticket_details);

// Contact dropdown
Expand Down
5 changes: 5 additions & 0 deletions post/scheduled_ticket_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@
if (isset($_POST['contact'])) {
$contact_id = intval($_POST['contact']);
}

$end_date = NULL;
if (isset($_POST['end_date'])) {
$end_date = sanitizeInput($_POST['end_date']);
}
4 changes: 2 additions & 2 deletions post/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@
}

// Add scheduled ticket
mysqli_query($mysqli, "INSERT INTO scheduled_tickets SET scheduled_ticket_subject = '$subject', scheduled_ticket_details = '$details', scheduled_ticket_priority = '$priority', scheduled_ticket_frequency = '$frequency', scheduled_ticket_start_date = '$start_date', scheduled_ticket_next_run = '$start_date', scheduled_ticket_created_by = $session_user_id, scheduled_ticket_client_id = $client_id, scheduled_ticket_contact_id = $contact_id, scheduled_ticket_asset_id = $asset_id");
mysqli_query($mysqli, "INSERT INTO scheduled_tickets SET scheduled_ticket_subject = '$subject', scheduled_ticket_details = '$details', scheduled_ticket_priority = '$priority', scheduled_ticket_frequency = '$frequency', scheduled_ticket_start_date = '$start_date', scheduled_ticket_next_run = '$start_date', scheduled_ticket_end_date = '$end_date', scheduled_ticket_created_by = $session_user_id, scheduled_ticket_client_id = $client_id, scheduled_ticket_contact_id = $contact_id, scheduled_ticket_asset_id = $asset_id");

$scheduled_ticket_id = mysqli_insert_id($mysqli);

Expand Down Expand Up @@ -971,7 +971,7 @@
}

// Edit scheduled ticket
mysqli_query($mysqli, "UPDATE scheduled_tickets SET scheduled_ticket_subject = '$subject', scheduled_ticket_details = '$details', scheduled_ticket_priority = '$priority', scheduled_ticket_frequency = '$frequency', scheduled_ticket_next_run = '$next_run_date', scheduled_ticket_asset_id = $asset_id, scheduled_ticket_contact_id = $contact_id WHERE scheduled_ticket_id = $scheduled_ticket_id");
mysqli_query($mysqli, "UPDATE scheduled_tickets SET scheduled_ticket_subject = '$subject', scheduled_ticket_details = '$details', scheduled_ticket_priority = '$priority', scheduled_ticket_frequency = '$frequency', scheduled_ticket_next_run = '$next_run_date', scheduled_ticket_end_date = '$end_date', scheduled_ticket_asset_id = $asset_id, scheduled_ticket_contact_id = $contact_id WHERE scheduled_ticket_id = $scheduled_ticket_id");

// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Scheduled Ticket', log_action = 'Modify', log_description = '$session_name modified scheduled ticket for $subject - $frequency', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $scheduled_ticket_id");
Expand Down
10 changes: 10 additions & 0 deletions scheduled_ticket_add_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@
</div>
</div>

<div class="form-group">
<label>Ending date <strong class="text-danger"></strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar-day"></i></span>
</div>
<input class="form-control" type="date" name="end_date" min="<?php echo date("Y-m-d"); ?>" max="2999-12-31" required>
</div>
</div>

<div class="form-group">
<label>Priority <strong class="text-danger">*</strong></label>
<div class="input-group">
Expand Down
10 changes: 10 additions & 0 deletions scheduled_ticket_edit_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@
</div>
</div>
<div class="form-group">
<label>Ending Date</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar-day"></i></span>
</div>
<input class="form-control" type="date" name="end_date" id="editTicketEndDate" max="2999-12-31">
</div>
</div>
<div class="form-group">
<label>Priority <strong class="text-danger">*</strong></label>
<div class="input-group">
Expand Down

0 comments on commit d81a04a

Please sign in to comment.