The only functional change was to start payment numbers at 1 instead of zero. All other changes are just white space and code movement.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@241 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -60,111 +60,148 @@ $grid_setup['onHeaderClick'] = array
|
|||||||
$('#receipt-form').ajaxForm(options);
|
$('#receipt-form').ajaxForm(options);
|
||||||
});
|
});
|
||||||
|
|
||||||
// pre-submit callback
|
// pre-submit callback
|
||||||
function verifyRequest(formData, jqForm, options) {
|
function verifyRequest(formData, jqForm, options) {
|
||||||
// formData is an array; here we use $.param to convert it to a string to display it
|
// 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
|
// but the form plugin does this for you automatically when it submits the data
|
||||||
//var_dump(formData);
|
//var_dump(formData);
|
||||||
//$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
//$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
||||||
$('#request-debug').html('Ommitted');
|
$('#request-debug').html('Ommitted');
|
||||||
//return false;
|
//return false;
|
||||||
|
|
||||||
$('#response-debug').html('Loading <BLINK>...</BLINK>');
|
$('#response-debug').html('Loading <BLINK>...</BLINK>');
|
||||||
$('#output-debug').html('Loading <BLINK>...</BLINK>');
|
$('#output-debug').html('Loading <BLINK>...</BLINK>');
|
||||||
|
|
||||||
// here we could return false to prevent the form from being submitted;
|
// here we could return false to prevent the form from being submitted;
|
||||||
// returning anything other than false will allow the form submit to continue
|
// returning anything other than false will allow the form submit to continue
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// post-submit callback
|
// post-submit callback
|
||||||
function showResponse(responseText, statusText) {
|
function showResponse(responseText, statusText) {
|
||||||
// for normal html responses, the first argument to the success callback
|
// for normal html responses, the first argument to the success callback
|
||||||
// is the XMLHttpRequest object's responseText property
|
// is the XMLHttpRequest object's responseText property
|
||||||
|
|
||||||
// if the ajaxForm method was passed an Options Object with the dataType
|
// if the ajaxForm method was passed an Options Object with the dataType
|
||||||
// property set to 'xml' then the first argument to the success callback
|
// property set to 'xml' then the first argument to the success callback
|
||||||
// is the XMLHttpRequest object's responseXML property
|
// is the XMLHttpRequest object's responseXML property
|
||||||
|
|
||||||
// if the ajaxForm method was passed an Options Object with the dataType
|
// if the ajaxForm method was passed an Options Object with the dataType
|
||||||
// property set to 'json' then the first argument to the success callback
|
// property set to 'json' then the first argument to the success callback
|
||||||
// is the json data object returned by the server
|
// is the json data object returned by the server
|
||||||
|
|
||||||
if (statusText == 'success') {
|
if (statusText == 'success') {
|
||||||
// get a clean slate
|
// get a clean slate
|
||||||
//resetForm();
|
//resetForm();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alert('not successful??');
|
alert('not successful??');
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$('#response-debug').html('<PRE>'+dump(statusText)+'</PRE>');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the form
|
|
||||||
function resetForm() {
|
|
||||||
$('#payment-entry-id').val(0);
|
|
||||||
$('#payments').html('');
|
|
||||||
|
|
||||||
$("#receipt-customer-id").html("INTERNAL ERROR");
|
$('#response-debug').html('<PRE>'+dump(statusText)+'</PRE>');
|
||||||
$("#receipt-customer-name").html("INTERNAL ERROR");
|
}
|
||||||
|
|
||||||
addPaymentSource(false);
|
// Reset the form
|
||||||
datepickerNow('TransactionStamp');
|
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) {
|
function addPaymentSource(flash) {
|
||||||
addDiv('payment-entry-id', 'payment', 'payments', flash,
|
addDiv('payment-entry-id', 'payment', 'payments', flash,
|
||||||
// HTML section
|
// HTML section
|
||||||
'<FIELDSET CLASS="payment subset">' +
|
'<FIELDSET CLASS="payment subset">' +
|
||||||
'<LEGEND>Payment #%{id} (%{remove})</LEGEND>' +
|
'<LEGEND>Payment #%{id} (%{remove})</LEGEND>' +
|
||||||
|
|
||||||
'<DIV ID="payment-type-div-%{id}">' +
|
'<DIV ID="payment-type-div-%{id}">' +
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$types = array();
|
$types = array();
|
||||||
foreach(array('Cash', 'Check', 'Money Order', /*'ACH', 'Credit Card'*/) AS $name)
|
foreach(array('Cash', 'Check', 'Money Order', /*'ACH', 'Credit Card'*/) AS $name)
|
||||||
$types[preg_replace("/ /", "", strtolower($name))] = $name;
|
$types[preg_replace("/ /", "", strtolower($name))] = $name;
|
||||||
|
|
||||||
foreach ($types AS $type => $name) {
|
foreach ($types AS $type => $name) {
|
||||||
$div = '<DIV>';
|
$div = '<DIV>';
|
||||||
$div .= '<INPUT TYPE="radio" NAME="data[LedgerEntry][%{id}][monetary_type_name]"';
|
$div .= '<INPUT TYPE="radio" NAME="data[LedgerEntry][%{id}][monetary_type_name]"';
|
||||||
$div .= ' ONCLICK="switchPaymentType(%{id}, \\\''.$type.'\\\')"';
|
$div .= ' ONCLICK="switchPaymentType(%{id}, \\\''.$type.'\\\')"';
|
||||||
$div .= ' CLASS="payment-type-%{id}" ID="payment-type-'.$type.'-%{id}"';
|
$div .= ' CLASS="payment-type-%{id}" ID="payment-type-'.$type.'-%{id}"';
|
||||||
$div .= ' VALUE="'.$name.'" ' . ($name == 'Cash' ? 'CHECKED ' : '') . '/>';
|
$div .= ' VALUE="'.$name.'" ' . ($name == 'Cash' ? 'CHECKED ' : '') . '/>';
|
||||||
$div .= ' <LABEL FOR="payment-type-'.$type.'-%{id}">'.$name.'</LABEL>';
|
$div .= ' <LABEL FOR="payment-type-'.$type.'-%{id}">'.$name.'</LABEL>';
|
||||||
$div .= '</DIV>';
|
$div .= '</DIV>';
|
||||||
echo "'$div' +\n";
|
echo "'$div' +\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
'</DIV>' +
|
'</DIV>' +
|
||||||
|
|
||||||
'<DIV ID="payment-amount-div-%{id}" CLASS="input text required">' +
|
'<DIV ID="payment-amount-div-%{id}" CLASS="input text required">' +
|
||||||
' <LABEL FOR="payment-amount-%{id}">Amount</LABEL>' +
|
' <LABEL FOR="payment-amount-%{id}">Amount</LABEL>' +
|
||||||
' <INPUT TYPE="text" SIZE="20"' +
|
' <INPUT TYPE="text" SIZE="20"' +
|
||||||
' NAME="data[LedgerEntry][%{id}][amount]"' +
|
' NAME="data[LedgerEntry][%{id}][amount]"' +
|
||||||
' ID="payment-amount-%{id}" />' +
|
' ID="payment-amount-%{id}" />' +
|
||||||
'</DIV>' +
|
'</DIV>' +
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
foreach ($types AS $type => $name) {
|
foreach ($types AS $type => $name) {
|
||||||
if ($type == 'cash')
|
if ($type == 'cash')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$div = '<DIV';
|
$div = '<DIV';
|
||||||
$div .= ' ID="payment-'.$type.'-div-%{id}"';
|
$div .= ' ID="payment-'.$type.'-div-%{id}"';
|
||||||
$div .= ' CLASS="payment-type-div-%{id}"';
|
$div .= ' CLASS="payment-type-div-%{id}"';
|
||||||
$div .= ' STYLE="display:none;">';
|
$div .= ' STYLE="display:none;">';
|
||||||
$div .= '</DIV>';
|
$div .= '</DIV>';
|
||||||
echo "'$div' +\n";
|
echo "'$div' +\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
'</FIELDSET>'
|
'</FIELDSET>'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchPaymentType(paymentid, type) {
|
function switchPaymentType(paymentid, type) {
|
||||||
@@ -283,44 +320,6 @@ function updateCharges(id) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--></script>
|
--></script>
|
||||||
|
|
||||||
@@ -398,8 +397,7 @@ echo $form->submit('Generate Receipt') . "\n";
|
|||||||
<div><H4>Response</H4><div id="response-debug"></div></div>
|
<div><H4>Response</H4><div id="response-debug"></div></div>
|
||||||
<div><H4>Output</H4><div id="output-debug"></div></div>
|
<div><H4>Output</H4><div id="output-debug"></div></div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript"><!--
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#TransactionStamp")
|
$("#TransactionStamp")
|
||||||
.attr('autocomplete', 'off')
|
.attr('autocomplete', 'off')
|
||||||
@@ -451,9 +449,7 @@ echo $form->submit('Generate Receipt') . "\n";
|
|||||||
/* }); */
|
/* }); */
|
||||||
|
|
||||||
});
|
});
|
||||||
|
--></script>
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user