diff --git a/controllers/accounts_controller.php b/controllers/accounts_controller.php index 1085f1c..738d9ad 100644 --- a/controllers/accounts_controller.php +++ b/controllers/accounts_controller.php @@ -209,15 +209,16 @@ class AccountsController extends AppController { } // Prepare a close page... - $tillable_account = $this->Account->paymentAccounts(); - $depositable_account = $this->Account->depositAccounts(); + $payment_accounts = $this->Account->paymentAccounts(); + $deposit_accounts = $this->Account->depositAccounts(); - foreach ($tillable_account AS &$acct) { - $acct['Account']['stats'] = $this->Account->stats($acct['Account']['id']); - } + foreach ($payment_accounts AS $acct_id => &$acct) + $acct = array('id' => $acct_id, + 'name' => $acct, + 'stats' => $this->Account->stats($acct_id)); $title = 'Account: Prepare Deposit'; - $this->set(compact('title', 'tillable_account', 'depositable_account')); + $this->set(compact('title', 'payment_accounts', 'deposit_accounts')); } diff --git a/views/accounts/deposit.ctp b/views/accounts/deposit.ctp index 31ba0a7..a6e7e61 100644 --- a/views/accounts/deposit.ctp +++ b/views/accounts/deposit.ctp @@ -5,69 +5,61 @@ echo '

Perform Bank Deposit

' . "\n"; echo '

Make sure to select the checkboxes below for only those types of currency (Cash, Check, etc) which you intend to actually deposit (you can see all the individual items by dropping down the list below the checkbox). Then, select the Deposit Account where you will make the deposit, and click "Perform Deposit" to close the books on the selected currency types and reset them to a zero balance. On the next page, you will be provided with a deposit slip to prepare the actual deposit.' . "\n"; echo '


' . "\n"; -//pr(compact('tillableAccount', 'depositableAccount')); +pr(compact('paymentAccounts', 'depositAccounts')); echo $form->create(null, array('id' => 'deposit-form', 'url' => array('controller' => 'accounts', 'action' => 'deposit'))); -foreach ($tillableAccount AS $acct) { +foreach ($paymentAccounts AS $acct) { //$acct = $acct['Account']; echo "\n"; - echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.checked', - array(//'label' => $acct['Account']['name'], + echo $form->input("Tillable.Ledger.{$acct['id']}.checked", + array(//'label' => $acct['name'], 'type' => 'checkbox', 'checked' => true, 'value' => true, 'label' => (" I have exactly " . - FormatHelper::currency($acct['Account']['stats']['Ledger']['balance']) . - " in " . ($acct['Account']['name'] === 'Cash' - ? 'Cash' - : Inflector::pluralize($acct['Account']['name'])) . + FormatHelper::currency($acct['stats']['Ledger']['balance']) . + " in " . Inflector::pluralize($acct['name']) . " and will be depositing it all.") )); echo "\n"; - echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.amount', + echo $form->input("Tillable.Ledger.{$acct['id']}.amount", array('type' => 'hidden', - 'value' => $acct['Account']['stats']['Ledger']['balance'], + 'value' => $acct['stats']['Ledger']['balance'], )); echo "\n"; - echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.account_id', + echo $form->input("Tillable.Ledger.{$acct['id']}.account_id", array('type' => 'hidden', - 'value' => $acct['Account']['id'], + 'value' => $acct['id'], )); echo "\n"; - echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.account_name', + echo $form->input("Tillable.Ledger.{$acct['id']}.account_name", array('type' => 'hidden', - 'value' => $acct['Account']['name'], + 'value' => $acct['name'], )); echo "\n"; - $grid_div_id = 'ledger_entries'.$acct['CurrentLedger']['id'].'-list'; - echo $this->element('ledger_entries', array - (// Element configuration - 'ledger_id' => $acct['CurrentLedger']['id'], - 'no_account' => true, - - // Grid configuration + $grid_div_id = "tenders-{$acct['id']}-list"; + echo $this->element('tenders', array + (// Grid configuration 'config' => array ( 'grid_div_id' => $grid_div_id, - 'caption' => ('Items in '.$acct['Account']['name'].' Ledger'), 'grid_setup' => array('hiddengrid' => true), + 'caption' => ('Items in '.$acct['name'].' Ledger'), + 'filter' => array('Tender.deposit_transaction_id' => null, + 'LedgerEntry.account_id' => $acct['id']), + 'exclude' => array(/*'Account'*/), ), )); } -$options = array(); -foreach ($depositableAccount AS $acct) { - $options[$acct['Account']['id']] = $acct['Account']['name']; -} - echo $form->input('Deposit.Account.id', array('label' => 'Deposit Account ', - 'options' => $options)); + 'options' => $depositAccounts)); echo $form->end('Perform Deposit'); /* End page div */