diff --git a/site/controllers/transactions_controller.php b/site/controllers/transactions_controller.php index 3939155..960b3fd 100644 --- a/site/controllers/transactions_controller.php +++ b/site/controllers/transactions_controller.php @@ -192,27 +192,32 @@ class TransactionsController extends AppController { $close_type_ids[] = $type_id; } + // Make sure we actually have something to deposit if (empty($deposit_type_ids) && empty($deposit_tender_ids)) { $this->Session->setFlash(__('Nothing to Deposit', true)); $this->redirect(array('controller' => 'tenders', 'action'=>'deposit')); } + // Build up a set of conditions based on user selection $deposit_conditions = array(); if (!empty($deposit_type_ids)) $deposit_conditions[] = array('TenderType.id' => $deposit_type_ids); if (!empty($deposit_tender_ids)) $deposit_conditions[] = array('DepositTender.id' => $deposit_tender_ids); + // Add in confirmation that items have not already been deposited $deposit_conditions = array(array('DepositTender.deposit_transaction_id' => null), array('OR' => $deposit_conditions)); + // Lookup the items to be deposited $tenders = $this->Transaction->DepositTender->find ('all', array('contain' => array('TenderType', 'LedgerEntry'), 'conditions' => $deposit_conditions, )); + // Build the deposit transaction $deposit = array('Transaction' => array(), 'Entry' => array()); foreach ($tenders AS $tender) { $deposit['Entry'][] = diff --git a/site/views/tenders/deposit.ctp b/site/views/tenders/deposit.ctp index cf19501..4616d18 100644 --- a/site/views/tenders/deposit.ctp +++ b/site/views/tenders/deposit.ctp @@ -13,7 +13,6 @@ echo $form->create(null, array('id' => 'deposit-form', 'action' => 'postDeposit'))); foreach ($depositTypes AS $type) { - //$acct = $acct['Account']; $names = Inflector::pluralize($type['name']); $radioOptions = @@ -39,7 +38,7 @@ foreach ($depositTypes AS $type) { // REVISIT : 20090729 // Would like to present an option for the user to close the ledger // associated with the form of tender, or to just leave it open. - // For now, just leave it open + // For now, just close it. echo "\n"; echo $form->input("TenderType.{$type['id']}.close", array('type' => 'hidden', @@ -74,24 +73,15 @@ foreach ($depositTypes AS $type) { array('hiddengrid' => true, 'multiselect' => true), - 'grid_events' => - array( -/* 'onHeaderClick' => */ -/* array('gridstate' => */ -/* 'onGridState("#"+$(this).attr("id"), gridstate)'), */ -/* 'gridComplete' => */ -/* array('' => "switchSelection({$type['id']})"), */ -/* 'loadBeforeSend' => */ -/* array('xhr' => "loadBeforeSend()"), */ - ), - 'caption' => "{$names} on hand", - 'filter' => array('deposit_transaction_id' => null, - 'TenderType.id' => $type['id']), + 'filter' => array('deposit_transaction_id' => null, + 'TenderType.id' => $type['id']), 'exclude' => array('Type'), ), )); + // Add a hidden item to hold the jqGrid selection, + // which we'll populate prior to form submission. echo "\n"; echo $form->input("TenderType.{$type['id']}.items", array('type' => 'hidden', @@ -111,17 +101,14 @@ echo '' . "\n";