Added User Statement information

This commit is contained in:
Deon George 2011-08-31 15:09:03 +10:00
parent 35543dd4a9
commit c55a8fe4cc
6 changed files with 190 additions and 73 deletions

View File

@ -25,9 +25,6 @@ class lnApp_Sort {
if (! $data)
return;
static $MASORT_CACHE = array();
if (empty($MASORT_CACHE[$sortby])) {
$code = "\$c=0;\n";
foreach (explode(',',$sortby) as $key) {
@ -96,10 +93,9 @@ class lnApp_Sort {
$code .= 'return $c;';
$MASORT_CACHE[$sortby] = create_function('$a, $b',$code);
}
$result = create_function('$a, $b',$code);
uasort($data,$MASORT_CACHE[$sortby]);
uasort($data,$result);
}
}
?>

View File

@ -0,0 +1,15 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Statement management
*
* @package lnApp
* @subpackage Page/Statement
* @category Controllers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_Statement extends Controller_TemplateDefault {
}
?>

View File

@ -0,0 +1,84 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides User Statement functions
*
* @package OSB
* @subpackage Statement
* @category Controllers/User
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_User_Statement extends Controller_TemplateDefault_User {
protected $secure_actions = array(
'show'=>TRUE,
);
/**
* Show a payments received
*/
public function action_show() {
$ta = array();
foreach ($this->ao->payment->find_all() as $o) {
$i = count($ta);
$ta[$i]['time'] = $o->date_payment;
$ta[$i]['payment'] = $o;
}
foreach ($this->ao->invoice->find_all() as $o) {
$i = count($ta);
$ta[$i]['time'] = $o->date_orig;
$ta[$i]['invoice'] = $o;
}
Sort::MAsort($ta,'time');
$t = 0;
$a = 0;
foreach ($ta as $k => $v) {
// If 2 metrics have the same time, we need to increment 1 by a small number so that it doesnt affect the next sorting
if ($a == $v['time']) {
$ta[$k]['time'] += 1;
}
if (isset($v['invoice']))
$t += $v['invoice']->total_amt;
elseif (isset($v['payment']))
$t -= $v['payment']->total_amt;
$ta[$k]['total'] = $t;
$a = $v['time'];
}
Sort::MAsort($ta,'time',1);
$pag = new Pagination(array(
'total_items'=>count($ta),
));
$output = (string)$pag;
$output .= View::factory('statement/user/show_head');
$i = 0;
foreach ($ta as $k => $v) {
if (++$i < $pag->current_first_item())
continue;
elseif ($i > $pag->current_last_item())
break;
$output .= View::factory('statement/user/show_body')
->set('o',$v)
->set('trc',$i%2 ? 'odd' : 'even');
}
$output .= View::factory('statement/user/show_foot');
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Transaactions For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>$output,
));
}
}
?>

View File

@ -0,0 +1,14 @@
<tr class="<?php echo $trc; ?>">
<?php if (isset($o['invoice'])) { ?>
<td><?php echo $o['invoice']->display('date_orig'); ?></td>
<td>Invoice</td>
<td><?php echo HTML::anchor('user/invoice/view/'.$o['invoice']->id,$o['invoice']->id()); ?></td>
<td class="right"><?php echo $o['invoice']->display('total_amt'); ?></td>
<?php } elseif (isset($o['payment'])) { ?>
<td><?php echo $o['payment']->display('date_payment'); ?></td>
<td>Payment</td>
<td><?php echo $o['payment']->checkout->display('name'); ?></td>
<td class="right"><?php echo $o['payment']->display('total_amt'); ?></td>
<?php } ?>
<td class="right"><?php echo Currency::display($o['total']); ?></td>
</tr>

View File

@ -0,0 +1 @@
</table>

View File

@ -0,0 +1,7 @@
<table class="box-left" border="0" id="list-table">
<tr>
<td class="head">Date</td>
<td class="head" colspan="2">Type</td>
<td class="head">Amt</td>
<td class="head">Total</td>
</tr>