Changed the relationship between grid visibility and text of the selected item.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@207 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-04 17:38:22 +00:00
parent 27503ac4f9
commit 6a8d21dad7
4 changed files with 77 additions and 52 deletions

View File

@@ -16,7 +16,7 @@ $custom_post_data = compact('nothing');
$jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'customers');
$jqGrid_options += compact('action', 'caption',
'grid_div_id', 'grid_id', 'grid_setup',
'grid_div_id', 'grid_div_class', 'grid_id', 'grid_setup',
'nolinks', 'limit');
if (isset($customers)) {

View File

@@ -16,7 +16,7 @@ $custom_post_data = compact('nothing');
$jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'units');
$jqGrid_options += compact('action', 'caption',
'grid_div_id', 'grid_id', 'grid_setup',
'grid_div_id', 'grid_div_class', 'grid_id', 'grid_setup',
'nolinks', 'limit');
if (isset($units)) {

View File

@@ -19,7 +19,12 @@ if (isset($customer['id']))
$customer_grid_setup['onSelectRow'] = array
('--special' =>
'function(ids) { if (ids != null) { onCustomerRowSelect("#"+$(this).attr("id"), ids); } }'
'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();
@@ -29,49 +34,58 @@ if (isset($unit['id']))
$unit_grid_setup['onSelectRow'] = array
('--special' =>
'function(ids) { if (ids != null) { onUnitRowSelect("#"+$(this).attr("id"), ids); } }'
'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"><!--
function datepickerNow() {
now = new Date();
$("#datepicker").val($.datepicker.formatDate('mm/dd/yy', now)
+ ' '
+ (now.getHours() < 10 ? '0' : '')
+ now.getHours() + ':'
+ (now.getMinutes() < 10 ? '0' : '')
+ now.getMinutes());
// Reset the form
function resetForm() {
$("#customer-id").val(0);
$("#movein-customer").html("INTERNAL ERROR");
$("#unit-id").val(0);
$("#movein-unit").html("INTERNAL ERROR");
}
function onCustomerRowSelect(grid_id, cust_id) {
// Set the customer id that will be returned with the form
$("#customer-id").val(cust_id);
function onRowSelect(grid_id, item_type, item_id) {
cell_name = item_type.charAt(0).toUpperCase() + item_type.substr(1) + "-name";
// Get the customer name from the grid
$("#movein_customer").html($(grid_id).getCell(cust_id, "Customer-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_customer").hide();
$("#current_customer").show();
$("#no-"+item_type).hide();
$("#current-"+item_type).show();
$("#customers-list .HeaderButton").click();
$("#"+item_type+"s-list .HeaderButton").click();
}
function onUnitRowSelect(grid_id, unit_id) {
// Set the unit id that will be returned with the form
$("#unit-id").val(unit_id);
// Get the unit name from the grid
$("#movein_unit").html($(grid_id).getCell(unit_id, "Unit-name"));
// Hide the "no unit" message and show the current unit
$("#no_unit").hide();
$("#current_unit").show();
$("#units-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();
}
}
}
@@ -82,6 +96,7 @@ function onUnitRowSelect(grid_id, unit_id) {
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,
@@ -89,8 +104,14 @@ echo $this->element('customers',
'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,
@@ -100,23 +121,8 @@ echo $this->element('units',
));
echo ('<H2>' .
'<SPAN id="current_customer" style="display:'.(isset($customer['id'])?"inline":"none").'">' .
'Customer: ' .
'<SPAN id="movein_customer">' . (isset($customer['name']) ? $customer['name'] : "") . '</SPAN>' .
'</SPAN>' .
'<SPAN id="no_customer" style="display:'.(isset($customer['id'])?"none":"inline").'">' .
'Please select customer' .
'</SPAN>' .
'</H2>' . "\n");
echo ('<H2>' .
'<SPAN id="current_unit" style="display:'.(isset($unit['id'])?"inline":"none").'">' .
'Unit: ' .
'<SPAN id="movein_unit">' . (isset($unit['name']) ? $unit['name'] : "") . '</SPAN>' .
'</SPAN>' .
'<SPAN id="no_unit" style="display:'.(isset($unit['id'])?"none":"inline").'">' .
'Please select unit' .
'</SPAN>' .
'<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',
@@ -126,12 +132,12 @@ echo $form->create(null, array('id' => 'move-in-form',
echo $form->input("Lease.customer_id",
array('id' => 'customer-id',
'type' => 'hidden',
'value' => isset($customer['id']) ? $customer['id'] : 0));
'value' => 0));
echo $form->input("Lease.unit_id",
array('id' => 'unit-id',
'type' => 'hidden',
'value' => isset($unit['id']) ? $unit['id'] : 0));
'value' => 0));
echo 'Date: <input id="datepicker" name="data[Lease][movein_date]" type="text" /><BR>' . "\n";
echo 'Comment: <input id="comment" name="data[Lease][comment]" type="text" SIZE=80 /><BR>' . "\n";
@@ -147,11 +153,26 @@ echo $form->end('Move In Customer');
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>

View File

@@ -4,6 +4,7 @@
*/
/* table th, td { border: dashed 1px; } */
/* .debug-border { border: dashed 1px; } */
/************************************************************
************************************************************
@@ -178,6 +179,9 @@ table.deposit-summary td.quantity { padding-right: 0.8em; }
************************************************************
* jqGrid
*/
div.grid.text-below { margin-bottom: 0; }
table.Header th h2 {
color: #dd5;
font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif;