Changed invoice generation to match the receipt changes in r521 (no more debug, transition to the lease after entry, etc).
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@525 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -33,14 +33,8 @@ Configure::write('debug', '0');
|
|||||||
success: showResponse, // post-submit callback
|
success: showResponse, // post-submit callback
|
||||||
|
|
||||||
// other available options:
|
// 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
|
//clearForm: true, // clear all form fields after successful submit
|
||||||
//resetForm: true, // reset the form 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'
|
// bind form using 'ajaxForm'
|
||||||
@@ -49,16 +43,7 @@ Configure::write('debug', '0');
|
|||||||
|
|
||||||
// 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
|
$('#results').html('Working <BLINK>...</BLINK>');
|
||||||
// but the form plugin does this for you automatically when it submits the data
|
|
||||||
//var_dump(formData);
|
|
||||||
//$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
|
||||||
$('#request-debug').html('Ommitted');
|
|
||||||
//return false;
|
|
||||||
|
|
||||||
$('#response-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;
|
||||||
@@ -66,108 +51,41 @@ function verifyRequest(formData, jqForm, options) {
|
|||||||
|
|
||||||
// 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
|
|
||||||
// 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') {
|
if (statusText == 'success') {
|
||||||
|
var amount = 0;
|
||||||
|
$("input.invoice.amount").each(function(i) {
|
||||||
|
amount += (+ $(this).val().replace(/\$/,''));
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#results').html('<H3>Invoice Saved<BR>' +
|
||||||
|
$("#invoice-customer").html() +
|
||||||
|
' : ' + fmtCurrency(amount) +
|
||||||
|
'</H3>');
|
||||||
|
|
||||||
|
if (!$("#repeat").attr("checked")) {
|
||||||
|
window.location.href =
|
||||||
|
"<?php echo $html->url(array('controller' => 'leases',
|
||||||
|
'action' => 'view')); ?>"
|
||||||
|
+ "/" + $("#lease-id").val();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// get a clean slate
|
// get a clean slate
|
||||||
//resetForm();
|
//resetForm();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alert('not successful??');
|
$('#results').html('<H2>Failed to save invoice!</H2>');
|
||||||
|
alert('Failed to save invoice.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$('#response-debug').html('<PRE>'+dump(statusText)+'</PRE>');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the form
|
// Reset the form
|
||||||
function resetForm() {
|
function resetForm(nocharge) {
|
||||||
$("#charge-entry-id").val(1);
|
$('#charge-entry-id').val(1);
|
||||||
|
$('#charges').html('');
|
||||||
|
|
||||||
$("#invoice-lease").html("INTERNAL ERROR");
|
if (!nocharge)
|
||||||
$("#invoice-unit").html("INTERNAL ERROR");
|
addChargeSource(false);
|
||||||
$("#invoice-customer").html("INTERNAL ERROR");
|
|
||||||
$("#invoice-rent").html("INTERNAL ERROR");
|
|
||||||
$("#invoice-late").html("INTERNAL ERROR");
|
|
||||||
$("#invoice-deposit").html("INTERNAL ERROR");
|
|
||||||
|
|
||||||
|
|
||||||
<?php if (empty($movein)): ?>
|
|
||||||
|
|
||||||
addChargeSource(false);
|
|
||||||
datepickerNow('TransactionStamp');
|
|
||||||
|
|
||||||
<?php else: ?>
|
|
||||||
|
|
||||||
var id;
|
|
||||||
|
|
||||||
$("#TransactionStamp").datepicker('disable');
|
|
||||||
$("#TransactionStamp").val("<?php echo date('m/d/Y', $movein['time']); ?>");
|
|
||||||
$('#TransactionStamp').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Transaction][stamp]"' +
|
|
||||||
' value="<?php echo date('m/d/Y', $movein['time']); ?>">');
|
|
||||||
$("#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("<?php echo date('m/d/Y', $movein['effective_time']); ?>");
|
|
||||||
$('#Entry'+id+'EffectiveDate').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][effective_date]"' +
|
|
||||||
' value="<?php echo date('m/d/Y', $movein['effective_time']); ?>">');
|
|
||||||
$('#Entry'+id+'AccountId').val(<?php echo $securityDepositAccount; ?>);
|
|
||||||
$('#Entry'+id+'AccountId').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][account_id]"' +
|
|
||||||
' value="<?php echo $securityDepositAccount; ?>">');
|
|
||||||
$('#Entry'+id+'Amount').val("<?php echo FormatHelper::currency($movein['deposit']); ?>");
|
|
||||||
$('#Entry'+id+'Amount').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][amount]"' +
|
|
||||||
' value="<?php echo FormatHelper::currency($movein['deposit']); ?>">');
|
|
||||||
//$('#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("<?php echo date('m/d/Y', $movein['effective_time']); ?>");
|
|
||||||
$('#Entry'+id+'EffectiveDate').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][effective_date]"' +
|
|
||||||
' value="<?php echo date('m/d/Y', $movein['effective_time']); ?>">');
|
|
||||||
$('#Entry'+id+'ThroughDate').val("<?php echo date('m/d/Y', $movein['through_time']); ?>");
|
|
||||||
$('#Entry'+id+'ThroughDate').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][through_date]"' +
|
|
||||||
' value="<?php echo date('m/d/Y', $movein['through_time']); ?>">');
|
|
||||||
$('#Entry'+id+'AccountId').val(<?php echo $rentAccount; ?>);
|
|
||||||
$('#Entry'+id+'AccountId').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][account_id]"' +
|
|
||||||
' value="<?php echo $rentAccount; ?>">');
|
|
||||||
$('#Entry'+id+'Amount').val("<?php echo FormatHelper::currency($movein['prorated_rent']); ?>");
|
|
||||||
$('#Entry'+id+'Amount').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][amount]"' +
|
|
||||||
' value="<?php echo FormatHelper::currency($movein['prorated_rent']); ?>">');
|
|
||||||
$('#Entry'+id+'Comment').val('Move-In Rent'
|
|
||||||
<?php if ($movein['prorated']) echo "+ ' (Prorated)'" ?>);
|
|
||||||
$('#Entry'+id+'Comment').removeAttr('disabled');
|
|
||||||
|
|
||||||
<?php endif; ?>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -247,7 +165,7 @@ function addChargeSource(flash) {
|
|||||||
array('type' => 'text'),
|
array('type' => 'text'),
|
||||||
'between' => '<A HREF="#" ONCLICK="datepickerEOM(\'Entry%{id}EffectiveDate\',\'Entry%{id}ThroughDate\'); return false;">EOM</A>',
|
'between' => '<A HREF="#" ONCLICK="datepickerEOM(\'Entry%{id}EffectiveDate\',\'Entry%{id}ThroughDate\'); return false;">EOM</A>',
|
||||||
),
|
),
|
||||||
"amount" => true,
|
"amount" => array('opts' => array('class' => 'invoice amount')),
|
||||||
"comment" => array('opts' => array('size' => 50)),
|
"comment" => array('opts' => array('size' => 50)),
|
||||||
),
|
),
|
||||||
))) . "+\n";
|
))) . "+\n";
|
||||||
@@ -348,6 +266,10 @@ echo $this->element('form_table',
|
|||||||
|
|
||||||
/* echo '</fieldset>' . "\n"; */
|
/* echo '</fieldset>' . "\n"; */
|
||||||
|
|
||||||
|
echo "<BR>\n";
|
||||||
|
echo $form->input('repeat', array('type' => 'checkbox',
|
||||||
|
'id' => 'repeat',
|
||||||
|
'label' => 'Enter Multiple Invoices')) . "\n";
|
||||||
echo $form->submit('Generate Invoice') . "\n";
|
echo $form->submit('Generate Invoice') . "\n";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -362,9 +284,8 @@ echo $form->submit('Generate Invoice') . "\n";
|
|||||||
|
|
||||||
<?php echo $form->end('Generate Invoice'); ?>
|
<?php echo $form->end('Generate Invoice'); ?>
|
||||||
|
|
||||||
<div><H4>Request</H4><div id="request-debug"></div></div>
|
<div id="results"></div>
|
||||||
<div><H4>Response</H4><div id="response-debug"></div></div>
|
<div id="output-debug" style="display:none"></div>
|
||||||
<div><H4>Output</H4><div id="output-debug"></div></div>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Warnings _really_ screw up javascript
|
// Warnings _really_ screw up javascript
|
||||||
@@ -385,7 +306,82 @@ Configure::write('debug', '0');
|
|||||||
showCurrentAtPos: 0,
|
showCurrentAtPos: 0,
|
||||||
dateFormat: 'mm/dd/yy' });
|
dateFormat: 'mm/dd/yy' });
|
||||||
|
|
||||||
|
$("#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");
|
||||||
|
|
||||||
|
<?php if (empty($movein)): ?>
|
||||||
|
|
||||||
resetForm();
|
resetForm();
|
||||||
|
datepickerNow('TransactionStamp');
|
||||||
|
|
||||||
|
<?php else: ?>
|
||||||
|
|
||||||
|
var id;
|
||||||
|
resetForm(true);
|
||||||
|
|
||||||
|
$("#TransactionStamp").datepicker('disable');
|
||||||
|
$("#TransactionStamp").val("<?php echo date('m/d/Y', $movein['time']); ?>");
|
||||||
|
$('#TransactionStamp').after
|
||||||
|
('<input type="hidden"' +
|
||||||
|
' name="data[Transaction][stamp]"' +
|
||||||
|
' value="<?php echo date('m/d/Y', $movein['time']); ?>">');
|
||||||
|
$("#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("<?php echo date('m/d/Y', $movein['effective_time']); ?>");
|
||||||
|
$('#Entry'+id+'EffectiveDate').after
|
||||||
|
('<input type="hidden"' +
|
||||||
|
' name="data[Entry]['+id+'][effective_date]"' +
|
||||||
|
' value="<?php echo date('m/d/Y', $movein['effective_time']); ?>">');
|
||||||
|
$('#Entry'+id+'AccountId').val(<?php echo $securityDepositAccount; ?>);
|
||||||
|
$('#Entry'+id+'AccountId').after
|
||||||
|
('<input type="hidden"' +
|
||||||
|
' name="data[Entry]['+id+'][account_id]"' +
|
||||||
|
' value="<?php echo $securityDepositAccount; ?>">');
|
||||||
|
$('#Entry'+id+'Amount').val("<?php echo FormatHelper::currency($movein['deposit']); ?>");
|
||||||
|
$('#Entry'+id+'Amount').after
|
||||||
|
('<input type="hidden"' +
|
||||||
|
' name="data[Entry]['+id+'][amount]"' +
|
||||||
|
' value="<?php echo FormatHelper::currency($movein['deposit']); ?>">');
|
||||||
|
//$('#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("<?php echo date('m/d/Y', $movein['effective_time']); ?>");
|
||||||
|
$('#Entry'+id+'EffectiveDate').after
|
||||||
|
('<input type="hidden"' +
|
||||||
|
' name="data[Entry]['+id+'][effective_date]"' +
|
||||||
|
' value="<?php echo date('m/d/Y', $movein['effective_time']); ?>">');
|
||||||
|
$('#Entry'+id+'ThroughDate').val("<?php echo date('m/d/Y', $movein['through_time']); ?>");
|
||||||
|
$('#Entry'+id+'ThroughDate').after
|
||||||
|
('<input type="hidden"' +
|
||||||
|
' name="data[Entry]['+id+'][through_date]"' +
|
||||||
|
' value="<?php echo date('m/d/Y', $movein['through_time']); ?>">');
|
||||||
|
$('#Entry'+id+'AccountId').val(<?php echo $rentAccount; ?>);
|
||||||
|
$('#Entry'+id+'AccountId').after
|
||||||
|
('<input type="hidden"' +
|
||||||
|
' name="data[Entry]['+id+'][account_id]"' +
|
||||||
|
' value="<?php echo $rentAccount; ?>">');
|
||||||
|
$('#Entry'+id+'Amount').val("<?php echo FormatHelper::currency($movein['prorated_rent']); ?>");
|
||||||
|
$('#Entry'+id+'Amount').after
|
||||||
|
('<input type="hidden"' +
|
||||||
|
' name="data[Entry]['+id+'][amount]"' +
|
||||||
|
' value="<?php echo FormatHelper::currency($movein['prorated_rent']); ?>">');
|
||||||
|
$('#Entry'+id+'Comment').val('Move-In Rent'
|
||||||
|
<?php if ($movein['prorated']) echo "+ ' (Prorated)'" ?>);
|
||||||
|
$('#Entry'+id+'Comment').removeAttr('disabled');
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
||||||
<?php if (isset($lease['id'])): ?>
|
<?php if (isset($lease['id'])): ?>
|
||||||
$("#lease-id").val(<?php echo $lease['id']; ?>);
|
$("#lease-id").val(<?php echo $lease['id']; ?>);
|
||||||
@@ -408,5 +404,3 @@ Configure::write('debug', '0');
|
|||||||
--></script>
|
--></script>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="#" onClick="$('#debug').html(''); return false;">Clear Debug Output</a>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user