diff --git a/site/views/customers/receipt.ctp b/site/views/customers/receipt.ctp
index ff121cd..fe79d8b 100644
--- a/site/views/customers/receipt.ctp
+++ b/site/views/customers/receipt.ctp
@@ -35,10 +35,40 @@ Configure::write('debug', '0');
});
// 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]) + '
');
+ if (formData[i]['name'] == "data[Customer][id]" &&
+ !(formData[i]['value'] > 0)) {
+ //$("#debug").append('
Missing Customer ID'); + alert("Must select a customer first"); + return false; + } + + if (formData[i]['name'] == "data[Transaction][stamp]" && + formData[i]['value'] == '') { + //$("#debug").append('
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('
Bad Amount');
+ alert("Must enter a valid amount");
+ return false;
+ }
+ }
+
+ }
+
+ //$("#debug").append('OK');
+ //return false;
+
$('#results').html('Working ');
- // 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;
}
@@ -370,6 +400,7 @@ Configure::write('debug', '0');
showCurrentAtPos: 0,
dateFormat: 'mm/dd/yy' });
+ $("#customer-id").val(0);
$("#receipt-customer-name").html("INTERNAL ERROR");
$("#receipt-balance").html("INTERNAL ERROR");
$("#receipt-charges-caption").html("Outstanding Charges");
diff --git a/site/views/leases/invoice.ctp b/site/views/leases/invoice.ctp
index da0e3af..48974e8 100644
--- a/site/views/leases/invoice.ctp
+++ b/site/views/leases/invoice.ctp
@@ -43,9 +43,38 @@ Configure::write('debug', '0');
// pre-submit callback
function verifyRequest(formData, jqForm, options) {
+ //$("#debug").html('');
+ for (var i = 0; i < formData.length; ++i) {
+ //$("#debug").append(i + ') ' + dump(formData[i]) + '
');
+ if (formData[i]['name'] == "data[Lease][id]" &&
+ !(formData[i]['value'] > 0)) {
+ //$("#debug").append('
Missing Lease ID'); + alert("Must select a lease first"); + return false; + } + + if (formData[i]['name'] == "data[Transaction][stamp]" && + formData[i]['value'] == '') { + //$("#debug").append('
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('
Bad Amount'); + alert("Must enter a valid amount"); + return false; + } + } + } + + //$("#debug").append('OK'); + //return false; + $('#results').html('Working '); - // 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; } @@ -308,6 +337,7 @@ Configure::write('debug', '0'); showCurrentAtPos: 0, dateFormat: 'mm/dd/yy' }); + $("#lease-id").val(0); $("#invoice-lease").html("INTERNAL ERROR"); $("#invoice-unit").html("INTERNAL ERROR"); $("#invoice-customer").html("INTERNAL ERROR");