Added pre-submit data verification for invoice and receipt. The checking is pretty thin, but it's a start. I don't want to do more, as I'm sure there are lots of data validation tools out there and would prefer to go that route.
git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@806 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -36,9 +36,39 @@ Configure::write('debug', '0');
|
|||||||
|
|
||||||
// pre-submit callback
|
// pre-submit callback
|
||||||
function verifyRequest(formData, jqForm, options) {
|
function verifyRequest(formData, jqForm, options) {
|
||||||
|
//$("#debug").html('');
|
||||||
|
for (var i = 0; i < formData.length; ++i) {
|
||||||
|
//$("#debug").append(i + ') ' + dump(formData[i]) + '<BR>');
|
||||||
|
if (formData[i]['name'] == "data[Customer][id]" &&
|
||||||
|
!(formData[i]['value'] > 0)) {
|
||||||
|
//$("#debug").append('<P>Missing Customer ID');
|
||||||
|
alert("Must select a customer first");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formData[i]['name'] == "data[Transaction][stamp]" &&
|
||||||
|
formData[i]['value'] == '') {
|
||||||
|
//$("#debug").append('<P>Bad Stamp');
|
||||||
|
alert("Must enter a valid date stamp");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Terrible way to accomplish this...
|
||||||
|
for (var j = 0; j < 20; ++j) {
|
||||||
|
if (formData[i]['name'] == "data[Entry]["+j+"][amount]" &&
|
||||||
|
!(formData[i]['value'] > 0)) {
|
||||||
|
//$("#debug").append('<P>Bad Amount');
|
||||||
|
alert("Must enter a valid amount");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//$("#debug").append('OK');
|
||||||
|
//return false;
|
||||||
|
|
||||||
$('#results').html('Working <BLINK>...</BLINK>');
|
$('#results').html('Working <BLINK>...</BLINK>');
|
||||||
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,6 +400,7 @@ Configure::write('debug', '0');
|
|||||||
showCurrentAtPos: 0,
|
showCurrentAtPos: 0,
|
||||||
dateFormat: 'mm/dd/yy' });
|
dateFormat: 'mm/dd/yy' });
|
||||||
|
|
||||||
|
$("#customer-id").val(0);
|
||||||
$("#receipt-customer-name").html("INTERNAL ERROR");
|
$("#receipt-customer-name").html("INTERNAL ERROR");
|
||||||
$("#receipt-balance").html("INTERNAL ERROR");
|
$("#receipt-balance").html("INTERNAL ERROR");
|
||||||
$("#receipt-charges-caption").html("Outstanding Charges");
|
$("#receipt-charges-caption").html("Outstanding Charges");
|
||||||
|
|||||||
@@ -43,9 +43,38 @@ Configure::write('debug', '0');
|
|||||||
|
|
||||||
// pre-submit callback
|
// pre-submit callback
|
||||||
function verifyRequest(formData, jqForm, options) {
|
function verifyRequest(formData, jqForm, options) {
|
||||||
|
//$("#debug").html('');
|
||||||
|
for (var i = 0; i < formData.length; ++i) {
|
||||||
|
//$("#debug").append(i + ') ' + dump(formData[i]) + '<BR>');
|
||||||
|
if (formData[i]['name'] == "data[Lease][id]" &&
|
||||||
|
!(formData[i]['value'] > 0)) {
|
||||||
|
//$("#debug").append('<P>Missing Lease ID');
|
||||||
|
alert("Must select a lease first");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formData[i]['name'] == "data[Transaction][stamp]" &&
|
||||||
|
formData[i]['value'] == '') {
|
||||||
|
//$("#debug").append('<P>Bad Stamp');
|
||||||
|
alert("Must enter a valid date stamp");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Terrible way to accomplish this...
|
||||||
|
for (var j = 0; j < 20; ++j) {
|
||||||
|
if (formData[i]['name'] == "data[Entry]["+j+"][amount]" &&
|
||||||
|
!(formData[i]['value'] > 0)) {
|
||||||
|
//$("#debug").append('<P>Bad Amount');
|
||||||
|
alert("Must enter a valid amount");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//$("#debug").append('OK');
|
||||||
|
//return false;
|
||||||
|
|
||||||
$('#results').html('Working <BLINK>...</BLINK>');
|
$('#results').html('Working <BLINK>...</BLINK>');
|
||||||
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,6 +337,7 @@ Configure::write('debug', '0');
|
|||||||
showCurrentAtPos: 0,
|
showCurrentAtPos: 0,
|
||||||
dateFormat: 'mm/dd/yy' });
|
dateFormat: 'mm/dd/yy' });
|
||||||
|
|
||||||
|
$("#lease-id").val(0);
|
||||||
$("#invoice-lease").html("INTERNAL ERROR");
|
$("#invoice-lease").html("INTERNAL ERROR");
|
||||||
$("#invoice-unit").html("INTERNAL ERROR");
|
$("#invoice-unit").html("INTERNAL ERROR");
|
||||||
$("#invoice-customer").html("INTERNAL ERROR");
|
$("#invoice-customer").html("INTERNAL ERROR");
|
||||||
|
|||||||
Reference in New Issue
Block a user