Files
pmgr/views/leases/move_in.ctp
abijah d51c29bc91 Added a datepicker to the move-out view and put the input fields of both move-in and move-out into a table to tidy things up a bit.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@225 97e9348a-65ac-dc4b-aefc-98561f571b83
2009-07-06 04:32:14 +00:00

188 lines
5.4 KiB
PHP

<?php /* -*- mode:PHP -*- */ ?>
<div class="move-in input">
<?php
; // Editor alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
*
*/
$customer_grid_setup = array();
if (isset($customer['id']))
$customer_grid_setup['hiddengrid'] = true;
$customer_grid_setup['onSelectRow'] = array
('--special' =>
'function(ids) { if (ids != null) { onRowSelect("#"+$(this).attr("id"), "customer", ids); } }'
);
$customer_grid_setup['onHeaderClick'] = array
('--special' =>
'function(gridstate) { onGridState("#"+$(this).attr("id"), "customer", gridstate); }'
);
$unit_grid_setup = array();
if (isset($unit['id']))
$unit_grid_setup['hiddengrid'] = true;
$unit_grid_setup['onSelectRow'] = array
('--special' =>
'function(ids) { if (ids != null) { onRowSelect("#"+$(this).attr("id"), "unit", ids); } }'
);
$unit_grid_setup['onHeaderClick'] = array
('--special' =>
'function(gridstate) { onGridState("#"+$(this).attr("id"), "unit", gridstate); }'
);
?>
<script type="text/javascript"><!--
// Reset the form
function resetForm() {
$("#customer-id").val(0);
$("#movein-customer").html("INTERNAL ERROR");
$("#unit-id").val(0);
$("#movein-unit").html("INTERNAL ERROR");
}
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
$("#movein-"+item_type).html($(grid_id).getCell(item_id, cell_name));
// Hide the "no customer" message and show the current customer
$("#no-"+item_type).hide();
$("#current-"+item_type).show();
$("#"+item_type+"s-list .HeaderButton").click();
}
function onGridState(grid_id, item_type, state) {
if (state == 'visible') {
$("#no-"+item_type).hide();
$("#current-"+item_type).hide();
}
else {
//if ($(grid_id).getGridParam("selrow"))
//alert("id:" + $("#"+item_type+"-id").val());
if ($("#"+item_type+"-id").val() > 0) {
$("#current-"+item_type).show();
$("#no-"+item_type).hide();
} else {
$("#current-"+item_type).hide();
$("#no-"+item_type).show();
}
}
}
--></script>
<?php
; // align
echo $this->element('customers',
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' => $customer_grid_setup,
'nolinks' => true,
'limit' => 10,
));
echo ('<H2>' .
'<SPAN id="current-customer">Customer: <SPAN id="movein-customer"></SPAN></SPAN>' .
'<SPAN id="no-customer">Please select customer</SPAN>' .
'</H2>' . "\n");
echo $this->element('units',
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' => $unit_grid_setup,
'action' => 'unoccupied',
'nolinks' => true,
'limit' => 10,
));
echo ('<H2>' .
'<SPAN id="current-unit">Unit: <SPAN id="movein-unit"></SPAN></SPAN>' .
'<SPAN id="no-unit">Please select unit</SPAN>' .
'</H2>' . "\n");
echo $form->create(null, array('id' => 'move-in-form',
'url' => array('controller' => 'leases',
'action' => 'move_in')));
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));
echo $this->element('form_table',
array('class' => "item move-in entry",
'field_prefix' => 'Lease',
'fields' => array
("movein_date" => array('opts' => array('type' => 'text',
'id' => 'datepicker')),
"comment" => array('opts' => array('size' => 50)),
)));
echo $form->end('Move In Customer');
?>
<script type="text/javascript"><!--
$(document).ready(function(){
$("#datepicker").datepicker({ constrainInput: true,
numberOfMonths: [1, 1],
showCurrentAtPos: 0,
dateFormat: 'mm/dd/yy' })
.datepicker('setDate', '+0');
resetForm();
<?php if (isset($customer['id'])): ?>
$("#customer-id").val(<?php echo $customer['id']; ?>);
$("#movein-customer").html("<?php echo $customer['name']; ?>");
$("#current-customer").show();
$("#no-customer").hide();
<?php else: ?>
$("#current-customer").hide();
$("#no-customer").hide();
<?php endif; ?>
<?php if (isset($unit['id'])): ?>
$("#unit-id").val(<?php echo $unit['id']; ?>);
$("#movein-unit").html("<?php echo $unit['name']; ?>");
$("#current-unit").show();
$("#no-unit").hide();
<?php else: ?>
$("#current-unit").hide();
$("#no-unit").hide();
<?php endif; ?>
});
--></script>
</div>