git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@540 97e9348a-65ac-dc4b-aefc-98561f571b83
250 lines
7.5 KiB
PHP
250 lines
7.5 KiB
PHP
<?php /* -*- mode:PHP -*- */
|
|
|
|
$move_action = $this->action;
|
|
//$move_class = preg_replace("/_/", "-", $this->action);
|
|
//$move_date = preg_replace("/_/", "", $this->action) . "_date";
|
|
$move_type = preg_replace("/.*_/", "", $this->action);
|
|
|
|
?>
|
|
|
|
<div class="move-inout input">
|
|
|
|
<?php
|
|
; // Editor alignment
|
|
|
|
/**********************************************************************
|
|
**********************************************************************
|
|
**********************************************************************
|
|
**********************************************************************
|
|
* Javascript
|
|
*/
|
|
|
|
?>
|
|
|
|
<script type="text/javascript"><!--
|
|
|
|
// Reset the form
|
|
function resetForm() {
|
|
$("#customer-id").val(0);
|
|
$("#move-customer").html("INTERNAL ERROR");
|
|
$("#unit-id").val(0);
|
|
$("#move-unit").html("INTERNAL ERROR");
|
|
datepickerNow('LeaseMoveDate', false);
|
|
}
|
|
|
|
function onRowSelect(grid_id, item_type, item_id) {
|
|
cell_name = item_type.charAt(0).toUpperCase() + item_type.substr(1) + "-name";
|
|
|
|
// Set the item id that will be returned with the form
|
|
$("#"+item_type+"-id").val(item_id);
|
|
|
|
// Get the item name from the grid
|
|
$("#move-"+item_type).html($(grid_id).getCell(item_id, cell_name));
|
|
|
|
// If a unit was selected, update the rent and deposit
|
|
if (item_type == 'unit') {
|
|
$("#LeaseRent").val($(grid_id).getCell(item_id, 'Unit-rent'));
|
|
$("#LeaseDeposit").val($(grid_id).getCell(item_id, 'Unit-deposit'));
|
|
}
|
|
|
|
// Hide the "no customer" message and show the current customer
|
|
$("."+item_type+"-selection-invalid").hide();
|
|
$("."+item_type+"-selection-valid").show();
|
|
|
|
$("#"+item_type+"s-list .HeaderButton").click();
|
|
}
|
|
|
|
function onGridState(grid_id, item_type, state) {
|
|
if (state == 'visible') {
|
|
$("."+item_type+"-selection-invalid").hide();
|
|
$("."+item_type+"-selection-valid").hide();
|
|
}
|
|
else {
|
|
//if ($(grid_id).getGridParam("selrow"))
|
|
//alert("id:" + $("#"+item_type+"-id").val());
|
|
if ($("#"+item_type+"-id").val() > 0) {
|
|
$("."+item_type+"-selection-invalid").hide();
|
|
$("."+item_type+"-selection-valid").show();
|
|
} else {
|
|
$("."+item_type+"-selection-invalid").show();
|
|
$("."+item_type+"-selection-valid").hide();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
--></script>
|
|
|
|
<?php
|
|
; // align
|
|
|
|
if ($move_type !== 'out') {
|
|
echo $this->element('customers', array
|
|
('config' => array
|
|
('grid_div_id' => 'customers-list',
|
|
'grid_div_class' => 'text-below',
|
|
'caption' => ('<A HREF="#" ONCLICK="$(\'#customers-list .HeaderButton\').click();'.
|
|
' return false;">Select Customer</A>'),
|
|
'grid_setup' => array('hiddengrid' => isset($customer['id'])),
|
|
'grid_events' => array('onSelectRow' =>
|
|
array('ids' =>
|
|
'if (ids != null){onRowSelect("#"+$(this).attr("id"), "customer", ids);}'),
|
|
'onHeaderClick' =>
|
|
array('gridstate' =>
|
|
'onGridState("#"+$(this).attr("id"), "customer", gridstate)'),
|
|
),
|
|
'nolinks' => true,
|
|
'limit' => 10,
|
|
)));
|
|
}
|
|
|
|
echo ('<DIV CLASS="move-inout grid-selection-text">' .
|
|
|
|
'<DIV CLASS="customer-selection-valid" style="display:none">' .
|
|
'Customer: <SPAN id="move-customer"></SPAN>' .
|
|
'</DIV>' .
|
|
|
|
'<DIV CLASS="customer-selection-invalid" style="display:none">' .
|
|
'Please select customer' .
|
|
'</DIV>' .
|
|
|
|
'</DIV>' . "\n");
|
|
|
|
|
|
if ($move_type !== 'out') {
|
|
echo $this->element('units', array
|
|
('config' => array
|
|
('grid_div_id' => 'units-list',
|
|
'grid_div_class' => 'text-below',
|
|
'caption' => ('<A HREF="#" ONCLICK="$(\'#units-list .HeaderButton\').click();'.
|
|
' return false;">Select Unit</A>'),
|
|
'grid_setup' => array('hiddengrid' => isset($unit['id'])),
|
|
'grid_events' => array('onSelectRow' =>
|
|
array('ids' =>
|
|
'if (ids != null){onRowSelect("#"+$(this).attr("id"), "unit", ids);}'),
|
|
'onHeaderClick' =>
|
|
array('gridstate' =>
|
|
'onGridState("#"+$(this).attr("id"), "unit", gridstate)'),
|
|
),
|
|
'include' => array('Deposit'),
|
|
'exclude' => array('Balance'),
|
|
'action' => 'vacant',
|
|
'nolinks' => true,
|
|
'limit' => 10,
|
|
)));
|
|
}
|
|
|
|
echo ('<DIV CLASS="move-inout grid-selection-text">' .
|
|
|
|
'<DIV CLASS="unit-selection-valid" style="display:none">' .
|
|
'Unit: <SPAN id="move-unit"></SPAN>' .
|
|
'</DIV>' .
|
|
|
|
'<DIV CLASS="unit-selection-invalid" style="display:none">' .
|
|
'Please select unit' .
|
|
'</DIV>' .
|
|
|
|
'</DIV>' . "\n");
|
|
|
|
echo $form->create(null, array('id' => 'move-inout-form',
|
|
'url' => array('controller' => 'leases',
|
|
'action' => $move_action)));
|
|
|
|
echo $form->input("Lease.customer_id",
|
|
array('id' => 'customer-id',
|
|
'type' => 'hidden',
|
|
'value' => 0));
|
|
|
|
echo $form->input("Lease.unit_id",
|
|
array('id' => 'unit-id',
|
|
'type' => 'hidden',
|
|
'value' => 0));
|
|
|
|
if ($move_type === 'out') {
|
|
echo $form->input('Lease.id',
|
|
array('type' => 'hidden',
|
|
'value' => $lease['id'],
|
|
));
|
|
}
|
|
|
|
echo $this->element('form_table',
|
|
array('class' => "item move-inout entry",
|
|
'field_prefix' => 'Lease',
|
|
'fields' => array
|
|
('move'.$move_type.'_date' =>
|
|
array('opts' =>
|
|
array('type' => 'text',
|
|
'id' => "LeaseMoveDate"),
|
|
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'LeaseMoveDate\', false); return false;">Now</A>',
|
|
),
|
|
) +
|
|
($move_type === 'in' ? array
|
|
("deposit" =>
|
|
array('opts' => array
|
|
('value' => (!empty($unit)
|
|
? FormatHelper::currency($unit['deposit'])
|
|
: null))),
|
|
"rent" =>
|
|
array('opts' => array
|
|
('value' => (!empty($unit)
|
|
? FormatHelper::currency($unit['rent'])
|
|
: null))),
|
|
) : array()) + array
|
|
("comment" =>
|
|
($move_type !== 'out'
|
|
? array('opts' => array('size' => 50))
|
|
: null),
|
|
)));
|
|
|
|
if ($move_type === 'out') {
|
|
echo('<P><BR>Be sure that you really want to move this customer out of the unit,<BR>' .
|
|
'select the correct moveout date,' .
|
|
'and press the "Perform Move Out" button.' . "\n");
|
|
}
|
|
|
|
// Set up a redirect page. I use lower case 'redirect' here
|
|
// to avoid the model convention, which starts with upper-case.
|
|
if (isset($redirect)) {
|
|
foreach ($redirect AS $name => $value) {
|
|
echo $form->input("redirect.$name",
|
|
array('type' => 'hidden',
|
|
'value' => $value,
|
|
));
|
|
}
|
|
}
|
|
|
|
echo $form->end('Perform Move ' . ucfirst($move_type));
|
|
|
|
?>
|
|
|
|
<script type="text/javascript"><!--
|
|
$(document).ready(function(){
|
|
$("#LeaseMoveDate")
|
|
.attr('autocomplete', 'off')
|
|
.datepicker({ constrainInput: true,
|
|
numberOfMonths: [1, 1],
|
|
showCurrentAtPos: 0,
|
|
dateFormat: 'mm/dd/yy' });
|
|
|
|
resetForm();
|
|
|
|
<?php if (isset($customer['id'])): ?>
|
|
$("#customer-id").val(<?php echo $customer['id']; ?>);
|
|
$("#move-customer").html("<?php echo $customer['name']; ?>");
|
|
onGridState(null, 'customer', 'hidden');
|
|
<?php else: ?>
|
|
onGridState(null, 'customer', 'visible');
|
|
<?php endif; ?>
|
|
|
|
<?php if (isset($unit['id'])): ?>
|
|
$("#unit-id").val(<?php echo $unit['id']; ?>);
|
|
$("#move-unit").html("<?php echo $unit['name']; ?>");
|
|
onGridState(null, 'unit', 'hidden');
|
|
<?php else: ?>
|
|
onGridState(null, 'unit', 'visible');
|
|
<?php endif; ?>
|
|
});
|
|
--></script>
|
|
|
|
</div>
|