Added ability to re-open a lease
git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@1033 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -334,15 +334,6 @@ class LeasesController extends AppController {
|
|||||||
* - Closes a lease to any further action
|
* - Closes a lease to any further action
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// REVISIT <AP>: 20090809
|
|
||||||
// While cleaning up the sitelink data, then delete reldep()
|
|
||||||
function reldep($id) {
|
|
||||||
$this->Lease->id = $id;
|
|
||||||
$stamp = $this->Lease->field('moveout_date');
|
|
||||||
$this->Lease->releaseSecurityDeposits($id, $stamp);
|
|
||||||
$this->redirect(array('action'=>'view', $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
function close($id) {
|
function close($id) {
|
||||||
// REVISIT <AP>: 20090708
|
// REVISIT <AP>: 20090708
|
||||||
// We should probably seek confirmation first...
|
// We should probably seek confirmation first...
|
||||||
@@ -355,6 +346,21 @@ class LeasesController extends AppController {
|
|||||||
$this->redirect(array('action'=>'view', $id));
|
$this->redirect(array('action'=>'view', $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* action: open
|
||||||
|
* - Re-opens a lease for further action
|
||||||
|
*/
|
||||||
|
|
||||||
|
function open($id) {
|
||||||
|
// REVISIT <AP>: 20131204
|
||||||
|
// We should probably seek confirmation first, since this wipes out
|
||||||
|
// the old close date, with no way to restore that date.
|
||||||
|
$this->Lease->reopen($id);
|
||||||
|
$this->redirect(array('action'=>'view', $id));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -574,13 +580,18 @@ class LeasesController extends AppController {
|
|||||||
$this->addSideMenuLink('Write-Off',
|
$this->addSideMenuLink('Write-Off',
|
||||||
array('action' => 'bad_debt', $id), null,
|
array('action' => 'bad_debt', $id), null,
|
||||||
'ACTION');
|
'ACTION');
|
||||||
|
|
||||||
if ($this->Lease->closeable($id))
|
|
||||||
$this->addSideMenuLink('Close',
|
|
||||||
array('action' => 'close', $id), null,
|
|
||||||
'ACTION');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->Lease->closeable($id))
|
||||||
|
$this->addSideMenuLink('Close',
|
||||||
|
array('action' => 'close', $id), null,
|
||||||
|
'ACTION');
|
||||||
|
|
||||||
|
if ($this->Lease->isClosed($id))
|
||||||
|
$this->addSideMenuLink('Re-Open',
|
||||||
|
array('action' => 'open', $id), null,
|
||||||
|
'ACTION');
|
||||||
|
|
||||||
// Prepare to render
|
// Prepare to render
|
||||||
$title = 'Lease: #' . $lease['Lease']['id'];
|
$title = 'Lease: #' . $lease['Lease']['id'];
|
||||||
$this->set(compact('lease', 'title',
|
$this->set(compact('lease', 'title',
|
||||||
|
|||||||
@@ -728,6 +728,53 @@ class Lease extends AppModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* function: reopen
|
||||||
|
* - Re-Opens the lease for further action
|
||||||
|
*/
|
||||||
|
|
||||||
|
function reopen($id) {
|
||||||
|
$this->prEnter(compact('id'));
|
||||||
|
|
||||||
|
if (!$this->isClosed($id))
|
||||||
|
return $this->prReturn(false);
|
||||||
|
|
||||||
|
// Reset the data
|
||||||
|
$this->create();
|
||||||
|
$this->id = $id;
|
||||||
|
|
||||||
|
// Set the close date
|
||||||
|
$this->data['Lease']['close_date'] = null;
|
||||||
|
|
||||||
|
// Save it!
|
||||||
|
$this->save($this->data, false);
|
||||||
|
|
||||||
|
// Update the current lease count for the customer
|
||||||
|
$this->Customer->updateLeaseCount($this->field('customer_id'));
|
||||||
|
|
||||||
|
return $this->prReturn(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* function: isClosed
|
||||||
|
* - Checks to see if the lease is closed
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isClosed($id) {
|
||||||
|
$this->prEnter(compact('id'));
|
||||||
|
|
||||||
|
$this->recursive = -1;
|
||||||
|
$this->read(null, $id);
|
||||||
|
|
||||||
|
return $this->prReturn(!empty($this->data['Lease']['close_date']));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user