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:
Abijah
2013-12-05 02:00:51 +00:00
parent 20df22a002
commit 4cc81c2ebc
2 changed files with 72 additions and 14 deletions

View File

@@ -334,15 +334,6 @@ class LeasesController extends AppController {
* - 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) {
// REVISIT <AP>: 20090708
// We should probably seek confirmation first...
@@ -355,6 +346,21 @@ class LeasesController extends AppController {
$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,12 +580,17 @@ class LeasesController extends AppController {
$this->addSideMenuLink('Write-Off',
array('action' => 'bad_debt', $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
$title = 'Lease: #' . $lease['Lease']['id'];

View File

@@ -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']));
}
/**************************************************************************
**************************************************************************
**************************************************************************