Minor fixes to statement, services and internal things
Many misc updates
This commit is contained in:
@@ -13,77 +13,48 @@
|
||||
class Controller_Admin_Export extends Controller_TemplateDefault_Admin {
|
||||
protected $control_title = 'Export';
|
||||
protected $secure_actions = array(
|
||||
'index'=>TRUE,
|
||||
'export'=>TRUE,
|
||||
'add'=>TRUE,
|
||||
'edit'=>TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
* Export plugins must define an export action.
|
||||
* Add Export Maping items
|
||||
*/
|
||||
public function action_export() {
|
||||
if (empty($_POST['plugin']))
|
||||
$this->request->redirect('admin/export');
|
||||
public function action_add() {
|
||||
$eo = ORM::factory('export');
|
||||
$output = '';
|
||||
|
||||
$sc = sprintf('Export_%s',$_POST['plugin']);
|
||||
if (! class_exists($sc))
|
||||
throw new Kohana_Exception('Export Class doesnt exist for :plugin',array(':plugin'=>$_POST['plugin']));
|
||||
else
|
||||
$export = new $sc;
|
||||
if ($_POST AND $eo->values($_POST)->check()) {
|
||||
$eo->module_id = ORM::factory('module',array('name'=>'product'))->id; // @todo This probably should be in the form.
|
||||
$eo->plugin_name = 'quicken'; // @todo This should be in the form.
|
||||
// Entry updated
|
||||
if (! $eo->save())
|
||||
throw new Kohana_Exception('Unable to save data :post',array(':post'=>serialize($_POST)));
|
||||
|
||||
$export->export();
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Record add'),
|
||||
'type'=>'info',
|
||||
'body'=>_('Export Map entry added.')
|
||||
));
|
||||
}
|
||||
|
||||
$output .= Form::open();
|
||||
$output .= View::factory('export/admin/map/add')
|
||||
->set('eo',$eo);
|
||||
|
||||
$output .= '<div>'.Form::submit('submit',_('Add'),array('class'=>'form_button')).'</div>';
|
||||
$output .= Form::close();
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Add Export Map'),
|
||||
'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.
|
||||
* Edit Export Maping items
|
||||
*/
|
||||
public function action_index($daysago) {
|
||||
// @todo this should come from a file list
|
||||
$TBRexportplugins = array('quicken'=>'Export to Quicken');
|
||||
|
||||
if (! $daysago)
|
||||
$daysago = 30;
|
||||
|
||||
$payments = ORM::factory('payment')
|
||||
->export($daysago);
|
||||
|
||||
if (count($payments)) {
|
||||
$output = Form::open(Request::current()->uri(array('action'=>'export')));
|
||||
$output .= '<table class="box-left">';
|
||||
|
||||
$output .= View::factory('export/payment/header')
|
||||
->set('plugins',$TBRexportplugins);
|
||||
|
||||
$i = 0;
|
||||
foreach ($payments as $payment) {
|
||||
$output .= View::factory('export/payment/body')
|
||||
->set('payment',$payment)
|
||||
->set('i',$i++%2);
|
||||
}
|
||||
|
||||
$output .= '</table>';
|
||||
$output .= Form::submit('submit','export',array('class'=>'form_button'));
|
||||
$output .= Form::close();
|
||||
|
||||
Style::add(array(
|
||||
'type'=>'file',
|
||||
'data'=>'css/list.css',
|
||||
));
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Payments to Export'),
|
||||
'body'=>$output,
|
||||
));
|
||||
|
||||
# Nothing to export
|
||||
} else {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('No payments to export'),
|
||||
'type'=>'info',
|
||||
'body'=>sprintf(_('There are no payments within the last %s days (since %s) to show.'),
|
||||
$daysago,date(Kohana::config('osb')->get('date_format'),$daysago*86400+time())),
|
||||
));
|
||||
}
|
||||
public function action_edit() {
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -22,7 +22,7 @@ class Controller_Affiliate_Export extends Controller_TemplateDefault_Affiliate {
|
||||
*/
|
||||
public function action_export() {
|
||||
if (empty($_POST['plugin']))
|
||||
$this->request->redirect('affiliate/export');
|
||||
$this->request->redirect('affiliate/export/index');
|
||||
|
||||
$sc = sprintf('Export_%s',$_POST['plugin']);
|
||||
if (! class_exists($sc))
|
||||
@@ -38,43 +38,40 @@ class Controller_Affiliate_Export extends Controller_TemplateDefault_Affiliate {
|
||||
* 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_index($daysago) {
|
||||
public function action_index() {
|
||||
// @todo this should come from a file list
|
||||
$TBRexportplugins = array('quicken'=>'Export to Quicken');
|
||||
|
||||
if (! $daysago)
|
||||
$daysago = 30;
|
||||
|
||||
// @todo: Need to limit this to affiliate acounts
|
||||
$payments = ORM::factory('payment')
|
||||
->export($daysago);
|
||||
|
||||
if (count($payments)) {
|
||||
$output = Form::open(Request::current()->uri(array('action'=>'export')));
|
||||
$output .= '<table class="box-left">';
|
||||
|
||||
$output .= View::factory('export/payment/header')
|
||||
->set('plugins',$TBRexportplugins);
|
||||
|
||||
$i = 0;
|
||||
foreach ($payments as $payment) {
|
||||
$output .= View::factory('export/payment/body')
|
||||
->set('payment',$payment)
|
||||
->set('i',$i++%2);
|
||||
}
|
||||
|
||||
$output .= '</table>';
|
||||
$output .= Form::submit('submit','export',array('class'=>'form_button'));
|
||||
$output .= Form::close();
|
||||
|
||||
Style::add(array(
|
||||
'type'=>'file',
|
||||
'data'=>'css/list.css',
|
||||
));
|
||||
$p = ORM::factory('payment');
|
||||
|
||||
if ($p->find_all()->count()) {
|
||||
Block::add(array(
|
||||
'title'=>_('Payments to Export'),
|
||||
'body'=>$output,
|
||||
'body'=>Table::display(
|
||||
$p->find_all(),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID'),
|
||||
'date_payment'=>array('label'=>'Date'),
|
||||
'checkout->display("name")'=>array('label'=>'Method'),
|
||||
'account->accnum()'=>array('label'=>'Acc Num'),
|
||||
'account->name()'=>array('label'=>'Account'),
|
||||
'total_amt'=>array('label'=>'Total','class'=>'right'),
|
||||
'balance(TRUE)'=>array('label'=>'Balance','class'=>'right'),
|
||||
'invoicelist()'=>array('label'=>'Invoices'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>'affiliate/export/export',
|
||||
'hidden'=>array(
|
||||
Form::hidden('plugin','quicken'),
|
||||
),
|
||||
'button'=>array(
|
||||
Form::submit('submit',_('Export'),array('class'=>'form_button')),
|
||||
),
|
||||
)),
|
||||
));
|
||||
|
||||
# Nothing to export
|
||||
|
Reference in New Issue
Block a user