Added Revenue information

This commit is contained in:
Deon George
2013-10-29 10:36:57 +11:00
parent 1407da5e01
commit 28ea1ac613
14 changed files with 150 additions and 9 deletions

View File

@@ -13,6 +13,7 @@ class Controller_Reseller_Welcome extends Controller_Welcome {
protected $auth_required = TRUE;
public $secure_actions = array(
'index'=>TRUE,
'revenue'=>TRUE,
);
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));
}
}
?>

View File

@@ -125,5 +125,19 @@ class Period {
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;
}
}
?>

View File

@@ -17,11 +17,7 @@ return array
'checkout_notify'=>FALSE, // Test mode to test a particular checkout_notify item
'disabled_noaccess_redirect'=>FALSE, // Disable redirect when noaccess
'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_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'),
#'task_invoice_list_overdue'=>array('deon@leenooks.net'=>'Deon George'),
),
'invoice'=>0, // Number of invoices to generate in a pass
'site'=>FALSE, // Glogal site debug

View 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">&nbsp;</td></tr>
<tr>
<?php foreach ($details as $supplier => $summary) : ?>
<td>&nbsp;</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>