Added ability to create a new customer directly from the move in operation.
git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@760 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -132,14 +132,18 @@ class CustomersController extends AppController {
|
|||||||
* - Sets up the move-in page for the given customer.
|
* - Sets up the move-in page for the given customer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function move_in($id = null) {
|
function move_in($id = null, $unit_id = null) {
|
||||||
$customer = array();
|
$customer = array();
|
||||||
$unit = array();
|
$unit = array();
|
||||||
|
|
||||||
if (isset($id)) {
|
if (!empty($id)) {
|
||||||
$this->Customer->recursive = -1;
|
$this->Customer->recursive = -1;
|
||||||
$customer = current($this->Customer->read(null, $id));
|
$customer = current($this->Customer->read(null, $id));
|
||||||
}
|
}
|
||||||
|
if (!empty($unit_id)) {
|
||||||
|
$this->Customer->Lease->Unit->recursive = -1;
|
||||||
|
$unit = current($this->Customer->Lease->Unit->read(null, $unit_id));
|
||||||
|
}
|
||||||
$this->set(compact('customer', 'unit'));
|
$this->set(compact('customer', 'unit'));
|
||||||
|
|
||||||
$title = 'Customer Move-In';
|
$title = 'Customer Move-In';
|
||||||
@@ -336,7 +340,17 @@ class CustomersController extends AppController {
|
|||||||
$this->redirect(array('action'=>'view', $this->Customer->id));
|
$this->redirect(array('action'=>'view', $this->Customer->id));
|
||||||
|
|
||||||
// Since this is a new customer, go to the move in screen.
|
// Since this is a new customer, go to the move in screen.
|
||||||
$this->redirect(array('action'=>'move_in', $this->Customer->id));
|
// First set the move-in unit id, if there is one, ...
|
||||||
|
if (empty($this->data['movein']['Unit']['id']))
|
||||||
|
$unit_id = null;
|
||||||
|
else
|
||||||
|
$unit_id = $this->data['movein']['Unit']['id'];
|
||||||
|
|
||||||
|
// ... then redirect
|
||||||
|
$this->redirect(array('action'=>'move_in',
|
||||||
|
$this->Customer->id,
|
||||||
|
$unit_id,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
@@ -399,7 +413,8 @@ class CustomersController extends AppController {
|
|||||||
* - Add a new customer
|
* - Add a new customer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function add() {
|
function add($unit_id = null) {
|
||||||
|
$this->set('movein', array('Unit' => array('id' => $unit_id)));
|
||||||
$this->edit();
|
$this->edit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class UnitsController extends AppController {
|
|||||||
$customer = array();
|
$customer = array();
|
||||||
$unit = array();
|
$unit = array();
|
||||||
|
|
||||||
if (isset($id)) {
|
if (!empty($id)) {
|
||||||
$this->Unit->recursive = -1;
|
$this->Unit->recursive = -1;
|
||||||
$unit = current($this->Unit->read(null, $id));
|
$unit = current($this->Unit->read(null, $id));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -320,6 +320,11 @@ echo $form->submit(isset($this->data['Customer']) ? 'Update' : 'Add New Customer
|
|||||||
<?php
|
<?php
|
||||||
; // Alignment
|
; // Alignment
|
||||||
|
|
||||||
|
if (!empty($movein['Unit']['id']))
|
||||||
|
echo $form->input("movein.Unit.id",
|
||||||
|
array('type' => 'hidden',
|
||||||
|
'value' => $movein['Unit']['id'])) . "\n";
|
||||||
|
|
||||||
echo $form->submit(isset($this->data['Customer']) ? 'Update' : 'Add New Customer') . "\n";
|
echo $form->submit(isset($this->data['Customer']) ? 'Update' : 'Add New Customer') . "\n";
|
||||||
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
|
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
|
||||||
echo $form->end() . "\n";
|
echo $form->end() . "\n";
|
||||||
|
|||||||
@@ -47,6 +47,15 @@ function onRowSelect(grid_id, item_type, item_id) {
|
|||||||
$("#LeaseDeposit").val($(grid_id).getCell(item_id, 'Unit-deposit'));
|
$("#LeaseDeposit").val($(grid_id).getCell(item_id, 'Unit-deposit'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item_type == 'unit') {
|
||||||
|
$("#customer-selection-new-url").attr
|
||||||
|
('href',
|
||||||
|
"<?php echo
|
||||||
|
$html->url(array('controller' => 'customers',
|
||||||
|
'action' => 'add')); ?>"
|
||||||
|
+ '/' + $("#unit-id").val());
|
||||||
|
}
|
||||||
|
|
||||||
// Hide the "no customer" message and show the current customer
|
// Hide the "no customer" message and show the current customer
|
||||||
$("."+item_type+"-selection-invalid").hide();
|
$("."+item_type+"-selection-invalid").hide();
|
||||||
$("."+item_type+"-selection-valid").show();
|
$("."+item_type+"-selection-valid").show();
|
||||||
@@ -56,12 +65,12 @@ function onRowSelect(grid_id, item_type, item_id) {
|
|||||||
|
|
||||||
function onGridState(grid_id, item_type, state) {
|
function onGridState(grid_id, item_type, state) {
|
||||||
if (state == 'visible') {
|
if (state == 'visible') {
|
||||||
|
$("."+item_type+"-selection-new").show();
|
||||||
$("."+item_type+"-selection-invalid").hide();
|
$("."+item_type+"-selection-invalid").hide();
|
||||||
$("."+item_type+"-selection-valid").hide();
|
$("."+item_type+"-selection-valid").hide();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//if ($(grid_id).getGridParam("selrow"))
|
$("."+item_type+"-selection-new").hide();
|
||||||
//alert("id:" + $("#"+item_type+"-id").val());
|
|
||||||
if ($("#"+item_type+"-id").val() > 0) {
|
if ($("#"+item_type+"-id").val() > 0) {
|
||||||
$("."+item_type+"-selection-invalid").hide();
|
$("."+item_type+"-selection-invalid").hide();
|
||||||
$("."+item_type+"-selection-valid").show();
|
$("."+item_type+"-selection-valid").show();
|
||||||
@@ -100,6 +109,14 @@ if ($move_type !== 'out') {
|
|||||||
|
|
||||||
echo ('<DIV CLASS="move-inout grid-selection-text">' .
|
echo ('<DIV CLASS="move-inout grid-selection-text">' .
|
||||||
|
|
||||||
|
'<DIV CLASS="customer-selection-new" style="display:none">' .
|
||||||
|
$html->link('Create a new Customer',
|
||||||
|
array('controller' => 'customers',
|
||||||
|
'action' => 'add',
|
||||||
|
(empty($unit['id']) ? null : $unit['id'])),
|
||||||
|
array('id' => 'customer-selection-new-url')) .
|
||||||
|
'</DIV>' .
|
||||||
|
|
||||||
'<DIV CLASS="customer-selection-valid" style="display:none">' .
|
'<DIV CLASS="customer-selection-valid" style="display:none">' .
|
||||||
'Customer: <SPAN id="move-customer"></SPAN>' .
|
'Customer: <SPAN id="move-customer"></SPAN>' .
|
||||||
'</DIV>' .
|
'</DIV>' .
|
||||||
|
|||||||
Reference in New Issue
Block a user