Modified the application to reflect the changed field names in the accounts table. For example, payable is now payments.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@380 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -208,8 +208,8 @@ class AccountsController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare a close page...
|
// Prepare a close page...
|
||||||
$tillable_account = $this->Account->relatedAccounts('tillable');
|
$tillable_account = $this->Account->paymentAccounts();
|
||||||
$depositable_account = $this->Account->relatedAccounts('depositable');
|
$depositable_account = $this->Account->depositAccounts();
|
||||||
|
|
||||||
foreach ($tillable_account AS &$acct) {
|
foreach ($tillable_account AS &$acct) {
|
||||||
$acct['Account']['stats'] = $this->Account->stats($acct['Account']['id']);
|
$acct['Account']['stats'] = $this->Account->stats($acct['Account']['id']);
|
||||||
|
|||||||
@@ -166,60 +166,45 @@ class Account extends AppModel {
|
|||||||
|
|
||||||
function relatedAccounts($attribute, $extra = null) {
|
function relatedAccounts($attribute, $extra = null) {
|
||||||
$this->cacheQueries = true;
|
$this->cacheQueries = true;
|
||||||
$account = $this->find('all', array
|
$accounts = $this->find('all', array
|
||||||
('contain' => array('CurrentLedger'),
|
('contain' => array('CurrentLedger'),
|
||||||
'fields' => array('Account.id', 'Account.type', 'Account.name', 'CurrentLedger.id'),
|
'fields' => array('Account.id', 'Account.type', 'Account.name', 'CurrentLedger.id'),
|
||||||
'conditions' => array('Account.'.$attribute => true),
|
'conditions' => array('Account.'.$attribute => true),
|
||||||
'order' => array('Account.name'),
|
'order' => array('Account.name'),
|
||||||
) + (isset($extra) ? $extra : array())
|
) + (isset($extra) ? $extra : array())
|
||||||
);
|
);
|
||||||
$this->cacheQueries = false;
|
$this->cacheQueries = false;
|
||||||
|
|
||||||
return $account;
|
// Rearrange to be of the form (id => name)
|
||||||
|
$rel_accounts = array();
|
||||||
|
foreach ($accounts AS $acct) {
|
||||||
|
$rel_accounts[$acct['Account']['id']] = $acct['Account']['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rel_accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: chargeAccounts
|
* function: xxxAccounts
|
||||||
* - Returns an array of accounts suitable for charges
|
* - Returns an array of accounts suitable for activity xxx
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function chargeAccounts() {
|
function chargeAccounts() {
|
||||||
// Get all accounts that support charges
|
return $this->relatedAccounts('charges', array('order' => 'name'));
|
||||||
$accounts = $this->relatedAccounts('chargeable', array('order' => 'name'));
|
|
||||||
|
|
||||||
// Rearrange to be of the form (id => name)
|
|
||||||
$charge_accounts = array();
|
|
||||||
foreach ($accounts AS $acct) {
|
|
||||||
$charge_accounts[$acct['Account']['id']] = $acct['Account']['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $charge_accounts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: paymentAccounts
|
|
||||||
* - Returns an array of accounts suitable for payments
|
|
||||||
*/
|
|
||||||
|
|
||||||
function paymentAccounts() {
|
function paymentAccounts() {
|
||||||
// Get all accounts that support payments
|
return $this->relatedAccounts('payments', array('order' => 'name'));
|
||||||
$accounts = $this->relatedAccounts('payable', array('order' => 'name'));
|
|
||||||
|
|
||||||
// Rearrange to be of the form (id => name)
|
|
||||||
$payment_accounts = array();
|
|
||||||
foreach ($accounts AS $acct) {
|
|
||||||
$payment_accounts[$acct['Account']['id']] = $acct['Account']['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $payment_accounts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function depositAccounts() {
|
||||||
|
return $this->relatedAccounts('deposits', array('order' => 'name'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user