diff --git a/views/leases/invoice.ctp b/views/leases/invoice.ctp index fd74ac2..07aca35 100644 --- a/views/leases/invoice.ctp +++ b/views/leases/invoice.ctp @@ -33,14 +33,8 @@ Configure::write('debug', '0'); success: showResponse, // post-submit callback // other available options: - //url: url, // override for form's 'action' attribute - //type: 'get', // 'get' or 'post', override for form's 'method' attribute - //dataType: null, // 'xml', 'script', or 'json' (expected server response type) //clearForm: true, // clear all form fields after successful submit //resetForm: true, // reset the form after successful submit - - // $.ajax options can be used here too, for example: - //timeout: 3000, }; // bind form using 'ajaxForm' @@ -49,16 +43,7 @@ Configure::write('debug', '0'); // 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 '); - + $('#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; @@ -66,108 +51,41 @@ function verifyRequest(formData, jqForm, options) { // 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 'json' then the first argument to the success callback - // is the json data object returned by the server - if (statusText == 'success') { + var amount = 0; + $("input.invoice.amount").each(function(i) { + amount += (+ $(this).val().replace(/\$/,'')); + }); + + $('#results').html('
'+dump(statusText)+''); } // Reset the form -function resetForm() { - $("#charge-entry-id").val(1); +function resetForm(nocharge) { + $('#charge-entry-id').val(1); + $('#charges').html(''); - $("#invoice-lease").html("INTERNAL ERROR"); - $("#invoice-unit").html("INTERNAL ERROR"); - $("#invoice-customer").html("INTERNAL ERROR"); - $("#invoice-rent").html("INTERNAL ERROR"); - $("#invoice-late").html("INTERNAL ERROR"); - $("#invoice-deposit").html("INTERNAL ERROR"); - - - - - addChargeSource(false); - datepickerNow('TransactionStamp'); - - - - var id; - - $("#TransactionStamp").datepicker('disable'); - $("#TransactionStamp").val(""); - $('#TransactionStamp').after - (''); - $("#TransactionComment").val('Move-In Charges'); - - id = addChargeSource(false); - $('#Entry'+id+'Form').removeCol(2); - $('#Entry'+id+'Form input, #Entry'+id+'Form select').attr('disabled', true); - $('#Entry'+id+'EffectiveDate').val(""); - $('#Entry'+id+'EffectiveDate').after - (''); - $('#Entry'+id+'AccountId').val(); - $('#Entry'+id+'AccountId').after - (''); - $('#Entry'+id+'Amount').val(""); - $('#Entry'+id+'Amount').after - (''); - //$('#Entry'+id+'Comment').val('Move-In Security Deposit'); - $('#Entry'+id+'Comment').removeAttr('disabled'); - - - id = addChargeSource(false); - $('#Entry'+id+'Form').removeCol(2); - $('#Entry'+id+'Form input, #Entry'+id+'Form select').attr('disabled', true); - $('#Entry'+id+'EffectiveDate').val(""); - $('#Entry'+id+'EffectiveDate').after - (''); - $('#Entry'+id+'ThroughDate').val(""); - $('#Entry'+id+'ThroughDate').after - (''); - $('#Entry'+id+'AccountId').val(); - $('#Entry'+id+'AccountId').after - (''); - $('#Entry'+id+'Amount').val(""); - $('#Entry'+id+'Amount').after - (''); - $('#Entry'+id+'Comment').val('Move-In Rent' - ); - $('#Entry'+id+'Comment').removeAttr('disabled'); - - + if (!nocharge) + addChargeSource(false); } @@ -247,7 +165,7 @@ function addChargeSource(flash) { array('type' => 'text'), 'between' => 'EOM', ), - "amount" => true, + "amount" => array('opts' => array('class' => 'invoice amount')), "comment" => array('opts' => array('size' => 50)), ), ))) . "+\n"; @@ -348,6 +266,10 @@ echo $this->element('form_table', /* echo '' . "\n"; */ +echo "