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@202 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-02 20:00:50 +00:00
parent 591e1db81d
commit 504f1e7cc0
8 changed files with 352 additions and 57 deletions

View File

@@ -140,6 +140,42 @@ class CustomersController extends AppController {
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: move_out
* - prepare to move a customer out of one of their units
*/
function move_out($id) {
$customer = $this->Customer->find
('first', array
('contain' => array
(// Models
'Lease' =>
array('conditions' => array('Lease.moveout_date' => null),
// Models
'Unit' =>
array('order' => array('sort_order'),
'fields' => array('id', 'name'),
),
),
),
'conditions' => array('Customer.id' => $id),
));
$redirect = array('controller' => 'customers',
'action' => 'view',
$id);
$title = $customer['Customer']['name'] . ': Prepare Move-Out';
$this->set(compact('title', 'customer', 'redirect'));
$this->render('/leases/move_out');
}
/**************************************************************************
**************************************************************************
**************************************************************************
@@ -158,12 +194,31 @@ class CustomersController extends AppController {
$outstanding_balance = $customer['stats']['balance'];
$outstanding_deposit = $customer['deposits']['summary']['balance'];
$this->sidemenu_links[] =
array('name' => 'Operations', 'header' => true);
$this->sidemenu_links[] =
array('name' => 'Payment', 'url' => array('action' => 'payment', $id));
$this->sidemenu_links[] =
array('name' => 'Move-Out', 'url' => array('controller' => 'units', 'action' => 'move-out'));
// Figure out if this customer has any non-closed leases
$show_moveout = false;
$show_payment = false;
foreach ($customer['Lease'] AS $lease) {
if (!isset($lease['close_date']))
$show_payment = true;
if (!isset($lease['moveout_date']))
$show_moveout = true;
}
// Set up dynamic menu items
if ($show_moveout || $show_payment) {
$this->sidemenu_links[] =
array('name' => 'Operations', 'header' => true);
if ($show_moveout) {
$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 = $customer['Customer']['name'];

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',

View File

@@ -53,6 +53,7 @@ class MapsController extends AppController {
$this->redirect(array('action'=>'index'));
}
$this->set('info', $this->mapInfo($id, $requested_width));
$this->set('title', "Site Map");
}

View File

@@ -94,6 +94,42 @@ class UnitsController extends AppController {
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: move_out
* - prepare or execute a move out on a specific lease
*/
function move_out($id) {
$unit = $this->Unit->find
('first', array
('contain' => array
(// Models
'CurrentLease' =>
array(//'conditions' => array('Lease.moveout_date' => null),
// Models
'Customer' =>
array('fields' => array('id', 'name'),
),
),
),
'conditions' => array('Unit.id' => $id),
));
$redirect = array('controller' => 'units',
'action' => 'view',
$id);
$title = ('Lease' . $unit['CurrentLease']['number'] . ': ' .
$unit['Unit']['name'] . ': ' .
$unit['CurrentLease']['Customer']['name'] . ': Prepare Move-Out');
$this->set(compact('title', 'unit', 'redirect'));
$this->render('/leases/move_out');
}
/**************************************************************************
**************************************************************************
**************************************************************************
@@ -137,10 +173,22 @@ class UnitsController extends AppController {
$outstanding_deposit = $deposits['summary']['balance'];
}
$this->sidemenu_links[] =
array('name' => 'Operations', 'header' => true);
$this->sidemenu_links[] =
array('name' => 'Move-Out', 'url' => array('controller' => 'units', 'action' => 'move-out'));
// Set up dynamic menu items
if (isset($unit['CurrentLease']['id']) &&
!isset($unit['CurrentLease']['close_date'])) {
$this->sidemenu_links[] =
array('name' => 'Operations', 'header' => true);
if (!isset($unit['CurrentLease']['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 = 'Unit ' . $unit['Unit']['name'];