Merge pull request #11 from twetech:Invoice-add-ticket-modal-update

Improve invoice add ticket modal UI
This commit is contained in:
Andrew Malsbury 2024-01-10 15:31:48 -06:00 committed by GitHub
commit ac405e1eec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 34 deletions

View File

@ -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

View File

@ -8,25 +8,50 @@
<span>&times;</span>
</button>
</div>
<div class="modal->body bg-white">
<table class="table">
<tr>
<th>Ticket Number</th>
<th>Scope</th>
<th></th>
</tr>
<?php while ($row = mysqli_fetch_array($sql_tickets_billable)) {
$ticket_id = intval($row['ticket_id']);
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
?>
<tr>
<td><?php echo $ticket_id?></td>
<td><?php echo $ticket_subject ?></td>
<td></td>
<td><a href='ticket.php?ticket_id=<?php echo $ticket_id?>&invoice_id=<?php echo $invoice_id?>#addInvoiceFromTicketModal'>Add</a></td>
</tr>
<?php } ?>
</table>
<div class="modal-body bg-white">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Ticket Number</th>
<th>Scope</th>
<th>Add to Invoice</th>
</tr>
</thead>
<?php while ($row = mysqli_fetch_array($sql_tickets_billable)) {
$ticket_id = intval($row['ticket_id']);
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
$ticket_number = intval($row['ticket_number']);
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
$ticket_status = nullable_htmlentities($row['ticket_status']);
switch ($ticket_status) {
case 'Closed':
$ticket_status_class = 'badge-dark';
break;
case 'Auto Close':
$ticket_status_class = 'badge-warning';
break;
default:
$ticket_status_class = 'badge-secondary';
break;
}
?>
<tr>
<td>
<a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>">
<span class="badge badge-pill <?php echo $ticket_status_class?> p-3"><?php echo "$ticket_prefix$ticket_number"; ?></span>
</a>
</td>
<td><?php echo $ticket_subject ?></td>
<td><a href='ticket.php?ticket_id=<?php echo $ticket_id?>&invoice_id=<?php echo $invoice_id?>#addInvoiceFromTicketModal'>
<i class="fas fa-fw fa-plus-circle"></i></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
</div>