Marked Invoice status overdue if > due_date and not draft or paid, Added some nice statistic graphics for invoices

This commit is contained in:
root
2019-04-30 13:28:16 -04:00
parent eecdb18a06
commit 448267cb32
4 changed files with 110 additions and 30 deletions

View File

@@ -10,7 +10,6 @@
<tr>
<th>Number</th>
<th class="text-right">Amount</th>
<th class="text-right">Balance</th>
<th>Date</th>
<th>Due</th>
<th>Status</th>
@@ -27,10 +26,18 @@
$invoice_date = $row['invoice_date'];
$invoice_due = $row['invoice_due'];
$invoice_amount = $row['invoice_amount'];
//check to see if overdue
$now = time();
if(($invoice_status == "Sent" or $invoice_status == "Partial") and strtotime($invoice_due) < $now ){
$overdue_color = "text-danger font-weight-bold";
$overdue_badge = "badge-danger";
$invoice_status = "Overdue";
}else{
$overdue_color = "";
$overdue_badge = "";
}
//Set Badge color based off of invoice status
if($invoice_status == "Sent"){
$invoice_badge_color = "warning";
@@ -44,31 +51,15 @@
$invoice_badge_color = "secondary";
}
//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 invoice_id = $invoice_id");
$row = mysqli_fetch_array($sql_amount_paid);
$amount_paid = $row['amount_paid'];
$balance = $invoice_amount - $amount_paid;
//set Text color on balance
if($balance > 0){
$balance_text_color = "text-danger";
}else{
$balance_text_color = "";
}
?>
<tr>
<td><a href="invoice.php?invoice_id=<?php echo $invoice_id; ?>">INV-<?php echo $invoice_number; ?></a></td>
<td class="text-right text-monospace">$<?php echo number_format($invoice_amount,2); ?></td>
<td class="text-right text-monospace <?php echo $balance_text_color; ?>">$<?php echo number_format($balance,2); ?></td>
<td><?php echo $invoice_date; ?></td>
<td><div class="<?php echo $overdue_color; ?>"><?php echo $invoice_due; ?></div></td>
<td>
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?>">
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?> echo $overdue_badge;">
<?php echo $invoice_status; ?>
</span>
</td>