diff --git a/views/customers/receipt.ctp b/views/customers/receipt.ctp index 33e96a9..541de02 100644 --- a/views/customers/receipt.ctp +++ b/views/customers/receipt.ctp @@ -60,111 +60,148 @@ $grid_setup['onHeaderClick'] = array $('#receipt-form').ajaxForm(options); }); - // pre-submit callback - function verifyRequest(formData, jqForm, options) { - // formData is an array; here we use $.param to convert it to a string to display it - // but the form plugin does this for you automatically when it submits the data - //var_dump(formData); - //$('#request-debug').html('
'+dump(formData)+''); - $('#request-debug').html('Ommitted'); - //return false; +// pre-submit callback +function verifyRequest(formData, jqForm, options) { + // formData is an array; here we use $.param to convert it to a string to display it + // but the form plugin does this for you automatically when it submits the data + //var_dump(formData); + //$('#request-debug').html('
'+dump(formData)+''); + $('#request-debug').html('Ommitted'); + //return false; - $('#response-debug').html('Loading '); - $('#output-debug').html('Loading '); + $('#response-debug').html('Loading '); + $('#output-debug').html('Loading '); - // here we could return false to prevent the form from being submitted; - // returning anything other than false will allow the form submit to continue - return true; - } + // here we could return false to prevent the form from being submitted; + // returning anything other than false will allow the form submit to continue + return true; +} - // post-submit callback - function showResponse(responseText, statusText) { - // for normal html responses, the first argument to the success callback - // is the XMLHttpRequest object's responseText property +// post-submit callback +function showResponse(responseText, statusText) { + // for normal html responses, the first argument to the success callback + // is the XMLHttpRequest object's responseText property - // if the ajaxForm method was passed an Options Object with the dataType - // property set to 'xml' then the first argument to the success callback - // is the XMLHttpRequest object's responseXML property + // if the ajaxForm method was passed an Options Object with the dataType + // property set to 'xml' then the first argument to the success callback + // is the XMLHttpRequest object's responseXML property - // if the ajaxForm method was passed an Options Object with the dataType - // property set to 'json' then the first argument to the success callback - // is the json data object returned by the server + // if the ajaxForm method was passed an Options Object with the dataType + // property set to 'json' then the first argument to the success callback + // is the json data object returned by the server - if (statusText == 'success') { - // get a clean slate - //resetForm(); - } - else { - alert('not successful??'); - } - - - $('#response-debug').html('
'+dump(statusText)+''); + if (statusText == 'success') { + // get a clean slate + //resetForm(); + } + else { + alert('not successful??'); } - // Reset the form - function resetForm() { - $('#payment-entry-id').val(0); - $('#payments').html(''); - $("#receipt-customer-id").html("INTERNAL ERROR"); - $("#receipt-customer-name").html("INTERNAL ERROR"); + $('#response-debug').html('
'+dump(statusText)+''); +} - addPaymentSource(false); - datepickerNow('TransactionStamp'); +// Reset the form +function resetForm() { + $('#payment-entry-id').val(1); + $('#payments').html(''); + + $("#receipt-customer-id").html("INTERNAL ERROR"); + $("#receipt-customer-name").html("INTERNAL ERROR"); + + addPaymentSource(false); + datepickerNow('TransactionStamp'); +} + +function onRowSelect(grid_id, customer_id) { + // Set the customer id that will be returned with the form + $("#customer-id").val(customer_id); + + // Get the item names from the grid + $("#receipt-customer-id").html($(grid_id).getCell(customer_id, 'Customer-id')); + $("#receipt-customer-name").html($(grid_id).getCell(customer_id, 'Customer-name')); + + // Make sure the redirect is up to date, if necessary + if ($("#redirectController").val() == 'customers') + $("#redirect0").val(customer_id); + + // Hide the "no customer" message and show the current customer + $("#no-customer").hide(); + $("#current-customer").show(); + + // Update the charges grid to reflect this customer + updateCharges(customer_id); + + // Collapse the grid now that the user has selected + $("#customers-list .HeaderButton").click(); +} + +function onGridState(grid_id, state) { + if (state == 'visible') { + $("#no-customer").hide(); + $("#current-customer").hide(); } + else { + if ($("#customer-id").val() > 0) { + $("#current-customer").show(); + $("#no-customer").hide(); + } else { + $("#current-customer").hide(); + $("#no-customer").show(); + } + } +} - function addPaymentSource(flash) { - addDiv('payment-entry-id', 'payment', 'payments', flash, - // HTML section - '