Consistency updates for use of viewpath()
This commit is contained in:
@@ -14,6 +14,7 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
|
||||
protected $secure_actions = array(
|
||||
'add'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
'view'=>TRUE,
|
||||
'autocomplete'=>FALSE,
|
||||
'autoitemlist'=>FALSE,
|
||||
);
|
||||
@@ -40,24 +41,24 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
|
||||
if (! Request::current()->is_ajax() OR ! isset($_REQUEST['key']) OR ! trim($_REQUEST['key']))
|
||||
die();
|
||||
|
||||
$output = View::factory('payment/admin/item/list_head');
|
||||
$output = View::factory($this->viewpath().'/head');
|
||||
$this->auto_render = FALSE;
|
||||
|
||||
$i = 0;
|
||||
if (isset($_REQUEST['pid']))
|
||||
foreach (ORM::factory('payment_item')->where('payment_id','=',$_REQUEST['pid'])->find_all() as $pio)
|
||||
$output .= View::factory('payment/admin/item/list_body')
|
||||
$output .= View::factory($this->viewpath().'/body')
|
||||
->set('trc',$i++%2 ? 'odd' : 'even')
|
||||
->set('pio',$pio)
|
||||
->set('io',$pio->invoice);
|
||||
|
||||
foreach (ORM::factory('account',$_REQUEST['key'])->invoices_due() as $io)
|
||||
$output .= View::factory('payment/admin/item/list_body')
|
||||
$output .= View::factory($this->viewpath().'/body')
|
||||
->set('trc',$i++%2 ? 'odd' : 'even')
|
||||
->set('io',$io);
|
||||
|
||||
// @todo Need the JS to add up the payment allocation before submission
|
||||
$output .= View::factory('payment/admin/item/list_foot')
|
||||
$output .= View::factory($this->viewpath().'/foot')
|
||||
->set('trc',$i++%2 ? 'odd' : 'even');
|
||||
|
||||
$this->response->body($output);
|
||||
@@ -73,7 +74,7 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
|
||||
ORM::factory('payment')->find_all(),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>'admin/payment/add/'),
|
||||
'id'=>array('label'=>'ID','url'=>'admin/payment/view/'),
|
||||
'date_payment'=>array('label'=>'Date'),
|
||||
'account->accnum()'=>array('class'=>'right'),
|
||||
'account->name()'=>array('label'=>'Account'),
|
||||
@@ -85,24 +86,12 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>'admin/payment/add',
|
||||
'form'=>'admin/payment/view',
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
||||
public function action_add() {
|
||||
$output = '';
|
||||
|
||||
if (! $id = $this->request->param('id')) {
|
||||
if (isset($_POST['id']) AND is_array($_POST['id']))
|
||||
Table::post('payment_view','id');
|
||||
|
||||
list($id,$output) = Table::page('payment_view');
|
||||
|
||||
} else {
|
||||
$id = $this->request->param('id');
|
||||
}
|
||||
|
||||
private function add_view($id=NULL,$output='') {
|
||||
$po = ORM::factory('payment',$id);
|
||||
|
||||
if ($_POST) {
|
||||
@@ -122,13 +111,13 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
|
||||
SystemMessage::add(array(
|
||||
'title'=>'Payment Recorded',
|
||||
'type'=>'info',
|
||||
'body'=>'Payment successfully recorded.',
|
||||
'body'=>'Payment successfully recorded.',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$output .= Form::open();
|
||||
$output .= View::factory('payment/admin/add')
|
||||
$output .= View::factory('payment/admin/add_view')
|
||||
->set('po',$po);;
|
||||
$output .= Form::submit('submit','submit',array('class'=>'form_button'));
|
||||
$output .= Form::close();
|
||||
@@ -167,21 +156,21 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
|
||||
source: "'.URL::site('admin/payment/autocomplete').'",
|
||||
minLength: 2,
|
||||
change: function(event,ui) {
|
||||
// Send the request and update sub category dropdown
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
data: "key="+$(this).val(),
|
||||
dataType: "html",
|
||||
cache: false,
|
||||
url: "'.URL::site('admin/payment/autoitemlist').'",
|
||||
timeout: 2000,
|
||||
error: function(x) {
|
||||
alert("Failed to submit");
|
||||
},
|
||||
// Send the request and update sub category dropdown
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
data: "key="+$(this).val(),
|
||||
dataType: "html",
|
||||
cache: false,
|
||||
url: "'.URL::site('admin/payment/autoitemlist').'",
|
||||
timeout: 2000,
|
||||
error: function(x) {
|
||||
alert("Failed to submit");
|
||||
},
|
||||
success: function(data) {
|
||||
$("div[id=items]").replaceWith(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});'
|
||||
@@ -195,9 +184,22 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
|
||||
));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function action_add() {
|
||||
Block::add(array(
|
||||
'title'=>_('Add Payments Received'),
|
||||
'body'=>$output,
|
||||
'body'=>$this->add_view(),
|
||||
));
|
||||
}
|
||||
|
||||
public function action_view() {
|
||||
list($id,$output) = Table::page(__METHOD__);
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s',_('View Payments Received'),$id),
|
||||
'body'=>$this->add_view($id,$output),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user