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/modules/export/classes/Controller/Reseller/Export.php

105 lines
3.0 KiB
PHP
Raw Permalink Normal View History

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides OSB exporting capabilities.
*
* @package Export
* @category Controllers/Reseller
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Reseller_Export extends Controller_Export {
protected $secure_actions = array(
'export'=>TRUE,
'index'=>TRUE,
'list'=>TRUE,
);
/**
* Export plugins must define an export action.
*/
public function action_export() {
$this->auto_render = FALSE;
if (empty($_POST['export_module_id']) OR ! ($emo = ORM::factory('Export_Module',$_POST['export_module_id'])) OR ! $emo->loaded())
HTTP::redirect(URL::link('reseller','export/index'));
$emo->export->plugin($emo)->export($this->response);
}
/**
* Select our primary export target
*/
public function action_index() {
$output = '';
$output .= Form::open(URL::link('reseller','export/list'));
$output .= Form::select('eid',ORM::factory('Export')->list_select());
$output .= Form::button('submit','Submit',array('class'=>'btn btn-primary'));
2013-07-05 06:11:37 +00:00
$output .= Form::hidden('days',$this->request->param('id'));
$output .= Form::close();
Block::factory()
->title('Select Export Target')
->title_icon('icon-share')
->body($output);
}
/**
* This is the main call to export, providing a list of items to export and
* setting up the page to call the export plugin when submitted.
*/
public function action_list() {
if (empty($_POST['eid']))
HTTP::redirect(URL::link('reseller','export/index'));
$eo = ORM::factory('Export',$_POST['eid']);
if (! $eo->loaded())
HTTP::redirect(URL::link('reseller','export/index'));
$c = 0;
$output = '<div class="tabbable span11">';
$output .= '<ul class="nav nav-tabs">';
// @todo To limit to Reseller accounts only
foreach ($eo->export_module->find_all() as $emo)
$output .= sprintf('<li class="%s"><a href="#tab%s" data-toggle="tab">%s</a></li>',$c++ ? '' : 'active',$emo->id,ucfirst($emo->module->instance()->object_name()));
$output .= '</ul>';
$c = 0;
$output .= '<div class="tab-content">';
foreach ($eo->export_module->find_all() as $emo) {
$output .= sprintf('<div class="tab-pane %s" id="tab%s">',$c++ ? '' : 'active',$emo->id);
$output .= Table::factory()
2013-07-05 06:11:37 +00:00
->data($emo->list_export($this->request->post('days')))
->jssort($emo->id)
->columns(Arr::merge(array(
'id'=>'ID',
'account->name(TRUE)'=>'Account',
'date_orig'=>'Date',
'total(TRUE)'=>'Total',
'exported'=>'Exported',
),$emo->display ? $emo->display : array()))
->select(URL::link('reseller','export/export'),$emo->id,array('export_module_id'=>$emo->id))
->prepend(array(
'id'=>array('checkbox'=>'id[]'),
))->filters(array(
2014-08-25 04:41:07 +00:00
'exported'=>array(array('Site::Date',array(':value'))),
));
$output .= '</div>';
}
$output .= '</div>';
Block::factory()
->title('Export Transactions')
->title_icon('icon-share')
->body($output);
}
}
?>