Added the Containable behavior back into the AppModel, since it's obviously getting used in every controller.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@91 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -38,8 +38,7 @@
|
||||
*/
|
||||
class AppModel extends Model {
|
||||
|
||||
//var $actsAs = array('Containable');
|
||||
var $actsAs = array('Linkable');
|
||||
var $actsAs = array('Containable', 'Linkable');
|
||||
|
||||
/**
|
||||
* Get Enum Values
|
||||
|
||||
@@ -170,7 +170,6 @@ class AccountsController extends AppController {
|
||||
}
|
||||
|
||||
// Get details about the account and its ledgers (no ledger entries yet)
|
||||
$this->Account->Behaviors->attach('Containable');
|
||||
$account = $this->Account->find
|
||||
('first',
|
||||
array('contain' =>
|
||||
@@ -184,7 +183,6 @@ class AccountsController extends AppController {
|
||||
'conditions' => array(array('Account.id' => $id)),
|
||||
)
|
||||
);
|
||||
$this->Account->Behaviors->detach('Containable');
|
||||
|
||||
// Get all ledger entries of the CURRENT ledger
|
||||
$entries = $this->Account->findLedgerEntries($id);
|
||||
|
||||
@@ -65,16 +65,17 @@ class ContactsController extends AppController {
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
|
||||
$this->Contact->Behaviors->attach('Containable');
|
||||
$this->Contact->contain
|
||||
(array(// Models
|
||||
'ContactPhone',
|
||||
'ContactEmail',
|
||||
'ContactAddress',
|
||||
'Customer')
|
||||
);
|
||||
$contact = $this->Contact->read(null, $id);
|
||||
$this->Contact->Behaviors->detach('Containable');
|
||||
$contact = $this->Contact->find
|
||||
('first', array
|
||||
('contain' => array
|
||||
(// Models
|
||||
'ContactPhone',
|
||||
'ContactEmail',
|
||||
'ContactAddress',
|
||||
'Customer'),
|
||||
|
||||
'conditions' => array('Contact.id' => $id),
|
||||
));
|
||||
|
||||
// Prepare to render.
|
||||
$title = $contact['Contact']['display_name'];
|
||||
|
||||
@@ -117,26 +117,27 @@ class CustomersController extends AppController {
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
|
||||
$this->Customer->Behaviors->attach('Containable');
|
||||
$this->Customer->contain
|
||||
(array(// Models
|
||||
'Contact' =>
|
||||
array(// Models
|
||||
'ContactPhone',
|
||||
'ContactEmail',
|
||||
'ContactAddress',
|
||||
),
|
||||
'Account',
|
||||
'Lease' =>
|
||||
array('Unit' =>
|
||||
array('order' => array('sort_order'),
|
||||
'fields' => array('id', 'name'),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
$customer = $this->Customer->read(null, $id);
|
||||
$this->Customer->Behaviors->detach('Containable');
|
||||
$customer = $this->Customer->find
|
||||
('first', array
|
||||
('contain' => array
|
||||
(// Models
|
||||
'Contact' =>
|
||||
array(// Models
|
||||
'ContactPhone',
|
||||
'ContactEmail',
|
||||
'ContactAddress',
|
||||
),
|
||||
'Account',
|
||||
'Lease' =>
|
||||
array('Unit' =>
|
||||
array('order' => array('sort_order'),
|
||||
'fields' => array('id', 'name'),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
'conditions' => array('Customer.id' => $id),
|
||||
));
|
||||
|
||||
// Add the lease balance to each lease.
|
||||
foreach ($customer['Lease'] AS &$lease) {
|
||||
|
||||
@@ -120,7 +120,6 @@ class LeasesController extends AppController {
|
||||
}
|
||||
|
||||
// Get details about the lease and its ledgers (no ledger entries yet)
|
||||
$this->Lease->Behaviors->attach('Containable');
|
||||
$lease = $this->Lease->find
|
||||
('first',
|
||||
array('contain' =>
|
||||
@@ -134,7 +133,6 @@ class LeasesController extends AppController {
|
||||
'limit' => 2
|
||||
)
|
||||
);
|
||||
$this->Lease->Behaviors->detach('Containable');
|
||||
|
||||
// Summarize each ledger
|
||||
$this->Lease->statsMerge($lease,
|
||||
|
||||
@@ -33,7 +33,6 @@ class LedgerEntriesController extends AppController {
|
||||
}
|
||||
|
||||
// Get the LedgerEntry and related fields
|
||||
$this->LedgerEntry->Behaviors->attach('Containable');
|
||||
$entry = $this->LedgerEntry->find
|
||||
('first',
|
||||
array('contain' => array('MonetarySource.id',
|
||||
@@ -51,15 +50,15 @@ class LedgerEntriesController extends AppController {
|
||||
'fields' => array('LedgerEntry.id',
|
||||
'LedgerEntry.amount',
|
||||
'LedgerEntry.comment'),
|
||||
|
||||
'conditions' => array('LedgerEntry.id' => $id),
|
||||
));
|
||||
$this->LedgerEntry->Behaviors->detach('Containable');
|
||||
|
||||
// Because 'DebitLedger' and 'CreditLedger' both relate to 'Account',
|
||||
// CakePHP will not include them in the LedgerEntry->find (or so it
|
||||
// seems). We'll have to break out each Account separately.
|
||||
|
||||
// Get the Account from DebitLedger
|
||||
$this->LedgerEntry->DebitLedger->Account->Behaviors->attach('Containable');
|
||||
$account = $this->LedgerEntry->DebitLedger->Account->find
|
||||
('first',
|
||||
array('contain' => true,
|
||||
@@ -67,10 +66,8 @@ class LedgerEntriesController extends AppController {
|
||||
'conditions' => array('Account.id' => $entry['DebitLedger']['account_id']),
|
||||
));
|
||||
$entry['DebitLedger'] = array_merge($entry['DebitLedger'], $account);
|
||||
$this->LedgerEntry->DebitLedger->Account->Behaviors->detach('Containable');
|
||||
|
||||
// Get the Account from CreditLedger
|
||||
$this->LedgerEntry->CreditLedger->Account->Behaviors->attach('Containable');
|
||||
$account = $this->LedgerEntry->CreditLedger->Account->find
|
||||
('first',
|
||||
array('contain' => true,
|
||||
@@ -78,7 +75,6 @@ class LedgerEntriesController extends AppController {
|
||||
'conditions' => array('Account.id' => $entry['CreditLedger']['account_id']),
|
||||
));
|
||||
$entry['CreditLedger'] = array_merge($entry['CreditLedger'], $account);
|
||||
$this->LedgerEntry->CreditLedger->Account->Behaviors->detach('Containable');
|
||||
|
||||
// Prepare to render.
|
||||
$title = "Ledger Entry #{$entry['LedgerEntry']['id']}";
|
||||
|
||||
@@ -118,7 +118,6 @@ class LedgersController extends AppController {
|
||||
}
|
||||
|
||||
// Get details about the ledger itself (no entries yet)
|
||||
$this->Ledger->Behaviors->attach('Containable');
|
||||
$ledger = $this->Ledger->find
|
||||
('first',
|
||||
array('contain' =>
|
||||
@@ -128,7 +127,6 @@ class LedgersController extends AppController {
|
||||
'conditions' => array(array('Ledger.id' => $id)),
|
||||
)
|
||||
);
|
||||
$this->Ledger->Behaviors->detach('Containable');
|
||||
|
||||
// Get all ledger entries of this ledger
|
||||
$ledger['LedgerEntry'] = $this->Ledger->findLedgerEntries
|
||||
|
||||
@@ -97,30 +97,30 @@ class TransactionsController extends AppController {
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
|
||||
$this->Transaction->Behaviors->attach('Containable');
|
||||
$this->Transaction->contain
|
||||
(array(// Models
|
||||
'LedgerEntry' => array('fields' => array('LedgerEntry.id',
|
||||
'LedgerEntry.amount',
|
||||
'LedgerEntry.comment'),
|
||||
//Models
|
||||
$transaction = $this->Transaction->find
|
||||
('first',
|
||||
array('contain' =>
|
||||
array(// Models
|
||||
'LedgerEntry' => array('fields' => array('LedgerEntry.id',
|
||||
'LedgerEntry.amount',
|
||||
'LedgerEntry.comment'),
|
||||
//Models
|
||||
|
||||
'DebitLedger' => array
|
||||
('fields' => array('DebitLedger.id', 'DebitLedger.sequence'),
|
||||
'Account' => array
|
||||
('fields' => array('Account.id', 'Account.name')),
|
||||
),
|
||||
'DebitLedger' => array
|
||||
('fields' => array('DebitLedger.id', 'DebitLedger.sequence'),
|
||||
'Account' => array
|
||||
('fields' => array('Account.id', 'Account.name')),
|
||||
),
|
||||
|
||||
'CreditLedger' => array
|
||||
('fields' => array('CreditLedger.id', 'CreditLedger.sequence'),
|
||||
'Account' => array
|
||||
('fields' => array('Account.id', 'Account.name')),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
$transaction = $this->Transaction->read(null, $id);
|
||||
$this->Transaction->Behaviors->detach('Containable');
|
||||
'CreditLedger' => array
|
||||
('fields' => array('CreditLedger.id', 'CreditLedger.sequence'),
|
||||
'Account' => array
|
||||
('fields' => array('Account.id', 'Account.name')),
|
||||
),
|
||||
),
|
||||
),
|
||||
'conditions' => array('Transaction.id' => $id),
|
||||
));
|
||||
|
||||
// Figure out the transaction total
|
||||
$total = 0;
|
||||
|
||||
@@ -152,16 +152,16 @@ class UnitsController extends AppController {
|
||||
$this->redirect(array('action'=>''));
|
||||
}
|
||||
|
||||
$this->Unit->Behaviors->attach('Containable');
|
||||
$this->Unit->contain
|
||||
(array(// Models
|
||||
'UnitSize',
|
||||
'Lease' => array('Customer'),
|
||||
'CurrentLease' => array('Customer')
|
||||
)
|
||||
);
|
||||
$unit = $this->Unit->read(null, $id);
|
||||
$this->Unit->Behaviors->detach('Containable');
|
||||
$unit = $this->Unit->find
|
||||
('first',
|
||||
array('contain' =>
|
||||
array(// Models
|
||||
'UnitSize',
|
||||
'Lease' => array('Customer'),
|
||||
'CurrentLease' => array('Customer')
|
||||
),
|
||||
'conditions' => array('Unit.id' => $id),
|
||||
));
|
||||
|
||||
// Get the balance on each lease.
|
||||
foreach ($unit['Lease'] AS &$lease) {
|
||||
|
||||
Reference in New Issue
Block a user