diff --git a/client_tickets.php b/client_tickets.php index 8a02804d..a7fb7b10 100644 --- a/client_tickets.php +++ b/client_tickets.php @@ -18,6 +18,17 @@ if (isset($_GET['status']) && ($_GET['status']) == 'Open') { $ticket_status_snippet = "ticket_status != 'Closed'"; } +if (isset($_GET['billable']) && ($_GET['billable']) == '1') { + if (isset($_GET['unbilled'])) { + $billable = 1; + $ticket_billable_snippet = "ticket_billable = 1 AND ticket_invoice_id = 0"; + $ticket_status_snippet = '1 = 1'; + } +} else { + $billable = 0; + $ticket_billable_snippet = '1 = 1'; +} + //Rebuild URL $url_query_strings_sort = http_build_query($get_copy); @@ -31,6 +42,7 @@ $sql = mysqli_query( LEFT JOIN vendors ON ticket_vendor_id = vendor_id WHERE ticket_client_id = $client_id AND $ticket_status_snippet + AND $ticket_billable_snippet AND (CONCAT(ticket_prefix,ticket_number) 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%') ORDER BY $sort $order LIMIT $record_from, $record_to" ); diff --git a/invoice.php b/invoice.php index 1363bc62..92f72887 100644 --- a/invoice.php +++ b/invoice.php @@ -76,26 +76,37 @@ if (isset($_GET['invoice_id'])) { $sql_payments = mysqli_query($mysqli, "SELECT * FROM payments, accounts WHERE payment_account_id = account_id AND payment_invoice_id = $invoice_id ORDER BY payments.payment_id DESC"); $sql_tickets = mysqli_query($mysqli, " - SELECT - tickets.*, + SELECT + tickets.*, SEC_TO_TIME(SUM(TIME_TO_SEC(STR_TO_DATE(ticket_reply_time_worked, '%H:%i:%s')))) AS 'total_time_worked' - FROM - tickets - LEFT JOIN - ticket_replies ON tickets.ticket_id = ticket_replies.ticket_reply_ticket_id - WHERE - ticket_invoice_id = $invoice_id - GROUP BY - tickets.ticket_id - ORDER BY + FROM + tickets + LEFT JOIN + ticket_replies ON tickets.ticket_id = ticket_replies.ticket_reply_ticket_id + WHERE + ticket_invoice_id = $invoice_id + GROUP BY + tickets.ticket_id + ORDER BY ticket_id DESC "); //Get billable, and unbilled tickets to add to invoice - $sql_tickets_billable = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_client_id = $client_id AND ticket_billable = 1 AND ticket_invoice_id = 0;"); - - - + $sql_tickets_billable = mysqli_query( + $mysqli, " + SELECT + * + FROM + tickets + WHERE + ticket_client_id = $client_id + AND + ticket_billable = 1 + AND + ticket_invoice_id = 0 + AND + ticket_status LIKE '%close%'; + "); //Add up all the payments for the invoice and get the total amount paid to the invoice diff --git a/invoice_add_ticket_modal.php b/invoice_add_ticket_modal.php index 37c07ced..911c55a8 100644 --- a/invoice_add_ticket_modal.php +++ b/invoice_add_ticket_modal.php @@ -8,25 +8,50 @@ × - diff --git a/report_tickets_unbilled.php b/report_tickets_unbilled.php new file mode 100644 index 00000000..7accfbbf --- /dev/null +++ b/report_tickets_unbilled.php @@ -0,0 +1,183 @@ + (int)$days, + 'hour' => (int)$hours, + 'minute' => (int)$minutes, + 'second' => (int)$seconds, + ]; + + foreach ($sections as $name => $value){ + if ($value > 0){ + $timeParts[] = $value. ' '.$name.($value == 1 ? '' : 's'); + } + } + + return implode(', ', $timeParts); +} + +if (isset($_GET['year'])) { + $year = intval($_GET['year']); +} else { + $year = date('Y'); +} + +$sql_ticket_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(ticket_created_at) AS ticket_year FROM tickets ORDER BY ticket_year DESC"); + +$sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients ORDER BY client_name ASC"); + +$rows = 0; + + +?> + +
+
+

Unbilled Tickets By Client

+
+ +
+
+
+
+ +
+ +
+ + + + + + + + + + + 0) { + $rows = $rows + 1; + + ?> + + + + + + + + + + + + + +
ClientTickets RaisedBillable TicketsUnbilled Tickets
+ +
You are all caught up! There are no unbilled tickets for this year. +
+
+
+
+ +Collections

+ @@ -92,6 +98,7 @@

Tickets

+