2011-08-31 05:09:03 +00:00
|
|
|
<?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;
|
|
|
|
}
|
|
|
|
|
2012-10-07 04:15:34 +00:00
|
|
|
foreach ($this->ao->invoice->list_active() as $o) {
|
2011-08-31 05:09:03 +00:00
|
|
|
$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']))
|
2011-10-14 05:44:12 +00:00
|
|
|
$t += $v['invoice']->total();
|
2011-08-31 05:09:03 +00:00
|
|
|
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;
|
2011-12-21 01:39:21 +00:00
|
|
|
$output .= View::factory($this->viewpath().'/head');
|
2011-08-31 05:09:03 +00:00
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
foreach ($ta as $k => $v) {
|
|
|
|
if (++$i < $pag->current_first_item())
|
|
|
|
continue;
|
|
|
|
elseif ($i > $pag->current_last_item())
|
|
|
|
break;
|
|
|
|
|
2011-12-21 01:39:21 +00:00
|
|
|
$output .= View::factory($this->viewpath().'/body')
|
2011-08-31 05:09:03 +00:00
|
|
|
->set('o',$v)
|
|
|
|
->set('trc',$i%2 ? 'odd' : 'even');
|
|
|
|
}
|
|
|
|
|
2011-12-21 01:39:21 +00:00
|
|
|
$output .= View::factory($this->viewpath().'/foot');
|
2011-08-31 05:09:03 +00:00
|
|
|
|
|
|
|
Block::add(array(
|
2011-09-17 10:45:08 +00:00
|
|
|
'title'=>sprintf('%s: %s - %s',_('Transactions For'),$this->ao->accnum(),$this->ao->name(TRUE)),
|
2011-08-31 05:09:03 +00:00
|
|
|
'body'=>$output,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|