Fixed payment updates, admin update and minor SSL items

This commit is contained in:
Deon George
2011-12-29 13:52:24 +11:00
parent 50fe0583a3
commit 4a68621fc7
8 changed files with 90 additions and 49 deletions

View File

@@ -45,18 +45,25 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
$this->auto_render = FALSE;
$i = 0;
$list = array();
if (isset($_REQUEST['pid']))
foreach (ORM::factory('payment_item')->where('payment_id','=',$_REQUEST['pid'])->find_all() as $pio)
foreach (ORM::factory('payment',$_REQUEST['pid'])->items() as $pio) {
$output .= View::factory($this->viewpath().'/body')
->set('trc',$i++%2 ? 'odd' : 'even')
->set('pio',$pio)
->set('io',$pio->invoice);
// Remember the invoices we have listed
array_push($list,$pio->invoice_id);
}
foreach (ORM::factory('account',$_REQUEST['key'])->invoices_due() as $io)
$output .= View::factory($this->viewpath().'/body')
->set('trc',$i++%2 ? 'odd' : 'even')
->set('pio',ORM::factory('payment_item'))
->set('io',$io);
// Only list invoices not yet listed
if (! in_array($io->id,$list))
$output .= View::factory($this->viewpath().'/body')
->set('trc',$i++%2 ? 'odd' : 'even')
->set('pio',ORM::factory('payment_item'))
->set('io',$io);
// @todo Need the JS to add up the payment allocation before submission
$output .= View::factory($this->viewpath().'/foot')
@@ -96,20 +103,13 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
$po = ORM::factory('payment',$id);
if ($_POST) {
if (isset($_POST['payment_item']) AND count($_POST['payment_item'])) {
foreach ($_POST['payment_item'] as $k=>$v) {
if ($v) {
$pio = $po->add_item();
$pio->invoice_id = $k;
$pio->alloc_amt = $v;
}
}
}
// Update our invoice payment items
if (isset($_POST['payment_item']) AND count($_POST['payment_item']))
foreach ($_POST['payment_item'] as $k=>$v)
$po->add_item($k)->alloc_amt = is_numeric($v) ? $v : 0;
// Entry updated
if (! $po->values($_POST)->check() OR ! $po->save())
throw new Kohana_Exception('Unable to save payment');
else
if ($po->values($_POST)->check() AND $po->save())
SystemMessage::add(array(
'title'=>'Payment Recorded',
'type'=>'info',