mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Merge branch 'master' of github.com:itflow-org/itflow
This commit is contained in:
@@ -134,8 +134,7 @@ See the [forum](https://forum.itflow.org/d/11-road-map) and the [open issues](ht
|
|||||||
## Support & Contributions
|
## Support & Contributions
|
||||||
|
|
||||||
### Forum
|
### Forum
|
||||||
For help using ITFlow, feature requests, and general ideas / discussions please use the community [forum](https://forum.itflow.org).
|
For help using ITFlow, bugs, feature requests, and general ideas / discussions please use the community [forum](https://forum.itflow.org).
|
||||||
For bugs, please raise an [issue](https://github.com/itflow-org/itflow/issues).
|
|
||||||
|
|
||||||
### Contributing
|
### Contributing
|
||||||
If you want to improve ITFlow, feel free to fork the repo and create a pull request, but make sure to discuss significant changes or new features with fellow contributors on the forum first. This helps ensure that your contributions are aligned with project goals, and saves time for everyone. All contributions should follow our [code standards](https://docs.itflow.org/code_standards).
|
If you want to improve ITFlow, feel free to fork the repo and create a pull request, but make sure to discuss significant changes or new features with fellow contributors on the forum first. This helps ensure that your contributions are aligned with project goals, and saves time for everyone. All contributions should follow our [code standards](https://docs.itflow.org/code_standards).
|
||||||
|
|||||||
@@ -7,15 +7,13 @@ $order = "DESC";
|
|||||||
|
|
||||||
require_once "inc_all_client.php";
|
require_once "inc_all_client.php";
|
||||||
|
|
||||||
if (isset($_GET['status']) && ($_GET['status']) == 'Open') {
|
if (isset($_GET['status']) && ($_GET['status']) == 'Closed') {
|
||||||
$status = 'Open';
|
|
||||||
$ticket_status_snippet = "ticket_status != 'Closed'";
|
|
||||||
} elseif (isset($_GET['status']) && ($_GET['status']) == 'Closed') {
|
|
||||||
$status = 'Closed';
|
$status = 'Closed';
|
||||||
$ticket_status_snippet = "ticket_status = 'Closed'";
|
$ticket_status_snippet = "ticket_closed_at IS NOT NULL";
|
||||||
} else {
|
} else {
|
||||||
|
// Default - Show open tickets
|
||||||
$status = 'Open';
|
$status = 'Open';
|
||||||
$ticket_status_snippet = "ticket_status != 'Closed'";
|
$ticket_status_snippet = "ticket_closed_at IS NULL";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['billable']) && ($_GET['billable']) == '1') {
|
if (isset($_GET['billable']) && ($_GET['billable']) == '1') {
|
||||||
@@ -40,6 +38,7 @@ $sql = mysqli_query(
|
|||||||
LEFT JOIN assets ON ticket_asset_id = asset_id
|
LEFT JOIN assets ON ticket_asset_id = asset_id
|
||||||
LEFT JOIN locations ON ticket_location_id = location_id
|
LEFT JOIN locations ON ticket_location_id = location_id
|
||||||
LEFT JOIN vendors ON ticket_vendor_id = vendor_id
|
LEFT JOIN vendors ON ticket_vendor_id = vendor_id
|
||||||
|
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||||
WHERE ticket_client_id = $client_id
|
WHERE ticket_client_id = $client_id
|
||||||
AND $ticket_status_snippet
|
AND $ticket_status_snippet
|
||||||
AND $ticket_billable_snippet
|
AND $ticket_billable_snippet
|
||||||
@@ -50,12 +49,12 @@ $sql = mysqli_query(
|
|||||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
|
|
||||||
//Get Total tickets open
|
//Get Total tickets open
|
||||||
$sql_total_tickets_open = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_client_id = $client_id AND ticket_status != 'Closed'");
|
$sql_total_tickets_open = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_client_id = $client_id AND ticket_closed_at IS NULL");
|
||||||
$row = mysqli_fetch_array($sql_total_tickets_open);
|
$row = mysqli_fetch_array($sql_total_tickets_open);
|
||||||
$total_tickets_open = intval($row['total_tickets_open']);
|
$total_tickets_open = intval($row['total_tickets_open']);
|
||||||
|
|
||||||
//Get Total tickets closed
|
//Get Total tickets closed
|
||||||
$sql_total_tickets_closed = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_closed FROM tickets WHERE ticket_client_id = $client_id AND ticket_status = 'Closed'");
|
$sql_total_tickets_closed = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_closed FROM tickets WHERE ticket_client_id = $client_id AND ticket_closed_at IS NOT NULL");
|
||||||
$row = mysqli_fetch_array($sql_total_tickets_closed);
|
$row = mysqli_fetch_array($sql_total_tickets_closed);
|
||||||
$total_tickets_closed = intval($row['total_tickets_closed']);
|
$total_tickets_closed = intval($row['total_tickets_closed']);
|
||||||
|
|
||||||
@@ -142,14 +141,16 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
|
|||||||
$ticket_number = nullable_htmlentities($row['ticket_number']);
|
$ticket_number = nullable_htmlentities($row['ticket_number']);
|
||||||
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
||||||
$ticket_priority = nullable_htmlentities($row['ticket_priority']);
|
$ticket_priority = nullable_htmlentities($row['ticket_priority']);
|
||||||
$ticket_status = nullable_htmlentities($row['ticket_status']);
|
$ticket_status_id = intval($row['ticket_status_id']);
|
||||||
|
$ticket_status_name = nullable_htmlentities($row['ticket_status_name']);
|
||||||
|
$ticket_status_color = nullable_htmlentities($row['ticket_status_color']);
|
||||||
$ticket_billable = intval($row['ticket_billable']);
|
$ticket_billable = intval($row['ticket_billable']);
|
||||||
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
|
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
|
||||||
$ticket_created_at_time_ago = timeAgo($row['ticket_created_at']);
|
$ticket_created_at_time_ago = timeAgo($row['ticket_created_at']);
|
||||||
$ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']);
|
$ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']);
|
||||||
$ticket_updated_at_time_ago = timeAgo($row['ticket_updated_at']);
|
$ticket_updated_at_time_ago = timeAgo($row['ticket_updated_at']);
|
||||||
if (empty($ticket_updated_at)) {
|
if (empty($ticket_updated_at)) {
|
||||||
if ($ticket_status == "Closed") {
|
if (!empty($ticket_closed_at)) {
|
||||||
$ticket_updated_at_display = "<p>Never</p>";
|
$ticket_updated_at_display = "<p>Never</p>";
|
||||||
} else {
|
} else {
|
||||||
$ticket_updated_at_display = "<p class='text-danger'>Never</p>";
|
$ticket_updated_at_display = "<p class='text-danger'>Never</p>";
|
||||||
@@ -159,8 +160,6 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
|
|||||||
}
|
}
|
||||||
$ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']);
|
$ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']);
|
||||||
|
|
||||||
$ticket_status_color = getTicketStatusColor($ticket_status);
|
|
||||||
|
|
||||||
if ($ticket_priority == "High") {
|
if ($ticket_priority == "High") {
|
||||||
$ticket_priority_display = "<span class='p-2 badge badge-danger'>$ticket_priority</span>";
|
$ticket_priority_display = "<span class='p-2 badge badge-danger'>$ticket_priority</span>";
|
||||||
} elseif ($ticket_priority == "Medium") {
|
} elseif ($ticket_priority == "Medium") {
|
||||||
@@ -173,7 +172,7 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
|
|||||||
|
|
||||||
$ticket_assigned_to = intval($row['ticket_assigned_to']);
|
$ticket_assigned_to = intval($row['ticket_assigned_to']);
|
||||||
if (empty($ticket_assigned_to)) {
|
if (empty($ticket_assigned_to)) {
|
||||||
if ($ticket_status == "Closed") {
|
if (!empty($ticket_closed_at)) {
|
||||||
$ticket_assigned_to_display = "<p>Not Assigned</p>";
|
$ticket_assigned_to_display = "<p>Not Assigned</p>";
|
||||||
} else {
|
} else {
|
||||||
$ticket_assigned_to_display = "<p class='text-danger'>Not Assigned</p>";
|
$ticket_assigned_to_display = "<p class='text-danger'>Not Assigned</p>";
|
||||||
@@ -181,7 +180,7 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
|
|||||||
} else {
|
} else {
|
||||||
$ticket_assigned_to_display = nullable_htmlentities($row['user_name']);
|
$ticket_assigned_to_display = nullable_htmlentities($row['user_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$project_id = intval($row['ticket_project_id']);
|
$project_id = intval($row['ticket_project_id']);
|
||||||
|
|
||||||
$contact_name = nullable_htmlentities($row['contact_name']);
|
$contact_name = nullable_htmlentities($row['contact_name']);
|
||||||
@@ -261,7 +260,7 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
|
|||||||
|
|
||||||
<!-- Ticket Status -->
|
<!-- Ticket Status -->
|
||||||
<td>
|
<td>
|
||||||
<span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status; ?></span>
|
<span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status_name; ?></span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<!-- Ticket Assigned agent -->
|
<!-- Ticket Assigned agent -->
|
||||||
@@ -286,7 +285,7 @@ $total_scheduled_tickets = intval($row['total_scheduled_tickets']);
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Edit actions, for open tickets
|
// Edit actions, for open tickets
|
||||||
if ($ticket_status !== "Closed") {
|
if (empty($ticket_closed_at)) {
|
||||||
|
|
||||||
require "ticket_assign_modal.php";
|
require "ticket_assign_modal.php";
|
||||||
|
|
||||||
|
|||||||
18
cron.php
18
cron.php
@@ -225,9 +225,7 @@ foreach ($warranty_alert_array as $day) {
|
|||||||
|
|
||||||
// Notify of New Tickets
|
// Notify of New Tickets
|
||||||
// Get Ticket Pending Assignment
|
// Get Ticket Pending Assignment
|
||||||
$sql_tickets_pending_assignment = mysqli_query($mysqli,"SELECT ticket_id FROM tickets
|
$sql_tickets_pending_assignment = mysqli_query($mysqli,"SELECT ticket_id FROM tickets WHERE ticket_status = 1");
|
||||||
WHERE ticket_status = 'New'"
|
|
||||||
);
|
|
||||||
|
|
||||||
$tickets_pending_assignment = mysqli_num_rows($sql_tickets_pending_assignment);
|
$tickets_pending_assignment = mysqli_num_rows($sql_tickets_pending_assignment);
|
||||||
|
|
||||||
@@ -258,9 +256,9 @@ if (mysqli_num_rows($sql_scheduled_tickets) > 0) {
|
|||||||
$contact_id = intval($row['scheduled_ticket_contact_id']);
|
$contact_id = intval($row['scheduled_ticket_contact_id']);
|
||||||
$asset_id = intval($row['scheduled_ticket_asset_id']);
|
$asset_id = intval($row['scheduled_ticket_asset_id']);
|
||||||
|
|
||||||
$ticket_status = 'New'; // Default
|
$ticket_status = 1; // Default
|
||||||
if ($assigned_id > 0) {
|
if ($assigned_id > 0) {
|
||||||
$ticket_status = 'Open'; // Set to open if we've auto-assigned an agent
|
$ticket_status = 2; // Set to open if we've auto-assigned an agent
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign this new ticket the next ticket number
|
// Assign this new ticket the next ticket number
|
||||||
@@ -381,7 +379,7 @@ if ($config_ticket_autoclose == 1) {
|
|||||||
$sql_tickets_to_chase = mysqli_query(
|
$sql_tickets_to_chase = mysqli_query(
|
||||||
$mysqli,
|
$mysqli,
|
||||||
"SELECT * FROM tickets
|
"SELECT * FROM tickets
|
||||||
WHERE ticket_status = 'Auto Close'
|
WHERE ticket_status = 4
|
||||||
AND ticket_updated_at < NOW() - INTERVAL $config_ticket_autoclose_hours HOUR"
|
AND ticket_updated_at < NOW() - INTERVAL $config_ticket_autoclose_hours HOUR"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -395,7 +393,7 @@ if ($config_ticket_autoclose == 1) {
|
|||||||
$ticket_assigned_to = sanitizeInput($row['ticket_assigned_to']);
|
$ticket_assigned_to = sanitizeInput($row['ticket_assigned_to']);
|
||||||
$client_id = intval($row['ticket_client_id']);
|
$client_id = intval($row['ticket_client_id']);
|
||||||
|
|
||||||
mysqli_query($mysqli,"UPDATE tickets SET ticket_status = 'Closed', ticket_closed_at = NOW(), ticket_closed_by = $ticket_assigned_to WHERE ticket_id = $ticket_id");
|
mysqli_query($mysqli,"UPDATE tickets SET ticket_status = 5, ticket_closed_at = NOW(), ticket_closed_by = $ticket_assigned_to WHERE ticket_id = $ticket_id");
|
||||||
|
|
||||||
//Logging
|
//Logging
|
||||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Ticket', log_action = 'Closed', log_description = '$ticket_prefix$ticket_number auto closed', log_entity_id = $ticket_id");
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Ticket', log_action = 'Closed', log_description = '$ticket_prefix$ticket_number auto closed', log_entity_id = $ticket_id");
|
||||||
@@ -410,7 +408,7 @@ if ($config_ticket_autoclose == 1) {
|
|||||||
"SELECT contact_name, contact_email, ticket_id, ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_client_id FROM tickets
|
"SELECT contact_name, contact_email, ticket_id, ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_client_id FROM tickets
|
||||||
LEFT JOIN clients ON ticket_client_id = client_id
|
LEFT JOIN clients ON ticket_client_id = client_id
|
||||||
LEFT JOIN contacts ON ticket_contact_id = contact_id
|
LEFT JOIN contacts ON ticket_contact_id = contact_id
|
||||||
WHERE ticket_status = 'Auto Close'
|
WHERE ticket_status = 4
|
||||||
AND ticket_updated_at < NOW() - INTERVAL 48 HOUR"
|
AND ticket_updated_at < NOW() - INTERVAL 48 HOUR"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -422,7 +420,7 @@ if ($config_ticket_autoclose == 1) {
|
|||||||
$ticket_prefix = sanitizeInput($row['ticket_prefix']);
|
$ticket_prefix = sanitizeInput($row['ticket_prefix']);
|
||||||
$ticket_number = intval($row['ticket_number']);
|
$ticket_number = intval($row['ticket_number']);
|
||||||
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
||||||
$ticket_status = sanitizeInput($row['ticket_status']);
|
$ticket_status = sanitizeInput( getTicketStatusName($row['ticket_status']));
|
||||||
$client_id = intval($row['ticket_client_id']);
|
$client_id = intval($row['ticket_client_id']);
|
||||||
|
|
||||||
$sql_ticket_reply = mysqli_query($mysqli, "SELECT ticket_reply FROM ticket_replies WHERE ticket_reply_type = 'Public' AND ticket_reply_ticket_id = $ticket_id ORDER BY ticket_reply_created_at DESC LIMIT 1");
|
$sql_ticket_reply = mysqli_query($mysqli, "SELECT ticket_reply FROM ticket_replies WHERE ticket_reply_type = 'Public' AND ticket_reply_ticket_id = $ticket_id ORDER BY ticket_reply_created_at DESC LIMIT 1");
|
||||||
@@ -431,7 +429,7 @@ if ($config_ticket_autoclose == 1) {
|
|||||||
|
|
||||||
$subject = "Ticket pending closure - [$ticket_prefix$ticket_number] - $ticket_subject";
|
$subject = "Ticket pending closure - [$ticket_prefix$ticket_number] - $ticket_subject";
|
||||||
|
|
||||||
$body = "<i style=\'color: #808080\'>##- Please type your reply above this line -##</i><br><br>Hello, $contact_name<br><br>This is an automatic friendly reminder that your ticket regarding \"$ticket_subject\" will be closed, unless you respond.<br><br>--------------------------------<br>$ticket_reply--------------------------------<br><br>If your issue is resolved, you can ignore this email - the ticket will automatically close. If you need further assistance, please respond to this email. <br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status<br>Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id<br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
|
$body = "<i style=\'color: #808080\'>##- Please type your reply above this line -##</i><br><br>Hello, $contact_name<br><br>This is an automatic friendly reminder that your ticket regarding \"$ticket_subject\" will be closed, unless you respond.<br><br>--------------------------------<br>$ticket_reply--------------------------------<br><br>If your issue is resolved, you can ignore this email - the ticket will automatically close. If you need further assistance, please respond to this email. <br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status <br>Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id<br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date
|
|||||||
$message = nl2br($message);
|
$message = nl2br($message);
|
||||||
$message = mysqli_escape_string($mysqli, "<i>Email from: $contact_email at $date:-</i> <br><br>$message");
|
$message = mysqli_escape_string($mysqli, "<i>Email from: $contact_email at $date:-</i> <br><br>$message");
|
||||||
|
|
||||||
mysqli_query($mysqli, "INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$message', ticket_priority = 'Low', ticket_status = 'New', ticket_created_by = 0, ticket_contact_id = $contact_id, ticket_client_id = $client_id");
|
mysqli_query($mysqli, "INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$message', ticket_priority = 'Low', ticket_status = 1, ticket_created_by = 0, ticket_contact_id = $contact_id, ticket_client_id = $client_id");
|
||||||
$id = mysqli_insert_id($mysqli);
|
$id = mysqli_insert_id($mysqli);
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
@@ -243,7 +243,7 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac
|
|||||||
$client_name = sanitizeInput($row['client_name']);
|
$client_name = sanitizeInput($row['client_name']);
|
||||||
|
|
||||||
// Check ticket isn't closed - tickets can't be re-opened
|
// Check ticket isn't closed - tickets can't be re-opened
|
||||||
if ($ticket_status == "Closed") {
|
if ($ticket_status == 5) {
|
||||||
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Ticket', notification = 'Email parser: $from_email attempted to re-open ticket $config_ticket_prefix$ticket_number (ID $ticket_id) - check inbox manually to see email', notification_action = 'ticket.php?ticket_id=$ticket_id', notification_client_id = $client_id");
|
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Ticket', notification = 'Email parser: $from_email attempted to re-open ticket $config_ticket_prefix$ticket_number (ID $ticket_id) - check inbox manually to see email', notification_action = 'ticket.php?ticket_id=$ticket_id', notification_client_id = $client_id");
|
||||||
|
|
||||||
$email_subject = "Action required: This ticket is already closed";
|
$email_subject = "Action required: This ticket is already closed";
|
||||||
@@ -360,7 +360,7 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update Ticket Last Response Field & set ticket to open as client has replied
|
// Update Ticket Last Response Field & set ticket to open as client has replied
|
||||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 'Open' WHERE ticket_id = $ticket_id AND ticket_client_id = $client_id LIMIT 1");
|
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 2 WHERE ticket_id = $ticket_id AND ticket_client_id = $client_id LIMIT 1");
|
||||||
|
|
||||||
echo "Updated existing ticket.<br>";
|
echo "Updated existing ticket.<br>";
|
||||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Update', log_description = 'Email parser: Client contact $from_email updated ticket $config_ticket_prefix$ticket_number ($subject)', log_client_id = $client_id");
|
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Update', log_description = 'Email parser: Client contact $from_email updated ticket $config_ticket_prefix$ticket_number ($subject)', log_client_id = $client_id");
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ if ($user_config_dashboard_financial_enable == 1) {
|
|||||||
//Define var so it doesnt throw errors in logs
|
//Define var so it doesnt throw errors in logs
|
||||||
$largest_income_month = 0;
|
$largest_income_month = 0;
|
||||||
|
|
||||||
|
|
||||||
//Get Total income
|
//Get Total income
|
||||||
$sql_total_payments_to_invoices = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments_to_invoices FROM payments WHERE YEAR(payment_date) = $year");
|
$sql_total_payments_to_invoices = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments_to_invoices FROM payments WHERE YEAR(payment_date) = $year");
|
||||||
$row = mysqli_fetch_array($sql_total_payments_to_invoices);
|
$row = mysqli_fetch_array($sql_total_payments_to_invoices);
|
||||||
@@ -169,7 +169,7 @@ if ($user_config_dashboard_financial_enable == 1) {
|
|||||||
|
|
||||||
if ($config_module_enable_ticketing && $config_module_enable_accounting) {
|
if ($config_module_enable_ticketing && $config_module_enable_accounting) {
|
||||||
//Get Unbilled, closed tickets
|
//Get Unbilled, closed tickets
|
||||||
$sql_unbilled_tickets = mysqli_query($mysqli, "SELECT COUNT('ticket_id') AS unbilled_tickets FROM tickets WHERE ticket_status = 'Closed' AND ticket_billable = 1 AND ticket_invoice_id = 0 AND YEAR(ticket_created_at) = $year");
|
$sql_unbilled_tickets = mysqli_query($mysqli, "SELECT COUNT('ticket_id') AS unbilled_tickets FROM tickets WHERE ticket_closed_at IS NOT NULL AND ticket_billable = 1 AND ticket_invoice_id = 0 AND YEAR(ticket_created_at) = $year");
|
||||||
$row = mysqli_fetch_array($sql_unbilled_tickets);
|
$row = mysqli_fetch_array($sql_unbilled_tickets);
|
||||||
$unbilled_tickets = intval($row['unbilled_tickets']);
|
$unbilled_tickets = intval($row['unbilled_tickets']);
|
||||||
} else {
|
} else {
|
||||||
@@ -772,13 +772,14 @@ if ($user_config_dashboard_technical_enable == 1) {
|
|||||||
$ticket_number = intval($row['ticket_number']);
|
$ticket_number = intval($row['ticket_number']);
|
||||||
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
||||||
$ticket_priority = nullable_htmlentities($row['ticket_priority']);
|
$ticket_priority = nullable_htmlentities($row['ticket_priority']);
|
||||||
$ticket_status = nullable_htmlentities($row['ticket_status']);
|
$ticket_status_id = intval($row['ticket_status']);
|
||||||
|
$ticket_status_name = sanitizeInput(getTicketStatusName($row['ticket_status']));
|
||||||
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
|
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
|
||||||
$ticket_created_at_time_ago = timeAgo($row['ticket_created_at']);
|
$ticket_created_at_time_ago = timeAgo($row['ticket_created_at']);
|
||||||
$ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']);
|
$ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']);
|
||||||
$ticket_updated_at_time_ago = timeAgo($row['ticket_updated_at']);
|
$ticket_updated_at_time_ago = timeAgo($row['ticket_updated_at']);
|
||||||
if (empty($ticket_updated_at)) {
|
if (empty($ticket_updated_at)) {
|
||||||
if ($ticket_status == "Closed") {
|
if (!empty($ticket_closed_at)) {
|
||||||
$ticket_updated_at_display = "<p>Never</p>";
|
$ticket_updated_at_display = "<p>Never</p>";
|
||||||
} else {
|
} else {
|
||||||
$ticket_updated_at_display = "<p class='text-danger'>Never</p>";
|
$ticket_updated_at_display = "<p class='text-danger'>Never</p>";
|
||||||
@@ -791,17 +792,7 @@ if ($user_config_dashboard_technical_enable == 1) {
|
|||||||
$contact_id = intval($row['ticket_contact_id']);
|
$contact_id = intval($row['ticket_contact_id']);
|
||||||
$contact_name = nullable_htmlentities($row['contact_name']);
|
$contact_name = nullable_htmlentities($row['contact_name']);
|
||||||
|
|
||||||
if ($ticket_status == "New") {
|
$ticket_status_color = getTicketStatusColor($ticket_status_id);
|
||||||
$ticket_status_color = "danger";
|
|
||||||
} elseif ($ticket_status == "Open") {
|
|
||||||
$ticket_status_color = "primary";
|
|
||||||
} elseif ($ticket_status == "On Hold") {
|
|
||||||
$ticket_status_color = "success";
|
|
||||||
} elseif ($ticket_status == "Auto Close") {
|
|
||||||
$ticket_status_color = "dark";
|
|
||||||
} elseif ($ticket_status == "Closed") {
|
|
||||||
$ticket_status_color = "dark";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ticket_priority == "High") {
|
if ($ticket_priority == "High") {
|
||||||
$ticket_priority_color = "danger";
|
$ticket_priority_color = "danger";
|
||||||
@@ -831,7 +822,7 @@ if ($user_config_dashboard_technical_enable == 1) {
|
|||||||
</td>
|
</td>
|
||||||
<td><?php echo $contact_display; ?></td>
|
<td><?php echo $contact_display; ?></td>
|
||||||
<td><span class='p-2 badge badge-pill badge-<?php echo $ticket_priority_color; ?>'><?php echo $ticket_priority; ?></span></td>
|
<td><span class='p-2 badge badge-pill badge-<?php echo $ticket_priority_color; ?>'><?php echo $ticket_priority; ?></span></td>
|
||||||
<td><span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status; ?></span></td>
|
<td><span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status_name; ?></span></td>
|
||||||
<td><?php echo $ticket_updated_at_display; ?></td>
|
<td><?php echo $ticket_updated_at_display; ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|||||||
@@ -1688,7 +1688,6 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CURRENT_DATABASE_VERSION == '1.1.3') {
|
if (CURRENT_DATABASE_VERSION == '1.1.3') {
|
||||||
|
|
||||||
mysqli_query($mysqli, "ALTER TABLE `networks` ADD `network_subnet` VARCHAR(200) DEFAULT NULL AFTER `network`");
|
mysqli_query($mysqli, "ALTER TABLE `networks` ADD `network_subnet` VARCHAR(200) DEFAULT NULL AFTER `network`");
|
||||||
mysqli_query($mysqli, "ALTER TABLE `networks` ADD `network_primary_dns` VARCHAR(200) DEFAULT NULL AFTER `network_gateway`");
|
mysqli_query($mysqli, "ALTER TABLE `networks` ADD `network_primary_dns` VARCHAR(200) DEFAULT NULL AFTER `network_gateway`");
|
||||||
mysqli_query($mysqli, "ALTER TABLE `networks` ADD `network_secondary_dns` VARCHAR(200) DEFAULT NULL AFTER `network_primary_dns`");
|
mysqli_query($mysqli, "ALTER TABLE `networks` ADD `network_secondary_dns` VARCHAR(200) DEFAULT NULL AFTER `network_primary_dns`");
|
||||||
@@ -1747,10 +1746,39 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
|||||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.1.5'");
|
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.1.5'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (CURRENT_DATABASE_VERSION == '1.1.5') {
|
if (CURRENT_DATABASE_VERSION == '1.1.5') {
|
||||||
// // Insert queries here required to update to DB version 1.1.6
|
|
||||||
|
// Add new ticket_statuses table
|
||||||
|
mysqli_query($mysqli,
|
||||||
|
"CREATE TABLE `ticket_statuses` (
|
||||||
|
`ticket_status_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`ticket_status_name` VARCHAR(200) NOT NULL,
|
||||||
|
`ticket_status_color` VARCHAR(200) NOT NULL,
|
||||||
|
`ticket_status_active` TINYINT(1) NOT NULL DEFAULT '1',
|
||||||
|
PRIMARY KEY (`ticket_status_id`)
|
||||||
|
)");
|
||||||
|
|
||||||
|
// Pre-seed default system/built-in ticket statuses
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'New', ticket_status_color = 'danger'"); // Default ID for new tickets is 1
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'Open', ticket_status_color = 'primary'"); // 2
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'On Hold', ticket_status_color = 'success'"); // 3
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'Auto Close', ticket_status_color = 'dark'"); // 4
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'Closed', ticket_status_color = 'dark'"); // 5
|
||||||
|
|
||||||
|
// Update existing tickets to use new values
|
||||||
|
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 1 WHERE ticket_status = 'New'"); // New
|
||||||
|
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 2 WHERE ticket_status = 'Open'"); // Open
|
||||||
|
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 3 WHERE ticket_status = 'On Hold'"); // On Hold
|
||||||
|
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 4 WHERE ticket_status = 'Auto Close'"); // Auto Close
|
||||||
|
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 5 WHERE ticket_closed_at IS NOT NULL"); // Closed
|
||||||
|
|
||||||
|
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.1.6'");
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (CURRENT_DATABASE_VERSION == '1.1.6') {
|
||||||
|
// // Insert queries here required to update to DB version 1.1.7
|
||||||
// // 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.1.6'");
|
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.1.7'");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -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.1.5");
|
DEFINE("LATEST_DATABASE_VERSION", "1.1.6");
|
||||||
|
|||||||
15
db.sql
15
db.sql
@@ -1618,6 +1618,19 @@ CREATE TABLE `ticket_templates` (
|
|||||||
) 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 `ticket_statuses`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `ticket_statuses`;
|
||||||
|
CREATE TABLE IF NOT EXISTS `ticket_statuses` (
|
||||||
|
`ticket_status_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`ticket_status_name` varchar(200) NOT NULL,
|
||||||
|
`ticket_status_color` varchar(200) NOT NULL,
|
||||||
|
`ticket_status_active` TINYINT(1) NOT NULL DEFAULT '1',
|
||||||
|
PRIMARY KEY (`ticket_status_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `ticket_views`
|
-- Table structure for table `ticket_views`
|
||||||
--
|
--
|
||||||
@@ -1862,4 +1875,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 2024-03-27 19:16:15
|
-- As of 2024 03 29
|
||||||
|
|||||||
@@ -1139,15 +1139,32 @@ function createiCalStrCancel($originaliCalStr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getTicketStatusColor($ticket_status) {
|
function getTicketStatusColor($ticket_status) {
|
||||||
if ($ticket_status == "New") {
|
|
||||||
return "danger";
|
global $mysqli;
|
||||||
} elseif ($ticket_status == "Open") {
|
|
||||||
return "primary";
|
$status_id = intval($ticket_status);
|
||||||
} elseif ($ticket_status == "On Hold") {
|
$row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT ticket_status_color FROM ticket_statuses WHERE ticket_status_id = $status_id LIMIT 1"));
|
||||||
return "success";
|
|
||||||
} elseif ($ticket_status == "Auto Close") {
|
if ($row) {
|
||||||
return "dark";
|
return nullable_htmlentities($row['ticket_status_color']);
|
||||||
} elseif ($ticket_status == "Closed") {
|
|
||||||
return "dark";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default return
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTicketStatusName($ticket_status) {
|
||||||
|
|
||||||
|
global $mysqli;
|
||||||
|
|
||||||
|
$status_id = intval($ticket_status);
|
||||||
|
$row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT * FROM ticket_statuses WHERE ticket_status_id = $status_id LIMIT 1"));
|
||||||
|
|
||||||
|
if ($row) {
|
||||||
|
return nullable_htmlentities($row['ticket_status_name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default return
|
||||||
|
return "Unknown";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ if (isset($_GET['query'])) {
|
|||||||
AND client_name LIKE '%$query%'
|
AND client_name LIKE '%$query%'
|
||||||
ORDER BY client_id DESC LIMIT 5"
|
ORDER BY client_id DESC LIMIT 5"
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql_contacts = mysqli_query($mysqli, "SELECT * FROM contacts
|
$sql_contacts = mysqli_query($mysqli, "SELECT * FROM contacts
|
||||||
LEFT JOIN clients ON client_id = contact_client_id
|
LEFT JOIN clients ON client_id = contact_client_id
|
||||||
WHERE contact_archived_at IS NULL
|
WHERE contact_archived_at IS NULL
|
||||||
@@ -37,7 +37,7 @@ if (isset($_GET['query'])) {
|
|||||||
OR contact_mobile LIKE '%$phone_query%')
|
OR contact_mobile LIKE '%$phone_query%')
|
||||||
ORDER BY contact_id DESC LIMIT 5"
|
ORDER BY contact_id DESC LIMIT 5"
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql_vendors = mysqli_query($mysqli, "SELECT * FROM vendors
|
$sql_vendors = mysqli_query($mysqli, "SELECT * FROM vendors
|
||||||
LEFT JOIN clients ON vendor_client_id = client_id
|
LEFT JOIN clients ON vendor_client_id = client_id
|
||||||
WHERE vendor_archived_at IS NULL
|
WHERE vendor_archived_at IS NULL
|
||||||
@@ -52,20 +52,20 @@ if (isset($_GET['query'])) {
|
|||||||
AND domain_name LIKE '%$query%'
|
AND domain_name LIKE '%$query%'
|
||||||
ORDER BY domain_id DESC LIMIT 5"
|
ORDER BY domain_id DESC LIMIT 5"
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql_products = mysqli_query($mysqli, "SELECT * FROM products
|
$sql_products = mysqli_query($mysqli, "SELECT * FROM products
|
||||||
WHERE product_archived_at IS NULL
|
WHERE product_archived_at IS NULL
|
||||||
AND product_name LIKE '%$query%'
|
AND product_name LIKE '%$query%'
|
||||||
ORDER BY product_id DESC LIMIT 5"
|
ORDER BY product_id DESC LIMIT 5"
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql_documents = mysqli_query($mysqli, "SELECT * FROM documents
|
$sql_documents = mysqli_query($mysqli, "SELECT * FROM documents
|
||||||
LEFT JOIN clients on document_client_id = clients.client_id
|
LEFT JOIN clients on document_client_id = clients.client_id
|
||||||
WHERE document_archived_at IS NULL
|
WHERE document_archived_at IS NULL
|
||||||
AND MATCH(document_content_raw) AGAINST ('$query')
|
AND MATCH(document_content_raw) AGAINST ('$query')
|
||||||
ORDER BY document_id DESC LIMIT 5"
|
ORDER BY document_id DESC LIMIT 5"
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql_tickets = mysqli_query($mysqli, "SELECT * FROM tickets
|
$sql_tickets = mysqli_query($mysqli, "SELECT * FROM tickets
|
||||||
LEFT JOIN clients on tickets.ticket_client_id = clients.client_id
|
LEFT JOIN clients on tickets.ticket_client_id = clients.client_id
|
||||||
WHERE ticket_archived_at IS NULL
|
WHERE ticket_archived_at IS NULL
|
||||||
@@ -73,7 +73,7 @@ if (isset($_GET['query'])) {
|
|||||||
OR ticket_number = '$ticket_num_query')
|
OR ticket_number = '$ticket_num_query')
|
||||||
ORDER BY ticket_id DESC LIMIT 5"
|
ORDER BY ticket_id DESC LIMIT 5"
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql_logins = mysqli_query($mysqli, "SELECT * FROM logins
|
$sql_logins = mysqli_query($mysqli, "SELECT * FROM logins
|
||||||
LEFT JOIN contacts ON login_contact_id = contact_id
|
LEFT JOIN contacts ON login_contact_id = contact_id
|
||||||
LEFT JOIN clients ON login_client_id = client_id
|
LEFT JOIN clients ON login_client_id = client_id
|
||||||
@@ -108,10 +108,10 @@ if (isset($_GET['query'])) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$q = nullable_htmlentities($_GET['query']);
|
$q = nullable_htmlentities($_GET['query']);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
@@ -291,7 +291,7 @@ if (isset($_GET['query'])) {
|
|||||||
$domain_id = intval($row['domain_id']);
|
$domain_id = intval($row['domain_id']);
|
||||||
$client_id = intval($row['client_id']);
|
$client_id = intval($row['client_id']);
|
||||||
$client_name = nullable_htmlentities($row['client_name']);
|
$client_name = nullable_htmlentities($row['client_name']);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="client_domains.php?client_id=<?php echo $client_id; ?>&domain_id=<?php echo $domain_id; ?>"><?php echo $domain_name; ?></a>
|
<td><a href="client_domains.php?client_id=<?php echo $client_id; ?>&domain_id=<?php echo $domain_id; ?>"><?php echo $domain_name; ?></a>
|
||||||
@@ -308,7 +308,7 @@ if (isset($_GET['query'])) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php if (mysqli_num_rows($sql_products) > 0) { ?>
|
<?php if (mysqli_num_rows($sql_products) > 0) { ?>
|
||||||
|
|
||||||
<!-- Products -->
|
<!-- Products -->
|
||||||
@@ -418,7 +418,7 @@ if (isset($_GET['query'])) {
|
|||||||
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
|
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
|
||||||
$ticket_number = intval($row['ticket_number']);
|
$ticket_number = intval($row['ticket_number']);
|
||||||
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
||||||
$ticket_status = nullable_htmlentities($row['ticket_status']);
|
$ticket_status = nullable_htmlentities(getTicketStatusName($row['ticket_status']));
|
||||||
$client_name = nullable_htmlentities($row['client_name']);
|
$client_name = nullable_htmlentities($row['client_name']);
|
||||||
$client_id = intval($row['ticket_client_id']);
|
$client_id = intval($row['ticket_client_id']);
|
||||||
|
|
||||||
@@ -598,7 +598,7 @@ if (isset($_GET['query'])) {
|
|||||||
if (empty($contact_name)) {
|
if (empty($contact_name)) {
|
||||||
$contact_name_display = "-";
|
$contact_name_display = "-";
|
||||||
}else{
|
}else{
|
||||||
$contact_name_display = "<a href='client_contact_details.php?client_id=$client_id&contact_id=$contact_id'>$contact_name</a>";
|
$contact_name_display = "<a href='client_contact_details.php?client_id=$client_id&contact_id=$contact_id'>$contact_name</a>";
|
||||||
}
|
}
|
||||||
$contact_archived_at = nullable_htmlentities($row['contact_archived_at']);
|
$contact_archived_at = nullable_htmlentities($row['contact_archived_at']);
|
||||||
if (empty($contact_archived_at)) {
|
if (empty($contact_archived_at)) {
|
||||||
@@ -652,12 +652,12 @@ if (isset($_GET['query'])) {
|
|||||||
|
|
||||||
while ($row = mysqli_fetch_array($sql_ticket_replies)) {
|
while ($row = mysqli_fetch_array($sql_ticket_replies)) {
|
||||||
$ticket_id = intval($row['ticket_id']);
|
$ticket_id = intval($row['ticket_id']);
|
||||||
|
|
||||||
// Only output the ticket header if we're at a new ticket
|
// Only output the ticket header if we're at a new ticket
|
||||||
if ($ticket_id !== $last_ticket_id) {
|
if ($ticket_id !== $last_ticket_id) {
|
||||||
if ($last_ticket_id !== null) {
|
if ($last_ticket_id !== null) {
|
||||||
// Close the previous ticket's card (except for the very first ticket)
|
// Close the previous ticket's card (except for the very first ticket)
|
||||||
echo '</div></div>';
|
echo '</div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
|
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
|
||||||
@@ -699,7 +699,7 @@ if (isset($_GET['query'])) {
|
|||||||
|
|
||||||
if ($last_ticket_id !== null) {
|
if ($last_ticket_id !== null) {
|
||||||
// Close the last ticket's card
|
// Close the last ticket's card
|
||||||
echo '</div></div>';
|
echo '</div></div>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -721,4 +721,4 @@ require_once "footer.php";
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script src="js/pretty_content.js"></script>
|
<script src="js/pretty_content.js"></script>
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ function verifyContactTicketAccess($requested_ticket_id, $expected_ticket_state)
|
|||||||
// Setup
|
// Setup
|
||||||
if ($expected_ticket_state == "Closed") {
|
if ($expected_ticket_state == "Closed") {
|
||||||
// Closed tickets
|
// Closed tickets
|
||||||
$ticket_state_snippet = "ticket_status = 'Closed'";
|
$ticket_state_snippet = "ticket_status = 5";
|
||||||
} else {
|
} else {
|
||||||
// Open (working/hold) tickets
|
// Open (working/hold) tickets
|
||||||
$ticket_state_snippet = "ticket_status != 'Closed'";
|
$ticket_state_snippet = "ticket_status != 5";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the contact has access to the provided ticket ID
|
// Verify the contact has access to the provided ticket ID
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ if (isset($_POST['add_ticket'])) {
|
|||||||
$new_config_ticket_next_number = $config_ticket_next_number + 1;
|
$new_config_ticket_next_number = $config_ticket_next_number + 1;
|
||||||
mysqli_query($mysqli, "UPDATE settings SET config_ticket_next_number = $new_config_ticket_next_number WHERE company_id = 1");
|
mysqli_query($mysqli, "UPDATE settings SET config_ticket_next_number = $new_config_ticket_next_number WHERE company_id = 1");
|
||||||
|
|
||||||
mysqli_query($mysqli, "INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_priority = '$priority', ticket_status = 'New', ticket_created_by = 0, ticket_contact_id = $contact, ticket_client_id = $client_id");
|
mysqli_query($mysqli, "INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_priority = '$priority', ticket_status = 1, ticket_created_by = 0, ticket_contact_id = $contact, ticket_client_id = $client_id");
|
||||||
$id = mysqli_insert_id($mysqli);
|
$id = mysqli_insert_id($mysqli);
|
||||||
|
|
||||||
// Notify agent DL of the new ticket, if populated with a valid email
|
// Notify agent DL of the new ticket, if populated with a valid email
|
||||||
@@ -86,7 +86,7 @@ if (isset($_POST['add_ticket_comment'])) {
|
|||||||
$ticket_reply_id = mysqli_insert_id($mysqli);
|
$ticket_reply_id = mysqli_insert_id($mysqli);
|
||||||
|
|
||||||
// Update Ticket Last Response Field & set ticket to open as client has replied
|
// Update Ticket Last Response Field & set ticket to open as client has replied
|
||||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 'Open' WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id LIMIT 1");
|
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 2 WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id LIMIT 1");
|
||||||
|
|
||||||
|
|
||||||
// Get ticket details & Notify the assigned tech (if any)
|
// Get ticket details & Notify the assigned tech (if any)
|
||||||
@@ -201,7 +201,7 @@ if (isset($_GET['close_ticket'])) {
|
|||||||
if (verifyContactTicketAccess($ticket_id, "Open")) {
|
if (verifyContactTicketAccess($ticket_id, "Open")) {
|
||||||
|
|
||||||
// Close ticket
|
// Close ticket
|
||||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 'Closed', ticket_closed_at = NOW() WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id");
|
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 5, ticket_closed_at = NOW() WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id");
|
||||||
|
|
||||||
// Add reply
|
// Add reply
|
||||||
mysqli_query($mysqli, "INSERT INTO ticket_replies SET ticket_reply = 'Ticket closed by $session_contact_name.', ticket_reply_type = 'Client', ticket_reply_by = $session_contact_id, ticket_reply_ticket_id = $ticket_id");
|
mysqli_query($mysqli, "INSERT INTO ticket_replies SET ticket_reply = 'Ticket closed by $session_contact_name.', ticket_reply_type = 'Client', ticket_reply_by = $session_contact_id, ticket_reply_ticket_id = $ticket_id");
|
||||||
|
|||||||
@@ -20,10 +20,21 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
|
|||||||
|
|
||||||
if ($session_contact_primary == 1 || $session_contact_is_technical_contact) {
|
if ($session_contact_primary == 1 || $session_contact_is_technical_contact) {
|
||||||
// For a primary / technical contact viewing all tickets
|
// For a primary / technical contact viewing all tickets
|
||||||
$ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN users on ticket_assigned_to = user_id WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id");
|
$ticket_sql = mysqli_query($mysqli,
|
||||||
|
"SELECT * FROM tickets
|
||||||
|
LEFT JOIN users on ticket_assigned_to = user_id
|
||||||
|
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||||
|
WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id"
|
||||||
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// For a user viewing their own ticket
|
// For a user viewing their own ticket
|
||||||
$ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN users on ticket_assigned_to = user_id WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id");
|
$ticket_sql = mysqli_query($mysqli,
|
||||||
|
"SELECT * FROM tickets
|
||||||
|
LEFT JOIN users on ticket_assigned_to = user_id
|
||||||
|
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||||
|
WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ticket_row = mysqli_fetch_array($ticket_sql);
|
$ticket_row = mysqli_fetch_array($ticket_sql);
|
||||||
@@ -32,11 +43,12 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
|
|||||||
|
|
||||||
$ticket_prefix = nullable_htmlentities($ticket_row['ticket_prefix']);
|
$ticket_prefix = nullable_htmlentities($ticket_row['ticket_prefix']);
|
||||||
$ticket_number = intval($ticket_row['ticket_number']);
|
$ticket_number = intval($ticket_row['ticket_number']);
|
||||||
$ticket_status = nullable_htmlentities($ticket_row['ticket_status']);
|
$ticket_status = nullable_htmlentities($ticket_row['ticket_status_name']);
|
||||||
$ticket_priority = nullable_htmlentities($ticket_row['ticket_priority']);
|
$ticket_priority = nullable_htmlentities($ticket_row['ticket_priority']);
|
||||||
$ticket_subject = nullable_htmlentities($ticket_row['ticket_subject']);
|
$ticket_subject = nullable_htmlentities($ticket_row['ticket_subject']);
|
||||||
$ticket_details = $purifier->purify($ticket_row['ticket_details']);
|
$ticket_details = $purifier->purify($ticket_row['ticket_details']);
|
||||||
$ticket_assigned_to = nullable_htmlentities($ticket_row['user_name']);
|
$ticket_assigned_to = nullable_htmlentities($ticket_row['user_name']);
|
||||||
|
$ticket_closed_at = nullable_htmlentities($ticket_row['ticket_closed_at']);
|
||||||
$ticket_feedback = nullable_htmlentities($ticket_row['ticket_feedback']);
|
$ticket_feedback = nullable_htmlentities($ticket_row['ticket_feedback']);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -56,7 +68,7 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
|
|||||||
<h4 class="mt-1">
|
<h4 class="mt-1">
|
||||||
Ticket <?php echo $ticket_prefix, $ticket_number ?>
|
Ticket <?php echo $ticket_prefix, $ticket_number ?>
|
||||||
<?php
|
<?php
|
||||||
if ($ticket_status !== "Closed") { ?>
|
if (empty($ticket_closed_at)) { ?>
|
||||||
<a href="portal_post.php?close_ticket=<?php echo $ticket_id; ?>" class="btn btn-sm btn-outline-success float-right text-white confirm-link"><i class="fas fa-fw fa-check text-success"></i> Close ticket</a>
|
<a href="portal_post.php?close_ticket=<?php echo $ticket_id; ?>" class="btn btn-sm btn-outline-success float-right text-white confirm-link"><i class="fas fa-fw fa-check text-success"></i> Close ticket</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</h4>
|
</h4>
|
||||||
@@ -70,7 +82,7 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
|
|||||||
<br>
|
<br>
|
||||||
<strong>Priority:</strong> <?php echo $ticket_priority ?>
|
<strong>Priority:</strong> <?php echo $ticket_priority ?>
|
||||||
<br>
|
<br>
|
||||||
<?php if (!empty($ticket_assigned_to) && $ticket_status !== "Closed") { ?>
|
<?php if (empty($ticket_closed_at)) { ?>
|
||||||
<strong>Assigned to: </strong> <?php echo $ticket_assigned_to ?>
|
<strong>Assigned to: </strong> <?php echo $ticket_assigned_to ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</p>
|
</p>
|
||||||
@@ -81,7 +93,7 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
|
|||||||
|
|
||||||
<!-- Either show the reply comments box, ticket smiley feedback, or thanks for feedback -->
|
<!-- Either show the reply comments box, ticket smiley feedback, or thanks for feedback -->
|
||||||
|
|
||||||
<?php if ($ticket_status !== "Closed") { ?>
|
<?php if (empty($ticket_closed_at)) { ?>
|
||||||
|
|
||||||
<form action="portal_post.php" enctype="multipart/form-data" method="post">
|
<form action="portal_post.php" enctype="multipart/form-data" method="post">
|
||||||
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id ?>">
|
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id ?>">
|
||||||
|
|||||||
@@ -16,19 +16,16 @@ if ($session_contact_primary == 0 && !$session_contact_is_technical_contact) {
|
|||||||
if (!isset($_GET['status'])) {
|
if (!isset($_GET['status'])) {
|
||||||
// If nothing is set, assume we only want to see open tickets
|
// If nothing is set, assume we only want to see open tickets
|
||||||
$status = 'Open';
|
$status = 'Open';
|
||||||
$ticket_status_snippet = "ticket_status != 'Closed'";
|
$ticket_status_snippet = "ticket_status != 5";
|
||||||
} elseif (isset($_GET['status']) && ($_GET['status']) == 'Open') {
|
|
||||||
$status = 'Open';
|
|
||||||
$ticket_status_snippet = "ticket_status != 'Closed'";
|
|
||||||
} elseif (isset($_GET['status']) && ($_GET['status']) == 'Closed') {
|
} elseif (isset($_GET['status']) && ($_GET['status']) == 'Closed') {
|
||||||
$status = 'Closed';
|
$status = 'Closed';
|
||||||
$ticket_status_snippet = "ticket_status = 'Closed'";
|
$ticket_status_snippet = "ticket_status = 5";
|
||||||
} else {
|
} else {
|
||||||
$status = '%';
|
$status = '%';
|
||||||
$ticket_status_snippet = "ticket_status LIKE '%'";
|
$ticket_status_snippet = "ticket_status LIKE '%'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$all_tickets = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN contacts ON ticket_contact_id = contact_id WHERE $ticket_status_snippet AND ticket_client_id = $session_client_id ORDER BY ticket_id DESC");
|
$all_tickets = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN contacts ON ticket_contact_id = contact_id LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id WHERE $ticket_status_snippet AND ticket_client_id = $session_client_id ORDER BY ticket_id DESC");
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<h2>All tickets</h2>
|
<h2>All tickets</h2>
|
||||||
@@ -61,7 +58,7 @@ $all_tickets = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN contacts O
|
|||||||
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
|
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
|
||||||
$ticket_number = intval($row['ticket_number']);
|
$ticket_number = intval($row['ticket_number']);
|
||||||
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
||||||
$ticket_status = nullable_htmlentities($row['ticket_status']);
|
$ticket_status = nullable_htmlentities($row['ticket_status_name']);
|
||||||
$ticket_contact_name = nullable_htmlentities($row['contact_name']);
|
$ticket_contact_name = nullable_htmlentities($row['contact_name']);
|
||||||
|
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
|
|||||||
@@ -13,32 +13,29 @@ require_once "inc_portal.php";
|
|||||||
if (!isset($_GET['status'])) {
|
if (!isset($_GET['status'])) {
|
||||||
// If nothing is set, assume we only want to see open tickets
|
// If nothing is set, assume we only want to see open tickets
|
||||||
$status = 'Open';
|
$status = 'Open';
|
||||||
$ticket_status_snippet = "ticket_status != 'Closed'";
|
$ticket_status_snippet = "ticket_status != 5 AND ticket_status != 'Closed'";
|
||||||
} elseif (isset($_GET['status']) && ($_GET['status']) == 'Open') {
|
|
||||||
$status = 'Open';
|
|
||||||
$ticket_status_snippet = "ticket_status != 'Closed'";
|
|
||||||
} elseif (isset($_GET['status']) && ($_GET['status']) == 'Closed') {
|
} elseif (isset($_GET['status']) && ($_GET['status']) == 'Closed') {
|
||||||
$status = 'Closed';
|
$status = 'Closed';
|
||||||
$ticket_status_snippet = "ticket_status = 'Closed'";
|
$ticket_status_snippet = "ticket_status = 5 OR ticket_status = 'Closed'";
|
||||||
} else {
|
} else {
|
||||||
$status = '%';
|
$status = '%';
|
||||||
$ticket_status_snippet = "ticket_status LIKE '%'";
|
$ticket_status_snippet = "ticket_status LIKE '%'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact_tickets = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN contacts ON ticket_contact_id = contact_id WHERE $ticket_status_snippet AND ticket_contact_id = $session_contact_id AND ticket_client_id = $session_client_id ORDER BY ticket_id DESC");
|
$contact_tickets = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN contacts ON ticket_contact_id = contact_id LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id WHERE $ticket_status_snippet AND ticket_contact_id = $session_contact_id AND ticket_client_id = $session_client_id ORDER BY ticket_id DESC");
|
||||||
|
|
||||||
//Get Total tickets closed
|
//Get Total tickets closed
|
||||||
$sql_total_tickets_closed = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_closed FROM tickets WHERE ticket_status = 'Closed' AND ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id");
|
$sql_total_tickets_closed = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_closed FROM tickets WHERE ticket_closed_at IS NOT NULL AND ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id");
|
||||||
$row = mysqli_fetch_array($sql_total_tickets_closed);
|
$row = mysqli_fetch_array($sql_total_tickets_closed);
|
||||||
$total_tickets_closed = intval($row['total_tickets_closed']);
|
$total_tickets_closed = intval($row['total_tickets_closed']);
|
||||||
|
|
||||||
//Get Total tickets open
|
//Get Total tickets open
|
||||||
$sql_total_tickets_open = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_status != 'Closed' AND ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id");
|
$sql_total_tickets_open = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_closed_at IS NULL AND ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id");
|
||||||
$row = mysqli_fetch_array($sql_total_tickets_open);
|
$row = mysqli_fetch_array($sql_total_tickets_open);
|
||||||
$total_tickets_open = intval($row['total_tickets_open']);
|
$total_tickets_open = intval($row['total_tickets_open']);
|
||||||
|
|
||||||
//Get Total tickets
|
//Get Total tickets
|
||||||
$sql_total_tickets = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets FROM tickets WHERE ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id");
|
$sql_total_tickets = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets FROM tickets WHERE ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id");
|
||||||
$row = mysqli_fetch_array($sql_total_tickets);
|
$row = mysqli_fetch_array($sql_total_tickets);
|
||||||
$total_tickets = intval($row['total_tickets']);
|
$total_tickets = intval($row['total_tickets']);
|
||||||
|
|
||||||
@@ -65,7 +62,7 @@ $total_tickets = intval($row['total_tickets']);
|
|||||||
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
|
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
|
||||||
$ticket_number = intval($row['ticket_number']);
|
$ticket_number = intval($row['ticket_number']);
|
||||||
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
||||||
$ticket_status = nullable_htmlentities($row['ticket_status']);
|
$ticket_status = nullable_htmlentities($row['ticket_status_name']);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ if (isset($_POST['add_ticket'])) {
|
|||||||
$client_id = intval($_POST['client']);
|
$client_id = intval($_POST['client']);
|
||||||
$assigned_to = intval($_POST['assigned_to']);
|
$assigned_to = intval($_POST['assigned_to']);
|
||||||
if ($assigned_to == 0) {
|
if ($assigned_to == 0) {
|
||||||
$ticket_status = 'New';
|
$ticket_status = 1;
|
||||||
} else {
|
} else {
|
||||||
$ticket_status = 'Open';
|
$ticket_status = 2;
|
||||||
}
|
}
|
||||||
$contact = intval($_POST['contact']);
|
$contact = intval($_POST['contact']);
|
||||||
$subject = sanitizeInput($_POST['subject']);
|
$subject = sanitizeInput($_POST['subject']);
|
||||||
@@ -63,7 +63,7 @@ if (isset($_POST['add_ticket'])) {
|
|||||||
// Check that task_name is not-empty (For some reason the !empty on the array doesnt work here like in watchers)
|
// Check that task_name is not-empty (For some reason the !empty on the array doesnt work here like in watchers)
|
||||||
if (!empty($task_name)) {
|
if (!empty($task_name)) {
|
||||||
mysqli_query($mysqli,"INSERT INTO tasks SET task_name = '$task_name', task_ticket_id = $ticket_id");
|
mysqli_query($mysqli,"INSERT INTO tasks SET task_name = '$task_name', task_ticket_id = $ticket_id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,6 +94,7 @@ if (isset($_POST['add_ticket'])) {
|
|||||||
$ticket_details = mysqli_escape_string($mysqli, $row['ticket_details']);
|
$ticket_details = mysqli_escape_string($mysqli, $row['ticket_details']);
|
||||||
$ticket_priority = sanitizeInput($row['ticket_priority']);
|
$ticket_priority = sanitizeInput($row['ticket_priority']);
|
||||||
$ticket_status = sanitizeInput($row['ticket_status']);
|
$ticket_status = sanitizeInput($row['ticket_status']);
|
||||||
|
$ticket_status_name = sanitizeInput(getTicketStatusName($row['ticket_status']));
|
||||||
$client_id = intval($row['ticket_client_id']);
|
$client_id = intval($row['ticket_client_id']);
|
||||||
$ticket_created_by = intval($row['ticket_created_by']);
|
$ticket_created_by = intval($row['ticket_created_by']);
|
||||||
$ticket_assigned_to = intval($row['ticket_assigned_to']);
|
$ticket_assigned_to = intval($row['ticket_assigned_to']);
|
||||||
@@ -343,8 +344,10 @@ if (isset($_POST['assign_ticket'])) {
|
|||||||
$ticket_id = intval($_POST['ticket_id']);
|
$ticket_id = intval($_POST['ticket_id']);
|
||||||
$assigned_to = intval($_POST['assigned_to']);
|
$assigned_to = intval($_POST['assigned_to']);
|
||||||
$ticket_status = sanitizeInput($_POST['ticket_status']);
|
$ticket_status = sanitizeInput($_POST['ticket_status']);
|
||||||
if ($ticket_status == 'New' && $assigned_to !== 0) {
|
|
||||||
$ticket_status = 'Open';
|
// New > Open as assigned
|
||||||
|
if ($ticket_status == 1 && $assigned_to !== 0) {
|
||||||
|
$ticket_status = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow for un-assigning tickets
|
// Allow for un-assigning tickets
|
||||||
@@ -369,7 +372,7 @@ if (isset($_POST['assign_ticket'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get & verify ticket details
|
// Get & verify ticket details
|
||||||
$ticket_details_sql = mysqli_query($mysqli, "SELECT ticket_prefix, ticket_number, ticket_subject, ticket_client_id, client_name FROM tickets LEFT JOIN clients ON ticket_client_id = client_id WHERE ticket_id = '$ticket_id' AND ticket_status != 'Closed'");
|
$ticket_details_sql = mysqli_query($mysqli, "SELECT ticket_prefix, ticket_number, ticket_subject, ticket_client_id, client_name FROM tickets LEFT JOIN clients ON ticket_client_id = client_id WHERE ticket_id = '$ticket_id' AND ticket_status != 5");
|
||||||
$ticket_details = mysqli_fetch_array($ticket_details_sql);
|
$ticket_details = mysqli_fetch_array($ticket_details_sql);
|
||||||
|
|
||||||
$ticket_prefix = sanitizeInput($ticket_details['ticket_prefix']);
|
$ticket_prefix = sanitizeInput($ticket_details['ticket_prefix']);
|
||||||
@@ -439,15 +442,16 @@ if (isset($_GET['delete_ticket'])) {
|
|||||||
$ticket_id = intval($_GET['delete_ticket']);
|
$ticket_id = intval($_GET['delete_ticket']);
|
||||||
|
|
||||||
// Get Ticket and Client ID for logging and alert message
|
// Get Ticket and Client ID for logging and alert message
|
||||||
$sql = mysqli_query($mysqli, "SELECT ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_client_id FROM tickets WHERE ticket_id = $ticket_id");
|
$sql = mysqli_query($mysqli, "SELECT ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_closed_at, ticket_client_id FROM tickets WHERE ticket_id = $ticket_id");
|
||||||
$row = mysqli_fetch_array($sql);
|
$row = mysqli_fetch_array($sql);
|
||||||
$ticket_prefix = sanitizeInput($row['ticket_prefix']);
|
$ticket_prefix = sanitizeInput($row['ticket_prefix']);
|
||||||
$ticket_number = sanitizeInput($row['ticket_number']);
|
$ticket_number = sanitizeInput($row['ticket_number']);
|
||||||
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
||||||
$ticket_status = sanitizeInput($row['ticket_status']);
|
$ticket_status = sanitizeInput($row['ticket_status']);
|
||||||
|
$ticket_closed_at = sanitizeInput($row['ticket_closed_at']);
|
||||||
$client_id = intval($row['ticket_client_id']);
|
$client_id = intval($row['ticket_client_id']);
|
||||||
|
|
||||||
if ($ticket_status !== 'Closed') {
|
if (empty($ticket_closed_at)) {
|
||||||
mysqli_query($mysqli, "DELETE FROM tickets WHERE ticket_id = $ticket_id");
|
mysqli_query($mysqli, "DELETE FROM tickets WHERE ticket_id = $ticket_id");
|
||||||
|
|
||||||
// Delete all ticket replies
|
// Delete all ticket replies
|
||||||
@@ -491,8 +495,8 @@ if (isset($_POST['bulk_assign_ticket'])) {
|
|||||||
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
||||||
$client_id = intval($row['ticket_client_id']);
|
$client_id = intval($row['ticket_client_id']);
|
||||||
|
|
||||||
if ($ticket_status == 'New' && $assigned_to !== 0) {
|
if ($ticket_status == 1 && $assigned_to !== 0) {
|
||||||
$ticket_status = 'Open';
|
$ticket_status = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow for un-assigning tickets
|
// Allow for un-assigning tickets
|
||||||
@@ -634,7 +638,7 @@ if (isset($_POST['bulk_close_tickets'])) {
|
|||||||
|
|
||||||
$ticket_prefix = sanitizeInput($row['ticket_prefix']);
|
$ticket_prefix = sanitizeInput($row['ticket_prefix']);
|
||||||
$ticket_number = intval($row['ticket_number']);
|
$ticket_number = intval($row['ticket_number']);
|
||||||
$ticket_status = sanitizeInput($row['ticket_status']);
|
$ticket_status = sanitizeInput(getTicketStatusName($row['ticket_status']));
|
||||||
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
||||||
$current_ticket_priority = sanitizeInput($row['ticket_priority']);
|
$current_ticket_priority = sanitizeInput($row['ticket_priority']);
|
||||||
$client_id = intval($row['ticket_client_id']);
|
$client_id = intval($row['ticket_client_id']);
|
||||||
@@ -726,6 +730,7 @@ if (isset($_POST['bulk_ticket_reply'])) {
|
|||||||
// POST variables
|
// POST variables
|
||||||
$ticket_reply = mysqli_escape_string($mysqli, $_POST['bulk_reply_details']);
|
$ticket_reply = mysqli_escape_string($mysqli, $_POST['bulk_reply_details']);
|
||||||
$ticket_status = sanitizeInput($_POST['bulk_status']);
|
$ticket_status = sanitizeInput($_POST['bulk_status']);
|
||||||
|
$ticket_status_name = sanitizeInput(getTicketStatusName($row['ticket_status']));
|
||||||
$private_note = intval($_POST['bulk_private_reply']);
|
$private_note = intval($_POST['bulk_private_reply']);
|
||||||
if ($private_note == 1) {
|
if ($private_note == 1) {
|
||||||
$ticket_reply_type = 'Internal';
|
$ticket_reply_type = 'Internal';
|
||||||
@@ -793,7 +798,7 @@ if (isset($_POST['bulk_ticket_reply'])) {
|
|||||||
if (filter_var($contact_email, FILTER_VALIDATE_EMAIL)) {
|
if (filter_var($contact_email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
|
||||||
$subject = "Ticket update - [$ticket_prefix$ticket_number] - $ticket_subject";
|
$subject = "Ticket update - [$ticket_prefix$ticket_number] - $ticket_subject";
|
||||||
$body = "<i style=\'color: #808080\'>##- Please type your reply above this line -##</i><br><br>Hello $contact_name,<br><br>Your ticket regarding $ticket_subject has been updated.<br><br>--------------------------------<br>$ticket_reply<br>--------------------------------<br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status<br>Portal: https://$base_url/portal/ticket.php?id=$ticket_id<br><br>--<br>$company_name - Support<br>$from_email<br>$company_phone";
|
$body = "<i style=\'color: #808080\'>##- Please type your reply above this line -##</i><br><br>Hello $contact_name,<br><br>Your ticket regarding $ticket_subject has been updated.<br><br>--------------------------------<br>$ticket_reply<br>--------------------------------<br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status_name<br>Portal: https://$base_url/portal/ticket.php?id=$ticket_id<br><br>--<br>$company_name - Support<br>$from_email<br>$company_phone";
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
@@ -854,15 +859,13 @@ if (isset($_POST['add_ticket_reply'])) {
|
|||||||
|
|
||||||
$ticket_id = intval($_POST['ticket_id']);
|
$ticket_id = intval($_POST['ticket_id']);
|
||||||
$ticket_reply = mysqli_real_escape_string($mysqli, $_POST['ticket_reply']);
|
$ticket_reply = mysqli_real_escape_string($mysqli, $_POST['ticket_reply']);
|
||||||
$ticket_status = sanitizeInput($_POST['status']);
|
$ticket_status = intval($_POST['status']);
|
||||||
|
$ticket_status_name = sanitizeInput(getTicketStatusName($row['ticket_status']));
|
||||||
// Handle the time inputs for hours, minutes, and seconds
|
// Handle the time inputs for hours, minutes, and seconds
|
||||||
$hours = intval($_POST['hours']);
|
$hours = intval($_POST['hours']);
|
||||||
$minutes = intval($_POST['minutes']);
|
$minutes = intval($_POST['minutes']);
|
||||||
$seconds = intval($_POST['seconds']);
|
$seconds = intval($_POST['seconds']);
|
||||||
|
|
||||||
//var_dump($_POST);
|
|
||||||
//exit;
|
|
||||||
|
|
||||||
// Combine into a single time string
|
// Combine into a single time string
|
||||||
$ticket_reply_time_worked = sanitizeInput(sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds));
|
$ticket_reply_time_worked = sanitizeInput(sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds));
|
||||||
|
|
||||||
@@ -880,9 +883,10 @@ if (isset($_POST['add_ticket_reply'])) {
|
|||||||
$ticket_reply_id = mysqli_insert_id($mysqli);
|
$ticket_reply_id = mysqli_insert_id($mysqli);
|
||||||
|
|
||||||
// Update Ticket Last Response Field
|
// Update Ticket Last Response Field
|
||||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = '$ticket_status' WHERE ticket_id = $ticket_id");
|
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = $ticket_status WHERE ticket_id = $ticket_id");
|
||||||
|
|
||||||
if ($ticket_status == 'Closed') {
|
// CLose the ticket, if set
|
||||||
|
if ($ticket_status == 5) {
|
||||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_closed_at = NOW() WHERE ticket_id = $ticket_id");
|
mysqli_query($mysqli, "UPDATE tickets SET ticket_closed_at = NOW() WHERE ticket_id = $ticket_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,15 +926,15 @@ if (isset($_POST['add_ticket_reply'])) {
|
|||||||
|
|
||||||
// Slightly different email subject/text depending on if this update closed the ticket or not
|
// Slightly different email subject/text depending on if this update closed the ticket or not
|
||||||
|
|
||||||
if ($ticket_status == 'Closed') {
|
if ($ticket_status == 5) {
|
||||||
$subject = "Ticket closed - [$ticket_prefix$ticket_number] - $ticket_subject | (do not reply)";
|
$subject = "Ticket closed - [$ticket_prefix$ticket_number] - $ticket_subject | (do not reply)";
|
||||||
$body = "Hello $contact_name,<br><br>Your ticket regarding $ticket_subject has been closed.<br><br>--------------------------------<br>$ticket_reply<br>--------------------------------<br><br>We hope the request/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. <br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id<br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
|
$body = "Hello $contact_name,<br><br>Your ticket regarding $ticket_subject has been closed.<br><br>--------------------------------<br>$ticket_reply<br>--------------------------------<br><br>We hope the request/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. <br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id<br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
|
||||||
} elseif ($ticket_status == 'Auto Close') {
|
} elseif ($ticket_status == 4) {
|
||||||
$subject = "Ticket update - [$ticket_prefix$ticket_number] - $ticket_subject | (pending closure)";
|
$subject = "Ticket update - [$ticket_prefix$ticket_number] - $ticket_subject | (pending closure)";
|
||||||
$body = "<i style=\'color: #808080\'>##- Please type your reply above this line -##</i><br><br>Hello $contact_name,<br><br>Your ticket regarding $ticket_subject has been updated and is pending closure.<br><br>--------------------------------<br>$ticket_reply<br>--------------------------------<br><br>If your request/issue is resolved, you can simply ignore this email. If you need further assistance, please respond to let us know! <br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status<br>Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id<br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
|
$body = "<i style=\'color: #808080\'>##- Please type your reply above this line -##</i><br><br>Hello $contact_name,<br><br>Your ticket regarding $ticket_subject has been updated and is pending closure.<br><br>--------------------------------<br>$ticket_reply<br>--------------------------------<br><br>If your request/issue is resolved, you can simply ignore this email. If you need further assistance, please respond to let us know! <br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status_name<br>Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id<br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
|
||||||
} else {
|
} else {
|
||||||
$subject = "Ticket update - [$ticket_prefix$ticket_number] - $ticket_subject";
|
$subject = "Ticket update - [$ticket_prefix$ticket_number] - $ticket_subject";
|
||||||
$body = "<i style=\'color: #808080\'>##- Please type your reply above this line -##</i><br><br>Hello $contact_name,<br><br>Your ticket regarding $ticket_subject has been updated.<br><br>--------------------------------<br>$ticket_reply<br>--------------------------------<br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status<br>Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id<br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
|
$body = "<i style=\'color: #808080\'>##- Please type your reply above this line -##</i><br><br>Hello $contact_name,<br><br>Your ticket regarding $ticket_subject has been updated.<br><br>--------------------------------<br>$ticket_reply<br>--------------------------------<br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status_name<br>Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id<br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|||||||
@@ -94,12 +94,12 @@ $sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients
|
|||||||
$ticket_raised_count = intval($row['ticket_raised_count']);
|
$ticket_raised_count = intval($row['ticket_raised_count']);
|
||||||
|
|
||||||
// Calculate total tickets raised in period that are closed
|
// Calculate total tickets raised in period that are closed
|
||||||
$sql_ticket_closed_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS ticket_closed_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_client_id = $client_id AND ticket_status = 'Closed'");
|
$sql_ticket_closed_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS ticket_closed_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_client_id = $client_id AND ticket_closed_at IS NOT NULL");
|
||||||
$row = mysqli_fetch_array($sql_ticket_closed_count);
|
$row = mysqli_fetch_array($sql_ticket_closed_count);
|
||||||
$ticket_closed_count = intval($row['ticket_closed_count']);
|
$ticket_closed_count = intval($row['ticket_closed_count']);
|
||||||
|
|
||||||
// Used to calculate average time to close tickets that were raised in period specified
|
// Used to calculate average time to close tickets that were raised in period specified
|
||||||
$sql_tickets = mysqli_query($mysqli, "SELECT ticket_created_at, ticket_closed_at FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_client_id = $client_id AND ticket_status = 'Closed' AND ticket_closed_at IS NOT NULL");
|
$sql_tickets = mysqli_query($mysqli, "SELECT ticket_created_at, ticket_closed_at FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_client_id = $client_id AND ticket_closed_at IS NOT NULL");
|
||||||
|
|
||||||
if ($ticket_raised_count > 0) {
|
if ($ticket_raised_count > 0) {
|
||||||
|
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ if (isset($_POST['add_company_settings'])) {
|
|||||||
unlink('uploads/tmp/cronkey.php');
|
unlink('uploads/tmp/cronkey.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create Main Account Types
|
// Create Main Account Types
|
||||||
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Asset', account_type_parent = 1, account_type_description = 'Assets are economic resources which are expected to benefit the business in the future.'");
|
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Asset', account_type_parent = 1, account_type_description = 'Assets are economic resources which are expected to benefit the business in the future.'");
|
||||||
@@ -295,6 +295,12 @@ if (isset($_POST['add_company_settings'])) {
|
|||||||
//Create Calendar
|
//Create Calendar
|
||||||
mysqli_query($mysqli,"INSERT INTO calendars SET calendar_name = 'Default', calendar_color = 'blue'");
|
mysqli_query($mysqli,"INSERT INTO calendars SET calendar_name = 'Default', calendar_color = 'blue'");
|
||||||
|
|
||||||
|
// Add default ticket statuses
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'New', ticket_status_color = 'danger'"); // Default ID for new tickets is 1
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'Open', ticket_status_color = 'primary'"); // 2
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'On Hold', ticket_status_color = 'success'"); // 3
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'Auto Close', ticket_status_color = 'success'"); // 4
|
||||||
|
mysqli_query($mysqli, "INSERT INTO ticket_statuses SET ticket_status_name = 'Closed', ticket_status_color = 'dark'"); // 5
|
||||||
|
|
||||||
|
|
||||||
$_SESSION['alert_message'] = "Company <strong>$name</strong> created!";
|
$_SESSION['alert_message'] = "Company <strong>$name</strong> created!";
|
||||||
|
|||||||
66
ticket.php
66
ticket.php
@@ -27,6 +27,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
LEFT JOIN locations ON ticket_location_id = location_id
|
LEFT JOIN locations ON ticket_location_id = location_id
|
||||||
LEFT JOIN assets ON ticket_asset_id = asset_id
|
LEFT JOIN assets ON ticket_asset_id = asset_id
|
||||||
LEFT JOIN vendors ON ticket_vendor_id = vendor_id
|
LEFT JOIN vendors ON ticket_vendor_id = vendor_id
|
||||||
|
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||||
WHERE ticket_id = $ticket_id LIMIT 1"
|
WHERE ticket_id = $ticket_id LIMIT 1"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -76,8 +77,9 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
}
|
}
|
||||||
$ticket_feedback = nullable_htmlentities($row['ticket_feedback']);
|
$ticket_feedback = nullable_htmlentities($row['ticket_feedback']);
|
||||||
|
|
||||||
$ticket_status = nullable_htmlentities($row['ticket_status']);
|
$ticket_status = intval($row['ticket_status_id']);
|
||||||
$ticket_status_color = getTicketStatusColor($ticket_status);
|
$ticket_status_name = nullable_htmlentities($row['ticket_status_name']);
|
||||||
|
$ticket_status_color = nullable_htmlentities($row['ticket_status_color']);
|
||||||
|
|
||||||
$ticket_vendor_ticket_number = nullable_htmlentities($row['ticket_vendor_ticket_number']);
|
$ticket_vendor_ticket_number = nullable_htmlentities($row['ticket_vendor_ticket_number']);
|
||||||
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
|
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
|
||||||
@@ -261,15 +263,16 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
</ol>
|
</ol>
|
||||||
<div class="card card-body">
|
<div class="card card-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-7">
|
<div class="col-7">
|
||||||
<h3><i class="fas fa-fw fa-life-ring text-secondary mr-2"></i>Ticket <?php echo "$ticket_prefix$ticket_number"; ?> <span class='p-2 badge badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status ?></span></h3>
|
<h3><i class="fas fa-fw fa-life-ring text-secondary mr-2"></i>Ticket <?php echo "$ticket_prefix$ticket_number"; ?> <span class='p-2 badge badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status_name ?></span></h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-5">
|
<div class="col-5">
|
||||||
|
|
||||||
<div class="btn-group float-right d-print-none">
|
<div class="btn-group float-right d-print-none">
|
||||||
|
|
||||||
<?php if ($ticket_status !== "Closed") { ?>
|
<?php if (empty($ticket_closed_at)) { ?>
|
||||||
<div class="dropdown dropleft text-center mr-3">
|
<div class="dropdown dropleft text-center mr-3">
|
||||||
<button class="btn btn-default btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown">
|
<button class="btn btn-default btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown">
|
||||||
<i class="fas fa-fw fa-plus mr-2"></i>Add
|
<i class="fas fa-fw fa-plus mr-2"></i>Add
|
||||||
@@ -301,11 +304,11 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
</a>
|
</a>
|
||||||
<?php }
|
<?php }
|
||||||
|
|
||||||
if ($ticket_status !== "Closed") { ?>
|
if (empty($ticket_closed_at)) { ?>
|
||||||
<a href="post.php?close_ticket=<?php echo $ticket_id; ?>" class="btn btn-secondary btn-sm confirm-link" id="ticket_close">
|
<a href="post.php?close_ticket=<?php echo $ticket_id; ?>" class="btn btn-secondary btn-sm confirm-link" id="ticket_close">
|
||||||
<i class="fas fa-fw fa-gavel mr-2"></i>Close
|
<i class="fas fa-fw fa-gavel mr-2"></i>Close
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="dropdown dropleft text-center ml-3">
|
<div class="dropdown dropleft text-center ml-3">
|
||||||
<button class="btn btn-secondary btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown">
|
<button class="btn btn-secondary btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown">
|
||||||
<i class="fas fa-fw fa-ellipsis-v"></i>
|
<i class="fas fa-fw fa-ellipsis-v"></i>
|
||||||
@@ -360,12 +363,12 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Only show ticket reply modal if status is not closed -->
|
<!-- Only show ticket reply modal if status is not closed -->
|
||||||
<?php if ($ticket_status != "Closed") { ?>
|
<?php if (empty($ticket_closed_at)) { ?>
|
||||||
<form class="mb-3 d-print-none" action="post.php" method="post" autocomplete="off">
|
<form class="mb-3 d-print-none" action="post.php" method="post" autocomplete="off">
|
||||||
<input type="hidden" name="ticket_id" id="ticket_id" value="<?php echo $ticket_id; ?>">
|
<input type="hidden" name="ticket_id" id="ticket_id" value="<?php echo $ticket_id; ?>">
|
||||||
<input type="hidden" name="client_id" id="client_id" value="<?php echo $client_id; ?>">
|
<input type="hidden" name="client_id" id="client_id" value="<?php echo $client_id; ?>">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?php if($config_ai_enable) { ?>
|
<?php if ($config_ai_enable) { ?>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<textarea class="form-control tinymceai" id="textInput" name="ticket_reply" placeholder="Type a response"></textarea>
|
<textarea class="form-control tinymceai" id="textInput" name="ticket_reply" placeholder="Type a response"></textarea>
|
||||||
</div>
|
</div>
|
||||||
@@ -388,16 +391,15 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
<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="status" required>
|
<select class="form-control select2" name="status" required>
|
||||||
<option <?php if ($ticket_status == "Open") {
|
|
||||||
echo "selected";
|
<!-- Show all active ticket statuses, apart from new or closed as these are system-managed -->
|
||||||
} ?>>Open</option>
|
<?php $sql_ticket_status = mysqli_query($mysqli, "SELECT * FROM ticket_statuses WHERE ticket_status_id != 1 AND ticket_status_id != 5 AND ticket_status_active = 1");
|
||||||
<option <?php if ($ticket_status == "On Hold") {
|
while ($row = mysqli_fetch_array($sql_ticket_status)) {
|
||||||
echo "selected";
|
$ticket_status_id = intval($row['ticket_status_id']);
|
||||||
} ?>>On Hold</option>
|
$ticket_status_name = nullable_htmlentities($row['ticket_status_name']); ?>
|
||||||
<?php if ($config_ticket_autoclose) { ?>
|
|
||||||
<option <?php if ($ticket_status == 'Auto Close') {
|
<option value="<?php echo $ticket_status_id ?>" <?php if ($ticket_status == $ticket_status_id) { echo 'selected'; } ?>> <?php echo $ticket_status_name ?> </option>
|
||||||
echo "selected";
|
|
||||||
} ?>>Auto Close</option>
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -545,7 +547,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
</div>
|
</div>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<?php if ($ticket_reply_type !== "Client" && $ticket_status !== "Closed") { ?>
|
<?php if ($ticket_reply_type !== "Client" && empty($ticket_closed_at)) { ?>
|
||||||
<div class="card-tools d-print-none">
|
<div class="card-tools d-print-none">
|
||||||
<div class="dropdown dropleft">
|
<div class="dropdown dropleft">
|
||||||
<button class="btn btn-tool" type="button" id="dropdownMenuButton" data-toggle="dropdown">
|
<button class="btn btn-tool" type="button" id="dropdownMenuButton" data-toggle="dropdown">
|
||||||
@@ -608,7 +610,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
|
|
||||||
<!-- Ticket closure info -->
|
<!-- Ticket closure info -->
|
||||||
<?php
|
<?php
|
||||||
if ($ticket_status == "Closed") {
|
if (!empty($ticket_closed_at)) {
|
||||||
$sql_closed_by = mysqli_query($mysqli, "SELECT * FROM tickets, users WHERE ticket_closed_by = user_id");
|
$sql_closed_by = mysqli_query($mysqli, "SELECT * FROM tickets, users WHERE ticket_closed_by = user_id");
|
||||||
$row = mysqli_fetch_array($sql_closed_by);
|
$row = mysqli_fetch_array($sql_closed_by);
|
||||||
$ticket_closed_by_display = nullable_htmlentities($row['user_name']);
|
$ticket_closed_by_display = nullable_htmlentities($row['user_name']);
|
||||||
@@ -624,7 +626,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Ticket scheduling
|
// Ticket scheduling
|
||||||
if ($ticket_status !== "Closed") { ?>
|
if (empty ($ticket_closed_at)) { ?>
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
<i class="fa fa-fw fa-calendar-check text-secondary mr-2"></i>Scheduled: <a href="#" data-toggle="modal" data-target="#editTicketScheduleModal"> <?php echo $ticket_scheduled_wording ?> </a>
|
<i class="fa fa-fw fa-calendar-check text-secondary mr-2"></i>Scheduled: <a href="#" data-toggle="modal" data-target="#editTicketScheduleModal"> <?php echo $ticket_scheduled_wording ?> </a>
|
||||||
</div>
|
</div>
|
||||||
@@ -653,6 +655,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<!-- Assigned to -->
|
<!-- Assigned to -->
|
||||||
<form action="post.php" method="post">
|
<form action="post.php" method="post">
|
||||||
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
|
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
|
||||||
@@ -662,7 +665,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<select onchange="this.form.submit()" class="form-control select2" name="assigned_to" <?php if ($ticket_status == "Closed") { echo "disabled"; } ?>>
|
<select onchange="this.form.submit()" class="form-control select2" name="assigned_to" <?php if (!empty($ticket_closed_at)) { echo "disabled"; } ?>>
|
||||||
<option value="0">Not Assigned</option>
|
<option value="0">Not Assigned</option>
|
||||||
<?php
|
<?php
|
||||||
while ($row = mysqli_fetch_array($sql_assign_to_select)) {
|
while ($row = mysqli_fetch_array($sql_assign_to_select)) {
|
||||||
@@ -671,7 +674,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
<option <?php if ($ticket_assigned_to == $user_id) { echo "selected"; } ?> value="<?php echo $user_id; ?>"><?php echo $user_name; ?></option>
|
<option <?php if ($ticket_assigned_to == $user_id) { echo "selected"; } ?> value="<?php echo $user_id; ?>"><?php echo $user_name; ?></option>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<!-- End Assigned to -->
|
<!-- End Assigned to -->
|
||||||
</div>
|
</div>
|
||||||
@@ -726,7 +729,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
if ($prev_ticket_row) {
|
if ($prev_ticket_row) {
|
||||||
$prev_ticket_id = intval($prev_ticket_row['ticket_id']);
|
$prev_ticket_id = intval($prev_ticket_row['ticket_id']);
|
||||||
$prev_ticket_subject = nullable_htmlentities($prev_ticket_row['ticket_subject']);
|
$prev_ticket_subject = nullable_htmlentities($prev_ticket_row['ticket_subject']);
|
||||||
$prev_ticket_status = nullable_htmlentities($prev_ticket_row['ticket_status']);
|
$prev_ticket_status = nullable_htmlentities( getTicketStatusName($prev_ticket_row['ticket_status']));
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
@@ -787,7 +790,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
</td>
|
</td>
|
||||||
<td><?php echo $task_name; ?></td>
|
<td><?php echo $task_name; ?></td>
|
||||||
<td>
|
<td>
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<div class="dropdown dropleft text-center">
|
<div class="dropdown dropleft text-center">
|
||||||
<button class="btn btn-link text-secondary btn-sm" type="button" data-toggle="dropdown">
|
<button class="btn btn-link text-secondary btn-sm" type="button" data-toggle="dropdown">
|
||||||
@@ -813,7 +816,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
|
|
||||||
|
|
||||||
<!-- Ticket watchers card -->
|
<!-- Ticket watchers card -->
|
||||||
<?php if ($ticket_status !== "Closed" && mysqli_num_rows($sql_ticket_watchers) > 0) { ?>
|
<?php if (empty($ticket_closed_at) && mysqli_num_rows($sql_ticket_watchers) > 0) { ?>
|
||||||
|
|
||||||
<div class="card card-body card-outline card-dark mb-3">
|
<div class="card card-body card-outline card-dark mb-3">
|
||||||
<h5 class="text-secondary">Watchers</h5>
|
<h5 class="text-secondary">Watchers</h5>
|
||||||
@@ -826,7 +829,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
?>
|
?>
|
||||||
<div class='mt-1'>
|
<div class='mt-1'>
|
||||||
<i class="fa fa-fw fa-eye text-secondary mr-2"></i><?php echo $ticket_watcher_email; ?>
|
<i class="fa fa-fw fa-eye text-secondary mr-2"></i><?php echo $ticket_watcher_email; ?>
|
||||||
<?php if ($ticket_status !== "Closed") { ?>
|
<?php if (empty($ticket_closed_at)) { ?>
|
||||||
<a class="confirm-link float-right" href="post.php?delete_ticket_watcher=<?php echo $watcher_id; ?>">
|
<a class="confirm-link float-right" href="post.php?delete_ticket_watcher=<?php echo $watcher_id; ?>">
|
||||||
<i class="fas fa-fw fa-trash-alt text-secondary"></i>
|
<i class="fas fa-fw fa-trash-alt text-secondary"></i>
|
||||||
</a>
|
</a>
|
||||||
@@ -838,7 +841,6 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
<!-- End Ticket watchers card -->
|
<!-- End Ticket watchers card -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Asset card -->
|
<!-- Asset card -->
|
||||||
<?php if ($asset_id) { ?>
|
<?php if ($asset_id) { ?>
|
||||||
<div class="card card-body card-outline card-dark mb-3">
|
<div class="card card-body card-outline card-dark mb-3">
|
||||||
@@ -935,7 +937,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
<?php if ($vendor_id) { ?>
|
<?php if ($vendor_id) { ?>
|
||||||
<div class="card card-body card-outline card-dark mb-3">
|
<div class="card card-body card-outline card-dark mb-3">
|
||||||
<h5 class="text-secondary">Vendor</h5>
|
<h5 class="text-secondary">Vendor</h5>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<i class="fa fa-fw fa-building text-secondary mr-2"></i><strong><?php echo $vendor_name; ?></strong>
|
<i class="fa fa-fw fa-building text-secondary mr-2"></i><strong><?php echo $vendor_name; ?></strong>
|
||||||
</div>
|
</div>
|
||||||
@@ -970,7 +972,7 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
<i class="fa fa-fw fa-globe text-secondary mr-2"></i><?php echo $vendor_website; ?>
|
<i class="fa fa-fw fa-globe text-secondary mr-2"></i><?php echo $vendor_website; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<?php } //End Else ?>
|
<?php } //End Else ?>
|
||||||
<!-- End Vendor card -->
|
<!-- End Vendor card -->
|
||||||
@@ -1013,7 +1015,7 @@ require_once "footer.php";
|
|||||||
|
|
||||||
<script src="js/show_modals.js"></script>
|
<script src="js/show_modals.js"></script>
|
||||||
|
|
||||||
<?php if ($ticket_status !== "Closed") { ?>
|
<?php if (empty($ticket_closed_at)) { ?>
|
||||||
<!-- Ticket Time Tracking JS -->
|
<!-- Ticket Time Tracking JS -->
|
||||||
<script src="js/ticket_time_tracking.js"></script>
|
<script src="js/ticket_time_tracking.js"></script>
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<form action="post.php" method="post" autocomplete="off">
|
<form action="post.php" method="post" autocomplete="off">
|
||||||
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
|
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
|
||||||
<input type="hidden" name="ticket_status" value="<?php echo $ticket_status; ?>">
|
<input type="hidden" name="ticket_status" value="<?php echo $ticket_status_id; ?>">
|
||||||
<div class="modal-body bg-white">
|
<div class="modal-body bg-white">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
101
tickets.php
101
tickets.php
@@ -14,27 +14,29 @@ if (isset($_GET['status']) && is_array($_GET['status']) && !empty($_GET['status'
|
|||||||
$sanitizedStatuses = array();
|
$sanitizedStatuses = array();
|
||||||
foreach ($_GET['status'] as $status) {
|
foreach ($_GET['status'] as $status) {
|
||||||
// Escape each status to prevent SQL injection
|
// Escape each status to prevent SQL injection
|
||||||
$sanitizedStatuses[] = "'" . sanitizeInput($status) . "'";
|
$sanitizedStatuses[] = "'" . intval($status) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the sanitized statuses into a comma-separated string
|
// Convert the sanitized statuses into a comma-separated string
|
||||||
$sanitizedStatusesString = implode(",", $sanitizedStatuses);
|
$sanitizedStatusesString = implode(",", $sanitizedStatuses);
|
||||||
$ticket_status_snippet = "ticket_status IN ($sanitizedStatusesString)";
|
$ticket_status_snippet = "ticket_status IN ($sanitizedStatusesString)";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (isset($_GET['status']) && ($_GET['status']) == 'Open') {
|
if (isset($_GET['status']) && ($_GET['status']) == 'Closed') {
|
||||||
$status = 'Open';
|
|
||||||
$ticket_status_snippet = "ticket_status != 'Closed'";
|
|
||||||
} elseif (isset($_GET['status']) && ($_GET['status']) == 'Closed') {
|
|
||||||
$status = 'Closed';
|
$status = 'Closed';
|
||||||
$ticket_status_snippet = "ticket_status = 'Closed'";
|
$ticket_status_snippet = "ticket_closed_at IS NOT NULL";
|
||||||
} else {
|
} else {
|
||||||
|
// Default - Show open tickets
|
||||||
$status = 'Open';
|
$status = 'Open';
|
||||||
$ticket_status_snippet = "ticket_status != 'Closed'";
|
$ticket_status_snippet = "ticket_closed_at IS NULL";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ticket assignment status filter
|
// Ticket assignment status filter
|
||||||
|
// Default - any
|
||||||
|
$ticket_assigned_query = '';
|
||||||
|
$ticket_assigned_filter_id = '';
|
||||||
if (isset($_GET['assigned']) & !empty($_GET['assigned'])) {
|
if (isset($_GET['assigned']) & !empty($_GET['assigned'])) {
|
||||||
if ($_GET['assigned'] == 'unassigned') {
|
if ($_GET['assigned'] == 'unassigned') {
|
||||||
$ticket_assigned_query = 'AND ticket_assigned_to = 0';
|
$ticket_assigned_query = 'AND ticket_assigned_to = 0';
|
||||||
@@ -43,14 +45,10 @@ if (isset($_GET['assigned']) & !empty($_GET['assigned'])) {
|
|||||||
$ticket_assigned_query = 'AND ticket_assigned_to = ' . intval($_GET['assigned']);
|
$ticket_assigned_query = 'AND ticket_assigned_to = ' . intval($_GET['assigned']);
|
||||||
$ticket_assigned_filter_id = intval($_GET['assigned']);
|
$ticket_assigned_filter_id = intval($_GET['assigned']);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Default - any
|
|
||||||
$ticket_assigned_query = '';
|
|
||||||
$ticket_assigned_filter_id = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Rebuild URL
|
//Rebuild URL
|
||||||
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order, 'status' => $status, 'assigned' => $ticket_assigned_filter)));
|
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order, 'status' => $status, 'assigned' => $ticket_assigned_filter_id)));
|
||||||
|
|
||||||
// Main ticket query:
|
// Main ticket query:
|
||||||
$sql = mysqli_query(
|
$sql = mysqli_query(
|
||||||
@@ -62,6 +60,7 @@ $sql = mysqli_query(
|
|||||||
LEFT JOIN assets ON ticket_asset_id = asset_id
|
LEFT JOIN assets ON ticket_asset_id = asset_id
|
||||||
LEFT JOIN locations ON ticket_location_id = location_id
|
LEFT JOIN locations ON ticket_location_id = location_id
|
||||||
LEFT JOIN vendors ON ticket_vendor_id = vendor_id
|
LEFT JOIN vendors ON ticket_vendor_id = vendor_id
|
||||||
|
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||||
WHERE $ticket_status_snippet " . $ticket_assigned_query . "
|
WHERE $ticket_status_snippet " . $ticket_assigned_query . "
|
||||||
AND DATE(ticket_created_at) BETWEEN '$dtf' AND '$dtt'
|
AND DATE(ticket_created_at) BETWEEN '$dtf' AND '$dtt'
|
||||||
AND (CONCAT(ticket_prefix,ticket_number) LIKE '%$q%' OR client_name LIKE '%$q%' OR ticket_subject LIKE '%$q%' OR ticket_status LIKE '%$q%' OR ticket_priority LIKE '%$q%' OR user_name LIKE '%$q%' OR contact_name LIKE '%$q%' OR asset_name LIKE '%$q%' OR vendor_name LIKE '%$q%' OR ticket_vendor_ticket_number LIKE '%q%')
|
AND (CONCAT(ticket_prefix,ticket_number) LIKE '%$q%' OR client_name LIKE '%$q%' OR ticket_subject LIKE '%$q%' OR ticket_status LIKE '%$q%' OR ticket_priority LIKE '%$q%' OR user_name LIKE '%$q%' OR contact_name LIKE '%$q%' OR asset_name LIKE '%$q%' OR vendor_name LIKE '%$q%' OR ticket_vendor_ticket_number LIKE '%q%')
|
||||||
@@ -71,12 +70,12 @@ $sql = mysqli_query(
|
|||||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
|
|
||||||
//Get Total tickets open
|
//Get Total tickets open
|
||||||
$sql_total_tickets_open = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_status != 'Closed'");
|
$sql_total_tickets_open = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_open FROM tickets WHERE ticket_closed_at IS NULL");
|
||||||
$row = mysqli_fetch_array($sql_total_tickets_open);
|
$row = mysqli_fetch_array($sql_total_tickets_open);
|
||||||
$total_tickets_open = intval($row['total_tickets_open']);
|
$total_tickets_open = intval($row['total_tickets_open']);
|
||||||
|
|
||||||
//Get Total tickets closed
|
//Get Total tickets closed
|
||||||
$sql_total_tickets_closed = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_closed FROM tickets WHERE ticket_status = 'Closed'");
|
$sql_total_tickets_closed = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_closed FROM tickets WHERE ticket_closed_at IS NOT NULL");
|
||||||
$row = mysqli_fetch_array($sql_total_tickets_closed);
|
$row = mysqli_fetch_array($sql_total_tickets_closed);
|
||||||
$total_tickets_closed = intval($row['total_tickets_closed']);
|
$total_tickets_closed = intval($row['total_tickets_closed']);
|
||||||
|
|
||||||
@@ -86,12 +85,12 @@ $row = mysqli_fetch_array($sql_total_scheduled_tickets);
|
|||||||
$total_scheduled_tickets = intval($row['total_scheduled_tickets']);
|
$total_scheduled_tickets = intval($row['total_scheduled_tickets']);
|
||||||
|
|
||||||
//Get Unassigned tickets
|
//Get Unassigned tickets
|
||||||
$sql_total_tickets_unassigned = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_unassigned FROM tickets WHERE ticket_assigned_to = '0' AND ticket_status != 'Closed'");
|
$sql_total_tickets_unassigned = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_unassigned FROM tickets WHERE ticket_assigned_to = '0' AND ticket_closed_at IS NULL");
|
||||||
$row = mysqli_fetch_array($sql_total_tickets_unassigned);
|
$row = mysqli_fetch_array($sql_total_tickets_unassigned);
|
||||||
$total_tickets_unassigned = intval($row['total_tickets_unassigned']);
|
$total_tickets_unassigned = intval($row['total_tickets_unassigned']);
|
||||||
|
|
||||||
//Get Total tickets assigned to me
|
//Get Total tickets assigned to me
|
||||||
$sql_total_tickets_assigned = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_assigned FROM tickets WHERE ticket_assigned_to = $session_user_id AND ticket_status != 'Closed'");
|
$sql_total_tickets_assigned = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS total_tickets_assigned FROM tickets WHERE ticket_assigned_to = $session_user_id AND ticket_closed_at IS NULL");
|
||||||
$row = mysqli_fetch_array($sql_total_tickets_assigned);
|
$row = mysqli_fetch_array($sql_total_tickets_assigned);
|
||||||
$user_active_assigned_tickets = intval($row['total_tickets_assigned']);
|
$user_active_assigned_tickets = intval($row['total_tickets_assigned']);
|
||||||
|
|
||||||
@@ -235,11 +234,15 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Ticket Status</label>
|
<label>Ticket Status</label>
|
||||||
<select onchange="this.form.submit()" class="form-control select2" name="status[]" data-placeholder="Select Status" multiple>
|
<select onchange="this.form.submit()" class="form-control select2" name="status[]" data-placeholder="Select Status" multiple>
|
||||||
<option value="New" <?php if (isset($_GET['status']) && is_array($_GET['status']) && in_array('New', $_GET['status'])) { echo 'selected'; } ?>>New</option>
|
|
||||||
<option value="Open" <?php if (isset($_GET['status']) && is_array($_GET['status']) && in_array('Open', $_GET['status'])) { echo 'selected'; } ?>>Open</option>
|
<?php $sql_ticket_status = mysqli_query($mysqli, "SELECT * FROM ticket_statuses WHERE ticket_status_active = 1");
|
||||||
<option value="On Hold" <?php if (isset($_GET['status']) && is_array($_GET['status']) && in_array('On Hold', $_GET['status'])) { echo 'selected'; } ?>>On Hold</option>
|
while ($row = mysqli_fetch_array($sql_ticket_status)) {
|
||||||
<option value="Auto Close" <?php if (isset($_GET['status']) && is_array($_GET['status']) && in_array('Auto Close', $_GET['status'])) { echo 'selected'; } ?>>Auto Close</option>
|
$ticket_status_id = intval($row['ticket_status_id']);
|
||||||
<option value="Closed" <?php if (isset($_GET['status']) && is_array($_GET['status']) && in_array('Closed', $_GET['status'])) { echo 'selected'; } ?>>Closed</option>
|
$ticket_status_name = nullable_htmlentities($row['ticket_status_name']); ?>
|
||||||
|
|
||||||
|
<option value="<?php echo $ticket_status_id ?>" <?php if (isset($_GET['status']) && is_array($_GET['status']) && in_array($ticket_status_id, $_GET['status'])) { echo 'selected'; } ?>> <?php echo $ticket_status_name ?> </option>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -311,15 +314,18 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
|
|||||||
$ticket_number = intval($row['ticket_number']);
|
$ticket_number = intval($row['ticket_number']);
|
||||||
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
||||||
$ticket_priority = nullable_htmlentities($row['ticket_priority']);
|
$ticket_priority = nullable_htmlentities($row['ticket_priority']);
|
||||||
$ticket_status = nullable_htmlentities($row['ticket_status']);
|
$ticket_status_id = intval($row['ticket_status_id']);
|
||||||
|
$ticket_status_name = nullable_htmlentities($row['ticket_status_name']);
|
||||||
|
$ticket_status_color = nullable_htmlentities($row['ticket_status_color']);
|
||||||
$ticket_billable = intval($row['ticket_billable']);
|
$ticket_billable = intval($row['ticket_billable']);
|
||||||
$ticket_scheduled_for = nullable_htmlentities($row['ticket_schedule']);
|
$ticket_scheduled_for = nullable_htmlentities($row['ticket_schedule']);
|
||||||
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
|
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
|
||||||
$ticket_created_at_time_ago = timeAgo($row['ticket_created_at']);
|
$ticket_created_at_time_ago = timeAgo($row['ticket_created_at']);
|
||||||
$ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']);
|
$ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']);
|
||||||
$ticket_updated_at_time_ago = timeAgo($row['ticket_updated_at']);
|
$ticket_updated_at_time_ago = timeAgo($row['ticket_updated_at']);
|
||||||
|
$ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']);
|
||||||
if (empty($ticket_updated_at)) {
|
if (empty($ticket_updated_at)) {
|
||||||
if ($ticket_status == "Closed") {
|
if (!empty($ticket_closed_at)) {
|
||||||
$ticket_updated_at_display = "<p>Never</p>";
|
$ticket_updated_at_display = "<p>Never</p>";
|
||||||
} else {
|
} else {
|
||||||
$ticket_updated_at_display = "<p class='text-danger'>Never</p>";
|
$ticket_updated_at_display = "<p class='text-danger'>Never</p>";
|
||||||
@@ -327,25 +333,14 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
|
|||||||
} else {
|
} else {
|
||||||
$ticket_updated_at_display = "$ticket_updated_at_time_ago<br><small class='text-secondary'>$ticket_updated_at</small>";
|
$ticket_updated_at_display = "$ticket_updated_at_time_ago<br><small class='text-secondary'>$ticket_updated_at</small>";
|
||||||
}
|
}
|
||||||
$ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']);
|
|
||||||
$project_id = intval($row['ticket_project_id']);
|
$project_id = intval($row['ticket_project_id']);
|
||||||
|
|
||||||
$client_id = intval($row['ticket_client_id']);
|
$client_id = intval($row['ticket_client_id']);
|
||||||
$client_name = nullable_htmlentities($row['client_name']);
|
$client_name = nullable_htmlentities($row['client_name']);
|
||||||
$contact_name = nullable_htmlentities($row['contact_name']);
|
$contact_name = nullable_htmlentities($row['contact_name']);
|
||||||
$contact_email = nullable_htmlentities($row['contact_email']);
|
$contact_email = nullable_htmlentities($row['contact_email']);
|
||||||
|
|
||||||
if ($ticket_status == "New") {
|
|
||||||
$ticket_status_color = "danger";
|
|
||||||
} elseif ($ticket_status == "Open") {
|
|
||||||
$ticket_status_color = "primary";
|
|
||||||
} elseif ($ticket_status == "On Hold") {
|
|
||||||
$ticket_status_color = "success";
|
|
||||||
} elseif ($ticket_status == "Auto Close") {
|
|
||||||
$ticket_status_color = "dark";
|
|
||||||
} elseif ($ticket_status == "Closed") {
|
|
||||||
$ticket_status_color = "dark";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ticket_priority == "High") {
|
if ($ticket_priority == "High") {
|
||||||
$ticket_priority_color = "danger";
|
$ticket_priority_color = "danger";
|
||||||
} elseif ($ticket_priority == "Medium") {
|
} elseif ($ticket_priority == "Medium") {
|
||||||
@@ -356,7 +351,7 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
|
|||||||
|
|
||||||
$ticket_assigned_to = intval($row['ticket_assigned_to']);
|
$ticket_assigned_to = intval($row['ticket_assigned_to']);
|
||||||
if (empty($ticket_assigned_to)) {
|
if (empty($ticket_assigned_to)) {
|
||||||
if ($ticket_status == "Closed") {
|
if (!empty($ticket_closed_at)) {
|
||||||
$ticket_assigned_to_display = "<p>Not Assigned</p>";
|
$ticket_assigned_to_display = "<p>Not Assigned</p>";
|
||||||
} else {
|
} else {
|
||||||
$ticket_assigned_to_display = "<p class='text-danger'>Not Assigned</p>";
|
$ticket_assigned_to_display = "<p class='text-danger'>Not Assigned</p>";
|
||||||
@@ -372,14 +367,20 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get who last updated the ticket - to be shown in the last Response column
|
// Get who last updated the ticket - to be shown in the last Response column
|
||||||
$ticket_reply_type = "Client"; // Default to client for unreplied tickets
|
|
||||||
$ticket_reply_by_display = ""; // Default none
|
// Defaults to prevent undefined errors
|
||||||
$sql_ticket_reply = mysqli_query($mysqli, "SELECT ticket_reply_type, ticket_reply_created_at, contact_name, user_name FROM ticket_replies
|
$ticket_reply_created_at = "";
|
||||||
LEFT JOIN users ON ticket_reply_by = user_id
|
$ticket_reply_created_at_time_ago = "";
|
||||||
LEFT JOIN contacts ON ticket_reply_by = contact_id
|
$ticket_reply_by_display = "";
|
||||||
WHERE ticket_reply_ticket_id = $ticket_id
|
$ticket_reply_type = "Client"; // Default to client for un-replied tickets
|
||||||
AND ticket_reply_archived_at IS NULL
|
|
||||||
ORDER BY ticket_reply_id DESC LIMIT 1"
|
$sql_ticket_reply = mysqli_query($mysqli,
|
||||||
|
"SELECT ticket_reply_type, ticket_reply_created_at, contact_name, user_name FROM ticket_replies
|
||||||
|
LEFT JOIN users ON ticket_reply_by = user_id
|
||||||
|
LEFT JOIN contacts ON ticket_reply_by = contact_id
|
||||||
|
WHERE ticket_reply_ticket_id = $ticket_id
|
||||||
|
AND ticket_reply_archived_at IS NULL
|
||||||
|
ORDER BY ticket_reply_id DESC LIMIT 1"
|
||||||
);
|
);
|
||||||
$row = mysqli_fetch_array($sql_ticket_reply);
|
$row = mysqli_fetch_array($sql_ticket_reply);
|
||||||
|
|
||||||
@@ -396,11 +397,11 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<tr class="<?php if(empty($ticket_reply_created_at)) { echo "text-bold"; }?> <?php if ($ticket_reply_type == "Client") { echo "table-warning"; } ?>">
|
<tr class="<?php if(empty($ticket_closed_at) && empty($ticket_updated_at)) { echo "text-bold"; }?> <?php if (empty($ticket_closed_at) && $ticket_reply_type == "Client") { echo "table-warning"; } ?>">
|
||||||
|
|
||||||
<!-- Ticket Bulk Select -->
|
<!-- Ticket Bulk Select (for open tickets) -->
|
||||||
<td>
|
<td>
|
||||||
<?php if ($ticket_status !== "Closed") { ?>
|
<?php if (empty($ticket_closed_at)) { ?>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input bulk-select" type="checkbox" name="ticket_ids[]" value="<?php echo $ticket_id ?>">
|
<input class="form-check-input bulk-select" type="checkbox" name="ticket_ids[]" value="<?php echo $ticket_id ?>">
|
||||||
</div>
|
</div>
|
||||||
@@ -447,7 +448,7 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
|
|||||||
|
|
||||||
<!-- Ticket Status -->
|
<!-- Ticket Status -->
|
||||||
<td>
|
<td>
|
||||||
<span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status; ?></span> <?php if ($ticket_status == 'On Hold' && isset ($ticket_scheduled_for)) { echo "<div class=\"mt-1\"> <small class='text-secondary'> $ticket_scheduled_for </small></div>"; } ?>
|
<span class='p-2 badge badge-pill badge-<?php echo $ticket_status_color; ?>'><?php echo $ticket_status_name; ?></span> <?php if (isset ($ticket_scheduled_for)) { echo "<div class=\"mt-1\"> <small class='text-secondary'> $ticket_scheduled_for </small></div>"; } ?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<!-- Ticket Assigned agent -->
|
<!-- Ticket Assigned agent -->
|
||||||
@@ -472,7 +473,7 @@ $user_active_assigned_tickets = intval($row['total_tickets_assigned']);
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Edit actions, for open tickets
|
// Edit actions, for open tickets
|
||||||
if ($ticket_status !== "Closed") {
|
if (empty($ticket_closed_at)) {
|
||||||
|
|
||||||
require "ticket_assign_modal.php";
|
require "ticket_assign_modal.php";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user