Rework service, change module_method configuration

This commit is contained in:
Deon George 2013-06-04 21:50:41 +10:00
parent 1a40f95b30
commit 951845f6c6
35 changed files with 780 additions and 1022 deletions

View File

@ -16,12 +16,45 @@ class Controller_Admin_Module extends Controller_Module {
'list'=>TRUE, 'list'=>TRUE,
); );
protected function _classes($dir,$class,$array=NULL,$key='') {
$result = array();
if (is_null($array)) {
$array = Kohana::list_files('classes');
$array = $array['classes/Controller'];
$key = 'classes/Controller';
}
if (! $class)
return array_keys($array);
if (! $dir) {
if (! empty($array[$key.'/'.$class]))
$result = Arr::merge($result,$this->_classes('','',$array[$key.'/'.$class],$key.'/'.$class));
if (! empty($array[$key.'/'.$class.'.php']))
array_push($result,$key.'/'.$class);
} else {
if (! empty($array[$key.'/'.$dir]))
$result = Arr::merge($result,$this->_classes('',$class,$array[$key.'/'.$dir],$key.'/'.$dir));
if (! empty($array[$key.'/'.$dir.'/'.$class.'.php']))
array_push($result,$key.'/'.$dir.'/'.$class);
}
foreach ($result as $k=>$v)
$result[$k] = str_replace('.php','',str_replace('/','_',preg_replace('/^classes\//','',$v)));
return $result;
}
/** /**
* Get the list of methods for a class * Get the list of methods for a class
*/ */
protected function _methods($class) { protected function _methods($class) {
$class = Kohana::classname($class);
// Get a list of methods this module has // Get a list of methods this module has
$ch = 'Controller_%s';
$methods = $secure_actions = $auth_required = array(); $methods = $secure_actions = $auth_required = array();
// List of classes where all our methods are, including this one. // List of classes where all our methods are, including this one.
@ -30,20 +63,26 @@ class Controller_Admin_Module extends Controller_Module {
foreach ($classes as $c) { foreach ($classes as $c) {
$x = URL::dir($c); $x = URL::dir($c);
$cn = Kohana::classname('Controller_'.($x ? $x.'_'.$class : $class)); $cp = $this->_classes($x,$class);
if (class_exists($cn)) { foreach ($cp as $cn)
$r = new ReflectionClass($cn); if (class_exists($cn)) {
$sc = preg_replace(sprintf('/^Controller_%s%s_?/',$x ? $x.'_' : '',$class),'',$cn);
$r = new ReflectionClass($cn);
$rdp = $r->getDefaultProperties(); $rdp = $r->getDefaultProperties();
$secure_actions[$cn] = $rdp['secure_actions']; $secure_actions[$cn] = $rdp['secure_actions'];
$auth_required[$cn] = $rdp['auth_required']; $auth_required[$cn] = $rdp['auth_required'];
foreach ($r->getMethods() as $method) { foreach ($r->getMethods() as $method)
if (preg_match('/^action_/',$method->name)) if (preg_match('/^action_/',$method->name))
array_push($methods,str_replace('action_',strtolower(($x ? $x.'_' : $x)),$method->name)); array_push($methods,
str_replace('action_',
#strtolower(($x ? $x.'_' : '').($sc ? $sc.'_' : '')),
strtolower($x.($sc ? '_'.$sc : '').':'),
$method->name)
);
} }
}
} }
return array('methods'=>$methods,'secure_actions'=>$secure_actions,'auth_required'=>$auth_required); return array('methods'=>$methods,'secure_actions'=>$secure_actions,'auth_required'=>$auth_required);

View File

@ -39,7 +39,7 @@ class Controller_Reseller_Account extends Controller_Account {
Block::add(array( Block::add(array(
'title'=>_('Customer List'), 'title'=>_('Customer List'),
'body'=>Table::display( 'body'=>Table::display(
$this->filter(ORM::factory('Account')->list_active(),$this->ao->RTM->customers($this->ao->RTM),'sortkey(TRUE)','id'), $this->filter(ORM::factory('Account')->list_active(),$this->ao->RTM->customers($this->ao->RTM),'id','sortkey(TRUE)'),
25, 25,
array( array(
'id'=>array('label'=>'ID','url'=>URL::link('reseller','invoice/list/')), 'id'=>array('label'=>'ID','url'=>URL::link('reseller','invoice/list/')),
@ -64,7 +64,7 @@ class Controller_Reseller_Account extends Controller_Account {
Block::add(array( Block::add(array(
'title'=>_('Account Login Log'), 'title'=>_('Account Login Log'),
'body'=>Table::display( 'body'=>Table::display(
$this->filter(ORM::factory('Account_Log')->find_all(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id'), $this->filter(ORM::factory('Account_Log')->find_all(),$this->ao->RTM->customers($this->ao->RTM),'account_id'),
25, 25,
array( array(
'id'=>array('label'=>'ID'), 'id'=>array('label'=>'ID'),

View File

@ -52,9 +52,13 @@ class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
/** /**
* This will filter a search query to only return those accounts for a reseller * This will filter a search query to only return those accounts for a reseller
* @todo Swap the order of these params and make flid necessary *
* @param $o Our ORM Object that we are searching on
* @param $fl Our array of items that we must return
* @param $flid The ID that must be in the $fl
* @param $sort Sort the results
*/ */
protected function filter($o,array $fl,$sort=NULL,$flid=NULL) { protected function filter($o,array $fl,$flid,$sort=NULL) {
$result = array(); $result = array();
foreach ($o as $x) foreach ($o as $x)

View File

@ -13,17 +13,17 @@ class Menu {
private static function collapse(array $array) { private static function collapse(array $array) {
$result = array(); $result = array();
foreach ($array as $item) { foreach ($array as $mmo) {
if (isset($result[$item->module->name])) { if (isset($result[$mmo->module->name])) {
if (! is_array($result[$item->module->name])) if (! is_array($result[$mmo->module->name]))
$result[$item->module->name] = array($result[$item->module->name]); $result[$mmo->module->name] = array($result[$mmo->module->name]);
array_push($result[$item->module->name],$item); array_push($result[$mmo->module->name],$mmo);
continue; continue;
} else { } else {
$result[$item->module->name] = $item; $result[$mmo->module->name] = $mmo;
} }
} }
@ -36,10 +36,10 @@ class Menu {
if (empty(URL::$method_directory[$type])) if (empty(URL::$method_directory[$type]))
return NULL; return NULL;
$uo = Auth::instance()->get_user(); $ao = Auth::instance()->get_user();
foreach ($uo->methods() as $mmo) foreach ($ao->methods() as $mmo)
if ($mmo->menu_display AND preg_match('/^'.$type.'_/',$mmo->name)) if ($mmo->menu_display AND $type == $mmo->directory())
if (empty($result[$mmo->id])) if (empty($result[$mmo->id]))
$result[$mmo->id] = $mmo; $result[$mmo->id] = $mmo;

View File

@ -123,7 +123,7 @@ class Model_Account extends Model_Auth_UserDefault {
if (empty($result[$mmo->id])) if (empty($result[$mmo->id]))
$result[$mmo->id] = $mmo; $result[$mmo->id] = $mmo;
Sort::MAsort($result,'module->name,name'); Sort::MAsort($result,'module->name,menu_display');
return $result; return $result;
} }

View File

@ -31,12 +31,29 @@ class Model_Module_Method extends ORM_OSB {
protected $status; protected $status;
// Temporarily adjust our name
// @todo This is temporary until all our method names are colon delimited.
protected function _load_values(array $values) {
parent::_load_values($values);
if (substr_count($this->name,'_') == 1 AND ! substr_count($this->name,':'))
$this->name = str_replace('_',':',$this->name);
elseif (substr_count($this->name,'_') > 1)
throw HTTP_Exception::factory(501,'Method :id has double underscore',array(':id'=>$this->id));
return $this;
}
public function controller_sub() {
return substr_count($this->name,'_') ? substr($this->name,($x=strpos($this->name,'_')),strpos($this->name,':')-$x) : '';
}
public function controller() { public function controller() {
return Kohana::classname(sprintf('Controller%s_%s',($this->directory() ? '_' : '').$this->directory(),$this->module->name)); return Kohana::classname(sprintf('Controller%s_%s',($this->directory() ? '_' : '').$this->directory(),$this->module->name).$this->controller_sub());
} }
public function directory() { public function directory() {
return substr($this->name,0,strpos($this->name,'_')); return substr($this->name,0,substr_count($this->name,'_') ? strpos($this->name,'_') : strpos($this->name,':'));
} }
/** /**
@ -51,7 +68,7 @@ class Model_Module_Method extends ORM_OSB {
} }
public function method() { public function method() {
return substr($this->name,strpos($this->name,'_')+1); return substr($this->name,strpos($this->name,':')+1);
} }
public function status($status=NULL) { public function status($status=NULL) {
@ -62,12 +79,12 @@ class Model_Module_Method extends ORM_OSB {
} }
public function url() { public function url() {
if (! preg_match('/_/',$this->name)) if (! preg_match('/:/',$this->name))
return NULL; return NULL;
list($type,$action) = preg_split('/_/',$this->name,2); list($type,$action) = preg_split('/:/',$this->name,2);
return URL::link($type,$this->module->name.'/'.$action); return URL::link($this->directory(),$this->module->name.$this->controller_sub().'/'.$action);
} }
} }
?> ?>

View File

@ -39,13 +39,18 @@ class Request extends Kohana_Request {
$result = NULL; $result = NULL;
$mo = ORM::factory('Module',array('name'=>$this->_controller)); list($c,$x) = substr_count($this->_controller,'_') ? explode('_',$this->_controller,2) : array($this->_controller,'');
$mo = ORM::factory('Module',array('name'=>$c));
if ($mo->loaded() AND $mo->status) { if ($mo->loaded() AND $mo->status) {
$method = strtolower($this->_directory ? sprintf('%s_%s',$this->_directory,$this->_action) : $this->_action); $method = strtolower($this->_directory ? sprintf('%s:%s',$this->_directory.($x ? '_'.$x : ''),$this->_action) : $this->_action);
// Get the method number // Get the method number
$mmo = $mo->module_method->where('name','=',$method)->find(); $mmo = $mo->module_method
->where('name','=',$method)
->or_where('name','=',str_replace(':','_',$method)) // @todo This is temporary until all our method names have a colon delimiter
->find();
if ($mmo->loaded()) if ($mmo->loaded())
$result = $mmo; $result = $mmo;

View File

@ -57,5 +57,5 @@
</div> </div>
</div> </div>
</fieldset> </fieldset>
</div> <!-- /span8 --> </div> <!-- /span -->
</div> <!-- /row --> </div> <!-- /row -->

View File

@ -12,5 +12,5 @@
</div> </div>
</div> </div>
</fieldset> </fieldset>
</div> </div> <!-- /span -->
</div> </div> <!-- /row -->

View File

@ -0,0 +1,92 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Reseller ADSL Service functions
*
* @package ADSL
* @category Controllers/Reseller
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Reseller_Service_Adsl extends Controller_Service {
protected $secure_actions = array(
'list'=>TRUE,
);
private function consoltraffic($svs,$date) {
$data = array();
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;
$c[$month] = 1;
}
if (isset($data['data'][$metric][$month]))
$data['data'][$metric][$month] += (int)$traffic;
else
$data['data'][$metric][$month] = (int)$traffic;
}
}
}
ksort($data['svs']);
foreach ($data['data'] as $metric => $details)
ksort($data['data'][$metric]);
return $data;
}
public function action_list() {
$svs = $this->filter(ORM::factory('Service')->list_byplugin('ADSL'),$this->ao->RTM->customers($this->ao->RTM),'account_id','name()');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('Legacy')
->type('vertical_bar')
->title(sprintf('ADSL traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
foreach ($data['data'] as $key => $values)
$google->sdata(array('yl'=>$key),array($key=>$values));
$google->sdata(array('yr'=>'services'),array('services'=>$data['svs']));
Block::add(array('body'=>(string)$google));
Block::factory()
->title('ADSL Services')
->title_icon('icon-th-list')
->body(Table::factory()
->jssort('adsl')
->data($svs)
->columns(array(
'id'=>'ID',
'name()'=>'Service',
'plugin()->ipaddress()'=>'IP Address',
'product->plugin()->speed'=>'Speed',
'product->plugin()->allowance()'=>'Allowance',
'plugin()->traffic_thismonth()'=>'This Month',
'plugin()->traffic_lastmonth()'=>'Last Month',
'recur_schedule'=>'Billing',
'price(TRUE,TRUE)'=>'Price',
'account->accnum()'=>'Cust ID',
'account->name()'=>'Customer',
'date_next_invoice'=>'Next Invoice',
'due(TRUE)'=>'Due Invoices',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')),
))
);
}
}
?>

View File

@ -59,7 +59,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
public function service_view() { public function service_view() {
return View::factory('service/user/plugin/adsl/view') return View::factory('service/user/plugin/adsl/view')
->set('so',$this); ->set('o',$this);
} }
public function username_value() { public function username_value() {
@ -81,8 +81,10 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
return Config::date($this->service_contract_date); return Config::date($this->service_contract_date);
} }
public function contract_date_end() { public function contract_date_end($format=FALSE) {
return Config::date(strtotime(sprintf('+%s months',$this->contract_term),$this->service_contract_date)); $x = strtotime(sprintf('+%s months',$this->contract_term),$this->service_contract_date);
return $format ? Config::date($x) : $x;
} }
public function hasOffpeak() { public function hasOffpeak() {

View File

@ -1,28 +1,18 @@
<!-- //@todo To translate --> <fieldset class="span6">
<table class="box-full"> <legend>ADSL Features</legend>
<tr>
<td style="width: 40%;">Speed</td> <div class="dl-horizontal">
<td class="data" style="width: 60%;" colspan="2"><?php echo $po->display('speed'); ?></td>
</tr> <dt>Speed</dt>
<tr> <dd><?php echo $po->display('speed'); ?></dd>
<td>&nbsp;</td>
</tr> <dt>Peak Downloads Included</dt>
<tr> <dd><?php echo $po->base_down_peak/1000; ?> GB, excess <?php echo $po->display('extra_down_peak'); ?>/GB.
<td>&nbsp;</td>
<td>Peak</td> <?php if ($po->base_down_offpeak OR $po->extra_down_offpeak) : ?>
<?php if ($po->base_down_offpeak OR $po->extra_down_offpeak) { ?> <dt>OffPeak Downloads Included</dt>
<td>Off Peak</td> <dd><?php echo $po->base_down_offpeak/1000; ?> GB, excess <?php echo $po->display('extra_down_offpeak'); ?>/GB.
<?php } ?> <?php endif ?>
</tr>
<tr> </div> <!-- /dl-horizontal -->
<td>Included Download Traffic</td> </fieldset>
<!-- // @todo Since price is stored in the DB in GB, so should the traffic. -->
<td class="data"><?php echo $po->base_down_peak/1000; ?> GB</td>
<td class="data"><?php echo $po->base_down_offpeak ? ($po->base_down_offpeak/1000).'GB' : HTML::nbsp(''); ?></td>
</tr>
<tr>
<td>Extra Download Traffic</td>
<td class="data"><?php echo $po->display('extra_down_peak'); ?>/GB</td>
<td class="data"><?php echo $po->extra_down_offpeak ? $po->display('extra_down_offpeak').'/GB' : HTML::nbsp(''); ?></td>
</tr>
</table>

View File

@ -1,79 +1,60 @@
<!-- //@todo To translate --> <fieldset class="span5">
<table class="box-full"> <legend>Service Details</legend>
<tr>
<td class="head" colspan="3">Service Details</td> <div class="dl-horizontal">
</tr>
<tr> <dt>Service Number</dt>
<td colspan="3">&nbsp;</td> <dd><?php echo $o->display('service_number'); ?></dd>
</tr>
<tr> <dt>Service Address</dt>
<td> <dd><?php echo $o->display('service_address'); ?></dd>
<table>
<tr> <dt>Connect Date</dt>
<td style="width: 40%;">Service Number</td> <dd><?php echo $o->display('service_connect_date'); ?></dd>
<td style="width: 60%;" class="data"><?php echo $so->display('service_number'); ?></td>
</tr> <dt>Contract Term</dt>
<tr> <dd><?php echo $o->display('contract_term'); ?></dd>
<td>Service Address</td>
<td class="data"><?php echo $so->display('service_address'); ?></td> <dt>Contract End Date</dt>
</tr> <dd><?php echo $o->contract_date_end(TRUE); ?></dd>
<tr>
<td>Contract Term</td> <dt>Service Username</dt>
<td class="data"><?php echo $so->display('contract_term'); ?></td> <dd><?php echo $o->display('service_username'); ?></dd>
</tr>
<tr> <dt>Service Password</dt>
<td>Connect Date</td> <dd><?php echo $o->display('service_password'); ?></dd>
<td class="data"><?php echo $so->display('service_connect_date'); ?></td>
</tr> <dt>Service IP</dt>
<tr> <dd><?php echo $o->ipaddress(); ?></dd>
<td>Contract End Date</td>
<td class="data"><?php echo $so->contract_date_end(); ?></td> <?php if ($o->hasOffPeak() AND $o->offpeak_start AND $o->offpeak_end) : ?>
</tr> <dt>Offpeak Period</dt>
<tr> <dd><?php printf('%s-%s',$o->offpeak_start,$o->offpeak_end); ?></dd>
<td>Service Username</td> <?php endif ?>
<td class="data"><?php echo $so->display('service_username'); ?></td>
</tr> </div> <!-- dl-horizontal -->
<tr> </fieldset>
<td>Service Password</td>
<td class="data"><?php # @todo Enable the ability to hide this value echo $so->display('service_password'); ?></td> <fieldset class="span6">
</tr> <legend>Traffic Usage</legend>
<tr>
<td>Service IP</td> <div class="dl-horizontal">
<td class="data"><?php echo $so->ipaddress(); ?></td> <dt>This Month</dt>
</tr> <dd>&nbsp;<?php echo $o->traffic_month(NULL); ?></dd>
<?php if ($so->hasOffPeak() AND $so->offpeak_start AND $so->offpeak_end) { ?>
<tr> <dt>Last Month</dt>
<td>Offpeak Period</td> <dd>&nbsp;<?php echo $o->traffic_lastmonth(); ?></dd>
<td class="data"><?php printf('%s-%s',$so->offpeak_start,$so->offpeak_end); ?></td> </div> <!-- dl-horizontal -->
</tr> </fieldset>
<?php } ?>
</table> <fieldset class="span6">
</td> <table>
<td style="vertical-align: top;" colspan="2"> <tr>
<table> <td>View Daily Traffic for Month</td>
<tr> <td><?php echo Form::open(); echo Form::select('month',array_merge(array(''),$o->get_traffic_months()),(isset($_POST['month']) ? $_POST['month'] : '')); echo Form::submit('submit',_('Show'),array('class'=>'form_button')); echo Form::close(); ?></td>
<td style="width: 40%;">Traffic Used This Month</td> </tr>
<td style="width: 60%;" class="data"><?php echo $so->traffic_month(NULL); ?></td> </table>
</tr>
<tr> <?php echo $o->graph_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?><br>
<td>Traffic Used Last Month</td> <?php echo $o->table_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?>
<td class="data"><?php echo $so->traffic_lastmonth(); ?></td> </fieldset>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="3">
<table>
<tr>
<td>View Daily Traffic for Month</td>
<td><?php echo Form::open(); echo Form::select('month',array_merge(array(''),$so->get_traffic_months()),(isset($_POST['month']) ? $_POST['month'] : '')); echo Form::submit('submit',_('Show'),array('class'=>'form_button')); echo Form::close(); ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"><?php echo $so->graph_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?></td>
<td><?php echo $so->table_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?></td>
</tr>
</table>

View File

@ -12,6 +12,7 @@
class Model_Charge extends ORM_OSB { class Model_Charge extends ORM_OSB {
// Charge doesnt use the update column // Charge doesnt use the update column
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
protected $_serialize_column = array( protected $_serialize_column = array(
'attributes', 'attributes',
); );
@ -41,5 +42,14 @@ class Model_Charge extends ORM_OSB {
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type)); throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
} }
} }
public function total($format=FALSE) {
$result = $this->quantity * $this->amount;
if ($this->taxable)
$result = Tax::add($result);
return $format ? Currency::display($result) : $result;
}
} }
?> ?>

View File

@ -0,0 +1,41 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Reseller Domain Service functions
*
* @package Domain
* @category Controllers/Reseller
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Reseller_Service_Domain extends Controller_Service {
protected $secure_actions = array(
'list'=>TRUE,
);
public function action_list() {
Block::factory()
->title('Domain License Services')
->title_icon('icon-th-list')
->body(Table::factory()
->jssort('adsl')
->data($this->filter(ORM::factory('Service')->list_byplugin('DOMAIN'),$this->ao->RTM->customers($this->ao->RTM),'account_id','name()'))
->columns(array(
'id'=>'ID',
'name()'=>'Service',
'plugin()->display("domain_expire")'=>'Expire',
'recur_schedule'=>'Billing',
'price(TRUE,TRUE)'=>'Price',
'account->accnum()'=>'Cust ID',
'account->name()'=>'Customer',
'date_next_invoice'=>'Next Invoice',
'due(TRUE)'=>'Due Invoices',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')),
))
);
}
}
?>

View File

@ -54,7 +54,7 @@ class Model_Service_Plugin_Domain extends Model_Service_Plugin {
public function service_view() { public function service_view() {
return View::factory('service/user/plugin/domain/view') return View::factory('service/user/plugin/domain/view')
->set('so',$this); ->set('o',$this);
} }
public function username_value() { public function username_value() {

View File

@ -26,7 +26,7 @@ class Service_Domain_PlanetDomain extends Service_Domain {
$output .= Form::input($this->login_pass_field,substr(md5($spdo->password_value()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t))); $output .= Form::input($this->login_pass_field,substr(md5($spdo->password_value()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t)));
$output .= Form::input('page.next',sprintf('/newdnr/action/dns/getDNSDetails.jsp?domain.name=%s',$d),array('type'=>'hidden')); $output .= Form::input('page.next',sprintf('/newdnr/action/dns/getDNSDetails.jsp?domain.name=%s',$d),array('type'=>'hidden'));
$output .= Form::close(); $output .= Form::close();
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$spdo->service_id,$t))); $output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$spdo->service_id,$t)));
return $output; return $output;
} }

View File

@ -26,7 +26,7 @@ class Service_Domain_TPP extends Service_Domain {
$output .= Form::input($this->login_user_field,$spdo->username_value(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spdo->service_id,$t))); $output .= Form::input($this->login_user_field,$spdo->username_value(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spdo->service_id,$t)));
$output .= Form::input($this->login_pass_field,substr(md5($spdo->password_value()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t))); $output .= Form::input($this->login_pass_field,substr(md5($spdo->password_value()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t)));
$output .= Form::close(); $output .= Form::close();
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$spdo->service_id,$t))); $output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$spdo->service_id,$t)));
return $output; return $output;
} }

View File

@ -1,51 +1,26 @@
<!-- //@todo To translate --> <fieldset class="span5">
<table class="box-full"> <legend>Service Details</legend>
<tr>
<td class="head" colspan="2">Service Details</td> <div class="dl-horizontal">
</tr>
<tr> <dt>Domain Name</dt>
<td colspan="2">&nbsp;</td> <dd><?php echo $o->name(); ?></dd>
</tr>
<tr> <dt>Domain Expire</dt>
<td style="width: 50%"> <dd><?php echo $o->display('domain_expire'); ?></dd>
<table width="100%">
<tr> <dt>Domain Auth Password</dt>
<td style="width: 40%;">Domain Name</td> <dd><?php echo $o->display('registrar_auth_password'); ?></dd>
<td style="width: 60%;" class="data"><?php echo $so->name(); ?></td>
</tr> <?php if ($x=$o->manage_button()) : ?>
<tr> <dt>Registrar</dt>
<td>Domain Expire</td> <dd><?php echo $x; ?></dd>
<td class="data"><?php echo $so->display('domain_expire'); ?></td> <?php endif ?>
</tr>
<tr> <?php if ($x=$o->manage_dns_button()) : ?>
<td>Domain Primary Name Servers</td> <dt>DNS</dt>
<td class="data"><?php echo $so->display('registrar_ns'); ?> <span style="small">(Last Sync: <?php echo $so->display('registrar_lastsync'); ?>)</span></td> <dd><?php echo $x; ?></dd>
</tr> <?php endif ?>
<tr>
<td>Domain Auth Password</td> </div> <!-- dl-horizontal -->
<td class="data"><?php echo $so->display('registrar_auth_password'); ?></td> </fieldset>
</tr>
<tr>
<td>Domain Type</td>
<td class="data"><?php echo $so->display('registrar_type'); ?></td>
</tr>
</table>
</td>
<td style="width: 50%">
<table width="100%">
<?php if ($x=$so->manage_button()) { ?>
<tr>
<td style="width: 40%;">Manage Registrar</td>
<td style="width: 60%;" class="data"><?php echo $x; ?></td>
</tr>
<?php } ?>
<?php if ($x=$so->manage_dns_button()) { ?>
<tr>
<td style="width: 40%;">Manage DNS</td>
<td style="width: 60%;" class="data"><?php echo $x; ?></td>
</tr>
<?php } ?>
</table>
</td>
</tr>
</table>

View File

@ -16,5 +16,5 @@
'column_name'=>array('input'=>array('key'=>'display[__VALUE__]','values'=>$o->display)), 'column_name'=>array('input'=>array('key'=>'display[__VALUE__]','values'=>$o->display)),
)); ?> )); ?>
</fieldset> </fieldset>
</div> <!-- /span8 --> </div> <!-- /span -->
</div> <!-- /row --> </div> <!-- /row -->

View File

@ -57,7 +57,7 @@ echo __METHOD__;die();
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden','id'=>sprintf('u_%s_%s',$sid,$t))); $output .= Form::input($this->login_user_field,$u,array('type'=>'hidden','id'=>sprintf('u_%s_%s',$sid,$t)));
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden','id'=>sprintf('p_%s_%s',$sid,$t))); $output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden','id'=>sprintf('p_%s_%s',$sid,$t)));
$output .= Form::close(); $output .= Form::close();
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$sid,$t))); $output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$sid,$t)));
return $output; return $output;
} }

View File

@ -71,7 +71,7 @@ abstract class Host_Plugin_Plesk extends Host_Plugin {
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden','id'=>sprintf('u_%s_%s',$sid,$t))); $output .= Form::input($this->login_user_field,$u,array('type'=>'hidden','id'=>sprintf('u_%s_%s',$sid,$t)));
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden','id'=>sprintf('p_%s_%s',$sid,$t))); $output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden','id'=>sprintf('p_%s_%s',$sid,$t)));
$output .= Form::close(); $output .= Form::close();
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$sid,$t))); $output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$sid,$t),'nocg'=>TRUE));
return $output; return $output;
} }

View File

@ -50,7 +50,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
public function service_view() { public function service_view() {
return View::factory('service/user/plugin/host/view') return View::factory('service/user/plugin/host/view')
->set('so',$this); ->set('o',$this);
} }
public function username_value() { public function username_value() {

View File

@ -1,33 +1,19 @@
<!-- //@todo To translate --> <fieldset class="span5">
<table class="box-full"> <legend>Service Details</legend>
<tr>
<td class="head" colspan="2">Service Details</td> <div class="dl-horizontal">
</tr>
<tr> <dt>Domain Name</dt>
<td colspan="2">&nbsp;</td> <dd><?php echo $o->name(); ?></dd>
</tr>
<tr> <dt>Hosting Expire</dt>
<td style="width: 50%"> <dd><?php echo $o->display('host_expire'); ?></dd>
<table width="100%">
<tr> <?php if ($x=$o->manage_button()) : ?>
<td style="width: 40%;">Domain Name</td> <div class="offset1">
<td style="width: 60%;" class="data"><?php echo $so->name(); ?></td> <?php echo $x; ?>
</tr> </div>
<tr> <?php endif ?>
<td>Hosting Expire</td>
<td class="data"><?php echo $so->display('host_expire'); ?></td> </div> <!-- dl-horizontal -->
</tr> </fieldset>
</table>
</td>
<td style="width: 50%">
<table width="100%">
<?php if ($x=$so->manage_button()) { ?>
<tr>
<td style="width: 40%;">Panel Login</td>
<td style="width: 60%;" class="data"><?php echo $x; ?></td>
</tr>
<?php } ?>
</table>
</td>
</tr>
</table>

View File

@ -14,7 +14,7 @@
<div class="tab-content"> <div class="tab-content">
<?php $c=0;foreach (StaticList_RecurSchedule::table() as $k=>$v) : ?> <?php $c=0;foreach (StaticList_RecurSchedule::table() as $k=>$v) : ?>
<div class="tab-pane <?php echo $c++ ? '' : 'active'; ?>" id="tab<?php echo $k; ?>"> <div class="tab-pane <?php echo $c++ ? '' : 'active'; ?>" id="tab<?php echo $k; ?>">
<?php echo Form::checkbox("price_group[$k][show]",1,$o->isPriceShown($k),array('label'=>'Price Active','class'=>'span2')); ?> <?php echo Form::checkbox("price_group[$k][show]",1,$o->is_price_shown($k),array('label'=>'Price Active','class'=>'span2')); ?>
<?php foreach ($o->availPriceGroups() as $g) : ?> <?php foreach ($o->availPriceGroups() as $g) : ?>
<div class="row"> <div class="row">
@ -72,5 +72,5 @@
</div> </div>
</fieldset> </fieldset>
</div> <!-- /span8 --> </div> <!-- /span -->
</div> <!-- /row --> </div> <!-- /row -->

View File

@ -32,5 +32,5 @@
</div> </div>
</div> </div>
</fieldset> </fieldset>
</div> <!-- /span8 --> </div> <!-- /span -->
</div> <!-- /row --> </div> <!-- /row -->

View File

@ -9,23 +9,16 @@
* @copyright (c) 2009-2013 Open Source Billing * @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Controller_Admin_Service extends Controller_TemplateDefault_Admin { class Controller_Admin_Service extends Controller_Service {
// @todo This "module" menu items should belong in the module dir.
protected $secure_actions = array( protected $secure_actions = array(
'ajaxlist'=>TRUE, 'ajaxlist'=>TRUE,
'ajaxjson_traffic'=>TRUE, 'ajaxjson_traffic'=>TRUE,
'adslstat'=>TRUE, 'adslstat'=>TRUE,
'list'=>TRUE,
'listbycheckout'=>TRUE,
'listadslbilling'=>TRUE, 'listadslbilling'=>TRUE,
'listadslservices'=>TRUE,
'listexpiring'=>TRUE, 'listexpiring'=>TRUE,
'listdomainservices'=>TRUE,
'listdomainservicesbysupplier'=>TRUE, 'listdomainservicesbysupplier'=>TRUE,
'listdomainservicesbydnshost'=>TRUE, 'listdomainservicesbydnshost'=>TRUE,
'listhostservices'=>TRUE,
'listhostservicesbysupplier'=>TRUE, 'listhostservicesbysupplier'=>TRUE,
'listhspaservices'=>TRUE,
'listwebservices'=>TRUE, 'listwebservices'=>TRUE,
'listinvoicesoon'=>TRUE, 'listinvoicesoon'=>TRUE,
'update'=>TRUE, 'update'=>TRUE,
@ -63,111 +56,6 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
$this->response->body($google->json()); $this->response->body($google->json());
} }
/**
* Show a list of services
*/
public function action_list() {
$id = $this->request->param('id');
$svs = ORM::factory('Service');
if ($id)
$svs->where_active()->and_where('account_id','=',$id);
Block::add(array(
'title'=>_('Customer Services'),
'body'=>Table::display(
$svs->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('user','service/view'),
)),
));
}
/**
* List all services by their default checkout method
*/
public function action_listbycheckout() {
$svs = array();
// @todo This needs to be configurable
$go = ORM::factory('Group',array('name'=>'Personal'));
foreach (ORM::factory('Account')->list_active() as $ao)
if ($ao->has_any('group',array($go)))
foreach ($ao->service->list_active() as $so)
if (! $so->service_billing->checkout_plugin_id)
array_push($svs,$so);
if ($svs)
Block::add(array(
'title'=>'Services that should be auto-billed',
'body'=>Table::display(
$svs,
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
'account->invoices_due_total(NULL,TRUE)'=>array('label'=>'Due Invoices'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('user','service/view'),
)),
));
foreach (ORM::factory('Checkout')->list_active() as $co) {
$svs = array();
foreach ($co->account->find_all() as $ao)
foreach ($ao->service->list_active() as $so)
if ($so->service_billing->checkout_plugin_id == $co->id)
array_push($svs,$so);
if ($svs)
Block::add(array(
'title'=>$co->name,
'body'=>Table::display(
$svs,
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
'account->invoices_due_total(NULL,TRUE)'=>array('label'=>'Due Invoices'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('user','service/view'),
)),
));
}
}
private function consoltraffic($svs,$date) { private function consoltraffic($svs,$date) {
$data = array(); $data = array();
@ -200,51 +88,6 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
return $data; return $data;
} }
public function action_listadslservices() {
$id = $this->request->param('id');
$svs = $list = ORM::factory('Service')->list_bylistgroup('ADSL');
if ($id) {
$svs = array();
foreach ($list as $so)
if ($so->account_id == $id)
array_push($svs,$so);
}
$google = GoogleChart::factory('ComboChart')
->dataurl(URL::link('admin','service/ajaxjson_traffic',TRUE))
->title(sprintf('ADSL traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
Block::add(array('body'=>(string)$google));
Block::add(array(
'title'=>_('ADSL Services'),
'body'=>Table::display(
$svs,
NULL,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'name()'=>array('label'=>'Service'),
'plugin()->ipaddress()'=>array('label'=>'IP Address'),
'product->plugin()->speed'=>array('label'=>'Speed'),
'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(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
'product->display("status")'=>array('label'=>'Current'),
),
array(
'type'=>'select',
'form'=>URL::link('user','service/view'),
)),
));
}
/** /**
* Show a list of services that are expiring or have expired * Show a list of services that are expiring or have expired
*/ */
@ -271,74 +114,6 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
)); ));
} }
public function action_listhspaservices() {
$svs = ORM::factory('Service')->list_bylistgroup('HSPA');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('Legacy')
->type('vertical_bar')
->title(sprintf('HSPA traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
foreach ($data['data'] as $key => $values)
$google->data(array('yl'=>$key),array($key=>$values));
$google->data(array('yr'=>'services'),array('services'=>$data['svs']));
Block::add(array('body'=>(string)$google));
Block::add(array(
'title'=>_('HSPA Services'),
'body'=>Table::display(
$svs,
NULL,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'name()'=>array('label'=>'Service'),
'plugin()->ipaddress()'=>array('label'=>'IP Address'),
'product->plugin()->speed'=>array('label'=>'Speed'),
'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(TRUE,TRUE)'=>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'=>URL::link('user','service/view'),
)),
));
}
public function action_listdomainservices() {
$svs = ORM::factory('Service')->list_bylistgroup('DOMAIN');
Sort::MAsort($svs,'name()');
Block::add(array(
'title'=>_('Domain Names'),
'body'=>Table::display(
$svs,
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'),
'plugin()->display("domain_expire")'=>array('label'=>'Expire'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>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'=>URL::link('user','service/view'),
)),
));
}
public function action_listdomainservicesbysupplier() { public function action_listdomainservicesbysupplier() {
$svs = ORM::factory('Service')->list_bylistgroup('DOMAIN'); $svs = ORM::factory('Service')->list_bylistgroup('DOMAIN');
Sort::MAsort($svs,'plugin()->domain_registrar_id,name()'); Sort::MAsort($svs,'plugin()->domain_registrar_id,name()');
@ -402,33 +177,6 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
)); ));
} }
public function action_listhostservices() {
$svs = ORM::factory('Service')->list_bylistgroup('HOST');
Sort::MAsort($svs,'name()');
Block::add(array(
'title'=>_('Hosting Services'),
'body'=>Table::display(
$svs,
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'),
'plugin()->display("host_expire")'=>array('label'=>'Expire'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>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'=>URL::link('user','service/view'),
)),
));
}
public function action_listhostservicesbysupplier() { public function action_listhostservicesbysupplier() {
$svs = ORM::factory('Service')->list_bylistgroup('HOST'); $svs = ORM::factory('Service')->list_bylistgroup('HOST');
Sort::MAsort($svs,'plugin()->host_server,name()'); Sort::MAsort($svs,'plugin()->host_server,name()');
@ -691,7 +439,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
'recur_schedule'=>array('label'=>'Billing'), 'recur_schedule'=>array('label'=>'Billing'),
'date_next_invoice'=>array('label'=>'Next Invoice'), 'date_next_invoice'=>array('label'=>'Next Invoice'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'), 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'charges_new()'=>array('label'=>'Charges','class'=>'right'), 'charges()'=>array('label'=>'Charges','class'=>'right'),
'status'=>array('label'=>'Active'), 'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'), 'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'), 'account->name()'=>array('label'=>'Customer'),
@ -787,8 +535,6 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
if (is_null($bt)) if (is_null($bt))
$bt = $iio->date_start; $bt = $iio->date_start;
// $doutput .= sprintf('%s: BT is: %s [%s]<br/>',$iio->id,Config::date($bt),$bt);
$pdata = Period::details($iio->recurring_schedule,$a ? NULL : $iio->product->price_recurr_weekday,$bt,TRUE); $pdata = Period::details($iio->recurring_schedule,$a ? NULL : $iio->product->price_recurr_weekday,$bt,TRUE);
switch ($iio->recurring_schedule) { switch ($iio->recurring_schedule) {

View File

@ -1,287 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Affiliate Service functions
*
* @package Service
* @category Controllers/Affiliate
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate {
protected $secure_actions = array(
'list'=>TRUE,
'listbycheckout'=>TRUE,
'listadslservices'=>TRUE,
'listdomainservices'=>TRUE,
'listhostservices'=>TRUE,
'listhspaservices'=>TRUE,
);
/**
* Show a list of services
*/
public function action_list() {
Block::add(array(
'title'=>_('Customer Services'),
'body'=>Table::display(
$this->filter(ORM::factory('Service')->list_active(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id'),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('user','service/view'),
)),
));
}
/**
* List all services by their default checkout method
*/
public function action_listbycheckout() {
$svs = array();
// @todo This needs to be configurable
$go = ORM::factory('Group',array('name'=>'Personal'));
foreach (ORM::factory('Account')->list_active() as $ao)
if ($ao->has_any('group',array($go)))
foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id') as $so)
if (! $so->service_billing->checkout_plugin_id)
array_push($svs,$so);
if ($svs)
Block::add(array(
'title'=>'Services that should be auto-billed',
'body'=>Table::display(
$svs,
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
'account->invoices_due_total(NULL,TRUE)'=>array('label'=>'Due Invoices'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('user','service/view'),
)),
));
else
Block::add(array(
'title'=>'Services that should be auto-billed',
'body'=>_('None found'),
));
foreach (ORM::factory('Checkout')->list_active() as $co) {
$svs = array();
foreach ($co->account->find_all() as $ao)
foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id') as $so)
if ($so->service_billing->checkout_plugin_id == $co->id)
array_push($svs,$so);
if ($svs)
Block::add(array(
'title'=>$co->name,
'body'=>Table::display(
$svs,
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
'account->invoices_due_total(NULL,TRUE)'=>array('label'=>'Due Invoices'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('user','service/view'),
)),
));
}
}
private function consoltraffic($svs,$date) {
$data = array();
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;
$c[$month] = 1;
}
if (isset($data['data'][$metric][$month]))
$data['data'][$metric][$month] += (int)$traffic;
else
$data['data'][$metric][$month] = (int)$traffic;
}
}
}
ksort($data['svs']);
foreach ($data['data'] as $metric => $details)
ksort($data['data'][$metric]);
return $data;
}
public function action_listadslservices() {
$svs = $this->filter(ORM::factory('Service')->list_bylistgroup('ADSL'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('Legacy')
->type('vertical_bar')
->title(sprintf('ADSL traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
foreach ($data['data'] as $key => $values)
$google->sdata(array('yl'=>$key),array($key=>$values));
$google->sdata(array('yr'=>'services'),array('services'=>$data['svs']));
Block::add(array('body'=>(string)$google));
Block::add(array(
'title'=>_('ADSL Services'),
'body'=>Table::display(
$svs,
50,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'name()'=>array('label'=>'Service'),
'plugin()->ipaddress()'=>array('label'=>'IP Address'),
'product->plugin()->speed'=>array('label'=>'Speed'),
'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(TRUE,TRUE)'=>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'=>URL::link('user','service/view'),
)),
));
}
public function action_listhspaservices() {
$svs = $this->filter(ORM::factory('Service')->list_bylistgroup('HSPA'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('Legacy')
->type('vertical_bar')
->title(sprintf('HSPA traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
foreach ($data['data'] as $key => $values)
$google->sdata(array('yl'=>$key),array($key=>$values));
$google->sdata(array('yr'=>'services'),array('services'=>$data['svs']));
Block::add(array('body'=>(string)$google));
Block::add(array(
'title'=>_('HSPA Services'),
'body'=>Table::display(
$svs,
NULL,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'name()'=>array('label'=>'Service'),
'plugin()->ipaddress()'=>array('label'=>'IP Address'),
'product->plugin()->speed'=>array('label'=>'Speed'),
'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(TRUE,TRUE)'=>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'=>URL::link('user','service/view'),
)),
));
}
public function action_listdomainservices() {
Block::add(array(
'title'=>_('Domain Names'),
'body'=>Table::display(
$this->filter(ORM::factory('Service')->list_bylistgroup('DOMAIN'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id'),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'),
'plugin()->display("domain_expire")'=>array('label'=>'Expire'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>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'=>URL::link('user','service/view'),
)),
));
}
public function action_listhostservices() {
Block::add(array(
'title'=>_('Hosting Services'),
'body'=>Table::display(
$this->filter(ORM::factory('Service')->list_bylistgroup('HOST'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id'),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
'service_name()'=>array('label'=>'Details'),
'plugin()->display("host_expire")'=>array('label'=>'Expire'),
'recur_schedule'=>array('label'=>'Billing'),
'price(TRUE,TRUE)'=>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'=>URL::link('user','service/view'),
)),
));
}
}
?>

View File

@ -0,0 +1,112 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Reseller Service functions
*
* @package Service
* @category Controllers/Reseller
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Reseller_Service extends Controller_Service {
protected $secure_actions = array(
'list'=>TRUE,
'listbycheckout'=>TRUE,
'listhostservices'=>TRUE,
);
/**
* Show a list of services
*/
public function action_list() {
Block::factory()
->title('Customer Services')
->title_icon('icon-th-list')
->body(Table::factory()
->jssort('services')
->data($this->filter(ORM::factory('Service')->find_all(),$this->ao->RTM->customers($this->ao->RTM),'account_id'))
->columns(array(
'id'=>'ID',
'service_name()'=>'Service',
'recur_schedule'=>'Billing',
'price(TRUE,TRUE)'=>'Price',
'status(TRUE)'=>'Active',
'account->accnum()'=>'Cust ID',
'account->name()'=>'Customer',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')),
))
);
}
/**
* List all services by their default checkout method
*/
public function action_listbycheckout() {
$svs = array();
// @todo This needs to be configurable
$go = ORM::factory('Group',array('name'=>'Personal'));
foreach (ORM::factory('Account')->list_active() as $ao)
if ($ao->has_any('group',array($go)))
foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),'account_id') as $so)
if (! $so->service_billing->checkout_plugin_id)
array_push($svs,$so);
if ($svs)
Block::factory()
->title('Services that should be auto-billed')
->title_icon('icon-pencil')
->body(Table::factory()
->jssort('services')
->data($svs)
->columns(array(
'id'=>'ID',
'service_name()'=>'Service',
'recur_schedule'=>'Billing',
'price(TRUE,TRUE)'=>'Price',
'account->accnum()'=>'Cust ID',
'account->name()'=>'Customer',
'date_next_invoice'=>'Next Invoice',
'due(TRUE)'=>'Due Invoices',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')),
))
);
foreach (ORM::factory('Checkout')->find_all() as $co) {
$svs = array();
foreach ($co->account->find_all() as $ao)
foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),'account_id') as $so)
if ($so->service_billing->checkout_plugin_id == $co->id)
array_push($svs,$so);
if ($svs)
Block::factory()
->title($co->name)
->title_icon('icon-repeat')
->body(Table::factory()
->jssort($co->id)
->data($svs)
->columns(array(
'id'=>'ID',
'service_name()'=>'Service',
'recur_schedule'=>'Billing',
'price(TRUE,TRUE)'=>'Price',
'account->accnum()'=>'Cust ID',
'account->name()'=>'Customer',
'date_next_invoice'=>'Next Invoice',
'due(TRUE)'=>'Due Invoices',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')),
))
);
}
}
}
?>

View File

@ -9,13 +9,16 @@
* @copyright (c) 2009-2013 Open Source Billing * @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Controller_User_Service extends Controller_TemplateDefault_User { class Controller_User_Service extends Controller_Service {
protected $secure_actions = array( protected $secure_actions = array(
'ajaxmanage'=>TRUE, 'ajaxmanage'=>TRUE,
'list'=>TRUE, 'list'=>TRUE,
'view'=>TRUE, 'view'=>TRUE,
); );
/**
* This ajax functions obtains the manage button login/password for this service
*/
public function action_ajaxmanage() { public function action_ajaxmanage() {
$this->auto_render = FALSE; $this->auto_render = FALSE;
@ -36,24 +39,23 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
* Show a list of services * Show a list of services
*/ */
public function action_list() { public function action_list() {
Block::add(array( Block::factory()
'title'=>sprintf('%s: %s - %s',_('Services For'),$this->ao->accnum(),$this->ao->name(TRUE)), ->title(sprintf('Services for Account: %s',$this->ao->accnum()))
'body'=>Table::display( ->title_icon('icon-th-list')
$this->ao->service->find_all(), ->body(Table::factory()
25, ->jssort('services')
array( ->data($this->ao->service->find_all())
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')), ->columns(array(
'service_name()'=>array('label'=>'Details'), 'id'=>'ID',
'recur_schedule'=>array('label'=>'Billing'), 'service_name()'=>'Service',
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'), 'recur_schedule'=>'Billing',
'status'=>array('label'=>'Active'), 'price(TRUE,TRUE)'=>'Price',
), 'status(TRUE)'=>'Active',
array( ))
'page'=>TRUE, ->prepend(array(
'type'=>'select', 'id'=>array('url'=>URL::link('user','service/view/')),
'form'=>URL::link('user','service/view'), ))
)), );
));
} }
public function action_view() { public function action_view() {
@ -61,18 +63,16 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
$so = ORM::factory('Service',$id); $so = ORM::factory('Service',$id);
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) { if (! $so->loaded() OR ! Auth::instance()->authorised($so->account))
$this->template->content = 'Unauthorised or doesnt exist?'; throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
return FALSE;
}
$output .= View::factory($this->viewpath()) $output .= View::factory('service/user/view')
->set('so',$so); ->set('o',$so);
Block::add(array( Block::factory()
'title'=>sprintf('%s: %s',$so->id(),$so->service_name()), ->title(sprintf('%s: %s',$so->id(),$so->service_name()))
'body'=>$output, ->title_icon('icon-list-alt')
)); ->body($output);
} }
} }
?> ?>

View File

@ -18,6 +18,7 @@ class Model_Service extends ORM_OSB {
'service_billing'=>array('far_key'=>'account_billing_id','foreign_key'=>'id'), 'service_billing'=>array('far_key'=>'account_billing_id','foreign_key'=>'id'),
); );
protected $_has_many = array( protected $_has_many = array(
'charge'=>array('far_key'=>'id'),
'invoice_item'=>array('far_key'=>'id'), 'invoice_item'=>array('far_key'=>'id'),
'invoice'=>array('through'=>'invoice_item'), 'invoice'=>array('through'=>'invoice_item'),
'service_change'=>array('far_key'=>'id'), 'service_change'=>array('far_key'=>'id'),
@ -46,33 +47,27 @@ class Model_Service extends ORM_OSB {
); );
/** /**
* Return the object of the product plugin * Get the additional charges associated with this service
*/ */
public function plugin($type='') { public function charges($unprocessed=TRUE,$format=FALSE) {
if (! $this->product->prod_plugin_file) $result = 0;
return NULL;
$o = ORM::factory(Kohana::classname(sprintf('Service_Plugin_%s',$this->product->prod_plugin_file)),array('service_id'=>$this->id)); foreach ($this->charge_list($unprocessed) as $co)
$result += $co->total();
return $type ? $o->$type : $o; return $format ? Currency::display($result) : $result;
} }
/** public function charge_list($unprocessed=FALSE) {
* Display the service number $x = $this->charge;
*/
public function id() {
return sprintf('%05s',$this->id);
}
/** if ($unprocessed)
* Display the service product name $x->where_open()
*/ ->where('processed','IS',NULL)
public function name() { ->or_where('processed','=',FALSE)
return is_null($plugin=$this->plugin()) ? $this->product->title() : $plugin->name(); ->where_close();
}
public function pending_change() { return $x->find_all();
return count($this->service_change->where_active()->where_open()->and_where('complete','!=',1)->or_where('complete','IS',null)->where_close()->find_all()->as_array());
} }
/** /**
@ -81,7 +76,7 @@ class Model_Service extends ORM_OSB {
public function due($format=FALSE) { public function due($format=FALSE) {
$total = 0; $total = 0;
foreach ($this->list_invoices(TRUE) as $io) foreach ($this->invoice_list(TRUE) as $io)
$total += $io->due(); $total += $io->due();
return $format ? Currency::display($total) : $total; return $format ? Currency::display($total) : $total;
@ -103,10 +98,80 @@ class Model_Service extends ORM_OSB {
/** /**
* Determine if a service expires in the next $days. * Determine if a service expires in the next $days.
*/ */
public function expiring($days) { public function expiring($days=0) {
return time()+$days*86400 > $this->expire(); return time()+$days*86400 > $this->expire();
} }
/**
* Display the service number
*/
public function id() {
return sprintf('%05s',$this->id);
}
/**
* List invoices for this service
*/
public function invoice_list($due=FALSE) {
$result = array();
$x = $this->invoice->distinct('id');
// If we only want due invoices, we can speed things up by only looking for unprocessed
if ($due)
$x->where_unprocessed();
foreach ($x->find_all() as $io)
if (! $due OR $io->due())
array_push($result,$io);
return $result;
}
/**
* Display the service product name
*/
public function name() {
return is_null($plugin=$this->plugin()) ? $this->product->title() : $plugin->name();
}
/**
* Returns TRUE of this service has a planend change
*/
public function pending_change() {
return $this->service_change()->loaded() ? TRUE : FALSE;
}
/**
* Show the product that this service will be changed to
*/
public function pending_product() {
return $this->service_change()->product;
}
/**
* Return the object of the product plugin
*/
public function plugin($type='') {
if (! $this->product->prod_plugin_file)
return NULL;
$o = ORM::factory(Kohana::classname(sprintf('Service_Plugin_%s',$this->product->prod_plugin_file)),array('service_id'=>$this->id));
return $type ? $o->$type : $o;
}
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 a descriptive name for this service
*/
public function service_name() {
return is_null($plugin=$this->plugin()) ? $this->name() : $plugin->service_name();
}
/** /**
* Return the service charge * Return the service charge
*/ */
@ -122,32 +187,18 @@ class Model_Service extends ORM_OSB {
return $format ? Currency::display($p) : $p; return $format ? Currency::display($p) : $p;
} }
public function service_name() {
return is_null($plugin=$this->plugin()) ? $this->name() : $plugin->service_name();
}
public function service_view() {
return is_null($plugin=$this->plugin()) ? HTML::nbsp('') : $plugin->service_view();
}
/**
* Display the product feature summary
*/
public function product_feature_summary() {
return $this->product->feature_summary();
}
/** /**
* Render some details for specific calls, eg: invoice * Render some details for specific calls, eg: invoice
*/ */
public function details($type) { public function details($type) {
$plugin = $this->plugin();
switch ($type) { switch ($type) {
case 'invoice_detail_items': case 'invoice_detail_items':
if (is_null($plugin = $this->plugin())) return is_null($plugin) ? array() : $plugin->_details($type);
return array();
else case 'service_view':
return $plugin->_details($type); return is_null($plugin) ? HTML::nbsp('') : $plugin->service_view();
break;
default: default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type)); throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
@ -170,7 +221,7 @@ class Model_Service extends ORM_OSB {
// @todo To implement // @todo To implement
public function charges_new() { public function charges_new() {
return 0; return $this->charges();
} }
/** LIST FUNCTIONS **/ /** LIST FUNCTIONS **/
@ -198,7 +249,20 @@ class Model_Service extends ORM_OSB {
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options); return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
} }
/**
* List all products by their plugin type
*/
public function list_byplugin($plugin) {
return $this
->join('product')
->on($this->table_name().'.site_id','=','product.site_id') // @todo This should be automatic
->on($this->table_name().'.product_id','=','product.id')
->where('prod_plugin_file','=',$plugin)
->and_where('service.status','=',TRUE)
->find_all();
}
public function list_bylistgroup($cat) { public function list_bylistgroup($cat) {
$result = array(); $result = array();
@ -223,19 +287,6 @@ class Model_Service extends ORM_OSB {
return $result; return $result;
} }
/**
* List invoices for this service
*/
public function list_invoices($due=FALSE) {
$result = array();
foreach ($this->invoice->find_all() as $io)
if (! $due OR $io->due())
array_push($result,$io);
return $result;
}
/** /**
* List services that need to be billed. * List services that need to be billed.
* *

View File

@ -1,80 +1,84 @@
<!-- @todo NEEDS TO BE TRANSLATED --> <div class="row">
<table width="100%"> <fieldset class="span5">
<tr> <legend>Service Information</legend>
<td>
<!-- Service Information --> <div class="dl-horizontal">
<table class="box-full">
<tr> <dt>Account</dt>
<td style="width: 40%;">Account</td> <dd><?php printf('%s (%s)',$o->account->name(),$o->account->accnum()); ?></dd>
<td style="width: 60%;" class="data"><?php printf('%s (%s)',$so->account->name(),$so->account->accnum()); ?></td>
</tr> <dt>Service Active</dt>
<tr> <dd><?php echo $o->label_bool('status',TRUE); ?></dd>
<td>Service Active</td>
<td class="data"><?php echo $so->display('status'); ?></td> <dt>Billing Period</dt>
</tr> <dd><?php echo $o->display('recur_schedule');?></dd>
<tr>
<td>Billing Period</td> <dt>Cost</dt>
<td class="data"><?php echo $so->display('recur_schedule');?></td> <dd><?php echo $o->price(TRUE,TRUE); if ($o->pending_change()) echo ' *'; ?></dd>
</tr>
<tr> <?php if (is_null($o->price) OR ($o->price<=$o->product->price($o->price_group,$o->recur_schedule,'price_base'))) : ?>
<td>Cost</td> <dt>Service</dt>
<td class="data"><?php echo $so->price(TRUE,TRUE); if ($so->pending_change()) echo ' *'; ?></td> <dd><?php echo HTML::anchor('product/view/'.$o->product_id,$o->product->title()); ?></dd>
</tr> <?php endif ?>
<?php if (is_null($so->price) OR ($so->price<=$so->product->price($so->price_group,$so->recur_schedule,'price_base'))) { ?>
<tr> <dt>Date Next Invoice</dt>
<td>Service</td> <dd><?php echo $o->display('date_next_invoice'); ?></dd>
<td class="data"><?php echo HTML::anchor('product/view/'.$so->product_id,$so->product->title()); ?></td>
</tr> <dt>Current Invoices Due</dt>
<?php } ?> <dd><?php echo $o->due(TRUE); ?></dd>
<tr>
<td>Date Next Invoice</td> </div> <!-- /dl-horizontal -->
<td class="data"><?php echo $so->display('date_next_invoice'); ?></td> </fieldset>
</tr>
<tr> <?php if ($o->product->feature_summary()) :
<td>Current Invoices Due</td> echo $o->product->feature_summary();
<td class="data"><?php echo Currency::display($so->account->invoices_due_total()); ?></td> endif ?>
</tr>
<?php if ($so->service_billing->loaded()) { ?> </div> <!-- /row -->
<tr>
<td>Direct Debit</td> <div class="row">
<td class="data"><?php echo $so->service_billing->checkout->name; ?></td> <?php echo $o->details('service_view'); ?>
</tr> </div> <!-- /row -->
<?php } ?>
</table> <div class="row">
<!-- END Service Information --> <?php if ($o->service_billing->loaded()) : ?>
</td> <fieldset class="span5">
<td style="vertical-align: top;"> <legend>Automatic Payment Details</legend>
<!-- Product Summary Info -->
<?php echo $so->product_feature_summary(); ?> <dt><?php echo $o->service_billing->checkout->display('name'); ?></dt>
<!-- END Product Summary Info --> <dd>&nbsp;</dd>
</td>
</tr> </fieldset>
</table> <?php endif ?>
<br/>
<?php echo $so->service_view(); ?> <?php if ($o->charges()) : ?>
<br/> <fieldset class="span5">
<table class="box-left" width="50%"> <legend>Service Charges to Bill: <?php echo $o->charges(TRUE,TRUE); ?></legend>
<tr>
<td class="head" colspan="2">Invoices for this service</td> <?php echo Table::factory()
</tr> ->data($o->charge_list(TRUE))
<tr> ->columns(array(
<td>&nbsp;</td> 'date_orig'=>'Date',
</tr> 'description'=>'Description',
<tr> 'total(TRUE)'=>'Amount',
<td colspan="2">Number</td> )); ?>
<td>Invoice Date</td>
<td>Due Date</td> </fieldset>
<td>Total</td> <?php endif ?>
<td>Balance</td>
</tr> <fieldset class="span5">
<?php $i=0; foreach ($so->invoice->distinct('id')->order_by('id DESC')->find_all() as $io) { ?> <legend>Invoices for this Service</legend>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>"> <?php echo Table::factory()
<td class="icon" width="20px"><?php echo HTML::anchor(URL::link('user','invoice/download/'.$io->id),HTML::image('media/img/gnome-pdf.png',array('alt'=>_('Download'),'width'=>20))); ?></td> ->data($o->invoice_list())
<td class="data"><?php echo HTML::anchor(URL::link('user','invoice/view/'.$io->id),$io->id()); ?></td> ->columns(array(
<td class="data"><?php echo $io->display('date_orig'); ?></td> 'id'=>'ID',
<td class="data"><?php echo $io->display('due_date'); ?></td> 'date_orig'=>'Date',
<td class="data"><?php echo $io->total(TRUE); ?></td> 'due_date'=>'Due',
<td class="data"><?php echo $io->due(TRUE); ?></td> 'total(TRUE)'=>'Amount',
</tr> 'due(TRUE)'=>'Due',
<?php } ?> ))
</table> ->prepend(array(
'id'=>array('url'=>URL::link('user','invoice/download/')),
)); ?>
</fieldset>
</div> <!-- /row -->

View File

@ -78,7 +78,7 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
public function service_view() { public function service_view() {
return View::factory('service/user/plugin/ssl/view') return View::factory('service/user/plugin/ssl/view')
->set('so',$this); ->set('o',$this);
} }
/** /**
@ -110,11 +110,14 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
if (! $this->service->status OR ! preg_match('/client/',$this->service->product->plugin()->extensions) OR $this->valid_to() < time()) if (! $this->service->status OR ! preg_match('/client/',$this->service->product->plugin()->extensions) OR $this->valid_to() < time())
return ''; return '';
// @todo Do some password validation $output = Form::open(URL::link('user','ssl/download'),array('class'=>'form-inline'));
$output = Form::open(URL::link('user','ssl/download'));
$output .= Form::hidden('sid',$this->service->id); $output .= Form::hidden('sid',$this->service->id);
$output .= _('Choose a password').': '.Form::password('passwd','').'<br/><br/>'; $output .= '<div class="input-append">';
$output .= Form::submit('download','Download',array('class'=>'form_button')); $output .= Form::password('passwd','',array('label'=>_('Choose a password'),'placeholder'=>'Password','required','nocg'=>TRUE,'pattern'=>'.{6,}','title'=>'Minimum 6 chars'));
$output .= Form::button('download','Download',array('class'=>'btn btn-default','nocg'=>TRUE));
$output .= '</div>';
$output .= Form::close();
return $output; return $output;
} }

View File

@ -1,11 +1,13 @@
<!-- //@todo To translate --> <fieldset class="span6">
<table class="box-full"> <legend>SSL Features</legend>
<tr>
<td style="width: 40%;">Validity Days</td> <div class="dl-horizontal">
<td class="data" style="width: 60%;" colspan="2"><?php echo $po->display('days'); ?></td>
</tr> <dt>Validatity Days</dt>
<tr> <dd><?php echo $po->display('days'); ?></dd>
<td>Type</td>
<td class="data"><?php echo $po->display('extensions'); ?></td> <dt>Type</dt>
</tr> <dd><?php echo $po->display('extensions'); ?></dd>
</table>
</div> <!-- /dl-horizontal -->
</fieldset>

View File

@ -1,56 +1,41 @@
<!-- //@todo To translate --> <fieldset class="span5">
<table class="box-full"> <legend>Service Details</legend>
<tr>
<td class="head" colspan="3">Service Details</td> <div class="dl-horizontal">
</tr>
<tr> <dt>Subject</dt>
<td colspan="3">&nbsp;</td> <dd><?php echo $o->dn(); ?></dd>
</tr>
<tr> <dt>Issuer</dt>
<td> <dd><?php echo $o->issuerdn(); ?></dd>
<table width="100%">
<tr> <dt>CA</dt>
<td style="width: 25%;">Subject</td> <dd><?php echo $o->SSL_CA->loaded() ? $o->SSL_CA->subject() : $o->issuer(); ?></dd>
<td style="width: 75%;" class="data"><?php echo $so->dn(); ?></td>
</tr> <dt>Valid From</dt>
<tr> <dd><?php echo $o->valid_from(TRUE); ?></dd>
<td>Issuer</td>
<td class="data"><?php echo $so->issuerdn(); ?></td> <dt>Valid To</dt>
</tr> <dd><?php echo $o->valid_to(TRUE); ?></dd>
<tr>
<td>CA</td> <dt>Serial Number</dt>
<td class="data"><?php echo $so->SSL_CA->loaded() ? $so->SSL_CA->subject() : $so->issuer(); ?></td> <dd><?php echo $o->serial(); ?></dd>
</tr>
<tr> <dt>Version</dt>
<td>Valid From</td> <dd><?php echo $o->version(); ?></dd>
<td class="data"><?php echo $so->valid_from(TRUE); ?></td>
</tr> <dt>Hash</dt>
<tr> <dd><?php echo $o->hash(); ?></dd>
<td>Valid To</td>
<td class="data"><?php echo $so->valid_to(TRUE); ?></td> <dt>Algorithm</dt>
</tr> <dd><?php echo $o->algorithm(); ?></dd>
<tr>
<td>Serial Number</td> </div> <!-- dl-horizontal -->
<td class="data"><?php echo $so->serial(); ?></td> </fieldset>
</tr>
<tr> <fieldset class="span6">
<td>Version</td> <legend>Certificate</legend>
<td class="data"><?php echo $so->version(); ?></td> <pre><?php echo $o->cert; ?></pre>
</tr>
<tr> <?php echo $o->download_button(); ?>
<td>Hash</td> </fieldset>
<td class="data"><?php echo $so->hash(); ?></td>
</tr>
<tr>
<td>Algorithm</td>
<td class="data"><?php echo $so->algorithm(); ?></td>
</tr>
<tr>
<td>Certificate</td>
<td class="data"><pre><?php echo $so->cert; ?></pre></td>
</tr>
</table>
</td>
<td style="text-align: right;"><?php echo $so->download_button(); ?></td>
</tr>
</table>