1));
$data['Lease'] = array_diff_key($customer['Lease'][0], array('Unit'=>1));
$data['Unit'] = $customer['Lease'][0]['Unit'];
}
elseif (isset($customer)) {
$class .= ' customer';
$data = $customer;
$multiple = true;
}
elseif (isset($unit)) {
$class .= ' unit';
$data = array_diff_key($unit, array('CurrentLease'=>1));
$data['Lease'] = array_diff_key($unit['CurrentLease'], array('Customer'=>1));
$data['Customer'] = $unit['CurrentLease']['Customer'];
}
else {
die("INTERNAL ERROR");
}
//pr(compact('customer', 'lease', 'unit', 'class', 'multiple', 'data', 'redirect'));
echo '
' . "\n";
echo('
Move Out: '. $data['Customer']['name'] .
(!$multiple ? ': Unit ' . $data['Unit']['name'] : '') .
'
' . "\n");
echo('
Be sure that you really want to move this customer out, ' .
($multiple ? 'select the correct unit to move out of, ' : '') .
'and press the "Perform Move Out" button.' . "\n");
echo '
' . "\n";
echo $form->create(null, array('id' => 'move-out-form',
'url' => array('controller' => 'leases',
'action' => 'move_out')));
// REVISIT : 20090702
// Ask how to handle the security deposit
// (apply to rent, damages, cleaning, etc).
// Possibly provide a move-out date.
// Let user select the next unit status
// (DAMAGED, COMPANY, UNAVAILABLE, RESERVED, DIRTY, VACANT)
if ($multiple) {
$options = array();
foreach ($data['Lease'] AS $lease)
$options[$lease['id']] = $lease['Unit']['name'];
echo $form->input('Lease.id', array('label' => 'Move Out of Unit: ',
'options' => $options));
}
else {
echo $form->input('Lease.id',
array('type' => 'hidden',
'value' => $data['Lease']['id'],
));
}
// Set up a redirect page. I use lower case 'redirect' here
// to avoid the model convention, which starts with upper-case.
foreach ($redirect AS $name => $value) {
echo $form->input("redirect.$name",
array('type' => 'hidden',
'value' => $value,
));
}
echo $form->end('Perform Move Out');
// End page div
echo '
' . "\n";