mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Updates to mark tickets billable, and keep track of which have been billed.
This commit is contained in:
102
invoice.php
102
invoice.php
@@ -75,6 +75,29 @@ 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.*,
|
||||
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
|
||||
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;");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
||||
$sql_amount_paid = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS amount_paid FROM payments WHERE payment_invoice_id = $invoice_id");
|
||||
$row = mysqli_fetch_array($sql_amount_paid);
|
||||
@@ -546,8 +569,85 @@ if (isset($_GET['invoice_id'])) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm d-print-none">
|
||||
<div class="card">
|
||||
<div class="card-header text-bold">
|
||||
<i class="fa fa-cog mr-2"></i>Tickets
|
||||
<div class="card-tools">
|
||||
|
||||
|
||||
<?php if (mysqli_num_rows($sql_tickets_billable) > 0) { ?>
|
||||
<a class="btn btn-tool" href="#" data-toggle="modal" data-target="#addTicketModal">
|
||||
<i class="fas fa-plus"></i>
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<a class="btn btn-tool" href="tickets.php?client_id=<?php echo $client_id; ?>">
|
||||
<i class="fas fa-external-link-alt"></i>
|
||||
</a>
|
||||
<button type="button" class="btn btn-tool" data-card-widget="collapse">
|
||||
<i class="fas fa-minus"></i>
|
||||
|
||||
</button>
|
||||
<button type="button" class="btn btn-tool" data-card-widget="remove">
|
||||
<i class="fas fa-times"></i>
|
||||
|
||||
</button>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead class="<?php if (mysqli_num_rows($sql_tickets) == 0) { echo "d-none"; } ?>">
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Subject</th>
|
||||
<th>Status</th>
|
||||
<th>Priority</th>
|
||||
<th>Assigned To</th>
|
||||
<th class="text-right">Time Worked</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while ($row = mysqli_fetch_array($sql_tickets)) {
|
||||
$ticket_id = intval($row['ticket_id']);
|
||||
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
|
||||
$ticket_subject = nullable_htmlentities($row['ticket_subject']);
|
||||
$ticket_status = nullable_htmlentities($row['ticket_status']);
|
||||
$ticket_priority = nullable_htmlentities($row['ticket_priority']);
|
||||
$ticket_assigned_to_id = intval($row['ticket_assigned_to']);
|
||||
$ticket_total_time_worked = floatval($row['total_time_worked']);
|
||||
|
||||
$sql_assigned_to = mysqli_query($mysqli, "SELECT * FROM users WHERE user_id = $ticket_assigned_to_id");
|
||||
$row = mysqli_fetch_array($sql_assigned_to);
|
||||
$ticket_assigned_to = nullable_htmlentities($row['user_name']);
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $ticket_created_at; ?></td>
|
||||
<td><?php echo $ticket_subject; ?></td>
|
||||
<td><?php echo $ticket_status; ?></td>
|
||||
<td><?php echo $ticket_priority; ?></td>
|
||||
<td><?php echo $ticket_assigned_to; ?></td>
|
||||
<td class="text-right"><?php echo $ticket_total_time_worked; ?></td>
|
||||
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
include_once "invoice_add_ticket_modal.php";
|
||||
|
||||
include_once "invoice_payment_add_modal.php";
|
||||
|
||||
include_once "invoice_copy_modal.php";
|
||||
@@ -558,8 +658,6 @@ if (isset($_GET['invoice_id'])) {
|
||||
|
||||
include_once "invoice_note_modal.php";
|
||||
|
||||
include_once "category_quick_add_modal.php";
|
||||
|
||||
}
|
||||
|
||||
require_once "footer.php";
|
||||
|
||||
Reference in New Issue
Block a user