Added Revenue information
This commit is contained in:
parent
1407da5e01
commit
28ea1ac613
@ -13,6 +13,7 @@ class Controller_Reseller_Welcome extends Controller_Welcome {
|
|||||||
protected $auth_required = TRUE;
|
protected $auth_required = TRUE;
|
||||||
public $secure_actions = array(
|
public $secure_actions = array(
|
||||||
'index'=>TRUE,
|
'index'=>TRUE,
|
||||||
|
'revenue'=>TRUE,
|
||||||
);
|
);
|
||||||
|
|
||||||
public function action_index() {
|
public function action_index() {
|
||||||
@ -102,5 +103,32 @@ class Controller_Reseller_Welcome extends Controller_Welcome {
|
|||||||
))
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -125,5 +125,19 @@ class Period {
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function multiple($rs) {
|
||||||
|
switch($rs) {
|
||||||
|
case 0: $multiple=52; break;
|
||||||
|
case 1: $multiple=12; break;
|
||||||
|
case 2: $multiple=4; break;
|
||||||
|
case 3: $multiple=2; break;
|
||||||
|
case 4: $multiple=1; break;
|
||||||
|
case 5: $multiple=0.5; break;
|
||||||
|
case 6: $multiple=0.33; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $multiple;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -17,11 +17,7 @@ return array
|
|||||||
'checkout_notify'=>FALSE, // Test mode to test a particular checkout_notify item
|
'checkout_notify'=>FALSE, // Test mode to test a particular checkout_notify item
|
||||||
'disabled_noaccess_redirect'=>FALSE, // Disable redirect when noaccess
|
'disabled_noaccess_redirect'=>FALSE, // Disable redirect when noaccess
|
||||||
'email_admin_only'=> array( // Override emails and send them to an admin instead
|
'email_admin_only'=> array( // Override emails and send them to an admin instead
|
||||||
'task_invoice_list_overdue'=>array('deon@leenooks.net'=>'Deon George'),
|
#'task_invoice_list_overdue'=>array('deon@leenooks.net'=>'Deon George'),
|
||||||
'task_invoice_remind_overdue_1'=>array('deon@leenooks.net'=>'Deon George'),
|
|
||||||
'task_invoice_remind_overdue_2'=>array('deon@leenooks.net'=>'Deon George'),
|
|
||||||
'task_invoice_remind_overdue_3'=>array('deon@leenooks.net'=>'Deon George'),
|
|
||||||
'adsl_traffic_notice'=>array('deon@leenooks.net'=>'Deon George'),
|
|
||||||
),
|
),
|
||||||
'invoice'=>0, // Number of invoices to generate in a pass
|
'invoice'=>0, // Number of invoices to generate in a pass
|
||||||
'site'=>FALSE, // Glogal site debug
|
'site'=>FALSE, // Glogal site debug
|
||||||
|
29
application/views/summary/reseller/index.php
Normal file
29
application/views/summary/reseller/index.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<table class="table table-striped table-condensed table-hover" id="list-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Category</th>
|
||||||
|
<th>Supplier</th>
|
||||||
|
<th>Count</th>
|
||||||
|
<th>Revenue</th>
|
||||||
|
<th>Cost</th>
|
||||||
|
<th>%</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($o as $cat => $details) : ?>
|
||||||
|
<tr><td><?php echo $cat; ?></td><td colspan="5"> </td></tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<?php foreach ($details as $supplier => $summary) : ?>
|
||||||
|
<td> </td>
|
||||||
|
<td><?php echo $supplier; ?></td>
|
||||||
|
<td><?php echo $summary['count']; ?></td>
|
||||||
|
<td><?php echo Currency::display($summary['revenue']); ?></td>
|
||||||
|
<td><?php echo Currency::display($summary['cost']); ?></td>
|
||||||
|
<td><?php echo $summary['cost'] ? Currency::display($summary['revenue']/$summary['cost'],2) : '-'; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach ?> <!-- /details -->
|
||||||
|
<?php endforeach ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
@ -13,6 +13,7 @@ class ADSL_Billing_Exetelvisp {
|
|||||||
private $data = NULL;
|
private $data = NULL;
|
||||||
private $data_exception = NULL;
|
private $data_exception = NULL;
|
||||||
private $exception = array();
|
private $exception = array();
|
||||||
|
private $excess = 0;
|
||||||
private $total = 0;
|
private $total = 0;
|
||||||
|
|
||||||
public function excess($service) {
|
public function excess($service) {
|
||||||
@ -56,6 +57,7 @@ class ADSL_Billing_Exetelvisp {
|
|||||||
if ($cost != $this->charge($service))
|
if ($cost != $this->charge($service))
|
||||||
$this->exception[$service]['info'] = 'Charging difference: '.Currency::display($cost-$this->charge($service));
|
$this->exception[$service]['info'] = 'Charging difference: '.Currency::display($cost-$this->charge($service));
|
||||||
|
|
||||||
|
$this->excess += $this->excess($service);
|
||||||
$this->total += $this->charge($service);
|
$this->total += $this->charge($service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,8 +153,11 @@ class ADSL_Billing_Exetelvisp {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function total($format=FALSE) {
|
public function totalcharge($format=FALSE) {
|
||||||
return $format ? Currency::display($this->total) : $this->total;
|
return $format ? Currency::display($this->total) : $this->total;
|
||||||
}
|
}
|
||||||
|
public function totalexcess($format=FALSE) {
|
||||||
|
return $format ? Currency::display($this->excess) : $this->excess;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -32,12 +32,22 @@ class Model_Product_Plugin_Adsl extends Model_Product_Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Our required abstract methods
|
// Our required abstract methods
|
||||||
|
public function cost($annual=FALSE) {
|
||||||
|
$x = $this->adsl_supplier_plan->total();
|
||||||
|
|
||||||
|
return $annual ? $x*12 : $x;
|
||||||
|
}
|
||||||
|
|
||||||
public function feature_summary() {
|
public function feature_summary() {
|
||||||
// @todo This view should render based on the the results of this::allowance();
|
// @todo This view should render based on the the results of this::allowance();
|
||||||
return View::factory('product/plugin/adsl/feature_summary')
|
return View::factory('product/plugin/adsl/feature_summary')
|
||||||
->set('po',$this);
|
->set('po',$this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supplier() {
|
||||||
|
return $this->adsl_supplier_plan->supplier_id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the ADSL allowance as a peak/offpeak metric
|
* Show the ADSL allowance as a peak/offpeak metric
|
||||||
*/
|
*/
|
||||||
|
@ -119,6 +119,8 @@ abstract class Service_Traffic_Adsl {
|
|||||||
$co->sweep_type = 6;
|
$co->sweep_type = 6;
|
||||||
$co->account_id = $so->account_id;
|
$co->account_id = $so->account_id;
|
||||||
$co->service_id = $so->id;
|
$co->service_id = $so->id;
|
||||||
|
// @todo This needs to be calculated.
|
||||||
|
$co->type = 5;
|
||||||
$co->amount = $details['rate'];
|
$co->amount = $details['rate'];
|
||||||
// @todo This needs to be calculated.
|
// @todo This needs to be calculated.
|
||||||
$co->taxable = TRUE;
|
$co->taxable = TRUE;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<table class="table table-striped table-condensed table-hover" id="list-table">
|
<table class="table table-striped table-condensed table-hover" id="list-table">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th>Service</th>
|
<th>Service</th>
|
||||||
|
<th>ID</th>
|
||||||
<th>Supplier Plan</th>
|
<th>Supplier Plan</th>
|
||||||
<th>Contract Start</th>
|
<th>Contract Start</th>
|
||||||
<th>Contract End</th>
|
<th>Contract End</th>
|
||||||
@ -16,6 +17,7 @@
|
|||||||
<tr class="<?php echo $o->charge($service_number) == $po->adsl_supplier_plan->total() ? '' : 'error'; ?>">
|
<tr class="<?php echo $o->charge($service_number) == $po->adsl_supplier_plan->total() ? '' : 'error'; ?>">
|
||||||
|
|
||||||
<td><?php echo $service_number; ?></td>
|
<td><?php echo $service_number; ?></td>
|
||||||
|
<td><?php echo HTML::anchor(URL::link('user','service/view/'.$so->id),$so->id); ?></td>
|
||||||
<td><?php echo $po->adsl_supplier_plan->name().($p->provided_adsl_plan_id ? '*' : ''); ?></td>
|
<td><?php echo $po->adsl_supplier_plan->name().($p->provided_adsl_plan_id ? '*' : ''); ?></td>
|
||||||
<td><?php echo $p->contract_date_start(TRUE); ?></td>
|
<td><?php echo $p->contract_date_start(TRUE); ?></td>
|
||||||
<td><?php echo $p->contract_date_end(TRUE); ?></td>
|
<td><?php echo $p->contract_date_end(TRUE); ?></td>
|
||||||
@ -26,6 +28,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
<tr class="info"><td colspan="5"> </td><td><?php echo $o->total(TRUE); ?></td><td> </td></tr>
|
<tr class="info"><td colspan="5"> </td><td><?php echo $o->totalcharge(TRUE); ?></td><td> </td><td><?php echo $o->totalexcess(TRUE); ?></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -16,6 +16,13 @@ class Model_Product_Plugin_Domain extends Model_Product_Plugin {
|
|||||||
|
|
||||||
// Our required abstract methods
|
// Our required abstract methods
|
||||||
public function admin_update() {}
|
public function admin_update() {}
|
||||||
|
|
||||||
|
public function cost($annual=FALSE) {
|
||||||
|
$x = 0;
|
||||||
|
|
||||||
|
return $annual ? $x*12 : $x;
|
||||||
|
}
|
||||||
|
|
||||||
public function feature_summary() {}
|
public function feature_summary() {}
|
||||||
|
|
||||||
// @todo This is not used, but should be.
|
// @todo This is not used, but should be.
|
||||||
@ -37,5 +44,9 @@ class Model_Product_Plugin_Domain extends Model_Product_Plugin {
|
|||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supplier() {
|
||||||
|
return 'internal';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -16,10 +16,20 @@ class Model_Product_Plugin_Host extends Model_Product_Plugin {
|
|||||||
|
|
||||||
// Our required abstract methods
|
// Our required abstract methods
|
||||||
public function admin_update() {}
|
public function admin_update() {}
|
||||||
|
|
||||||
|
public function cost($annual=FALSE) {
|
||||||
|
$x = 0;
|
||||||
|
|
||||||
|
return $annual ? $x*12 : $x;
|
||||||
|
}
|
||||||
|
|
||||||
public function feature_summary() {}
|
public function feature_summary() {}
|
||||||
|
|
||||||
// @todo This is not used, but should be.
|
// @todo This is not used, but should be.
|
||||||
public function order_features() {
|
public function order_features() {}
|
||||||
|
|
||||||
|
public function supplier() {
|
||||||
|
return 'internal';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -51,6 +51,10 @@ class Model_Product extends ORM_OSB {
|
|||||||
return $this->avail_category;
|
return $this->avail_category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function cost($annual=FALSE) {
|
||||||
|
return $this->plugin() ? $this->plugin()->cost($annual) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the translated description for a category.
|
* Return the translated description for a category.
|
||||||
*/
|
*/
|
||||||
@ -134,6 +138,10 @@ class Model_Product extends ORM_OSB {
|
|||||||
return $active ? $this->service->where_active() : $this->service;
|
return $active ? $this->service->where_active() : $this->service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supplier() {
|
||||||
|
return $this->plugin() ? $this->plugin()->supplier() : 'other';
|
||||||
|
}
|
||||||
|
|
||||||
private function translate() {
|
private function translate() {
|
||||||
return $this->product_translate->where('language_id','=',Config::language())->find();
|
return $this->product_translate->where('language_id','=',Config::language())->find();
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,17 @@ abstract class Model_Product_Plugin extends ORM_OSB {
|
|||||||
*/
|
*/
|
||||||
abstract public function admin_update();
|
abstract public function admin_update();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The cost of this service
|
||||||
|
*/
|
||||||
|
abstract public function cost($annual=FALSE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The feature summary should be implemented in plugins.
|
* The feature summary should be implemented in plugins.
|
||||||
* It is displayed on the product overview page, as a summary of the products features.
|
* It is displayed on the product overview page, as a summary of the products features.
|
||||||
*/
|
*/
|
||||||
abstract public function feature_summary();
|
abstract public function feature_summary();
|
||||||
|
|
||||||
|
abstract public function supplier();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -203,6 +203,15 @@ class Model_Service extends ORM_OSB {
|
|||||||
return $type ? $o->$type : $o;
|
return $type ? $o->$type : $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function revenue($annual=FALSE) {
|
||||||
|
$multiple = $annual ? Period::multiple($this->recur_schedule) : 1;
|
||||||
|
|
||||||
|
if ($this->suspend_billing)
|
||||||
|
$multiple = 0;
|
||||||
|
|
||||||
|
return $this->price(TRUE)*$multiple;
|
||||||
|
}
|
||||||
|
|
||||||
public function service_change() {
|
public function service_change() {
|
||||||
return $this->service_change->where_active()->where_open()->and_where('complete','!=',1)->or_where('complete','IS',null)->where_close()->find();
|
return $this->service_change->where_active()->where_open()->and_where('complete','!=',1)->or_where('complete','IS',null)->where_close()->find();
|
||||||
}
|
}
|
||||||
@ -258,7 +267,7 @@ class Model_Service extends ORM_OSB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function transactions() {
|
public function transactions() {
|
||||||
return $this->invoice_item->order_by('date_start,date_stop');
|
return $this->invoice_item->order_by('date_start')->order_by('date_stop');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** LIST FUNCTIONS **/
|
/** LIST FUNCTIONS **/
|
||||||
|
@ -15,10 +15,20 @@ class Model_Product_Plugin_Ssl extends Model_Product_Plugin {
|
|||||||
// Our required abstract methods
|
// Our required abstract methods
|
||||||
public function admin_update() {}
|
public function admin_update() {}
|
||||||
|
|
||||||
|
public function cost($annual=FALSE) {
|
||||||
|
$x = 0;
|
||||||
|
|
||||||
|
return $annual ? $x*12 : $x;
|
||||||
|
}
|
||||||
|
|
||||||
public function feature_summary() {
|
public function feature_summary() {
|
||||||
// @todo This view should render based on the the results of this::allowance();
|
// @todo This view should render based on the the results of this::allowance();
|
||||||
return View::factory('product/plugin/ssl/feature_summary')
|
return View::factory('product/plugin/ssl/feature_summary')
|
||||||
->set('po',$this);
|
->set('po',$this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supplier() {
|
||||||
|
return 'internal';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user