Update to statements and other minor items
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_User_Statement extends Controller_TemplateDefault_User {
|
||||
class Controller_User_Statement extends Controller_Statement {
|
||||
protected $secure_actions = array(
|
||||
'show'=>TRUE,
|
||||
);
|
||||
@@ -18,66 +18,37 @@ class Controller_User_Statement extends Controller_TemplateDefault_User {
|
||||
* Show a payments received
|
||||
*/
|
||||
public function action_show() {
|
||||
$ta = array();
|
||||
$result = array();
|
||||
$total = 0;
|
||||
|
||||
foreach ($this->ao->payment->find_all() as $o) {
|
||||
$i = count($ta);
|
||||
$ta[$i]['time'] = $o->date_payment;
|
||||
$ta[$i]['payment'] = $o;
|
||||
$key = $o->date_payment;
|
||||
|
||||
while (isset($result[$key]))
|
||||
$key += 1;
|
||||
|
||||
$result[$key] = $o;
|
||||
|
||||
$total += Currency::round($o->total());
|
||||
}
|
||||
|
||||
foreach ($this->ao->invoice->list_active() as $o) {
|
||||
$i = count($ta);
|
||||
$ta[$i]['time'] = $o->date_orig;
|
||||
$ta[$i]['invoice'] = $o;
|
||||
$key = $o->date_orig;
|
||||
|
||||
while (isset($result[$key]))
|
||||
$key += 1;
|
||||
|
||||
$result[$key] = $o;
|
||||
|
||||
$total -= Currency::round($o->total());
|
||||
}
|
||||
|
||||
Sort::MAsort($ta,'time');
|
||||
krsort($result);
|
||||
|
||||
$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();
|
||||
elseif (isset($v['payment']))
|
||||
$t -= $v['payment']->total();
|
||||
|
||||
$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($this->viewpath().'/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($this->viewpath().'/body')
|
||||
->set('o',$v)
|
||||
->set('trc',$i%2 ? 'odd' : 'even');
|
||||
}
|
||||
|
||||
$output .= View::factory($this->viewpath().'/foot');
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s - %s',_('Transactions For'),$this->ao->accnum(),$this->ao->name(TRUE)),
|
||||
'body'=>$output,
|
||||
));
|
||||
Block::factory()
|
||||
->title(sprintf('%s: %s - %s',_('Transactions For'),$this->ao->accnum(),$this->ao->name(TRUE)))
|
||||
->title_icon('icon-tasks')
|
||||
->body(View::factory('statement/user/show')->set('result',$result)->set('total',$total));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user