2011-08-16 02:27:19 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* OSB Admin Main home page
|
|
|
|
*
|
|
|
|
* @package OSB
|
2013-03-19 22:35:19 +00:00
|
|
|
* @category Controllers/Admin
|
2011-08-16 02:27:19 +00:00
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
2011-08-16 02:27:19 +00:00
|
|
|
*/
|
2013-04-04 22:42:29 +00:00
|
|
|
class Controller_Admin_Welcome extends Controller_Welcome {
|
|
|
|
protected $auth_required = TRUE;
|
2011-08-16 02:27:19 +00:00
|
|
|
public $secure_actions = array(
|
|
|
|
'index'=>TRUE,
|
|
|
|
);
|
|
|
|
|
|
|
|
public function action_index() {
|
|
|
|
$t = time();
|
|
|
|
|
|
|
|
// Show outstanding invoices
|
2012-11-09 23:13:57 +00:00
|
|
|
$o = ORM::factory('Invoice');
|
2011-08-16 02:27:19 +00:00
|
|
|
|
|
|
|
Block_Sub::add(array(
|
2011-09-27 11:22:13 +00:00
|
|
|
'title'=>'Invoices Overdue - No Auto Billing',
|
2011-08-27 06:33:46 +00:00
|
|
|
'body'=>Table::display(
|
2011-09-27 11:22:13 +00:00
|
|
|
$o->list_overdue_billing($t),
|
2011-08-27 06:33:46 +00:00
|
|
|
25,
|
|
|
|
array(
|
|
|
|
'due_date'=>array('label'=>'Due Date'),
|
2011-10-12 22:20:08 +00:00
|
|
|
'account->accnum()'=>array('label'=>'Num'),
|
2011-08-27 06:33:46 +00:00
|
|
|
'account->name()'=>array('label'=>'Account'),
|
|
|
|
'account->display("status")'=>array('label'=>'Active'),
|
2013-02-12 11:14:59 +00:00
|
|
|
'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')),
|
2011-10-11 08:52:31 +00:00
|
|
|
'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
|
2011-08-27 06:33:46 +00:00
|
|
|
'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'),
|
|
|
|
),
|
|
|
|
array('page'=>TRUE)),
|
2011-08-16 02:27:19 +00:00
|
|
|
'position'=>1,
|
|
|
|
'order'=>1,
|
|
|
|
));
|
|
|
|
|
2011-09-27 11:22:13 +00:00
|
|
|
Block_Sub::add(array(
|
|
|
|
'title'=>'Invoices Overdue - Auto Billing',
|
|
|
|
'body'=>Table::display(
|
|
|
|
$o->list_overdue_billing($t,TRUE),
|
|
|
|
25,
|
|
|
|
array(
|
|
|
|
'due_date'=>array('label'=>'Due Date'),
|
2011-10-12 22:20:08 +00:00
|
|
|
'account->accnum()'=>array('label'=>'Num'),
|
2011-09-27 11:22:13 +00:00
|
|
|
'account->name()'=>array('label'=>'Account'),
|
|
|
|
'account->display("status")'=>array('label'=>'Active'),
|
2013-02-12 11:14:59 +00:00
|
|
|
'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')),
|
2011-10-11 08:52:31 +00:00
|
|
|
'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
|
2011-09-27 11:22:13 +00:00
|
|
|
'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'),
|
|
|
|
),
|
|
|
|
array('page'=>TRUE)),
|
|
|
|
'position'=>2,
|
|
|
|
'order'=>1,
|
|
|
|
));
|
|
|
|
|
2011-08-16 02:27:19 +00:00
|
|
|
Block_Sub::add(array(
|
|
|
|
'title'=>'Invoices Due',
|
2011-08-27 06:33:46 +00:00
|
|
|
'body'=>Table::display(
|
2011-09-28 06:46:22 +00:00
|
|
|
$o->list_due(),
|
2011-08-27 06:33:46 +00:00
|
|
|
25,
|
|
|
|
array(
|
|
|
|
'due_date'=>array('label'=>'Due Date'),
|
2011-10-12 22:20:08 +00:00
|
|
|
'account->accnum()'=>array('label'=>'Num'),
|
2011-08-27 06:33:46 +00:00
|
|
|
'account->name()'=>array('label'),
|
|
|
|
'account->display("status")'=>array('label'=>'Active'),
|
2013-02-12 11:14:59 +00:00
|
|
|
'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')),
|
2011-10-11 08:52:31 +00:00
|
|
|
'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
|
2011-08-27 06:33:46 +00:00
|
|
|
'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'),
|
|
|
|
),
|
|
|
|
array('show_other'=>'due()')),
|
2011-09-27 11:22:13 +00:00
|
|
|
'position'=>3,
|
2011-08-16 02:27:19 +00:00
|
|
|
'order'=>1,
|
|
|
|
));
|
|
|
|
|
2012-08-01 12:43:33 +00:00
|
|
|
// Show un-applied payments
|
2011-08-16 02:27:19 +00:00
|
|
|
Block_Sub::add(array(
|
|
|
|
'title'=>'Unapplied Payments',
|
2011-08-27 06:33:46 +00:00
|
|
|
'body'=>Table::display(
|
2012-11-09 23:13:57 +00:00
|
|
|
ORM::factory('Payment')->list_unapplied(),
|
2011-08-27 06:33:46 +00:00
|
|
|
25,
|
|
|
|
array(
|
2011-09-28 06:46:22 +00:00
|
|
|
'date_payment'=>array('label'=>'Pay Date'),
|
2011-10-12 22:20:08 +00:00
|
|
|
'account->accnum()'=>array('label'=>'Num'),
|
2011-08-27 06:33:46 +00:00
|
|
|
'account->name()'=>array('label'=>'Account'),
|
|
|
|
'account->display("status")'=>array('label'=>'Active'),
|
2013-06-19 09:26:07 +00:00
|
|
|
'id'=>array('label'=>'ID','url'=>URL::link('admin','payment/edit/')),
|
|
|
|
'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
|
2011-08-27 06:33:46 +00:00
|
|
|
'balance(TRUE)'=>array('label'=>'Balance','class'=>'right'),
|
|
|
|
),
|
|
|
|
array('show_other'=>'balance()')),
|
2011-09-27 11:22:13 +00:00
|
|
|
'position'=>1,
|
|
|
|
'order'=>2,
|
2011-08-16 02:27:19 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
Block::add(array(
|
2013-04-04 22:42:29 +00:00
|
|
|
'title'=>sprintf('%s: %s %s',$this->ao->accnum(),$this->ao->first_name,$this->ao->last_name),
|
2011-08-16 02:27:19 +00:00
|
|
|
'subtitle'=>_('Administrator Overview'),
|
|
|
|
'body'=>(string)Block_Sub::factory(),
|
|
|
|
));
|
|
|
|
|
2013-04-04 22:42:29 +00:00
|
|
|
// We are a site administrator
|
2013-04-20 01:40:44 +00:00
|
|
|
$output = '';
|
2013-04-04 22:42:29 +00:00
|
|
|
if ($this->ao->rtm_id == NULL) {
|
|
|
|
$rtmo = ORM::factory('RTM',array('account_id','=',$this->ao->id))->find();
|
|
|
|
|
|
|
|
// Quick validation, if we are an admin, we should have an entry in the RTM table.
|
|
|
|
if (! $rtmo->loaded())
|
|
|
|
throw new Kohana_Exception('User :aid not set up properly',array(':aid'=>$this->ao->id));
|
|
|
|
|
|
|
|
$output = View::factory('welcome/admin')
|
|
|
|
->set('o',$rtmo);
|
|
|
|
|
|
|
|
} else {
|
2013-04-20 01:40:44 +00:00
|
|
|
$rtmo = ORM::factory('RTM',$this->ao->rtm_id);
|
2013-04-04 22:42:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($output)
|
|
|
|
Block::add(array(
|
|
|
|
'title'=>sprintf('Reseller %s',$this->ao->display('company')),
|
|
|
|
'body'=>$output,
|
|
|
|
));
|
2011-08-16 02:27:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|