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

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