Rename the remain items from Scheduled Tickets to Recurring Tickets

This commit is contained in:
johnnyq 2025-03-11 18:32:24 -04:00
parent a0a2fddd90
commit daab1bca3d
10 changed files with 192 additions and 165 deletions

View File

@ -2,56 +2,56 @@
require_once '../includes/ajax_header.php'; require_once '../includes/ajax_header.php';
$scheduled_ticket_id = intval($_GET['id']); $recurring_ticket_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets WHERE scheduled_ticket_id = $scheduled_ticket_id LIMIT 1"); $sql = mysqli_query($mysqli, "SELECT * FROM recurring_tickets WHERE recurring_ticket_id = $recurring_ticket_id LIMIT 1");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$client_id = intval($row['scheduled_ticket_client_id']); $client_id = intval($row['recurring_ticket_client_id']);
$scheduled_ticket_subject = nullable_htmlentities($row['scheduled_ticket_subject']); $recurring_ticket_subject = nullable_htmlentities($row['recurring_ticket_subject']);
$scheduled_ticket_details = nullable_htmlentities($row['scheduled_ticket_details']); $recurring_ticket_details = nullable_htmlentities($row['recurring_ticket_details']);
$scheduled_ticket_priority = nullable_htmlentities($row['scheduled_ticket_priority']); $recurring_ticket_priority = nullable_htmlentities($row['recurring_ticket_priority']);
$scheduled_ticket_frequency = nullable_htmlentities($row['scheduled_ticket_frequency']); $recurring_ticket_frequency = nullable_htmlentities($row['recurring_ticket_frequency']);
$scheduled_ticket_next_run = nullable_htmlentities($row['scheduled_ticket_next_run']); $recurring_ticket_next_run = nullable_htmlentities($row['recurring_ticket_next_run']);
$scheduled_ticket_assigned_to = intval($row['scheduled_ticket_assigned_to']); $recurring_ticket_assigned_to = intval($row['recurring_ticket_assigned_to']);
$scheduled_ticket_contact_id = intval($row['scheduled_ticket_contact_id']); $recurring_ticket_contact_id = intval($row['recurring_ticket_contact_id']);
$scheduled_ticket_asset_id = intval($row['scheduled_ticket_asset_id']); $recurring_ticket_asset_id = intval($row['recurring_ticket_asset_id']);
$scheduled_ticket_billable = intval($row['scheduled_ticket_billable']); $recurring_ticket_billable = intval($row['recurring_ticket_billable']);
// Generate the HTML form content using output buffering. // Generate the HTML form content using output buffering.
ob_start(); ob_start();
?> ?>
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title"><i class="fas fa-fw fa-calendar-check mr-2"></i>Editing Recurring Ticket: <strong><?php echo $scheduled_ticket_subject; ?></strong></h5> <h5 class="modal-title"><i class="fas fa-fw fa-calendar-check mr-2"></i>Editing Recurring Ticket: <strong><?php echo $recurring_ticket_subject; ?></strong></h5>
<button type="button" class="close text-white" data-dismiss="modal"> <button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span> <span>&times;</span>
</button> </button>
</div> </div>
<form action="post.php" method="post" autocomplete="off"> <form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="scheduled_ticket_id" value="<?php echo $scheduled_ticket_id; ?>"> <input type="hidden" name="recurring_ticket_id" value="<?php echo $recurring_ticket_id; ?>">
<input type="hidden" name="client" value="<?php echo $client_id; ?>"> <input type="hidden" name="client" value="<?php echo $client_id; ?>">
<div class="modal-body bg-white"> <div class="modal-body bg-white">
<ul class="nav nav-pills nav-justified mb-3"> <ul class="nav nav-pills nav-justified mb-3">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" data-toggle="pill" href="#pills-edit-details<?php echo $scheduled_ticket_id; ?>"><i class="fa fa-fw fa-life-ring mr-2"></i>Details</a> <a class="nav-link active" data-toggle="pill" href="#pills-edit-details<?php echo $recurring_ticket_id; ?>"><i class="fa fa-fw fa-life-ring mr-2"></i>Details</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-edit-contacts<?php echo $scheduled_ticket_id; ?>"><i class="fa fa-fw fa-users mr-2"></i>Contacts</a> <a class="nav-link" data-toggle="pill" href="#pills-edit-contacts<?php echo $recurring_ticket_id; ?>"><i class="fa fa-fw fa-users mr-2"></i>Contacts</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-edit-schedule<?php echo $scheduled_ticket_id; ?>"><i class="fa fa-fw fa-building mr-2"></i>Schedule</a> <a class="nav-link" data-toggle="pill" href="#pills-edit-schedule<?php echo $recurring_ticket_id; ?>"><i class="fa fa-fw fa-building mr-2"></i>Schedule</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-edit-assets<?php echo $scheduled_ticket_id; ?>"><i class="fa fa-fw fa-desktop mr-2"></i>Assets</a> <a class="nav-link" data-toggle="pill" href="#pills-edit-assets<?php echo $recurring_ticket_id; ?>"><i class="fa fa-fw fa-desktop mr-2"></i>Assets</a>
</li> </li>
</ul> </ul>
<div class="tab-content" <?php if (lookupUserPermission('module_support') <= 1) { echo 'inert'; } ?>> <div class="tab-content" <?php if (lookupUserPermission('module_support') <= 1) { echo 'inert'; } ?>>
<div class="tab-pane fade show active" id="pills-edit-details<?php echo $scheduled_ticket_id; ?>"> <div class="tab-pane fade show active" id="pills-edit-details<?php echo $recurring_ticket_id; ?>">
<div class="form-group"> <div class="form-group">
<label>Subject <strong class="text-danger">*</strong></label> <label>Subject <strong class="text-danger">*</strong></label>
@ -59,12 +59,12 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
</div> </div>
<input type="text" class="form-control" name="subject" placeholder="Subject" maxlength="500" value="<?php echo $scheduled_ticket_subject; ?>" required > <input type="text" class="form-control" name="subject" placeholder="Subject" maxlength="500" value="<?php echo $recurring_ticket_subject; ?>" required >
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<textarea class="form-control tinymce" name="details"><?php echo $scheduled_ticket_details; ?></textarea> <textarea class="form-control tinymce" name="details"><?php echo $recurring_ticket_details; ?></textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -74,9 +74,9 @@ ob_start();
<span class="input-group-text"><i class="fa fa-fw fa-thermometer-half"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-thermometer-half"></i></span>
</div> </div>
<select class="form-control select2" name="priority" required> <select class="form-control select2" name="priority" required>
<option <?php if ($scheduled_ticket_priority == "Low") { echo "selected"; } ?> >Low</option> <option <?php if ($recurring_ticket_priority == "Low") { echo "selected"; } ?> >Low</option>
<option <?php if ($scheduled_ticket_priority == "Medium") { echo "selected"; } ?> >Medium</option> <option <?php if ($recurring_ticket_priority == "Medium") { echo "selected"; } ?> >Medium</option>
<option <?php if ($scheduled_ticket_priority == "High") { echo "selected"; } ?> >High</option> <option <?php if ($recurring_ticket_priority == "High") { echo "selected"; } ?> >High</option>
</select> </select>
</div> </div>
</div> </div>
@ -100,7 +100,7 @@ ob_start();
$user_name_select = nullable_htmlentities($row['user_name']); $user_name_select = nullable_htmlentities($row['user_name']);
?> ?>
<option value="<?php echo $user_id_select; ?>" <?php if ($scheduled_ticket_assigned_to == $user_id_select) { echo "selected"; } ?>><?php echo $user_name_select; ?></option> <option value="<?php echo $user_id_select; ?>" <?php if ($recurring_ticket_assigned_to == $user_id_select) { echo "selected"; } ?>><?php echo $user_name_select; ?></option>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
@ -109,7 +109,7 @@ ob_start();
<div class="form-group <?php if (!$config_module_enable_accounting) { echo 'd-none'; } ?>"> <div class="form-group <?php if (!$config_module_enable_accounting) { echo 'd-none'; } ?>">
<div class="custom-control custom-switch"> <div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="editTicketBillable" name="billable" <input type="checkbox" class="custom-control-input" id="editTicketBillable" name="billable"
<?php if ($scheduled_ticket_billable == 1) { echo "checked"; } ?> value="1" <?php if ($recurring_ticket_billable == 1) { echo "checked"; } ?> value="1"
> >
<label class="custom-control-label" for="editTicketBillable">Mark Billable</label> <label class="custom-control-label" for="editTicketBillable">Mark Billable</label>
</div> </div>
@ -117,7 +117,7 @@ ob_start();
</div> </div>
<div class="tab-pane fade" id="pills-edit-contacts<?php echo $scheduled_ticket_id; ?>"> <div class="tab-pane fade" id="pills-edit-contacts<?php echo $recurring_ticket_id; ?>">
<div class="form-group"> <div class="form-group">
<label>Contact</label> <label>Contact</label>
@ -152,7 +152,7 @@ ob_start();
} }
?> ?>
<option value="<?php echo $contact_id_select; ?>" <?php if ($contact_id_select == $scheduled_ticket_contact_id) { echo "selected"; } ?>><?php echo "$contact_name_select$contact_title_display_select$contact_primary_display_select$contact_technical_display_select"; ?></option> <option value="<?php echo $contact_id_select; ?>" <?php if ($contact_id_select == $recurring_ticket_contact_id) { echo "selected"; } ?>><?php echo "$contact_name_select$contact_title_display_select$contact_primary_display_select$contact_technical_display_select"; ?></option>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
@ -160,7 +160,7 @@ ob_start();
</div> </div>
<div class="tab-pane fade" id="pills-edit-schedule<?php echo $scheduled_ticket_id; ?>"> <div class="tab-pane fade" id="pills-edit-schedule<?php echo $recurring_ticket_id; ?>">
<div class="form-group"> <div class="form-group">
<label>Frequency <strong class="text-danger">*</strong></label> <label>Frequency <strong class="text-danger">*</strong></label>
@ -169,11 +169,11 @@ ob_start();
<span class="input-group-text"><i class="fa fa-fw fa-recycle"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-recycle"></i></span>
</div> </div>
<select class="form-control select2" name="frequency"> <select class="form-control select2" name="frequency">
<option <?php if ($scheduled_ticket_frequency == "Weekly") { echo "selected"; } ?>>Weekly</option> <option <?php if ($recurring_ticket_frequency == "Weekly") { echo "selected"; } ?>>Weekly</option>
<option <?php if ($scheduled_ticket_frequency == "Monthly") { echo "selected"; } ?>>Monthly</option> <option <?php if ($recurring_ticket_frequency == "Monthly") { echo "selected"; } ?>>Monthly</option>
<option <?php if ($scheduled_ticket_frequency == "Quarterly") { echo "selected"; } ?>>Quarterly</option> <option <?php if ($recurring_ticket_frequency == "Quarterly") { echo "selected"; } ?>>Quarterly</option>
<option <?php if ($scheduled_ticket_frequency == "Biannually") { echo "selected"; } ?>>Biannually</option> <option <?php if ($recurring_ticket_frequency == "Biannually") { echo "selected"; } ?>>Biannually</option>
<option <?php if ($scheduled_ticket_frequency == "Annually") { echo "selected"; } ?>>Annually</option> <option <?php if ($recurring_ticket_frequency == "Annually") { echo "selected"; } ?>>Annually</option>
</select> </select>
</div> </div>
</div> </div>
@ -184,13 +184,13 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar-day"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-calendar-day"></i></span>
</div> </div>
<input class="form-control" type="date" name="next_date" max="2999-12-31" value="<?php echo $scheduled_ticket_next_run; ?>"> <input class="form-control" type="date" name="next_date" max="2999-12-31" value="<?php echo $recurring_ticket_next_run; ?>">
</div> </div>
</div> </div>
</div> </div>
<div class="tab-pane fade" id="pills-edit-assets<?php echo $scheduled_ticket_id; ?>"> <div class="tab-pane fade" id="pills-edit-assets<?php echo $recurring_ticket_id; ?>">
<div class="form-group"> <div class="form-group">
<label>Asset</label> <label>Asset</label>
@ -208,7 +208,7 @@ ob_start();
$asset_name_select = nullable_htmlentities($row['asset_name']); $asset_name_select = nullable_htmlentities($row['asset_name']);
$asset_contact_name_select = nullable_htmlentities($row['contact_name']); $asset_contact_name_select = nullable_htmlentities($row['contact_name']);
?> ?>
<option <?php if ($scheduled_ticket_asset_id == $asset_id_select) { echo "selected"; } ?> value="<?php echo $asset_id_select; ?>"><?php echo "$asset_name_select - $asset_contact_name_select"; ?></option> <option <?php if ($recurring_ticket_asset_id == $asset_id_select) { echo "selected"; } ?> value="<?php echo $asset_id_select; ?>"><?php echo "$asset_name_select - $asset_contact_name_select"; ?></option>
<?php <?php
} }

View File

@ -2490,10 +2490,37 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.9.4'"); mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.9.4'");
} }
// if (CURRENT_DATABASE_VERSION == '1.9.4') { if (CURRENT_DATABASE_VERSION == '1.9.4') {
// // Insert queries here required to update to DB version 1.9.5 mysqli_query($mysqli, "RENAME TABLE `scheduled_tickets` TO `recurring_tickets`");
mysqli_query($mysqli,
"ALTER TABLE `recurring_tickets`
CHANGE COLUMN `scheduled_ticket_id` `recurring_ticket_id` INT(11) NOT NULL AUTO_INCREMENT,
CHANGE COLUMN `scheduled_ticket_category` `recurring_ticket_category` VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
CHANGE COLUMN `scheduled_ticket_subject` `recurring_ticket_subject` VARCHAR(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
CHANGE COLUMN `scheduled_ticket_details` `recurring_ticket_details` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
CHANGE COLUMN `scheduled_ticket_priority` `recurring_ticket_priority` VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
CHANGE COLUMN `scheduled_ticket_frequency` `recurring_ticket_frequency` VARCHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
CHANGE COLUMN `scheduled_ticket_billable` `recurring_ticket_billable` TINYINT(1) NOT NULL DEFAULT 0,
CHANGE COLUMN `scheduled_ticket_start_date` `recurring_ticket_start_date` DATE NOT NULL,
CHANGE COLUMN `scheduled_ticket_next_run` `recurring_ticket_next_run` DATE NOT NULL,
CHANGE COLUMN `scheduled_ticket_created_at` `recurring_ticket_created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),
CHANGE COLUMN `scheduled_ticket_updated_at` `recurring_ticket_updated_at` DATETIME NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(),
CHANGE COLUMN `scheduled_ticket_created_by` `recurring_ticket_created_by` INT(11) NOT NULL DEFAULT 0,
CHANGE COLUMN `scheduled_ticket_assigned_to` `recurring_ticket_assigned_to` INT(11) NOT NULL DEFAULT 0,
CHANGE COLUMN `scheduled_ticket_client_id` `recurring_ticket_client_id` INT(11) NOT NULL DEFAULT 0,
CHANGE COLUMN `scheduled_ticket_contact_id` `recurring_ticket_contact_id` INT(11) NOT NULL DEFAULT 0,
CHANGE COLUMN `scheduled_ticket_asset_id` `recurring_ticket_asset_id` INT(11) NOT NULL DEFAULT 0
"
);
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.9.5'");
}
// if (CURRENT_DATABASE_VERSION == '1.9.5') {
// // Insert queries here required to update to DB version 1.9.6
// // Then, update the database to the next sequential version // // Then, update the database to the next sequential version
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.9.5'"); // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.9.6'");
// } // }
} else { } else {

58
db.sql
View File

@ -1494,6 +1494,34 @@ CREATE TABLE `recurring_payments` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `recurring_tickets`
--
DROP TABLE IF EXISTS `recurring_tickets`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `recurring_tickets` (
`recurring_ticket_id` int(11) NOT NULL AUTO_INCREMENT,
`recurring_ticket_category` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`recurring_ticket_subject` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`recurring_ticket_details` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`recurring_ticket_priority` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`recurring_ticket_frequency` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`recurring_ticket_billable` tinyint(1) NOT NULL DEFAULT 0,
`recurring_ticket_start_date` date NOT NULL,
`recurring_ticket_next_run` date NOT NULL,
`recurring_ticket_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`recurring_ticket_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
`recurring_ticket_created_by` int(11) NOT NULL DEFAULT 0,
`recurring_ticket_assigned_to` int(11) NOT NULL DEFAULT 0,
`recurring_ticket_client_id` int(11) NOT NULL DEFAULT 0,
`recurring_ticket_contact_id` int(11) NOT NULL DEFAULT 0,
`recurring_ticket_asset_id` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`recurring_ticket_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- Table structure for table `remember_tokens` -- Table structure for table `remember_tokens`
-- --
@ -1535,34 +1563,6 @@ CREATE TABLE `revenues` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `scheduled_tickets`
--
DROP TABLE IF EXISTS `scheduled_tickets`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `scheduled_tickets` (
`scheduled_ticket_id` int(11) NOT NULL AUTO_INCREMENT,
`scheduled_ticket_category` varchar(200) DEFAULT NULL,
`scheduled_ticket_subject` varchar(500) NOT NULL,
`scheduled_ticket_details` longtext NOT NULL,
`scheduled_ticket_priority` varchar(200) DEFAULT NULL,
`scheduled_ticket_frequency` varchar(10) NOT NULL,
`scheduled_ticket_billable` tinyint(1) NOT NULL DEFAULT 0,
`scheduled_ticket_start_date` date NOT NULL,
`scheduled_ticket_next_run` 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,
`scheduled_ticket_assigned_to` int(11) NOT NULL DEFAULT 0,
`scheduled_ticket_client_id` int(11) NOT NULL DEFAULT 0,
`scheduled_ticket_contact_id` int(11) NOT NULL DEFAULT 0,
`scheduled_ticket_asset_id` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`scheduled_ticket_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- Table structure for table `service_assets` -- Table structure for table `service_assets`
-- --
@ -2400,4 +2400,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2025-03-11 15:09:10 -- Dump completed on 2025-03-11 18:31:54

View File

@ -74,8 +74,8 @@
<p> <p>
Recurring Tickets Recurring Tickets
<?php <?php
if ($num_scheduled_tickets) { ?> if ($num_recurring_tickets) { ?>
<span class="right badge"><?php echo $num_scheduled_tickets; ?></span> <span class="right badge"><?php echo $num_recurring_tickets; ?></span>
<?php } ?> <?php } ?>
</p> </p>

View File

@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php * It is used in conjunction with database_updates.php
*/ */
DEFINE("LATEST_DATABASE_VERSION", "1.9.4"); DEFINE("LATEST_DATABASE_VERSION", "1.9.5");

View File

@ -10,7 +10,7 @@ $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('ticket_id') AS nu
$num_active_tickets = $row['num']; $num_active_tickets = $row['num'];
// Recurring Ticket Count // Recurring Ticket Count
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('scheduled_ticket_id') AS num FROM scheduled_tickets LEFT JOIN clients ON client_id = scheduled_ticket_client_id WHERE 1 = 1 $access_permission_query")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('recurring_ticket_id') AS num FROM recurring_tickets LEFT JOIN clients ON client_id = recurring_ticket_client_id WHERE 1 = 1 $access_permission_query"));
$num_recurring_tickets = $row['num']; $num_recurring_tickets = $row['num'];
// Active Project Count // Active Project Count

View File

@ -145,8 +145,8 @@ if (isset($_GET['client_id'])) {
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('ticket_id') AS num FROM tickets WHERE ticket_archived_at IS NULL AND ticket_closed_at IS NOT NULL AND ticket_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('ticket_id') AS num FROM tickets WHERE ticket_archived_at IS NULL AND ticket_closed_at IS NOT NULL AND ticket_client_id = $client_id"));
$num_closed_tickets = $row['num']; $num_closed_tickets = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('scheduled_ticket_id') AS num FROM scheduled_tickets WHERE scheduled_ticket_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('recurring_ticket_id') AS num FROM recurring_tickets WHERE recurring_ticket_client_id = $client_id"));
$num_scheduled_tickets = $row['num']; $num_recurring_tickets = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('service_id') AS num FROM services WHERE service_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('service_id') AS num FROM services WHERE service_client_id = $client_id"));
$num_services = $row['num']; $num_services = $row['num'];

View File

@ -2041,12 +2041,12 @@ if (isset($_POST['add_recurring_ticket'])) {
$start_date = sanitizeInput($_POST['start_date']); $start_date = sanitizeInput($_POST['start_date']);
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_billable = $billable, scheduled_ticket_start_date = '$start_date', scheduled_ticket_next_run = '$start_date', scheduled_ticket_assigned_to = $assigned_to, 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 recurring_tickets SET recurring_ticket_subject = '$subject', recurring_ticket_details = '$details', recurring_ticket_priority = '$priority', recurring_ticket_frequency = '$frequency', recurring_ticket_billable = $billable, recurring_ticket_start_date = '$start_date', recurring_ticket_next_run = '$start_date', recurring_ticket_assigned_to = $assigned_to, recurring_ticket_created_by = $session_user_id, recurring_ticket_client_id = $client_id, recurring_ticket_contact_id = $contact_id, recurring_ticket_asset_id = $asset_id");
$scheduled_ticket_id = mysqli_insert_id($mysqli); $recurring_ticket_id = mysqli_insert_id($mysqli);
// Logging // Logging
logAction("Recurring Ticket", "Create", "$session_name created recurring ticket for $subject - $frequency", $client_id, $scheduled_ticket_id); logAction("Recurring Ticket", "Create", "$session_name created recurring ticket for $subject - $frequency", $client_id, $recurring_ticket_id);
$_SESSION['alert_message'] = "Recurring ticket <strong>$subject - $frequency</strong> created"; $_SESSION['alert_message'] = "Recurring ticket <strong>$subject - $frequency</strong> created";
@ -2059,13 +2059,13 @@ if (isset($_POST['edit_recurring_ticket'])) {
require_once 'post/user/ticket_recurring_model.php'; require_once 'post/user/ticket_recurring_model.php';
$scheduled_ticket_id = intval($_POST['scheduled_ticket_id']); $recurring_ticket_id = intval($_POST['recurring_ticket_id']);
$next_run_date = sanitizeInput($_POST['next_date']); $next_run_date = sanitizeInput($_POST['next_date']);
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_billable = $billable, scheduled_ticket_next_run = '$next_run_date', scheduled_ticket_assigned_to = $assigned_to, scheduled_ticket_asset_id = $asset_id, scheduled_ticket_contact_id = $contact_id WHERE scheduled_ticket_id = $scheduled_ticket_id"); mysqli_query($mysqli, "UPDATE recurring_tickets SET recurring_ticket_subject = '$subject', recurring_ticket_details = '$details', recurring_ticket_priority = '$priority', recurring_ticket_frequency = '$frequency', recurring_ticket_billable = $billable, recurring_ticket_next_run = '$next_run_date', recurring_ticket_assigned_to = $assigned_to, recurring_ticket_asset_id = $asset_id, recurring_ticket_contact_id = $contact_id WHERE recurring_ticket_id = $recurring_ticket_id");
// Logging // Logging
logAction("Recurring Ticket", "Edit", "$session_name edited recurring ticket $subject", $client_id, $scheduled_ticket_id); logAction("Recurring Ticket", "Edit", "$session_name edited recurring ticket $subject", $client_id, $recurring_ticket_id);
$_SESSION['alert_message'] = "Recurring ticket <strong>$subject - $frequency</strong> updated"; $_SESSION['alert_message'] = "Recurring ticket <strong>$subject - $frequency</strong> updated";
@ -2077,24 +2077,24 @@ if (isset($_GET['force_recurring_ticket'])) {
enforceUserPermission('module_support', 2); enforceUserPermission('module_support', 2);
validateCSRFToken($_GET['csrf_token']); validateCSRFToken($_GET['csrf_token']);
$scheduled_ticket_id = intval($_GET['force_recurring_ticket']); $recurring_ticket_id = intval($_GET['force_recurring_ticket']);
$sql = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets WHERE scheduled_ticket_id = $scheduled_ticket_id"); $sql = mysqli_query($mysqli, "SELECT * FROM recurring_tickets WHERE recurring_ticket_id = $recurring_ticket_id");
if (mysqli_num_rows($sql) > 0) { if (mysqli_num_rows($sql) > 0) {
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$schedule_id = intval($row['scheduled_ticket_id']); $schedule_id = intval($row['recurring_ticket_id']);
$subject = sanitizeInput($row['scheduled_ticket_subject']); $subject = sanitizeInput($row['recurring_ticket_subject']);
$details = mysqli_real_escape_string($mysqli, $row['scheduled_ticket_details']); $details = mysqli_real_escape_string($mysqli, $row['recurring_ticket_details']);
$priority = sanitizeInput($row['scheduled_ticket_priority']); $priority = sanitizeInput($row['recurring_ticket_priority']);
$frequency = sanitizeInput(strtolower($row['scheduled_ticket_frequency'])); $frequency = sanitizeInput(strtolower($row['recurring_ticket_frequency']));
$billable = intval($row['scheduled_ticket_billable']); $billable = intval($row['recurring_ticket_billable']);
$old_next_scheduled_date = sanitizeInput($row['scheduled_ticket_next_run']); $old_next_recurring_date = sanitizeInput($row['recurring_ticket_next_run']);
$created_id = intval($row['scheduled_ticket_created_by']); $created_id = intval($row['recurring_ticket_created_by']);
$assigned_id = intval($row['scheduled_ticket_assigned_to']); $assigned_id = intval($row['recurring_ticket_assigned_to']);
$contact_id = intval($row['scheduled_ticket_contact_id']); $contact_id = intval($row['recurring_ticket_contact_id']);
$client_id = intval($row['scheduled_ticket_client_id']); $client_id = intval($row['recurring_ticket_client_id']);
$asset_id = intval($row['scheduled_ticket_asset_id']); $asset_id = intval($row['recurring_ticket_asset_id']);
$url_key = randomString(156); $url_key = randomString(156);
$ticket_status = 1; // Default $ticket_status = 1; // Default
@ -2167,22 +2167,22 @@ if (isset($_GET['force_recurring_ticket'])) {
addToMailQueue($data); addToMailQueue($data);
// Set the next run date (based on the scheduled date, rather than now, so things keep their schedule) // Set the next run date (based on the scheduled date, rather than now, so things keep their schedule)
$dt_old_next_scheduled_date = new DateTime($old_next_scheduled_date); $dt_old_next_recurring_date = new DateTime($old_next_recurring_date);
if ($frequency == "weekly") { if ($frequency == "weekly") {
$next_run = date_add($dt_old_next_scheduled_date, date_interval_create_from_date_string('1 week')); $next_run = date_add($dt_old_next_recurring_date, date_interval_create_from_date_string('1 week'));
} elseif ($frequency == "monthly") { } elseif ($frequency == "monthly") {
$next_run = date_add($dt_old_next_scheduled_date, date_interval_create_from_date_string('1 month')); $next_run = date_add($dt_old_next_recurring_date, date_interval_create_from_date_string('1 month'));
} elseif ($frequency == "quarterly") { } elseif ($frequency == "quarterly") {
$next_run = date_add($dt_old_next_scheduled_date, date_interval_create_from_date_string('3 months')); $next_run = date_add($dt_old_next_recurring_date, date_interval_create_from_date_string('3 months'));
} elseif ($frequency == "biannually") { } elseif ($frequency == "biannually") {
$next_run = date_add($dt_old_next_scheduled_date, date_interval_create_from_date_string('6 months')); $next_run = date_add($dt_old_next_recurring_date, date_interval_create_from_date_string('6 months'));
} elseif ($frequency == "annually") { } elseif ($frequency == "annually") {
$next_run = date_add($dt_old_next_scheduled_date, date_interval_create_from_date_string('12 months')); $next_run = date_add($dt_old_next_recurring_date, date_interval_create_from_date_string('12 months'));
} }
// Update the run date // Update the run date
$next_run = $next_run->format('Y-m-d'); $next_run = $next_run->format('Y-m-d');
mysqli_query($mysqli, "UPDATE scheduled_tickets SET scheduled_ticket_next_run = '$next_run' WHERE scheduled_ticket_id = $schedule_id"); mysqli_query($mysqli, "UPDATE recurring_tickets SET recurring_ticket_next_run = '$next_run' WHERE recurring_ticket_id = $schedule_id");
// Logging // Logging
logAction("Ticket", "Create", "$session_name force created recurring scheduled $frequency ticket - $config_ticket_prefix$ticket_number - $subject", $client_id, $id); logAction("Ticket", "Create", "$session_name force created recurring scheduled $frequency ticket - $config_ticket_prefix$ticket_number - $subject", $client_id, $id);
@ -2204,21 +2204,21 @@ if (isset($_GET['delete_recurring_ticket'])) {
enforceUserPermission('module_support', 3); enforceUserPermission('module_support', 3);
validateCSRFToken($_GET['csrf_token']); validateCSRFToken($_GET['csrf_token']);
$scheduled_ticket_id = intval($_GET['delete_recurring_ticket']); $recurring_ticket_id = intval($_GET['delete_recurring_ticket']);
// Get Scheduled Ticket Subject Ticket Prefix, Number and Client ID for logging and alert message // Get Scheduled Ticket Subject Ticket Prefix, Number and Client ID for logging and alert message
$sql = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets WHERE scheduled_ticket_id = $scheduled_ticket_id"); $sql = mysqli_query($mysqli, "SELECT * FROM recurring_tickets WHERE recurring_ticket_id = $recurring_ticket_id");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$subject = sanitizeInput($row['scheduled_ticket_subject']); $subject = sanitizeInput($row['recurring_ticket_subject']);
$frequency = sanitizeInput($row['scheduled_ticket_frequency']); $frequency = sanitizeInput($row['recurring_ticket_frequency']);
$client_id = intval($row['scheduled_ticket_client_id']); $client_id = intval($row['recurring_ticket_client_id']);
// Delete // Delete
mysqli_query($mysqli, "DELETE FROM scheduled_tickets WHERE scheduled_ticket_id = $scheduled_ticket_id"); mysqli_query($mysqli, "DELETE FROM recurring_tickets WHERE recurring_ticket_id = $recurring_ticket_id");
// Logging // Logging
logAction("Recurring Ticket", "Delete", "$session_name deleted recurring ticket $subject", $client_id, $scheduled_ticket_id); logAction("Recurring Ticket", "Delete", "$session_name deleted recurring ticket $subject", $client_id, $recurring_ticket_id);
$_SESSION['alert_type'] = "error"; $_SESSION['alert_type'] = "error";
$_SESSION['alert_message'] = "Recurring ticket <strong>$subject - $frequency</strong> deleted"; $_SESSION['alert_message'] = "Recurring ticket <strong>$subject - $frequency</strong> deleted";
@ -2226,23 +2226,23 @@ if (isset($_GET['delete_recurring_ticket'])) {
header("Location: " . $_SERVER["HTTP_REFERER"]); header("Location: " . $_SERVER["HTTP_REFERER"]);
} }
if (isset($_POST['bulk_delete_scheduled_tickets']) || isset($_POST['bulk_delete_recurring_tickets'])) { if (isset($_POST['bulk_delete_recurring_tickets']) || isset($_POST['bulk_delete_recurring_tickets'])) {
enforceUserPermission('module_support', 3); enforceUserPermission('module_support', 3);
validateCSRFToken($_POST['csrf_token']); validateCSRFToken($_POST['csrf_token']);
if (isset($_POST['scheduled_ticket_ids'])) { if (isset($_POST['recurring_ticket_ids'])) {
$count = count($_POST['scheduled_ticket_ids']); $count = count($_POST['recurring_ticket_ids']);
// Cycle through array and delete each recurring scheduled ticket // Cycle through array and delete each recurring scheduled ticket
foreach ($scheduled_ticket_ids as $scheduled_ticket_id) { foreach ($recurring_ticket_ids as $recurring_ticket_id) {
$scheduled_ticket_id = intval($scheduled_ticket_id); $recurring_ticket_id = intval($recurring_ticket_id);
mysqli_query($mysqli, "DELETE FROM scheduled_tickets WHERE scheduled_ticket_id = $scheduled_ticket_id"); mysqli_query($mysqli, "DELETE FROM recurring_tickets WHERE recurring_ticket_id = $recurring_ticket_id");
// Logging // Logging
logAction("Recurring Ticket", "Delete", "$session_name deleted recurring ticket", 0, $scheduled_ticket_id); logAction("Recurring Ticket", "Delete", "$session_name deleted recurring ticket", 0, $recurring_ticket_id);
} }

View File

@ -1,13 +1,13 @@
<?php <?php
// Default Column Sortby Filter // Default Column Sortby Filter
$sort = "scheduled_ticket_subject"; $sort = "recurring_ticket_subject";
$order = "ASC"; $order = "ASC";
// If client_id is in URI then show client Side Bar and client header // If client_id is in URI then show client Side Bar and client header
if (isset($_GET['client_id'])) { if (isset($_GET['client_id'])) {
require_once "includes/inc_all_client.php"; require_once "includes/inc_all_client.php";
$client_query = "AND scheduled_ticket_client_id = $client_id"; $client_query = "AND recurring_ticket_client_id = $client_id";
$client_url = "client_id=$client_id&"; $client_url = "client_id=$client_id&";
} else { } else {
require_once "includes/inc_all.php"; require_once "includes/inc_all.php";
@ -21,7 +21,7 @@ enforceUserPermission('module_support');
// Ticket client access snippet // Ticket client access snippet
$rec_ticket_permission_snippet = ''; $rec_ticket_permission_snippet = '';
if (!empty($client_access_string)) { if (!empty($client_access_string)) {
$rec_ticket_permission_snippet = "AND scheduled_ticket_client_id IN ($client_access_string)"; $rec_ticket_permission_snippet = "AND recurring_ticket_client_id IN ($client_access_string)";
} }
//Rebuild URL //Rebuild URL
@ -30,15 +30,15 @@ $url_query_strings_sort = http_build_query($get_copy);
// SQL // SQL
$sql = mysqli_query( $sql = mysqli_query(
$mysqli, $mysqli,
"SELECT SQL_CALC_FOUND_ROWS * FROM scheduled_tickets "SELECT SQL_CALC_FOUND_ROWS * FROM recurring_tickets
LEFT JOIN clients on scheduled_ticket_client_id = client_id LEFT JOIN clients on recurring_ticket_client_id = client_id
WHERE scheduled_tickets.scheduled_ticket_subject LIKE '%$q%' WHERE recurring_tickets.recurring_ticket_subject LIKE '%$q%'
$rec_ticket_permission_snippet $rec_ticket_permission_snippet
$client_query $client_query
ORDER BY ORDER BY
CASE CASE
WHEN '$sort' = 'scheduled_ticket_priority' THEN WHEN '$sort' = 'recurring_ticket_priority' THEN
CASE scheduled_ticket_priority CASE recurring_ticket_priority
WHEN 'High' THEN 1 WHEN 'High' THEN 1
WHEN 'Medium' THEN 2 WHEN 'Medium' THEN 2
WHEN 'Low' THEN 3 WHEN 'Low' THEN 3
@ -125,23 +125,23 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</th> </th>
<?php } ?> <?php } ?>
<th> <th>
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=scheduled_ticket_subject&order=<?php echo $disp; ?>"> <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=recurring_ticket_subject&order=<?php echo $disp; ?>">
Subject <?php if ($sort == 'scheduled_ticket_subject') { echo $order_icon; } ?> Subject <?php if ($sort == 'recurring_ticket_subject') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<th> <th>
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=scheduled_ticket_priority&order=<?php echo $disp; ?>"> <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=recurring_ticket_priority&order=<?php echo $disp; ?>">
Priority <?php if ($sort == 'scheduled_ticket_priority') { echo $order_icon; } ?> Priority <?php if ($sort == 'recurring_ticket_priority') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<th> <th>
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=scheduled_ticket_frequency&order=<?php echo $disp; ?>"> <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=recurring_ticket_frequency&order=<?php echo $disp; ?>">
Frequency <?php if ($sort == 'scheduled_ticket_frequency') { echo $order_icon; } ?> Frequency <?php if ($sort == 'recurring_ticket_frequency') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<th> <th>
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=scheduled_ticket_next_run&order=<?php echo $disp; ?>"> <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=recurring_ticket_next_run&order=<?php echo $disp; ?>">
Next Run Date <?php if ($sort == 'scheduled_ticket_next_run') { echo $order_icon; } ?> Next Run Date <?php if ($sort == 'recurring_ticket_next_run') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<?php if (lookupUserPermission("module_support") >= 2) { ?> <?php if (lookupUserPermission("module_support") >= 2) { ?>
@ -155,24 +155,24 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<?php <?php
while ($row = mysqli_fetch_array($sql)) { while ($row = mysqli_fetch_array($sql)) {
$scheduled_ticket_id = intval($row['scheduled_ticket_id']); $recurring_ticket_id = intval($row['recurring_ticket_id']);
$scheduled_ticket_client_id = intval($row['client_id']); $recurring_ticket_client_id = intval($row['client_id']);
$scheduled_ticket_subject = nullable_htmlentities($row['scheduled_ticket_subject']); $recurring_ticket_subject = nullable_htmlentities($row['recurring_ticket_subject']);
$scheduled_ticket_priority = nullable_htmlentities($row['scheduled_ticket_priority']); $recurring_ticket_priority = nullable_htmlentities($row['recurring_ticket_priority']);
$scheduled_ticket_frequency = nullable_htmlentities($row['scheduled_ticket_frequency']); $recurring_ticket_frequency = nullable_htmlentities($row['recurring_ticket_frequency']);
$scheduled_ticket_next_run = nullable_htmlentities($row['scheduled_ticket_next_run']); $recurring_ticket_next_run = nullable_htmlentities($row['recurring_ticket_next_run']);
$scheduled_ticket_client_name = nullable_htmlentities($row['client_name']); $recurring_ticket_client_name = nullable_htmlentities($row['client_name']);
?> ?>
<tr> <tr>
<td class="pr-0"> <td class="pr-0">
<div class="form-check"> <div class="form-check">
<input class="form-check-input bulk-select" type="checkbox" name="scheduled_ticket_ids[]" value="<?php echo $scheduled_ticket_id ?>"> <input class="form-check-input bulk-select" type="checkbox" name="recurring_ticket_ids[]" value="<?php echo $recurring_ticket_id ?>">
</div> </div>
</td> </td>
<?php if (!$client_url) { ?> <?php if (!$client_url) { ?>
<th><a href="recurring_tickets.php?client_id=<?php echo $scheduled_ticket_client_id; ?>"><?php echo $scheduled_ticket_client_name ?></a> <th><a href="recurring_tickets.php?client_id=<?php echo $recurring_ticket_client_id; ?>"><?php echo $recurring_ticket_client_name ?></a>
</th> </th>
<?php } ?> <?php } ?>
@ -181,17 +181,17 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-modal-size="lg" data-modal-size="lg"
data-ajax-url="ajax/ajax_recurring_ticket_edit.php" data-ajax-url="ajax/ajax_recurring_ticket_edit.php"
data-ajax-id="<?php echo $scheduled_ticket_id; ?>" data-ajax-id="<?php echo $recurring_ticket_id; ?>"
> >
<?php echo $scheduled_ticket_subject ?> <?php echo $recurring_ticket_subject ?>
</a> </a>
</td> </td>
<td><?php echo $scheduled_ticket_priority ?></td> <td><?php echo $recurring_ticket_priority ?></td>
<td><?php echo $scheduled_ticket_frequency ?></td> <td><?php echo $recurring_ticket_frequency ?></td>
<td class="text-bold"><?php echo $scheduled_ticket_next_run ?></td> <td class="text-bold"><?php echo $recurring_ticket_next_run ?></td>
<?php if (lookupUserPermission("module_support") >= 2) { ?> <?php if (lookupUserPermission("module_support") >= 2) { ?>
<td> <td>
@ -204,17 +204,17 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-modal-size="lg" data-modal-size="lg"
data-ajax-url="ajax/ajax_recurring_ticket_edit.php" data-ajax-url="ajax/ajax_recurring_ticket_edit.php"
data-ajax-id="<?php echo $scheduled_ticket_id; ?>" data-ajax-id="<?php echo $recurring_ticket_id; ?>"
> >
<i class="fas fa-fw fa-edit mr-2"></i>Edit <i class="fas fa-fw fa-edit mr-2"></i>Edit
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item" href="post.php?force_recurring_ticket=<?php echo $scheduled_ticket_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>"> <a class="dropdown-item" href="post.php?force_recurring_ticket=<?php echo $recurring_ticket_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>">
<i class="fa fa-fw fa-paper-plane text-secondary mr-2"></i>Force Reoccur <i class="fa fa-fw fa-paper-plane text-secondary mr-2"></i>Force Reoccur
</a> </a>
<?php if (lookupUserPermission("module_support") == 3) { ?> <?php if (lookupUserPermission("module_support") == 3) { ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_recurring_ticket=<?php echo $scheduled_ticket_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>"> <a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_recurring_ticket=<?php echo $recurring_ticket_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-trash mr-2"></i>Delete <i class="fas fa-fw fa-trash mr-2"></i>Delete
</a> </a>
<?php } ?> <?php } ?>

View File

@ -280,25 +280,25 @@ if ($tickets_pending_assignment > 0) {
logApp("Cron", "info", "Cron created notifications for new tickets that are pending assignment"); logApp("Cron", "info", "Cron created notifications for new tickets that are pending assignment");
} }
// Recurring (Scheduled) tickets // Recurring tickets
// Get recurring tickets for today // Get recurring tickets for today
$sql_scheduled_tickets = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets WHERE scheduled_ticket_next_run = CURDATE()"); $sql_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM recurring_tickets WHERE recurring_ticket_next_run = CURDATE()");
if (mysqli_num_rows($sql_scheduled_tickets) > 0) { if (mysqli_num_rows($sql_recurring_tickets) > 0) {
while ($row = mysqli_fetch_array($sql_scheduled_tickets)) { while ($row = mysqli_fetch_array($sql_recurring_tickets)) {
$schedule_id = intval($row['scheduled_ticket_id']); $schedule_id = intval($row['recurring_ticket_id']);
$subject = sanitizeInput($row['scheduled_ticket_subject']); $subject = sanitizeInput($row['recurring_ticket_subject']);
$details = mysqli_real_escape_string($mysqli, $row['scheduled_ticket_details']); $details = mysqli_real_escape_string($mysqli, $row['recurring_ticket_details']);
$priority = sanitizeInput($row['scheduled_ticket_priority']); $priority = sanitizeInput($row['recurring_ticket_priority']);
$frequency = sanitizeInput(strtolower($row['scheduled_ticket_frequency'])); $frequency = sanitizeInput(strtolower($row['recurring_ticket_frequency']));
$billable = intval($row['scheduled_ticket_billable']); $billable = intval($row['recurring_ticket_billable']);
$created_id = intval($row['scheduled_ticket_created_by']); $created_id = intval($row['recurring_ticket_created_by']);
$assigned_id = intval($row['scheduled_ticket_assigned_to']); $assigned_id = intval($row['recurring_ticket_assigned_to']);
$client_id = intval($row['scheduled_ticket_client_id']); $client_id = intval($row['recurring_ticket_client_id']);
$contact_id = intval($row['scheduled_ticket_contact_id']); $contact_id = intval($row['recurring_ticket_contact_id']);
$asset_id = intval($row['scheduled_ticket_asset_id']); $asset_id = intval($row['recurring_ticket_asset_id']);
$ticket_status = 1; // Default $ticket_status = 1; // Default
if ($assigned_id > 0) { if ($assigned_id > 0) {
@ -408,7 +408,7 @@ if (mysqli_num_rows($sql_scheduled_tickets) > 0) {
// Update the run date // Update the run date
$next_run = $next_run->format('Y-m-d'); $next_run = $next_run->format('Y-m-d');
$a = mysqli_query($mysqli, "UPDATE scheduled_tickets SET scheduled_ticket_next_run = '$next_run' WHERE scheduled_ticket_id = $schedule_id"); $a = mysqli_query($mysqli, "UPDATE recurring_tickets SET recurring_ticket_next_run = '$next_run' WHERE recurring_ticket_id = $schedule_id");
} }
} }