I’m working on a version to display month by month comparison for both last/current year as is vital information to run a wealthy business.
This is a little snippet to show the total paid on current/last financial year on the Dashboard.
Note: Australian financial year runs from 01/07/YYYY TO 30/06/YYYY+1 but you can adapt the dates to your country.
Requires to modify 3 files.
OPEN application/modules/dashboard/controllers/Dashboard.php
FIND
'invoice_status_totals' => $this->mdl_invoice_amounts->get_status_totals($invoice_overview_period),
CHANGE IT TO
'invoice_status_totals' => $this->mdl_invoice_amounts->get_status_totals('this-year'),
AND ADD AFTER
'invoice_last_year' => $this->mdl_invoice_amounts->get_status_totals('last-year'),
CLOSE AND UPLOAD
OPEN application/models/invoices/models/Mdl_invoice_amounts.php
REPLACE case ‘this-year’ and ‘last-year’ with:
case 'this-year':
$results = $this->db->query("
SELECT invoice_status_id, (CASE ip_invoices.invoice_status_id WHEN 4 THEN SUM(ip_invoice_amounts.invoice_paid) ELSE SUM(ip_invoice_amounts.invoice_balance) END) AS sum_total, COUNT(*) AS num_total
FROM ip_invoice_amounts
JOIN ip_invoices ON ip_invoices.invoice_id = ip_invoice_amounts.invoice_id
WHERE ip_invoices.invoice_date_created > '".date('Y')."-07-01' AND ip_invoices.invoice_date_created < '".date('Y',strtotime('+1 year'))."-06-30'
GROUP BY ip_invoices.invoice_status_id")->result_array();
break;
case 'last-year':
$results = $this->db->query("
SELECT invoice_status_id, (CASE ip_invoices.invoice_status_id WHEN 4 THEN SUM(ip_invoice_amounts.invoice_paid) ELSE SUM(ip_invoice_amounts.invoice_balance) END) AS sum_total, COUNT(*) AS num_total
FROM ip_invoice_amounts
JOIN ip_invoices ON ip_invoices.invoice_id = ip_invoice_amounts.invoice_id
WHERE ip_invoices.invoice_date_created > '".date('Y',strtotime('-1 year'))."-07-01' AND ip_invoices.invoice_date_created < '".date('Y')."-06-30'
GROUP BY ip_invoices.invoice_status_id")->result_array();
break;
Originally he software shows natural year in case you need to leave the commented line around:
// AND YEAR(ip_invoices.invoice_date_created) = YEAR(NOW())
CLOSE AND UPLOAD
OPEN application/modules/dashboard/views/index.php
SEARCH for the inside the div “table panel-invoice-overview” and REPLACE IT WITH:
<table class="table table-bordered table-condensed no-margin">
<?php foreach ($invoice_status_totals as $total) { ?>
<tr>
<td>
<a href="<?php echo site_url($total['href']); ?>">
<?php echo $total['label']; ?><?php if($total['label']=='Paid');
if($total['label']=='Paid') {
echo ' (this Finantial Year)';
} ?>
</a>
</td>
<td class="amount">
<span class="<?php echo $total['class']; ?>">
<?php echo format_currency($total['sum_total']); ?>
</span>
</td>
</tr>
<?php } ?>
<?php foreach ($invoice_last_year as $total) {
if($total['label']=='Paid') { ?>
<tr>
<td>
<a href="<?php echo site_url($total['href']); ?>">
<?php echo $total['label']; ?><?php if($total['label']=='Paid');
echo ' (last Finantial Year)';
?>
</a>
</td>
<td class="amount">
<span class="<?php echo $total['class']; ?>">
<?php echo format_currency($total['sum_total']); ?>
</span>
</td>
</tr>
<?php }
} ?>
</table>
CLOSE AND UPLOAD
You should be able to see the records now.