Fixes for statement

This commit is contained in:
Deon George 2014-02-18 14:51:29 +11:00
parent 06cbec3a94
commit e2b84fc063
3 changed files with 51 additions and 4 deletions

View File

@ -51,7 +51,7 @@ class Controller_Reseller_Statement extends Controller_Statement {
$result[$key] = $o;
$total += Currency::round($o->total());
$total -= Currency::round($o->total());
}
foreach ($ao->invoice->list_active() as $o) {
@ -62,7 +62,7 @@ class Controller_Reseller_Statement extends Controller_Statement {
$result[$key] = $o;
$total -= Currency::round($o->total());
$total += Currency::round($o->total());
}
krsort($result);

View File

@ -29,7 +29,7 @@ class Controller_User_Statement extends Controller_Statement {
$result[$key] = $o;
$total += Currency::round($o->total());
$total -= Currency::round($o->total());
}
foreach ($this->ao->invoice->list_active() as $o) {
@ -40,7 +40,7 @@ class Controller_User_Statement extends Controller_Statement {
$result[$key] = $o;
$total -= Currency::round($o->total());
$total += Currency::round($o->total());
}
krsort($result);

View File

@ -0,0 +1,47 @@
<?php $pag = new Pagination(array('total_items'=>count($result))); ?>
<?php echo (string)$pag; ?>
<table class="table table-striped table-condensed table-hover span6" id="list-table">
<thead><tr>
<th>Date</th>
<th>Type</th>
<th>Amt</th>
<th>Total</th>
</tr></thead>
<tbody>
<?php $i=0;foreach ($result as $o) :
$adjust = 0;
if ($o instanceof Model_Invoice)
$adjust = $o->total();
elseif ($o instanceof Model_Payment)
$adjust = -$o->total();
$total = Currency::round($total-$adjust);
if (++$i < $pag->current_first_item())
continue;
elseif ($i > $pag->current_last_item())
break;
?>
<tr>
<?php if ($o instanceof Model_Invoice) : ?>
<td><?php echo $o->display('date_orig'); ?></td>
<td><?php echo 'Invoice '.HTML::anchor(URL::link('user','invoice/view/'.$o->id),$o->id()); ?></td>
<?php elseif ($o instanceof Model_Payment) : ?>
<?php $adjust = -$o->total(); ?>
<td><?php echo $o->display('date_payment'); ?></td>
<td><?php printf('Payment %s (%s)',$o->id,$o->checkout->display('name')); ?></td>
<?php else : ?>
<td>-</td>
<td><?php echo 'Unknown '.$o->id; ?></td>
<?php endif ?>
<td class="text-right"><?php echo $o->total(TRUE); ?></td>
<td class="text-right"><?php echo Currency::display($total+$adjust); ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>