git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@239 97e9348a-65ac-dc4b-aefc-98561f571b83
207 lines
6.0 KiB
PHP
207 lines
6.0 KiB
PHP
<?php /* -*- mode:PHP -*- */ ?>
|
|
|
|
<div class="invoice input">
|
|
<?php
|
|
; // Editor alignment
|
|
|
|
/**********************************************************************
|
|
**********************************************************************
|
|
**********************************************************************
|
|
**********************************************************************
|
|
* Grid Setup / Javascript
|
|
*/
|
|
|
|
$lease_grid_setup = array();
|
|
|
|
if (isset($lease['Lease']['id']))
|
|
$lease_grid_setup['hiddengrid'] = true;
|
|
|
|
$lease_grid_setup['onSelectRow'] = array
|
|
('--special' =>
|
|
'function(ids) { if (ids != null) { onRowSelect("#"+$(this).attr("id"), ids); } }'
|
|
);
|
|
|
|
$lease_grid_setup['onHeaderClick'] = array
|
|
('--special' =>
|
|
'function(gridstate) { onGridState("#"+$(this).attr("id"), gridstate); }'
|
|
);
|
|
|
|
?>
|
|
|
|
<script type="text/javascript"><!--
|
|
|
|
// Reset the form
|
|
function resetForm() {
|
|
$("#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 onRowSelect(grid_id, lease_id) {
|
|
// Set the item id that will be returned with the form
|
|
$("#lease-id").val(lease_id);
|
|
|
|
// 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);
|
|
|
|
// Hide the "no lease" message and show the current lease
|
|
$("#no-lease").hide();
|
|
$("#current-lease").show();
|
|
|
|
// Collapse the grid now that the user has selected
|
|
$("#leases-list .HeaderButton").click();
|
|
}
|
|
|
|
function onGridState(grid_id, state) {
|
|
if (state == 'visible') {
|
|
$("#no-lease").hide();
|
|
$("#current-lease").hide();
|
|
}
|
|
else {
|
|
if ($("#lease-id").val() > 0) {
|
|
$("#current-lease").show();
|
|
$("#no-lease").hide();
|
|
} else {
|
|
$("#current-lease").hide();
|
|
$("#no-lease").show();
|
|
}
|
|
}
|
|
}
|
|
|
|
--></script>
|
|
|
|
<?php
|
|
; // align
|
|
|
|
echo $this->element('leases',
|
|
array('grid_div_id' => 'leases-list',
|
|
'grid_div_class' => 'text-below',
|
|
'caption' => ('<A HREF="#" ONCLICK="$(\'#leases-list .HeaderButton\').click();'.
|
|
' return false;">Select Lease</A>'),
|
|
'grid_setup' => $lease_grid_setup,
|
|
'nolinks' => true,
|
|
'limit' => 10,
|
|
));
|
|
|
|
echo ('<H2>' .
|
|
'<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' => 'invoice-form',
|
|
'url' => array('controller' => 'transactions',
|
|
'action' => 'postInvoice')));
|
|
|
|
echo $form->input("Lease.id",
|
|
array('id' => 'lease-id',
|
|
'type' => 'hidden',
|
|
'value' => 0));
|
|
|
|
echo $this->element('form_table',
|
|
array('class' => "item invoice transaction entry",
|
|
//'with_name_after' => ':',
|
|
'field_prefix' => 'Transaction',
|
|
'fields' => array
|
|
("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 invoice ledger-entry entry",
|
|
//'with_name_after' => ':',
|
|
'field_prefix' => 'LedgerEntry.0',
|
|
'fields' => array
|
|
("charge_type" => array('opts' =>
|
|
array('options' =>
|
|
array('rent' => 'Rent',
|
|
'late' => 'Late Charge'),
|
|
'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('Generate Invoice');
|
|
|
|
?>
|
|
|
|
<script type="text/javascript"><!--
|
|
$(document).ready(function(){
|
|
$("#charge_date")
|
|
.attr('autocomplete', 'off')
|
|
.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();
|
|
|
|
<?php if (isset($lease['Lease']['id'])): ?>
|
|
$("#lease-id").val(<?php echo $lease['Lease']['id']; ?>);
|
|
$("#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: ?>
|
|
onGridState(null, 'visible');
|
|
<?php endif; ?>
|
|
});
|
|
--></script>
|
|
|
|
</div>
|