2013-10-10 02:44:53 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
2013-10-09 05:43:41 +00:00
|
|
|
* OSB Reseller Main home page
|
2013-10-10 02:44:53 +00:00
|
|
|
*
|
|
|
|
* @package OSB
|
|
|
|
* @category Controllers/Reseller
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
|
|
|
class Controller_Reseller_Welcome extends Controller_Welcome {
|
|
|
|
protected $auth_required = TRUE;
|
2013-10-09 05:43:41 +00:00
|
|
|
public $secure_actions = array(
|
2013-10-10 02:44:53 +00:00
|
|
|
'index'=>TRUE,
|
2013-10-28 23:36:57 +00:00
|
|
|
'revenue'=>TRUE,
|
2013-10-10 02:44:53 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
public function action_index() {
|
2013-10-09 05:43:41 +00:00
|
|
|
$t = time();
|
|
|
|
|
|
|
|
// Show outstanding invoices
|
|
|
|
$o = ORM::factory('Invoice');
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title($this->ao->RTM->display('name'))
|
|
|
|
->body('');
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title('Invoices Overdue - No Auto Billing')
|
|
|
|
->title_icon('icon-info-sign')
|
|
|
|
->span(6)
|
|
|
|
->body(Table::factory()
|
|
|
|
->data($o->list_overdue_billing($t))
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'due_date'=>'Due',
|
|
|
|
'account->accnum()'=>'Num',
|
|
|
|
'account->name()'=>'Account',
|
|
|
|
'total(TRUE)'=>'Total',
|
|
|
|
'due(TRUE)'=>'Due',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','invoice/view/')),
|
|
|
|
))
|
|
|
|
);
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title('Invoices Overdue - Auto Billing')
|
|
|
|
->title_icon('icon-info-sign')
|
|
|
|
->span(6)
|
|
|
|
->body(Table::factory()
|
|
|
|
->data($o->list_overdue_billing($t,TRUE))
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'due_date'=>'Due',
|
|
|
|
'account->accnum()'=>'Num',
|
|
|
|
'account->name()'=>'Account',
|
|
|
|
'total(TRUE)'=>'Total',
|
|
|
|
'due(TRUE)'=>'Due',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','invoice/view/')),
|
|
|
|
))
|
|
|
|
);
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title('Upcoming Invoices')
|
|
|
|
->title_icon('icon-info-sign')
|
|
|
|
->span(6)
|
|
|
|
->body(Table::factory()
|
|
|
|
->data($o->list_due())
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'due_date'=>'Due',
|
|
|
|
'account->accnum()'=>'Num',
|
|
|
|
'account->name()'=>'Account',
|
|
|
|
'total(TRUE)'=>'Total',
|
|
|
|
'due(TRUE)'=>'Due',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','invoice/view/')),
|
|
|
|
))
|
|
|
|
);
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title('Un-applied payments')
|
|
|
|
->title_icon('icon-info-sign')
|
|
|
|
->span(6)
|
|
|
|
->body(Table::factory()
|
|
|
|
->data(ORM::factory('Payment')->where_authorised()->list_unapplied())
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'date_payment'=>'Pay Date',
|
|
|
|
'account->accnum()'=>'Num',
|
|
|
|
'account->name()'=>'Account',
|
2013-11-08 11:02:32 +00:00
|
|
|
'account->status'=>'Active',
|
2013-10-09 05:43:41 +00:00
|
|
|
'total(TRUE)'=>'Total',
|
|
|
|
'balance(TRUE)'=>'Balance',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('reseller','payment/view/')),
|
|
|
|
))
|
|
|
|
);
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
2013-10-28 23:36:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show Revenue Summary Information
|
|
|
|
*/
|
|
|
|
public function action_revenue() {
|
|
|
|
$result = array();
|
|
|
|
|
|
|
|
// ADSL
|
|
|
|
$svs = ORM::factory('Service')->where_authorised()->list_active();
|
|
|
|
foreach ($svs as $so) {
|
|
|
|
if (! isset($result[$so->product->prod_plugin_file][$so->product->supplier()])) {
|
|
|
|
$result[$so->product->prod_plugin_file][$so->product->supplier()]['count'] = 0;
|
|
|
|
$result[$so->product->prod_plugin_file][$so->product->supplier()]['cost'] = 0;
|
|
|
|
$result[$so->product->prod_plugin_file][$so->product->supplier()]['revenue'] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result[$so->product->prod_plugin_file][$so->product->supplier()]['count']++;
|
|
|
|
$result[$so->product->prod_plugin_file][$so->product->supplier()]['cost'] += $so->product->cost(TRUE);
|
|
|
|
$result[$so->product->prod_plugin_file][$so->product->supplier()]['revenue'] += $so->revenue(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title('Revenue / Cost Analysis')
|
|
|
|
->title_icon('icon-info-sign')
|
|
|
|
->span(6)
|
|
|
|
->body(View::factory('summary/reseller/index')->set('o',$result));
|
|
|
|
}
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
|
|
|
?>
|