Tidying/General quality of life updates

General quality of life updates:

- Ticket contact edit: 'No one' should be logged when ticket isn't associated with any contact, rather than a blank space; also fix email content
- Ticket portal/guest: Only show 'Assigned to' if someone is actually assigned
- Ticket tasks: Don't allow adding/modifying tasks for tickets in a resolved state
- Portal contacts: Properly align word 'Contacts' in a similar way all other page headings are aligned
- Client PDF export/handover: Now opens in a new self-closing window
This commit is contained in:
Marcus Hill 2024-12-28 01:12:59 +00:00
parent a2f0f392be
commit c85626a937
7 changed files with 44 additions and 39 deletions

View File

@ -7,13 +7,13 @@
<span>&times;</span> <span>&times;</span>
</button> </button>
</div> </div>
<form action="post.php" method="post" autocomplete="off"> <form action="post.php" method="post" autocomplete="off" target="_blank">
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>"> <input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<div class="modal-body bg-white"> <div class="modal-body bg-white">
<ul class="list-group"> <ul class="list-group">
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<li class="list-group-item"> <li class="list-group-item">
<div class="custom-control custom-checkbox"> <div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="contacts" name="export_contacts" value="1" checked> <input class="custom-control-input" type="checkbox" id="contacts" name="export_contacts" value="1" checked>
@ -98,7 +98,7 @@
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<li class="list-group-item"> <li class="list-group-item">
<div class="custom-control custom-checkbox"> <div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="scheduled_tickets" name="export_scheduled_tickets" value="1" checked> <input class="custom-control-input" type="checkbox" id="scheduled_tickets" name="export_scheduled_tickets" value="1" checked>
@ -170,7 +170,7 @@
</label> </label>
</div> </div>
</li> </li>
</div> </div>
</div> </div>
</ul> </ul>

View File

@ -80,7 +80,7 @@ if ($ticket_row) {
<br> <br>
<strong>Priority:</strong> <?php echo $ticket_priority ?> <strong>Priority:</strong> <?php echo $ticket_priority ?>
<br> <br>
<?php if (empty($ticket_closed_at)) { ?> <?php if (!empty($ticket_assigned_to) && 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>

View File

@ -17,8 +17,10 @@ $contacts_sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_
?> ?>
<div class="row"> <div class="row">
<h3>Contacts</h3> <div class="col">
<div class="col offset-7"> <h3>Contacts</h3>
</div>
<div class="col offset-6">
<a href="contact_add.php" class="btn btn-primary" role="button"><i class="fas fa-plus mr-2"></i>New Contact</a> <a href="contact_add.php" class="btn btn-primary" role="button"><i class="fas fa-plus mr-2"></i>New Contact</a>
</div> </div>
</div> </div>

View File

@ -92,17 +92,20 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
<h5><strong>Subject:</strong> <?php echo $ticket_subject ?></h5> <h5><strong>Subject:</strong> <?php echo $ticket_subject ?></h5>
<hr> <hr>
<p> <p>
<strong>State:</strong> <?php echo $ticket_status ?> <strong>State:</strong> <?php echo $ticket_status ?><br>
<br> <strong>Priority:</strong> <?php echo $ticket_priority ?><br>
<strong>Priority:</strong> <?php echo $ticket_priority ?>
<br>
<?php if (empty($ticket_closed_at)) { ?> <?php if (empty($ticket_closed_at)) { ?>
<?php if ($task_count) { ?> <?php if ($task_count) { ?>
<strong>Tasks: </strong> <?php echo $completed_task_count . " / " .$task_count ?> <strong>Tasks: </strong> <?php echo $completed_task_count . " / " .$task_count ?>
<br> <br>
<?php } ?> <?php } ?>
<strong>Assigned to: </strong> <?php echo $ticket_assigned_to ?>
<?php if (!empty($ticket_assigned_to)) { ?>
<strong>Assigned to: </strong> <?php echo $ticket_assigned_to ?>
<?php } ?>
<?php } ?> <?php } ?>
</p> </p>
<?php echo $ticket_details ?> <?php echo $ticket_details ?>

View File

@ -129,7 +129,7 @@ if (isset($_POST['edit_client'])) {
$sql = mysqli_query($mysqli, "SELECT category_name FROM categories WHERE category_type = 'Referral' AND category_archived_at IS NULL AND category_name = '$referral'"); $sql = mysqli_query($mysqli, "SELECT category_name FROM categories WHERE category_type = 'Referral' AND category_archived_at IS NULL AND category_name = '$referral'");
if(mysqli_num_rows($sql) == 0) { if(mysqli_num_rows($sql) == 0) {
mysqli_query($mysqli, "INSERT INTO categories SET category_name = '$referral', category_type = 'Referral'"); mysqli_query($mysqli, "INSERT INTO categories SET category_name = '$referral', category_type = 'Referral'");
// Logging // Logging
logAction("Category", "Create", "$session_name created referral category $referral"); logAction("Category", "Create", "$session_name created referral category $referral");
} }
@ -383,7 +383,7 @@ if (isset($_POST['export_clients_csv'])) {
//output all remaining data on a file pointer //output all remaining data on a file pointer
fpassthru($f); fpassthru($f);
logAction("Client", "Export", "$session_name exported $num_rows client(s) to a CSV file"); logAction("Client", "Export", "$session_name exported $num_rows client(s) to a CSV file");
} }
@ -1937,9 +1937,14 @@ if (isset($_POST['export_client_pdf'])) {
//pdfMake.createPdf(docDefinition).download('<?php echo strtoAZaz09($client_name); ?>-IT_Documentation-<?php echo date('Y-m-d'); ?>'); //pdfMake.createPdf(docDefinition).download('<?php echo strtoAZaz09($client_name); ?>-IT_Documentation-<?php echo date('Y-m-d'); ?>');
pdfMake.createPdf(docDefinition).download('<?php echo strtoAZaz09($client_name); ?>-IT_Documentation-<?php echo date('Y-m-d'); ?>'); pdfMake.createPdf(docDefinition).download('<?php echo strtoAZaz09($client_name); ?>-IT_Documentation-<?php echo date('Y-m-d'); ?>');
setTimeout(function(){
window.close();
}, 10000);
</script> </script>
<?php <?php
} }

View File

@ -295,39 +295,38 @@ if (isset($_POST['edit_ticket_contact'])) {
// Get Original contact, and ticket details // Get Original contact, and ticket details
$sql = mysqli_query($mysqli, "SELECT $sql = mysqli_query($mysqli, "SELECT
contact_name, contact_email, ticket_prefix, ticket_number, ticket_status_name, ticket_client_id contact_name, ticket_prefix, ticket_number, ticket_status_name, ticket_subject, ticket_details, ticket_url_key, ticket_client_id
FROM tickets FROM tickets
LEFT JOIN contacts ON ticket_contact_id = contact_id LEFT JOIN contacts ON ticket_contact_id = contact_id
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
WHERE ticket_id = $ticket_id" WHERE ticket_id = $ticket_id"
); );
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$original_contact_name = sanitizeInput($row['contact_name']);
$original_contact_email = sanitizeInput($row['contact_email']); // Original contact
$original_contact_name = !empty($row['contact_name']) ? sanitizeInput($row['contact_name']) : 'No one';
// Ticket details
$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_name']); $ticket_status = sanitizeInput($row['ticket_status_name']);
$ticket_category = sanitizeInput($row['ticket_category']);
$ticket_subject = sanitizeInput($row['ticket_subject']); $ticket_subject = sanitizeInput($row['ticket_subject']);
$ticket_details = mysqli_escape_string($mysqli, $row['ticket_details']); $ticket_details = mysqli_escape_string($mysqli, $row['ticket_details']);
$ticket_priority = sanitizeInput($row['ticket_priority']);
$client_id = intval($row['ticket_client_id']);
$ticket_created_by = intval($row['ticket_created_by']);
$ticket_assigned_to = intval($row['ticket_assigned_to']);
$url_key = sanitizeInput($row['ticket_url_key']); $url_key = sanitizeInput($row['ticket_url_key']);
$client_id = intval($row['ticket_client_id']); $client_id = intval($row['ticket_client_id']);
// Update the contact
mysqli_query($mysqli, "UPDATE tickets SET ticket_contact_id = $contact_id WHERE ticket_id = $ticket_id"); mysqli_query($mysqli, "UPDATE tickets SET ticket_contact_id = $contact_id WHERE ticket_id = $ticket_id");
// Get New contact details // Get New contact details
$sql = mysqli_query($mysqli, "SELECT contact_name, contact_email FROM contacts WHERE contact_id = $contact_id"); $sql = mysqli_query($mysqli, "SELECT contact_name, contact_email FROM contacts WHERE contact_id = $contact_id");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$contact_name = sanitizeInput($row['contact_name']); $contact_name = !empty($row['contact_name']) ? sanitizeInput($row['contact_name']) : 'No one';
$contact_email = sanitizeInput($row['contact_email']); $contact_email = sanitizeInput($row['contact_email']);
// Notify new contact if selected // Notify new contact (if selected, valid & configured)
if ($notify && !empty($config_smtp_host)) { if ($notify && filter_var($contact_email, FILTER_VALIDATE_EMAIL) && !empty($config_smtp_host)) {
// Get Company Phone Number // Get Company Phone Number
$sql = mysqli_query($mysqli, "SELECT company_name, company_phone FROM companies WHERE company_id = 1"); $sql = mysqli_query($mysqli, "SELECT company_name, company_phone FROM companies WHERE company_id = 1");
@ -344,18 +343,14 @@ if (isset($_POST['edit_ticket_contact'])) {
$subject = "Ticket Created - [$ticket_prefix$ticket_number] - $ticket_subject"; $subject = "Ticket Created - [$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>A ticket regarding \"$ticket_subject\" has been created for you.<br><br>--------------------------------<br>$ticket_details--------------------------------<br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status<br>Portal: <a href=\'https://$config_base_url/guest_view_ticket.php?ticket_id=$ticket_id&url_key=$url_key\'>View ticket</a><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>A ticket regarding \"$ticket_subject\" has been created for you.<br><br>--------------------------------<br>$ticket_details--------------------------------<br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status<br>Portal: <a href=\'https://$config_base_url/guest_view_ticket.php?ticket_id=$ticket_id&url_key=$url_key\'>View ticket</a><br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
$data[] = [
// Only add contact to email queue if email is valid 'from' => $config_ticket_from_email,
if (filter_var($contact_email, FILTER_VALIDATE_EMAIL)) { 'from_name' => $config_ticket_from_name,
$data[] = [ 'recipient' => $contact_email,
'from' => $config_ticket_from_email, 'recipient_name' => $contact_name,
'from_name' => $config_ticket_from_name, 'subject' => $subject,
'recipient' => $contact_email, 'body' => $body
'recipient_name' => $contact_name, ];
'subject' => $subject,
'body' => $body
];
}
addToMailQueue($mysqli, $data); addToMailQueue($mysqli, $data);
} }

View File

@ -895,7 +895,7 @@ if (isset($_GET['ticket_id'])) {
<!-- Tasks Card --> <!-- Tasks Card -->
<div class="card card-body"> <div class="card card-body">
<?php if (empty($ticket_closed_at) && lookupUserPermission("module_support") >= 2) { ?> <?php if (empty($ticket_resolved_at) && lookupUserPermission("module_support") >= 2) { ?>
<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; ?>">
<div class="form-group"> <div class="form-group">
@ -934,7 +934,7 @@ if (isset($_GET['ticket_id'])) {
<td><span class="text-secondary"><?php echo $task_completion_estimate; ?>m</span> - <?php echo $task_name; ?></td> <td><span class="text-secondary"><?php echo $task_completion_estimate; ?>m</span> - <?php echo $task_name; ?></td>
<td> <td>
<div class="float-right"> <div class="float-right">
<?php if (empty($ticket_closed_at) && lookupUserPermission("module_support") >= 2) { ?> <?php if (empty($ticket_resolved_at) && lookupUserPermission("module_support") >= 2) { ?>
<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">
<i class="fas fa-fw fa-ellipsis-v"></i> <i class="fas fa-fw fa-ellipsis-v"></i>