From 3084e9e0d38d8f002125c41122c630839a84bc15 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sat, 2 Mar 2024 18:31:01 +0000 Subject: [PATCH 1/2] Ticketing (and Invoicing) - Hide the ability to add/delete watchers when a ticket is closed - Hide watchers card entirely when tickets are closed, if the ticket had no watchers - Hide the ability to schedule a ticket when a ticket is closed - Don't include tickets in an auto-close state in the sidebar ticket counts - Small edit to the ticket closure wording to account for requests and issues - Small edits to invoice emails text --- cron.php | 13 +++++---- inc_all_client.php | 2 +- post/invoice.php | 36 +++++++++++------------ post/ticket.php | 6 ++-- ticket.php | 72 ++++++++++++++++++++++++++++------------------ 5 files changed, 73 insertions(+), 56 deletions(-) diff --git a/cron.php b/cron.php index 191a7360..acf65d03 100644 --- a/cron.php +++ b/cron.php @@ -420,7 +420,7 @@ if ($config_ticket_autoclose == 1) { $ticket_reply = $ticket_reply_row['ticket_reply']; $subject = "Ticket pending closure - [$ticket_prefix$ticket_number] - $ticket_subject"; - $body = "##- Please type your reply above this line -##

Hello, $contact_name

This is an automatic friendly reminder that your ticket regarding $ticket_subject will be closed, unless you respond.

--------------------------------
$ticket_reply--------------------------------

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.

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Status: $ticket_status
Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; + $body = "##- Please type your reply above this line -##

Hello, $contact_name

This is an automatic friendly reminder that your ticket regarding \"$ticket_subject\" will be closed, unless you respond.

--------------------------------
$ticket_reply--------------------------------

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.

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Status: $ticket_status
Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; $data = [ [ @@ -500,10 +500,10 @@ if ($config_send_invoice_reminders == 1) { mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Invoice Overdue', notification = 'Invoice $invoice_prefix$invoice_number for $client_name in the amount of $invoice_amount is overdue by $day days', notification_action = 'invoice.php?invoice_id=$invoice_id', notification_client_id = $client_id, notification_entity_id = $invoice_id"); - $subject = "Overdue Invoice $invoice_prefix$invoice_number"; - $body = "Hello $contact_name,

Our records indicate that we have not yet received payment for the invoice $invoice_prefix$invoice_number. We kindly request that you submit your payment as soon as possible. If you have any questions or concerns, please do not hesitate to contact us at $company_phone. + $subject = "$company_name Overdue Invoice $invoice_prefix$invoice_number"; + $body = "Hello $contact_name,

Our records indicate that we have not yet received payment for the invoice $invoice_prefix$invoice_number. We kindly request that you submit your payment as soon as possible. If you have any questions or concerns, please do not hesitate to contact us at $company_email or $company_phone.

- Kindly review the invoice details mentioned below.

Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . "
Due Date: $invoice_due
Over Due By: $day Days


To view your invoice click here


--
$company_name - Billing
$config_invoice_from_email
$company_phone"; + Kindly review the invoice details mentioned below.

Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . "
Due Date: $invoice_due
Over Due By: $day Days


To view your invoice, please click here.


--
$company_name - Billing
$config_invoice_from_email
$company_phone"; $mail = addToMailQueue($mysqli, [ [ @@ -610,6 +610,7 @@ while ($row = mysqli_fetch_array($sql_recurring)) { $row = mysqli_fetch_array($sql); $invoice_prefix = sanitizeInput($row['invoice_prefix']); $invoice_number = intval($row['invoice_number']); + $invoice_scope = sanitizeInput($row['invoice_scope']); $invoice_date = sanitizeInput($row['invoice_date']); $invoice_due = sanitizeInput($row['invoice_due']); $invoice_amount = floatval($row['invoice_amount']); @@ -619,8 +620,8 @@ while ($row = mysqli_fetch_array($sql_recurring)) { $contact_name = sanitizeInput($row['contact_name']); $contact_email = sanitizeInput($row['contact_email']); - $subject = "Invoice $invoice_prefix$invoice_number"; - $body = "Hello $contact_name,

Kindly review the invoice details mentioned below.

Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $recurring_currency_code) . "
Due Date: $invoice_due


To view your invoice click here


--
$company_name - Billing
$config_invoice_from_email
$company_phone"; + $subject = "$company_name Invoice $invoice_prefix$invoice_number"; + $body = "Hello $contact_name,

An invoice regarding \"$invoice_scope\" has been generated. Please view the details below.

Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $recurring_currency_code) . "
Due Date: $invoice_due


To view your invoice, please click here.


--
$company_name - Billing
$config_invoice_from_email
$company_phone"; $mail = addToMailQueue($mysqli, [ [ diff --git a/inc_all_client.php b/inc_all_client.php index 8e26cfd0..4ebc4ffb 100644 --- a/inc_all_client.php +++ b/inc_all_client.php @@ -124,7 +124,7 @@ if (isset($_GET['client_id'])) { $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('asset_id') AS num FROM assets WHERE asset_archived_at IS NULL AND asset_client_id = $client_id")); $num_assets = $row['num']; - $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('ticket_id') AS num FROM tickets WHERE ticket_archived_at IS NULL AND ticket_status != 'Closed' AND ticket_client_id = $client_id")); + $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('ticket_id') AS num FROM tickets WHERE ticket_archived_at IS NULL AND ticket_status != 'Closed' AND ticket_status != 'Auto Close' AND ticket_client_id = $client_id")); $num_active_tickets = $row['num']; $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('ticket_id') AS num FROM tickets WHERE ticket_archived_at IS NULL AND ticket_status = 'Closed' AND ticket_client_id = $client_id")); diff --git a/post/invoice.php b/post/invoice.php index 4ecc70f7..da872849 100644 --- a/post/invoice.php +++ b/post/invoice.php @@ -288,7 +288,7 @@ if (isset($_POST['add_recurring_item'])) { mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$name', item_description = '$description', item_quantity = $qty, item_price = $price, item_subtotal = $subtotal, item_tax = $tax_amount, item_total = $total, item_tax_id = $tax_id, item_order = $item_order, item_recurring_id = $recurring_id"); - //Get Discount + //Get Discount $sql = mysqli_query($mysqli,"SELECT * FROM recurring WHERE recurring_id = $recurring_id"); $row = mysqli_fetch_array($sql); @@ -461,7 +461,7 @@ if (isset($_POST['add_invoice_item'])) { } else { $invoice_discount = 0; } - + //add up all line items $sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_invoice_id = $invoice_id"); $invoice_total = 0; @@ -674,7 +674,7 @@ if (isset($_POST['add_payment'])) { if ($email_receipt == 1) { - $subject = "Payment Received - Invoice $invoice_prefix$invoice_number"; + $subject = "$company_name Payment Received - Invoice $invoice_prefix$invoice_number"; $body = "Hello $contact_name,

We have received your payment in the amount of " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.

Amount: " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . "
Balance: " . numfmt_format_currency($currency_format, $invoice_balance, $invoice_currency_code) . "

Thank you for your business!


--
$company_name - Billing Department
$config_invoice_from_email
$company_phone"; // Queue Mail @@ -706,9 +706,8 @@ if (isset($_POST['add_payment'])) { if ($email_receipt == 1) { - - $subject = "Partial Payment Recieved - Invoice $invoice_prefix$invoice_number"; - $body = "Hello $contact_name,

We have recieved partial payment in the amount of " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . " and it has been applied to invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.

Amount: " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . "
Balance: " . numfmt_format_currency($currency_format, $invoice_balance, $invoice_currency_code) . "

Thank you for your business!


~
$company_name - Billing
$config_invoice_from_email
$company_phone"; + $subject = "$company_name Partial Payment Received - Invoice $invoice_prefix$invoice_number"; + $body = "Hello $contact_name,

We have received partial payment in the amount of " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . " and it has been applied to invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.

Amount: " . numfmt_format_currency($currency_format, $amount, $invoice_currency_code) . "
Balance: " . numfmt_format_currency($currency_format, $invoice_balance, $invoice_currency_code) . "

Thank you for your business!


~
$company_name - Billing
$config_invoice_from_email
$company_phone"; // Queue Mail $email = [ @@ -813,7 +812,7 @@ if (isset($_POST['add_bulk_payment'])) { $payment_amount = $bulk_payment_amount; $invoice_status = "Partial"; } - + // Subtract the payment amount from the bulk payment amount $bulk_payment_amount -= $payment_amount; @@ -879,7 +878,7 @@ if (isset($_POST['add_bulk_payment'])) { mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Payment', log_action = 'Email', log_description = 'Bulk Payment receipt for multiple Invoices queued to $contact_email Email ID: $email_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $payment_id"); $_SESSION['alert_message'] .= "Email receipt sent and "; - + } // End Email // Logging @@ -950,6 +949,7 @@ if (isset($_GET['email_invoice'])) { $invoice_id = intval($row['invoice_id']); $invoice_prefix = sanitizeInput($row['invoice_prefix']); $invoice_number = intval($row['invoice_number']); + $invoice_scope = sanitizeInput($row['invoice_scope']); $invoice_status = sanitizeInput($row['invoice_status']); $invoice_date = sanitizeInput($row['invoice_date']); $invoice_due = sanitizeInput($row['invoice_due']); @@ -989,11 +989,11 @@ if (isset($_GET['email_invoice'])) { $balance = $invoice_amount - $amount_paid; if ($invoice_status == 'Paid') { - $subject = "Invoice $invoice_prefix$invoice_number Receipt"; - $body = "Hello $contact_name,

Please click on the link below to see your invoice marked paid.

Invoice Link


--
$company_name - Billing
$config_invoice_from_email
$company_phone"; + $subject = "$company_name Invoice $invoice_prefix$invoice_number Receipt"; + $body = "Hello $contact_name,

Please click on the link below to see your invoice regarding \"$invoice_scope\" marked paid.

Invoice Link


--
$company_name - Billing
$config_invoice_from_email
$company_phone"; } else { - $subject = "Invoice $invoice_prefix$invoice_number"; - $body = "Hello $contact_name,

Please view the details of the invoice below.

Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . "
Balance Due: " . numfmt_format_currency($currency_format, $balance, $invoice_currency_code) . "
Due Date: $invoice_due


To view your invoice click here


--
$company_name - Billing
$config_invoice_from_email
$company_phone"; + $subject = "$company_name Invoice $invoice_prefix$invoice_number"; + $body = "Hello $contact_name,

Please view the details of your invoice regarding \"$invoice_scope\" below.

Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . "
Balance Due: " . numfmt_format_currency($currency_format, $balance, $invoice_currency_code) . "
Due Date: $invoice_due


To view your invoice, please click here.


--
$company_name - Billing
$config_invoice_from_email
$company_phone"; } // Queue Mail @@ -1007,7 +1007,7 @@ if (isset($_GET['email_invoice'])) { 'body' => $body ] ]; - + addToMailQueue($mysqli, $data); // Get Email ID for reference @@ -1172,10 +1172,10 @@ if (isset($_GET['force_recurring'])) { // Email to client - $subject = "Invoice $invoice_prefix$invoice_number"; - $body = "Hello $contact_name,

Please view the details of the invoice below.

Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: $$invoice_amount
Due Date: $invoice_due


To view your invoice click here


--
$company_name - Billing
$company_phone"; + $subject = "$company_name Invoice $invoice_prefix$invoice_number"; + $body = "Hello $contact_name,

An invoice regarding \"$invoice_scope\" has been generated. Please view the details below.

Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: $$invoice_amount
Due Date: $invoice_due


To view your invoice, please click here.


--
$company_name - Billing
$company_phone"; + - $data = [ [ 'from' => $config_invoice_from_email, @@ -1338,7 +1338,7 @@ if (isset($_POST['export_client_payments_csv'])) { if (isset($_POST['update_recurring_item_order'])) { - + $item_id = intval($_POST['item_id']); $item_recurring_id = intval($_POST['item_recurring_id']); @@ -1373,7 +1373,7 @@ if (isset($_POST['update_recurring_item_order'])) { } if (isset($_POST['update_invoice_item_order'])) { - + $item_id = intval($_POST['item_id']); $item_invoice_id = intval($_POST['item_invoice_id']); diff --git a/post/ticket.php b/post/ticket.php index 59e3d969..923ed5d9 100644 --- a/post/ticket.php +++ b/post/ticket.php @@ -664,7 +664,7 @@ if (isset($_POST['bulk_close_tickets'])) { $data = []; $subject = "Ticket closed - [$ticket_prefix$ticket_number] - $ticket_subject | (do not reply)"; - $body = "Hello $contact_name,

Your ticket regarding \"$ticket_subject\" has been closed.

$details

We hope the issue was resolved to your satisfaction. If you need further assistance, please raise a new ticket using the below details. Please do not reply to this email.

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Portal: https://$base_url/portal/ticket.php?id=$ticket_id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; + $body = "Hello $contact_name,

Your ticket regarding \"$ticket_subject\" has been closed.

$details

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.

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Portal: https://$base_url/portal/ticket.php?id=$ticket_id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; // Email Ticket Contact // Queue Mail @@ -911,10 +911,10 @@ if (isset($_POST['add_ticket_reply'])) { if ($ticket_status == 'Closed') { $subject = "Ticket closed - [$ticket_prefix$ticket_number] - $ticket_subject | (do not reply)"; - $body = "Hello $contact_name,

Your ticket regarding $ticket_subject has been closed.

--------------------------------
$ticket_reply
--------------------------------

We hope the issue was resolved to your satisfaction. If you need further assistance, please raise a new ticket using the below details. Please do not reply to this email.

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; + $body = "Hello $contact_name,

Your ticket regarding $ticket_subject has been closed.

--------------------------------
$ticket_reply
--------------------------------

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.

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; } elseif ($ticket_status == 'Auto Close') { $subject = "Ticket update - [$ticket_prefix$ticket_number] - $ticket_subject | (pending closure)"; - $body = "##- Please type your reply above this line -##

Hello $contact_name,

Your ticket regarding $ticket_subject has been updated and is pending closure.

--------------------------------
$ticket_reply
--------------------------------

If your issue is resolved, you can ignore this email. If you need further assistance, please respond!

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Status: $ticket_status
Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; + $body = "##- Please type your reply above this line -##

Hello $contact_name,

Your ticket regarding $ticket_subject has been updated and is pending closure.

--------------------------------
$ticket_reply
--------------------------------

If your request/issue is resolved, you can simply ignore this email. If you need further assistance, please respond to let us know!

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Status: $ticket_status
Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; } else { $subject = "Ticket update - [$ticket_prefix$ticket_number] - $ticket_subject"; $body = "##- Please type your reply above this line -##

Hello $contact_name,

Your ticket regarding $ticket_subject has been updated.

--------------------------------
$ticket_reply
--------------------------------

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Status: $ticket_status
Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; diff --git a/ticket.php b/ticket.php index 9c57cb40..b99037d8 100644 --- a/ticket.php +++ b/ticket.php @@ -58,6 +58,11 @@ if (isset($_GET['ticket_id'])) { $ticket_billable = intval($row['ticket_billable']); $ticket_scheduled_for = nullable_htmlentities($row['ticket_schedule']); $ticket_onsite = nullable_htmlentities($row['ticket_onsite']); + if (empty($ticket_scheduled_for)) { + $ticket_scheduled_wording = "Add"; + } else { + $ticket_scheduled_wording = "$ticket_scheduled_for"; + } //Set Ticket Bage Color based of priority if ($ticket_priority == "High") { @@ -276,7 +281,7 @@ if (isset($_GET['ticket_id'])) {
- +
@@ -383,7 +388,7 @@ if (isset($_GET['ticket_id'])) {
- +
- +
@@ -633,28 +638,39 @@ if (isset($_GET['ticket_id'])) { + 0) { ?> +
Watchers
- - - -
- - - - + + + +
+ + + + + + +
+ +
@@ -671,38 +687,38 @@ if (isset($_GET['ticket_id'])) { Updated:
+ - -
Closed by:
Feedback:
- + - if (!empty($ticket_scheduled_for)) { ?> +
- Scheduled for: -
- -
- Scheduled for: Add + Scheduled:
Total time worked:
Billable: From 66e07b0c475275570a23df7c9f94448a6e150fb8 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sat, 2 Mar 2024 18:35:10 +0000 Subject: [PATCH 2/2] Ticket closure email wording --- post/ticket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/post/ticket.php b/post/ticket.php index 923ed5d9..d0c7a825 100644 --- a/post/ticket.php +++ b/post/ticket.php @@ -1137,7 +1137,7 @@ if (isset($_GET['close_ticket'])) { $data = []; $subject = "Ticket closed - [$ticket_prefix$ticket_number] - $ticket_subject | (do not reply)"; - $body = "Hello $contact_name,

Your ticket regarding \"$ticket_subject\" has been closed.

We hope the issue was resolved to your satisfaction. If you need further assistance, please raise a new ticket using the below details. Please do not reply to this email.

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; + $body = "Hello $contact_name,

Your ticket regarding \"$ticket_subject\" has been closed.

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.

Ticket: $ticket_prefix$ticket_number
Subject: $ticket_subject
Portal: https://$config_base_url/portal/ticket.php?id=$ticket_id

--
$company_name - Support
$config_ticket_from_email
$company_phone"; // Email Ticket Contact // Queue Mail