Fixed bug when fetching data for editing a customer (the details function was deleted sometime back and might be worth putting back in). Also, added a tiny helper feature to update cached items while things are still somewhat unstable. Any time customer edit is clicked, the customer (and associated leases) will all be updated. This should allow an easy customer workaround in case there is a bug in the field.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@599 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -326,7 +326,37 @@ class CustomersController extends AppController {
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$this->data = $this->Customer->details($id);
|
||||
// REVISIT <AP>: 20090816
|
||||
// This should never need to be done by a controller.
|
||||
// However, until things stabilize, this gives the
|
||||
// user a way to update any cached items on the
|
||||
// customer, by just clicking Edit then Cancel.
|
||||
$this->Customer->update($id);
|
||||
|
||||
// Get details on this customer, its contacts and leases
|
||||
$customer = $this->Customer->find
|
||||
('first', array
|
||||
('contain' => array
|
||||
(// Models
|
||||
'Contact' =>
|
||||
array('order' => array('Contact.display_name'),
|
||||
// Models
|
||||
'ContactPhone',
|
||||
'ContactEmail',
|
||||
'ContactAddress',
|
||||
),
|
||||
'Lease' =>
|
||||
array('Unit' =>
|
||||
array('order' => array('sort_order'),
|
||||
'fields' => array('id', 'name'),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
'conditions' => array('Customer.id' => $id),
|
||||
));
|
||||
|
||||
$this->data = $customer;
|
||||
$title = 'Customer: ' . $this->data['Customer']['name'] . " : Edit";
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -208,6 +208,7 @@ class Customer extends AppModel {
|
||||
* - Update any cached or calculated fields
|
||||
*/
|
||||
function update($id) {
|
||||
$this->prEnter(compact('id'));
|
||||
|
||||
// REVISIT <AP>: 20090812
|
||||
// updateLeaseCount is handled directly when needed.
|
||||
@@ -216,11 +217,21 @@ class Customer extends AppModel {
|
||||
|
||||
$current_leases =
|
||||
$this->find('all',
|
||||
array('link' => array('CurrentLease' => array('type' => 'INNER')),
|
||||
// REVISIT <AP>: 20090816
|
||||
// Do we need to update leases other than the current ones?
|
||||
// It may be necessary. For example, a non-current lease
|
||||
// can still be hit with an NSF item. In that case, it
|
||||
// could have stale data if we look only to current leases.
|
||||
//array('link' => array('CurrentLease' => array('type' => 'INNER')),
|
||||
array('link' => array('Lease' => array('type' => 'INNER')),
|
||||
'conditions' => array('Customer.id' => $id)));
|
||||
|
||||
foreach ($current_leases AS $lease)
|
||||
$this->Lease->update($lease['CurrentLease']['id']);
|
||||
foreach ($current_leases AS $lease) {
|
||||
if (!empty($lease['CurrentLease']['id']))
|
||||
$this->Lease->update($lease['CurrentLease']['id']);
|
||||
if (!empty($lease['Lease']['id']))
|
||||
$this->Lease->update($lease['Lease']['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -792,6 +792,8 @@ class Lease extends AppModel {
|
||||
* - Update any cached or calculated fields
|
||||
*/
|
||||
function update($id) {
|
||||
$this->prEnter(compact('id'));
|
||||
|
||||
$this->id = $id;
|
||||
$this->saveField('charge_through_date', $this->rentChargeThrough($id));
|
||||
$this->saveField('paid_through_date', $this->rentPaidThrough($id));
|
||||
|
||||
Reference in New Issue
Block a user