Took some of the new learnings from invoice generation and put into receipt generations. Also moved some shared functions to pmgr.js, and renamed things for consistency.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@239 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-07 02:55:55 +00:00
parent 8491d81496
commit 807dc48375
7 changed files with 189 additions and 217 deletions

View File

@@ -1,6 +1,6 @@
<?php /* -*- mode:PHP -*- */ ?>
<div class="assess input">
<div class="invoice input">
<?php
; // Editor alignment
@@ -8,7 +8,7 @@
**********************************************************************
**********************************************************************
**********************************************************************
*
* Grid Setup / Javascript
*/
$lease_grid_setup = array();
@@ -32,56 +32,27 @@ $lease_grid_setup['onHeaderClick'] = array
// Reset the form
function resetForm() {
$("#lease-entry-id").val(0);
$("#lease-lease").html("INTERNAL ERROR");
$("#charge-entry-id").val(0);
$("#invoice-lease").html("INTERNAL ERROR");
$("#invoice-unit").html("INTERNAL ERROR");
$("#invoice-customer").html("INTERNAL ERROR");
datepickerNow('charge_date');
$("#through_date").val('');
}
function datepickerNow(id) {
now = new Date();
// datepicker seems to squash the time portion,
// so we have to pass in a copy of now instead.
$("#"+id).datepicker('setDate', new Date(now));
$("#"+id).val($("#"+id).val()
+ ' '
+ (now.getHours() < 10 ? '0' : '')
+ now.getHours() + ':'
+ (now.getMinutes() < 10 ? '0' : '')
+ now.getMinutes());
}
function datepickerSet(fromid, id, a, b) {
if (fromid == null)
dt = new Date();
else
dt = new Date($("#"+fromid).datepicker('getDate'));
if (a != null)
dt.setDate(a);
if (b != null)
dt.setDate(b);
$("#"+id).datepicker('setDate', dt);
}
function datepickerBOM(fromid, id) {
datepickerSet(fromid, id, 1);
}
function datepickerEOM(fromid, id) {
datepickerSet(fromid, id, 32, 0);
}
function onRowSelect(grid_id, lease_id) {
// Set the item id that will be returned with the form
$("#lease-id").val(lease_id);
// Get the item name from the grid
$("#lease-lease").html('Lease '
+ $(grid_id).getCell(lease_id, 'Lease-number')
+ ' / Unit '
+ $(grid_id).getCell(lease_id, 'Unit-name')
);
// Get the item names from the grid
$("#invoice-lease").html($(grid_id).getCell(lease_id, 'Lease-number'));
$("#invoice-unit").html($(grid_id).getCell(lease_id, 'Unit-name'));
$("#invoice-customer").html($(grid_id).getCell(lease_id, 'Customer-name'));
// Make sure the redirect is up to date, if necessary
if ($("#redirectController").val() == 'leases')
$("#redirect0").val(lease_id);
@@ -89,6 +60,7 @@ function onRowSelect(grid_id, lease_id) {
$("#no-lease").hide();
$("#current-lease").show();
// Collapse the grid now that the user has selected
$("#leases-list .HeaderButton").click();
}
@@ -124,12 +96,17 @@ echo $this->element('leases',
));
echo ('<H2>' .
'<SPAN id="current-lease">Lease: <SPAN id="lease-lease"></SPAN></SPAN>' .
'<SPAN id="no-lease">Please select lease</SPAN>' .
'<SPAN id="current-lease" style="display:none">' .
'Lease <SPAN id="invoice-lease"></SPAN>' . ' / ' .
'Unit: <SPAN id="invoice-unit"></SPAN>' . ' / ' .
'Customer: <SPAN id="invoice-customer"></SPAN>' .
'</SPAN>' .
'<SPAN id="no-lease" style="display:none">' .
'Please select lease' .
'</SPAN>' .
'</H2>' . "\n");
echo $form->create(null, array('id' => 'assess-form',
echo $form->create(null, array('id' => 'invoice-form',
'url' => array('controller' => 'transactions',
'action' => 'postInvoice')));
@@ -139,7 +116,7 @@ echo $form->input("Lease.id",
'value' => 0));
echo $this->element('form_table',
array('class' => "item assess entry",
array('class' => "item invoice transaction entry",
//'with_name_after' => ':',
'field_prefix' => 'Transaction',
'fields' => array
@@ -159,7 +136,7 @@ echo $this->element('form_table',
echo ('<BR>' . "\n");
echo $this->element('form_table',
array('class' => "item assess entry",
array('class' => "item invoice ledger-entry entry",
//'with_name_after' => ':',
'field_prefix' => 'LedgerEntry.0',
'fields' => array
@@ -192,7 +169,7 @@ foreach ($redirect AS $name => $value) {
'value' => $value,
));
}
echo $form->end('Assess Charge');
echo $form->end('Generate Invoice');
?>
@@ -216,12 +193,12 @@ echo $form->end('Assess Charge');
<?php if (isset($lease['Lease']['id'])): ?>
$("#lease-id").val(<?php echo $lease['Lease']['id']; ?>);
$("#lease-lease").html("<?php echo 'Lease #' . $lease['Lease']['number'] . ' / Unit ' . $lease['Unit']['name']; ?>");
$("#current-lease").show();
$("#no-lease").hide();
$("#invoice-lease").html("<?php echo '#'.$lease['Lease']['number']; ?>");
$("#invoice-unit").html("<?php echo $lease['Unit']['name']; ?>");
$("#invoice-customer").html("<?php echo $lease['Customer']['name']; ?>");
onGridState(null, 'hidden');
<?php else: ?>
$("#current-lease").hide();
$("#no-lease").hide();
onGridState(null, 'visible');
<?php endif; ?>
});
--></script>