This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/application/classes/Controller/Reseller/Summary.php

44 lines
1.4 KiB
PHP
Raw Normal View History

2013-11-08 11:02:32 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Reseller Summary Stats
*
* @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_Summary extends Controller_Account {
protected $secure_actions = array(
'index'=>TRUE,
);
/**
*/
public function action_index() {
$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));
}
}
?>