mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Marked Invoice status overdue if > due_date and not draft or paid, Added some nice statistic graphics for invoices
This commit is contained in:
96
invoices.php
96
invoices.php
@@ -1,12 +1,87 @@
|
||||
<?php include("header.php"); ?>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status = 'Sent'"));
|
||||
$sent_count = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status = 'Partial'"));
|
||||
$partial_count = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status = 'Draft'"));
|
||||
$draft_count = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_due > CURDATE()"));
|
||||
$overdue_count = $row['num'];
|
||||
|
||||
$sql_total_sent = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_sent FROM invoices WHERE invoice_status = 'Sent'");
|
||||
$row = mysqli_fetch_array($sql_total_sent);
|
||||
$total_sent = $row['total_sent'];
|
||||
|
||||
$sql_total_partial = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_partial FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.invoice_status = 'Partial'");
|
||||
$row = mysqli_fetch_array($sql_total_partial);
|
||||
$total_partial = $row['total_partial'];
|
||||
$total_partial_count = mysqli_num_rows($sql_total_partial);
|
||||
|
||||
$sql_total_overdue_partial = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_overdue_partial FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.invoice_status = 'Partial' AND invoices.invoice_due < CURDATE()");
|
||||
$row = mysqli_fetch_array($sql_total_overdue_partial);
|
||||
$total_overdue_partial = $row['total_overdue_partial'];
|
||||
|
||||
$sql_total_overdue = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_overdue FROM invoices WHERE invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Paid' AND invoice_due < CURDATE()");
|
||||
$row = mysqli_fetch_array($sql_total_overdue);
|
||||
$total_overdue = $row['total_overdue'];
|
||||
|
||||
$real_overdue_amount = $total_overdue - $total_overdue_partial;
|
||||
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
|
||||
WHERE invoices.client_id = clients.client_id
|
||||
ORDER BY invoices.invoice_number DESC");
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-3 col-sm-6 mb-3">
|
||||
<div class="card text-white bg-warning o-hidden">
|
||||
<div class="card-body">
|
||||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-paper-plane"></i>
|
||||
</div>
|
||||
<div class="mr-5"><?php echo $sent_count; ?> Sent <h1>$<?php echo number_format($total_sent,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-3 col-sm-6 mb-3">
|
||||
<div class="card text-white bg-primary o-hidden">
|
||||
<div class="card-body">
|
||||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-wine-glass-alt"></i>
|
||||
</div>
|
||||
<div class="mr-5"><?php echo $partial_count; ?> Partial <h1>$<?php echo number_format($total_partial,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-3 col-sm-6 mb-3">
|
||||
<div class="card text-white bg-secondary o-hidden">
|
||||
<div class="card-body">
|
||||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-pencil-ruler"></i>
|
||||
</div>
|
||||
<div class="mr-5"><?php echo $draft_count; ?> Draft <h1>$<?php echo number_format($total_paid,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-3 col-sm-6 mb-3">
|
||||
<div class="card text-white bg-danger o-hidden">
|
||||
<div class="card-body">
|
||||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-skull-crossbones"></i>
|
||||
</div>
|
||||
<div class="mr-5"><?php echo $overdue_count; ?> Overdue <h1>$<?php echo number_format($real_overdue_amount,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h6 class="float-left mt-1"><i class="fa fa-file"></i> Invoices</h6>
|
||||
@@ -39,13 +114,24 @@
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
|
||||
$unixtime_invoice_due = strtotime($invoice_due);
|
||||
if($unixtime_invoice_due < time()){
|
||||
$overdue_color = "text-danger";
|
||||
$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 = "";
|
||||
}
|
||||
|
||||
//$unixtime_invoice_due = strtotime($invoice_due);
|
||||
//if($unixtime_invoice_due < time()){
|
||||
// $overdue_color = "text-danger";
|
||||
//}else{
|
||||
// $overdue_color = "";
|
||||
//}
|
||||
|
||||
if($invoice_status == "Sent"){
|
||||
$invoice_badge_color = "warning";
|
||||
}elseif($invoice_status == "Partial"){
|
||||
@@ -67,7 +153,7 @@
|
||||
<td><?php echo $invoice_date; ?></td>
|
||||
<td class="<?php echo $overdue_color; ?>"><?php echo $invoice_due; ?></td>
|
||||
<td>
|
||||
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?>">
|
||||
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?> <?php echo $overdue_badge; ?>">
|
||||
<?php echo $invoice_status; ?>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user