Finished basic functionality for Move-Out. This still needs some work to handle the security deposit.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@202 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-02 20:00:50 +00:00
parent e060c16252
commit 99504c6de5
8 changed files with 352 additions and 57 deletions

View File

@@ -88,6 +88,57 @@ class LeasesController extends AppController {
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: move_out
* - prepare or execute a move out on a specific lease
*/
function move_out($id = null) {
if ($this->data) {
// Handle the move out based on the data given
pr($this->data);
$this->Lease->moveOut($this->data['Lease']['id']);
$this->redirect($this->data['redirect']);
//$this->autoRender = false;
return;
}
if (!isset($id))
die("Oh Nooooo!!");
$lease = $this->Lease->find
('first', array
('contain' => array
(// Models
'Unit' =>
array('order' => array('sort_order'),
'fields' => array('id', 'name'),
),
'Customer' =>
array('fields' => array('id', 'name'),
),
),
'conditions' => array(array('Lease.id' => $id),
array('Lease.close_date' => null),
),
));
$redirect = array('controller' => 'leases',
'action' => 'view',
$id);
$title = ('Lease #' . $lease['Lease']['number'] . ': ' .
$lease['Unit']['name'] . ': ' .
$lease['Customer']['name'] . ': Prepare Move-Out');
$this->set(compact('title', 'lease', 'redirect'));
}
/**************************************************************************
**************************************************************************
**************************************************************************
@@ -111,7 +162,6 @@ class LeasesController extends AppController {
'Customer',
),
'conditions' => array(array('Lease.id' => $id)),
'limit' => 2
)
);
@@ -124,6 +174,22 @@ class LeasesController extends AppController {
$deposits = $this->Lease->findSecurityDeposits($lease['Lease']['id']);
$outstanding_deposit = $deposits['summary']['balance'];
// Set up dynamic menu items
if (!isset($lease['Lease']['close_date'])) {
$this->sidemenu_links[] =
array('name' => 'Operations', 'header' => true);
if (!isset($lease['Lease']['moveout_date'])) {
$this->sidemenu_links[] =
array('name' => 'Move-Out', 'url' => array('action' => 'move_out',
$id));
}
$this->sidemenu_links[] =
array('name' => 'Payment', 'url' => array('action' => 'payment',
$id));
}
// Prepare to render
$title = 'Lease: #' . $lease['Lease']['id'];
$this->set(compact('lease', 'title',