Major work to domain and hosting
Minor updates for ADSL services Updates to Sort::MAsort() Move core OSB items under application/ Moved ACCOUNT functions under application Minor updates to task
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides OSB service affiliate capabilities.
|
||||
* This class provides Affiliate Service functions
|
||||
*
|
||||
* @package OSB
|
||||
* @subpackage Service
|
||||
@@ -11,12 +11,12 @@
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate {
|
||||
protected $control = array('Services'=>'services');
|
||||
|
||||
protected $secure_actions = array(
|
||||
'list'=>TRUE,
|
||||
'listbycheckout'=>TRUE,
|
||||
'listadslservices'=>TRUE,
|
||||
'listdomainservices'=>TRUE,
|
||||
'listhostservices'=>TRUE,
|
||||
'listhspaservices'=>TRUE,
|
||||
);
|
||||
|
||||
@@ -24,17 +24,14 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
|
||||
* Show a list of services
|
||||
*/
|
||||
public function action_list() {
|
||||
$so = ORM::factory('service');
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('System Customer Services'),
|
||||
'title'=>_('Customer Services'),
|
||||
'body'=>Table::display(
|
||||
$so->where('affiliate_id','=',$this->ao->affiliate->id)->find_all(),
|
||||
$this->filter(ORM::factory('service')->list_active(),$this->ao->affiliate->id),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
|
||||
'type'=>array('label'=>'Type'),
|
||||
'name()'=>array('label'=>'Details'),
|
||||
'service_name()'=>array('label'=>'Details'),
|
||||
'recur_schedule'=>array('label'=>'Billing'),
|
||||
'price'=>array('label'=>'Price','class'=>'right'),
|
||||
'active'=>array('label'=>'Active'),
|
||||
@@ -44,7 +41,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>'user/email/view',
|
||||
'form'=>'user/service/view',
|
||||
)),
|
||||
));
|
||||
}
|
||||
@@ -123,181 +120,156 @@ ORDER BY c.id,s.recur_schedule,c.name,a.company,a.last_name,a.first_name
|
||||
));
|
||||
}
|
||||
|
||||
//@todo this should really be in a different class, since adsl wont be part of the main app
|
||||
public function action_listadslservices() {
|
||||
// @todo need to add the DB prefix here
|
||||
// @todo need to restrict this to affiliate services
|
||||
$services = DB::query(Database::SELECT,'
|
||||
SELECT A.service_id
|
||||
FROM ab_service__adsl A,ab_service B,ab_account C,ab_service D,ab_product E
|
||||
WHERE B.active=1 AND A.service_id=B.id AND A.site_id=B.site_id
|
||||
AND B.account_id=C.id AND B.site_id=C.site_id
|
||||
AND A.service_id=D.id AND A.site_id=D.site_id
|
||||
AND D.product_id=E.id AND D.site_id=E.site_id
|
||||
AND E.sku like "%ADSL%"
|
||||
ORDER BY C.last_name,B.account_id,A.service_number
|
||||
')
|
||||
->execute();
|
||||
private function consoltraffic($svs,$date) {
|
||||
$data = array();
|
||||
|
||||
// @todo If no items, show a nice message. This is not correct for ORM.
|
||||
if (! count($services)) {
|
||||
echo Kohana::debug('No services for ADSL');
|
||||
die();
|
||||
}
|
||||
foreach ($svs as $so) {
|
||||
$c = array();
|
||||
foreach ($so->plugin()->get_traffic_data_monthly($date) as $metric => $ma) {
|
||||
foreach ($ma as $month => $traffic) {
|
||||
// Only count the service once, not for each metric.
|
||||
if (! isset($c[$month])) {
|
||||
if (isset($data['svs'][$month]))
|
||||
$data['svs'][$month] += 1;
|
||||
else
|
||||
$data['svs'][$month] = 1;
|
||||
|
||||
$last_account = '';
|
||||
$i = 0;
|
||||
$output = '<table class="box-left">';
|
||||
foreach ($services as $service) {
|
||||
$so = ORM::factory('service',$service['service_id']);
|
||||
$c[$month] = 1;
|
||||
}
|
||||
|
||||
if ($last_account != $so->account_id) {
|
||||
if ($i)
|
||||
$output .= '<tr><td colspan="10"> </td></tr>';
|
||||
|
||||
$output .= View::factory('service/admin/list/adslservices_header')
|
||||
->set('service',$so);
|
||||
|
||||
$last_account = $so->account_id;
|
||||
if (isset($data['data'][$metric][$month]))
|
||||
$data['data'][$metric][$month] += (int)$traffic;
|
||||
else
|
||||
$data['data'][$metric][$month] = (int)$traffic;
|
||||
}
|
||||
}
|
||||
|
||||
$output .= View::factory('service/admin/list/adslservices_body')
|
||||
->set('service',$so)
|
||||
->set('i',$i++%2);
|
||||
}
|
||||
$output .= '</table>';
|
||||
|
||||
// Chart the traffic for the last 12 months.
|
||||
// @todo need to add the DB prefix here
|
||||
$traffic = DB::query(Database::SELECT,sprintf('
|
||||
SELECT DATE_FORMAT(DATE,"%%y-%%m") AS MONTH,SID,MAX(NUM) AS NUM,SUM(DOWN_PEAK) AS DOWN_PEAK,SUM(IFNULL(DOWN_OFFPEAK,0)+IFNULL(PEER,0)+IFNULL(INTERNAL,0)) AS DOWN_OFFPEAK
|
||||
FROM ab_view_traffic_adsl_daily
|
||||
WHERE SID in (%s) AND DATE>"%s"
|
||||
GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
|
||||
','1,2',date('Y-m',time()-365*86400)))
|
||||
->execute();
|
||||
ksort($data['svs']);
|
||||
foreach ($data['data'] as $metric => $details)
|
||||
ksort($data['data'][$metric]);
|
||||
|
||||
$peak = $offpeak = $services = array();
|
||||
return $data;
|
||||
}
|
||||
|
||||
foreach ($traffic as $a => $v) {
|
||||
$peak[$v['SID']]['Peak'][$v['MONTH']] = $v['DOWN_PEAK'];
|
||||
$peak[$v['SID']]['OffPeak'][$v['MONTH']] = $v['DOWN_OFFPEAK'];
|
||||
$peak[$v['SID']]['Services'][$v['MONTH']] = $v['NUM'];
|
||||
}
|
||||
public function action_listadslservices() {
|
||||
$svs = $this->filter(ORM::factory('service')->list_bylistgroup('ADSL'),$this->ao->affiliate->id,'name()');
|
||||
$data = $this->consoltraffic($svs,time());
|
||||
|
||||
$google = GoogleChart::factory('vertical_bar');
|
||||
$google->title = sprintf('ADSL traffic as at %s',date('Y-m-d',strtotime('yesterday')));
|
||||
$google->series(array(
|
||||
'title'=>array('Exetel-Peak','Exetel-Offpeak'),
|
||||
'axis'=>'x',
|
||||
'data'=>array('Exetel-Peak'=>$peak[1]['Peak'],'Exetel-OffPeak'=>$peak[1]['OffPeak'])));
|
||||
$google->series(array(
|
||||
'title'=>array('People-Peak','People-Offpeak'),
|
||||
'axis'=>'x',
|
||||
'data'=>array('People-Peak'=>$peak[2]['Peak'],'People-OffPeak'=>$peak[2]['OffPeak'])));
|
||||
$google->series(array(
|
||||
'title'=>'Exetel-Services',
|
||||
'axis'=>'r',
|
||||
'data'=>array('Exetel-Services'=>$peak[1]['Services'])));
|
||||
$google->series(array(
|
||||
'title'=>'People-Services',
|
||||
'axis'=>'r',
|
||||
'data'=>array('People-Services'=>$peak[2]['Services'])));
|
||||
$google->series(array('title'=>array_keys($data['data']),'axis'=>'x','data'=>$data['data']));
|
||||
$google->series(array('title'=>'Services','axis'=>'r','data'=>array('Services'=>$data['svs'])));
|
||||
|
||||
Block::add(array('body'=>$google));
|
||||
|
||||
Block::add(array(
|
||||
'body'=>$google,
|
||||
'title'=>_('ADSL Services'),
|
||||
'body'=>Table::display(
|
||||
$svs,
|
||||
NULL,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
|
||||
'name()'=>array('label'=>'Service'),
|
||||
'plugin()->ipaddress()'=>array('label'=>'IP Address'),
|
||||
'product->plugin()->allowance()'=>array('label'=>'Allowance'),
|
||||
'plugin()->traffic_thismonth()'=>array('label'=>'This Month'),
|
||||
'plugin()->traffic_lastmonth()'=>array('label'=>'Last Month'),
|
||||
'recur_schedule'=>array('label'=>'Billing'),
|
||||
'price'=>array('label'=>'Price','class'=>'right'),
|
||||
'account->accnum()'=>array('label'=>'Cust ID'),
|
||||
'account->name()'=>array('label'=>'Customer'),
|
||||
'date_next_invoice'=>array('label'=>'Next Invoice'),
|
||||
),
|
||||
array(
|
||||
'type'=>'select',
|
||||
'form'=>'user/service/view',
|
||||
)),
|
||||
));
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('List all ADSL Services'),
|
||||
'body'=>$output,
|
||||
));
|
||||
|
||||
Style::add(array(
|
||||
'type'=>'file',
|
||||
'data'=>'css/list.css',
|
||||
));
|
||||
}
|
||||
|
||||
public function action_listhspaservices() {
|
||||
// @todo need to add the DB prefix here
|
||||
// @todo need to restrict this to affiliate services
|
||||
$services = DB::query(Database::SELECT,'
|
||||
SELECT A.service_id
|
||||
FROM ab_service__adsl A,ab_service B,ab_account C,ab_service D,ab_product E
|
||||
WHERE B.active=1 AND A.service_id=B.id AND A.site_id=B.site_id
|
||||
AND B.account_id=C.id AND B.site_id=C.site_id
|
||||
AND A.service_id=D.id AND A.site_id=D.site_id
|
||||
AND D.product_id=E.id AND D.site_id=E.site_id
|
||||
AND E.sku like "%HSPA%"
|
||||
ORDER BY C.last_name,B.account_id,A.service_number
|
||||
')
|
||||
->execute();
|
||||
|
||||
// @todo If no items, show a nice message. This is not correct for ORM.
|
||||
if (! count($services)) {
|
||||
echo Kohana::debug('No services for HSPA');
|
||||
die();
|
||||
}
|
||||
|
||||
$last_account = '';
|
||||
$i = 0;
|
||||
$output = '<table class="box-left">';
|
||||
foreach ($services as $service) {
|
||||
$so = ORM::factory('service',$service['service_id']);
|
||||
|
||||
if ($last_account != $so->account_id) {
|
||||
if ($i)
|
||||
$output .= '<tr><td colspan="10"> </td></tr>';
|
||||
|
||||
$output .= View::factory('service/admin/list/adslservices_header')
|
||||
->set('service',$so);
|
||||
|
||||
$last_account = $so->account_id;
|
||||
}
|
||||
|
||||
$output .= View::factory('service/admin/list/adslservices_body')
|
||||
->set('service',$so)
|
||||
->set('i',$i++%2);
|
||||
}
|
||||
$output .= '</table>';
|
||||
|
||||
// Chart the traffic for the last 12 months.
|
||||
// @todo need to add the DB prefix here
|
||||
$traffic = DB::query(Database::SELECT,sprintf('
|
||||
SELECT DATE_FORMAT(DATE,"%%y-%%m") AS MONTH,SID,MAX(NUM) AS NUM,SUM(DOWN_PEAK)*1000 AS DOWN_PEAK,SUM(IFNULL(DOWN_OFFPEAK,0)+IFNULL(PEER,0)+IFNULL(INTERNAL,0))*1000 AS DOWN_OFFPEAK
|
||||
FROM ab_view_traffic_adsl_daily
|
||||
WHERE SID=%s AND DATE>"%s"
|
||||
GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
|
||||
',3,date('Y-m',time()-365*86400)))
|
||||
->execute();
|
||||
|
||||
$peak = $offpeak = $services = array();
|
||||
|
||||
foreach ($traffic as $a => $v) {
|
||||
$peak['Peak'][$v['MONTH']] = $v['DOWN_PEAK'];
|
||||
$peak['OffPeak'][$v['MONTH']] = $v['DOWN_OFFPEAK'];
|
||||
$peak['Services'][$v['MONTH']] = $v['NUM'];
|
||||
}
|
||||
$svs = $this->filter(ORM::factory('service')->list_bylistgroup('HSPA'),$this->ao->affiliate->id,'name()');
|
||||
$data = $this->consoltraffic($svs,time());
|
||||
|
||||
$google = GoogleChart::factory('vertical_bar');
|
||||
$google->title = sprintf('HSPA traffic as at %s',date('Y-m-d',strtotime('yesterday')));
|
||||
$google->series(array('title'=>array('Peak','Offpeak'),'axis'=>'x','data'=>array('Peak'=>$peak['Peak'],'OffPeak'=>$peak['OffPeak'])));
|
||||
$google->series(array('title'=>'Services','axis'=>'r','data'=>array('Services'=>$peak['Services'])));
|
||||
$google->series(array('title'=>array_keys($data['data']),'axis'=>'x','data'=>$data['data']));
|
||||
$google->series(array('title'=>'Services','axis'=>'r','data'=>array('Services'=>$data['svs'])));
|
||||
|
||||
Block::add(array('body'=>$google));
|
||||
|
||||
Block::add(array(
|
||||
'body'=>$google,
|
||||
'title'=>_('HSPA Services'),
|
||||
'body'=>Table::display(
|
||||
$svs,
|
||||
NULL,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
|
||||
'name()'=>array('label'=>'Service'),
|
||||
'plugin()->ipaddress()'=>array('label'=>'IP Address'),
|
||||
'product->plugin()->allowance()'=>array('label'=>'Allowance'),
|
||||
'plugin()->traffic_thismonth()'=>array('label'=>'This Month'),
|
||||
'plugin()->traffic_lastmonth()'=>array('label'=>'Last Month'),
|
||||
'recur_schedule'=>array('label'=>'Billing'),
|
||||
'price'=>array('label'=>'Price','class'=>'right'),
|
||||
'account->accnum()'=>array('label'=>'Cust ID'),
|
||||
'account->name()'=>array('label'=>'Customer'),
|
||||
'date_next_invoice'=>array('label'=>'Next Invoice'),
|
||||
),
|
||||
array(
|
||||
'type'=>'select',
|
||||
'form'=>'user/service/view',
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
||||
public function action_listdomainservices() {
|
||||
Block::add(array(
|
||||
'title'=>_('List all HSPA Services'),
|
||||
'body'=>$output,
|
||||
'title'=>_('Domain Names'),
|
||||
'body'=>Table::display(
|
||||
$this->filter(ORM::factory('service')->list_bylistgroup('DOMAIN'),$this->ao->affiliate->id,'name()'),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
|
||||
'service_name()'=>array('label'=>'Details'),
|
||||
'plugin()->display("domain_expire")'=>array('label'=>'Expire'),
|
||||
'recur_schedule'=>array('label'=>'Billing'),
|
||||
'price'=>array('label'=>'Price','class'=>'right'),
|
||||
'account->accnum()'=>array('label'=>'Cust ID'),
|
||||
'account->name()'=>array('label'=>'Customer'),
|
||||
'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>'user/service/view',
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
||||
Style::add(array(
|
||||
'type'=>'file',
|
||||
'data'=>'css/list.css',
|
||||
));
|
||||
public function action_listhostservices() {
|
||||
Block::add(array(
|
||||
'title'=>_('Hosting Services'),
|
||||
'body'=>Table::display(
|
||||
$this->filter(ORM::factory('service')->list_bylistgroup('HOST'),$this->ao->affiliate->id,'name()'),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
|
||||
'service_name()'=>array('label'=>'Details'),
|
||||
'plugin()->display("host_expire")'=>array('label'=>'Expire'),
|
||||
'recur_schedule'=>array('label'=>'Billing'),
|
||||
'price'=>array('label'=>'Price','class'=>'right'),
|
||||
'account->accnum()'=>array('label'=>'Cust ID'),
|
||||
'account->name()'=>array('label'=>'Customer'),
|
||||
'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>'user/service/view',
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user