2013-10-10 02:44:53 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides User Statement functions
|
|
|
|
*
|
|
|
|
* @package Statement
|
|
|
|
* @category Controllers/User
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
2014-02-06 00:03:25 +00:00
|
|
|
class Controller_User_Statement extends Controller_Statement {
|
2013-10-10 02:44:53 +00:00
|
|
|
protected $secure_actions = array(
|
|
|
|
'show'=>TRUE,
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a payments received
|
|
|
|
*/
|
|
|
|
public function action_show() {
|
2016-07-29 01:19:30 +00:00
|
|
|
$this->meta->title = 'Statement';
|
|
|
|
|
2014-02-06 00:03:25 +00:00
|
|
|
$result = array();
|
|
|
|
$total = 0;
|
2013-10-10 02:44:53 +00:00
|
|
|
|
|
|
|
foreach ($this->ao->payment->find_all() as $o) {
|
2014-02-06 00:03:25 +00:00
|
|
|
$key = $o->date_payment;
|
2013-10-10 02:44:53 +00:00
|
|
|
|
2014-02-06 00:03:25 +00:00
|
|
|
while (isset($result[$key]))
|
|
|
|
$key += 1;
|
2013-10-10 02:44:53 +00:00
|
|
|
|
2014-02-06 00:03:25 +00:00
|
|
|
$result[$key] = $o;
|
2013-10-10 02:44:53 +00:00
|
|
|
|
2014-02-18 03:51:29 +00:00
|
|
|
$total -= Currency::round($o->total());
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
|
|
|
|
2014-02-06 00:03:25 +00:00
|
|
|
foreach ($this->ao->invoice->list_active() as $o) {
|
|
|
|
$key = $o->date_orig;
|
2013-10-10 02:44:53 +00:00
|
|
|
|
2014-02-06 00:03:25 +00:00
|
|
|
while (isset($result[$key]))
|
|
|
|
$key += 1;
|
2013-10-10 02:44:53 +00:00
|
|
|
|
2014-02-06 00:03:25 +00:00
|
|
|
$result[$key] = $o;
|
2013-10-10 02:44:53 +00:00
|
|
|
|
2014-02-18 03:51:29 +00:00
|
|
|
$total += Currency::round($o->total());
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
|
|
|
|
2014-02-06 00:03:25 +00:00
|
|
|
krsort($result);
|
2013-10-10 02:44:53 +00:00
|
|
|
|
2014-02-06 00:03:25 +00:00
|
|
|
Block::factory()
|
2016-08-03 04:00:51 +00:00
|
|
|
->title(sprintf('%s: %s - %s',_('Transactions For'),$this->ao->refnum(),$this->ao->name()))
|
2014-02-06 00:03:25 +00:00
|
|
|
->title_icon('icon-tasks')
|
|
|
|
->body(View::factory('statement/user/show')->set('result',$result)->set('total',$total));
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|