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