Charge/Invoice assessment is working fairly well. Still need to accept multiple charges on a single invoice, have client side validation, and post through ajax to allow posting repeated invoices.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@236 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-07 00:43:41 +00:00
parent 66e2647c05
commit 5f8ae73049
3 changed files with 104 additions and 53 deletions

View File

@@ -34,6 +34,41 @@ $lease_grid_setup['onHeaderClick'] = array
function resetForm() {
$("#lease-entry-id").val(0);
$("#lease-lease").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) {
@@ -47,6 +82,9 @@ function onRowSelect(grid_id, lease_id) {
+ $(grid_id).getCell(lease_id, 'Unit-name')
);
if ($("#redirectController").val() == 'leases')
$("#redirect0").val(lease_id);
// Hide the "no lease" message and show the current lease
$("#no-lease").hide();
$("#current-lease").show();
@@ -102,41 +140,77 @@ echo $form->input("Lease.id",
echo $this->element('form_table',
array('class' => "item assess entry",
//'with_name_after' => ':',
'field_prefix' => 'Transaction',
'fields' => array
("stamp" => array('opts' => array('id' => 'charge_date',
'type' => 'text')),
"through_date" => array('opts' => array('id' => 'through_date',
'type' => 'text')),
"charge_type" => array('prefix' => 'LedgerEntry.0',
'opts' =>
("stamp" => array('opts' =>
array('id' => 'charge_date',
'type' => 'text'),
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'charge_date\'); return false;">Now</A>',
),
"through_date" => array('opts' =>
array('id' => 'through_date',
'type' => 'text'),
'between' => '<A HREF="#" ONCLICK="datepickerEOM(\'charge_date\',\'through_date\'); return false;">EOM</A>',
),
"comment" => array('opts' => array('size' => 50),
),
)));
echo ('<BR>' . "\n");
echo $this->element('form_table',
array('class' => "item assess entry",
//'with_name_after' => ':',
'field_prefix' => 'LedgerEntry.0',
'fields' => array
("charge_type" => array('opts' =>
array('options' =>
array('rent' => 'Rent',
'late' => 'Late Charge'),
'value' => $charge['type'])),
"amount" => array('prefix' => 'LedgerEntry.0',
'opts' =>
array('value' => $charge['amount'])),
'value' =>
(isset($charge['type'])
? $charge['type']
: null)
),
),
"amount" => array('opts' =>
array('value' =>
(isset($charge['amount'])
? $charge['amount']
: null)
),
),
"comment" => array('opts' => array('size' => 50)),
)));
// Set up a redirect page. I use lower case 'redirect' here
// to avoid the model convention, which starts with upper-case.
foreach ($redirect AS $name => $value) {
echo $form->input("redirect.$name",
array('type' => 'hidden',
'value' => $value,
));
}
echo $form->end('Assess Charge');
?>
<script type="text/javascript"><!--
$(document).ready(function(){
$("#charge_date").datepicker({ constrainInput: true,
numberOfMonths: [1, 1],
showCurrentAtPos: 0,
dateFormat: 'mm/dd/yy' })
.datepicker('setDate', '+0');
$("#charge_date")
.attr('autocomplete', 'off')
.datepicker({ constrainInput: true,
numberOfMonths: [1, 1],
showCurrentAtPos: 0,
dateFormat: 'mm/dd/yy' });
$("#through_date").datepicker({ constrainInput: true,
numberOfMonths: [1, 1],
showCurrentAtPos: 0,
dateFormat: 'mm/dd/yy' })
;
$("#through_date")
.attr('autocomplete', 'off')
.datepicker({ constrainInput: true,
numberOfMonths: [1, 1],
showCurrentAtPos: 0,
dateFormat: 'mm/dd/yy' });
resetForm();