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:
@@ -251,7 +251,7 @@ class CustomersController extends AppController {
|
|||||||
if ($show_payment) {
|
if ($show_payment) {
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Payment',
|
array('name' => 'Payment',
|
||||||
'url' => array('action' => 'payment',
|
'url' => array('action' => 'receipt',
|
||||||
$id));
|
$id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,11 +352,11 @@ class CustomersController extends AppController {
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* action: payment
|
* action: receipt
|
||||||
* - Sets up the payment entry page for the given customer.
|
* - Sets up the receipt entry page for the given customer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function payment($id = null) {
|
function receipt($id = null) {
|
||||||
/* if (!$id) { */
|
/* if (!$id) { */
|
||||||
/* $this->Session->setFlash(__('Invalid Item.', true)); */
|
/* $this->Session->setFlash(__('Invalid Item.', true)); */
|
||||||
/* $this->redirect(array('action'=>'index')); */
|
/* $this->redirect(array('action'=>'index')); */
|
||||||
@@ -379,7 +379,7 @@ class CustomersController extends AppController {
|
|||||||
$charges = array('balance' => 0, 'entry' => array());
|
$charges = array('balance' => 0, 'entry' => array());
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = 'Payment Entry';
|
$title = ($customer['name'] . ': Payment Entry');
|
||||||
$this->set(compact('customer', 'charges', 'title'));
|
$this->set(compact('customer', 'charges', 'title'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,11 +169,11 @@ class LeasesController extends AppController {
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* action: assess
|
* action: invoice
|
||||||
* - Assesses charges to the lease
|
* - Sets up the invoice entry page for the given customer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function assess($id = null, $type = null) {
|
function invoice($id = null, $type = null) {
|
||||||
|
|
||||||
$lease = $this->Lease->find
|
$lease = $this->Lease->find
|
||||||
('first', array
|
('first', array
|
||||||
@@ -209,7 +209,7 @@ class LeasesController extends AppController {
|
|||||||
|
|
||||||
$title = ('Lease #' . $lease['Lease']['number'] . ': ' .
|
$title = ('Lease #' . $lease['Lease']['number'] . ': ' .
|
||||||
$lease['Unit']['name'] . ': ' .
|
$lease['Unit']['name'] . ': ' .
|
||||||
$lease['Customer']['name'] . ': Assess Charges');
|
$lease['Customer']['name'] . ': Charge Entry');
|
||||||
$this->set(compact('title', 'lease', 'charge'));
|
$this->set(compact('title', 'lease', 'charge'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,11 +255,11 @@ class LeasesController extends AppController {
|
|||||||
array('name' => 'Operations', 'header' => true);
|
array('name' => 'Operations', 'header' => true);
|
||||||
|
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Assess Rent', 'url' => array('action' => 'assess',
|
array('name' => 'Assess Rent', 'url' => array('action' => 'invoice',
|
||||||
$id, 'rent'));
|
$id, 'rent'));
|
||||||
|
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Assess Late Charge', 'url' => array('action' => 'assess',
|
array('name' => 'Assess Late Charge', 'url' => array('action' => 'invoice',
|
||||||
$id, 'late'));
|
$id, 'late'));
|
||||||
|
|
||||||
if (!isset($lease['Lease']['moveout_date'])) {
|
if (!isset($lease['Lease']['moveout_date'])) {
|
||||||
@@ -270,7 +270,7 @@ class LeasesController extends AppController {
|
|||||||
|
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Payment', 'url' => array('controller' => 'customers',
|
array('name' => 'Payment', 'url' => array('controller' => 'customers',
|
||||||
'action' => 'payment',
|
'action' => 'receipt',
|
||||||
$lease['Customer']['id']));
|
$lease['Customer']['id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ class TransactionsController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->Transaction->addReceipt($this->data,
|
if (!$this->Transaction->addReceipt($this->data,
|
||||||
$this->data['customer_id'])) {
|
$this->data['Customer']['id'])) {
|
||||||
$this->Session->setFlash("RECEIPT FAILED", true);
|
$this->Session->setFlash("RECEIPT FAILED", true);
|
||||||
// REVISIT <AP> 20090706:
|
// REVISIT <AP> 20090706:
|
||||||
// Until we can work out the session problems,
|
// Until we can work out the session problems,
|
||||||
|
|||||||
@@ -222,8 +222,9 @@ class UnitsController extends AppController {
|
|||||||
if (isset($unit['CurrentLease']['id']) &&
|
if (isset($unit['CurrentLease']['id']) &&
|
||||||
!isset($unit['CurrentLease']['close_date'])) {
|
!isset($unit['CurrentLease']['close_date'])) {
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Payment', 'url' => array('action' => 'payment',
|
array('name' => 'Payment', 'url' => array('controller' => 'customers',
|
||||||
$id));
|
'action' => 'receipt',
|
||||||
|
$unit['CurrentLease']['customer_id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare to render.
|
// Prepare to render.
|
||||||
|
|||||||
@@ -1,47 +1,6 @@
|
|||||||
<?php /* -*- mode:PHP -*- */ ?>
|
<?php /* -*- mode:PHP -*- */ ?>
|
||||||
|
|
||||||
<div class="payment input">
|
<div class="receipt input">
|
||||||
|
|
||||||
<?php
|
|
||||||
; // Editor alignment
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
**********************************************************************
|
|
||||||
**********************************************************************
|
|
||||||
**********************************************************************
|
|
||||||
* Transaction Detail Main Section
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $rows = array(array('ID', $transaction['Transaction']['id']), */
|
|
||||||
/* array('Timestamp', FormatHelper::datetime($transaction['Transaction']['stamp'])), */
|
|
||||||
/* array('Through', FormatHelper::date($transaction['Transaction']['through_date'])), */
|
|
||||||
/* array('Due', FormatHelper::date($transaction['Transaction']['due_date'])), */
|
|
||||||
/* array('Comment', $transaction['Transaction']['comment'])); */
|
|
||||||
|
|
||||||
/* echo $this->element('table', */
|
|
||||||
/* array('class' => 'item transaction detail', */
|
|
||||||
/* 'caption' => 'Transaction Detail', */
|
|
||||||
/* 'rows' => $rows, */
|
|
||||||
/* 'column_class' => array('field', 'value'))); */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* Transaction Info Box
|
|
||||||
*/
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<DIV CLASS="infobox">
|
|
||||||
<DIV CLASS="summary grand total">
|
|
||||||
Total: <?php /*echo FormatHelper::currency($total);*/ ?>
|
|
||||||
</DIV>
|
|
||||||
</DIV>
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
; // Editor alignment
|
; // Editor alignment
|
||||||
|
|
||||||
@@ -49,7 +8,7 @@
|
|||||||
**********************************************************************
|
**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
*
|
* Grid Setup / Javascript
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$grid_setup = array();
|
$grid_setup = array();
|
||||||
@@ -62,6 +21,10 @@ $grid_setup['onSelectRow'] = array
|
|||||||
'function(ids) { if (ids != null) { onRowSelect("#"+$(this).attr("id"), ids); } }'
|
'function(ids) { if (ids != null) { onRowSelect("#"+$(this).attr("id"), ids); } }'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$grid_setup['onHeaderClick'] = array
|
||||||
|
('--special' =>
|
||||||
|
'function(gridstate) { onGridState("#"+$(this).attr("id"), gridstate); }'
|
||||||
|
);
|
||||||
|
|
||||||
// Customer
|
// Customer
|
||||||
// Outstanding balance
|
// Outstanding balance
|
||||||
@@ -93,11 +56,8 @@ $grid_setup['onSelectRow'] = array
|
|||||||
//timeout: 3000,
|
//timeout: 3000,
|
||||||
};
|
};
|
||||||
|
|
||||||
// get a clean slate
|
|
||||||
resetPaymentForm();
|
|
||||||
|
|
||||||
// bind form using 'ajaxForm'
|
// bind form using 'ajaxForm'
|
||||||
$('#payment-form').ajaxForm(options);
|
$('#receipt-form').ajaxForm(options);
|
||||||
});
|
});
|
||||||
|
|
||||||
// pre-submit callback
|
// pre-submit callback
|
||||||
@@ -132,7 +92,7 @@ $grid_setup['onSelectRow'] = array
|
|||||||
|
|
||||||
if (statusText == 'success') {
|
if (statusText == 'success') {
|
||||||
// get a clean slate
|
// get a clean slate
|
||||||
//resetPaymentForm();
|
//resetForm();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alert('not successful??');
|
alert('not successful??');
|
||||||
@@ -142,27 +102,20 @@ $grid_setup['onSelectRow'] = array
|
|||||||
$('#response-debug').html('<PRE>'+dump(statusText)+'</PRE>');
|
$('#response-debug').html('<PRE>'+dump(statusText)+'</PRE>');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset payment fields
|
// Reset the form
|
||||||
function resetPaymentForm() {
|
function resetForm() {
|
||||||
// Get a clean slate for our payments
|
$('#payment-entry-id').val(0);
|
||||||
$('#payments').html('');
|
$('#payments').html('');
|
||||||
$('#payment-id').val(0);
|
|
||||||
addPaymentSource(false);
|
|
||||||
datepickerNow();
|
|
||||||
}
|
|
||||||
|
|
||||||
function datepickerNow() {
|
$("#receipt-customer-id").html("INTERNAL ERROR");
|
||||||
now = new Date();
|
$("#receipt-customer-name").html("INTERNAL ERROR");
|
||||||
$("#datepicker").val($.datepicker.formatDate('mm/dd/yy', now)
|
|
||||||
+ ' '
|
addPaymentSource(false);
|
||||||
+ (now.getHours() < 10 ? '0' : '')
|
datepickerNow('TransactionStamp');
|
||||||
+ now.getHours() + ':'
|
|
||||||
+ (now.getMinutes() < 10 ? '0' : '')
|
|
||||||
+ now.getMinutes());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPaymentSource(flash) {
|
function addPaymentSource(flash) {
|
||||||
addDiv('payment-id', 'payment', 'payments', flash,
|
addDiv('payment-entry-id', 'payment', 'payments', flash,
|
||||||
// HTML section
|
// HTML section
|
||||||
'<FIELDSET CLASS="payment subset">' +
|
'<FIELDSET CLASS="payment subset">' +
|
||||||
'<LEGEND>Payment #%{id} (%{remove})</LEGEND>' +
|
'<LEGEND>Payment #%{id} (%{remove})</LEGEND>' +
|
||||||
@@ -312,7 +265,6 @@ function updateChargesGrid(idlist, balance) {
|
|||||||
function updateCharges(id) {
|
function updateCharges(id) {
|
||||||
var url = '<?php echo ($html->url(array("controller" => $this->params["controller"],
|
var url = '<?php echo ($html->url(array("controller" => $this->params["controller"],
|
||||||
"action" => "unreconciled"))); ?>';
|
"action" => "unreconciled"))); ?>';
|
||||||
//url += '/'+$("#customer-id").val();
|
|
||||||
url += '/'+id;
|
url += '/'+id;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -331,21 +283,43 @@ function updateCharges(id) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRowSelect(grid_id, cust_id) {
|
function onRowSelect(grid_id, customer_id) {
|
||||||
// Set the customer id that will be returned with the form
|
// Set the customer id that will be returned with the form
|
||||||
$("#customer-id").val(cust_id);
|
$("#customer-id").val(customer_id);
|
||||||
|
|
||||||
// Get the customer name from the grid
|
// Get the item names from the grid
|
||||||
$("#payment_customer").html($(grid_id).getCell(cust_id, "Customer-name"));
|
$("#receipt-customer-id").html($(grid_id).getCell(customer_id, 'Customer-id'));
|
||||||
|
$("#receipt-customer-name").html($(grid_id).getCell(customer_id, 'Customer-name'));
|
||||||
|
|
||||||
// Replace that with just the text portion of the hyperlink
|
// Make sure the redirect is up to date, if necessary
|
||||||
$("#payment_customer").html($("#payment_customer a").html());
|
if ($("#redirectController").val() == 'customers')
|
||||||
|
$("#redirect0").val(customer_id);
|
||||||
|
|
||||||
// Hide the "no customer" message and show the current customer
|
// Hide the "no customer" message and show the current customer
|
||||||
$("#no_customer").hide();
|
$("#no-customer").hide();
|
||||||
$("#current_customer").show();
|
$("#current-customer").show();
|
||||||
|
|
||||||
updateCharges(cust_id);
|
// Update the charges grid to reflect this customer
|
||||||
|
updateCharges(customer_id);
|
||||||
|
|
||||||
|
// Collapse the grid now that the user has selected
|
||||||
|
$("#customers-list .HeaderButton").click();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onGridState(grid_id, state) {
|
||||||
|
if (state == 'visible') {
|
||||||
|
$("#no-customer").hide();
|
||||||
|
$("#current-customer").hide();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($("#customer-id").val() > 0) {
|
||||||
|
$("#current-customer").show();
|
||||||
|
$("#no-customer").hide();
|
||||||
|
} else {
|
||||||
|
$("#current-customer").hide();
|
||||||
|
$("#no-customer").show();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
--></script>
|
--></script>
|
||||||
@@ -356,11 +330,24 @@ function onRowSelect(grid_id, cust_id) {
|
|||||||
|
|
||||||
echo $this->element('customers',
|
echo $this->element('customers',
|
||||||
array('grid_div_id' => 'customers-list',
|
array('grid_div_id' => 'customers-list',
|
||||||
|
'grid_div_class' => 'text-below',
|
||||||
'caption' => ('<A HREF="#" ONCLICK="$(\'#customers-list .HeaderButton\').click();'.
|
'caption' => ('<A HREF="#" ONCLICK="$(\'#customers-list .HeaderButton\').click();'.
|
||||||
' return false;">Select Customer</A>'),
|
' return false;">Select Customer</A>'),
|
||||||
'grid_setup' => $grid_setup,
|
'grid_setup' => $grid_setup,
|
||||||
|
'nolinks' => true,
|
||||||
|
'limit' => 10,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
echo ('<H2>' .
|
||||||
|
'<SPAN id="current-customer" style="display:none">' .
|
||||||
|
'Customer <SPAN id="receipt-customer-id"></SPAN>' .
|
||||||
|
': <SPAN id="receipt-customer-name"></SPAN>' .
|
||||||
|
'</SPAN>' .
|
||||||
|
'<SPAN id="no-customer" style="display:none">' .
|
||||||
|
'Please select customer' .
|
||||||
|
'</SPAN>' .
|
||||||
|
'</H2>' . "\n");
|
||||||
|
|
||||||
echo $this->element('ledger_entries',
|
echo $this->element('ledger_entries',
|
||||||
array('grid_div_id' => 'charge-entries',
|
array('grid_div_id' => 'charge-entries',
|
||||||
'caption' => 'Outstanding Charges',
|
'caption' => 'Outstanding Charges',
|
||||||
@@ -369,107 +356,72 @@ echo $this->element('ledger_entries',
|
|||||||
'limit' => 8,
|
'limit' => 8,
|
||||||
));
|
));
|
||||||
|
|
||||||
echo ('<H2>' .
|
echo $form->create(null, array('id' => 'receipt-form',
|
||||||
'<SPAN id="current_customer" style="display:'.(isset($customer['id'])?"inline":"none").'">' .
|
|
||||||
'Enter new receipt for ' .
|
|
||||||
'<SPAN id="payment_customer">' . (isset($customer['name']) ? $customer['name'] : "") . '</SPAN>' .
|
|
||||||
'</SPAN>' .
|
|
||||||
'<SPAN id="no_customer" style="display:'.(isset($customer['id'])?"none":"inline").'">' .
|
|
||||||
'Please select customer' .
|
|
||||||
'</SPAN>' .
|
|
||||||
'</H2>' . "\n");
|
|
||||||
|
|
||||||
echo $form->create(null, array('id' => 'payment-form',
|
|
||||||
'url' => array('controller' => 'transactions',
|
'url' => array('controller' => 'transactions',
|
||||||
'action' => 'postReceipt')));
|
'action' => 'postReceipt')));
|
||||||
|
|
||||||
/***************************************************
|
|
||||||
* Post data should look like this:
|
|
||||||
*
|
|
||||||
* data => Array
|
|
||||||
* (
|
|
||||||
* [Transaction] => Array
|
|
||||||
* (
|
|
||||||
* stamp => <Transaction Time Stamp>
|
|
||||||
* through_date => <Transaction Through Date, if any>
|
|
||||||
* due_date => <Transaction Due Date, if any>
|
|
||||||
* comment => <Transaction Comment>
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* [LedgerEntry] => Array
|
|
||||||
* (
|
|
||||||
* [0] => Array
|
|
||||||
* (
|
|
||||||
* name => <NOT TO INCLUDE??>
|
|
||||||
* amount => <Payment Amount>
|
|
||||||
* debit_ledger_id => <ID of the debit account's current ledger>
|
|
||||||
* credit_ledger_id => <ID of the debit account's current ledger>
|
|
||||||
* comment => <Ledger Entry Comment>
|
|
||||||
*
|
|
||||||
* [MonetarySource] => Array
|
|
||||||
* (
|
|
||||||
* name => <Name (may be useless parameter)>
|
|
||||||
* monetary_type_id => <Monetary Type ID>
|
|
||||||
* comment => <Monetary Source Comment>
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* REVISIT: Reconciliations will be tricker.
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
***************************************************/
|
|
||||||
|
|
||||||
|
echo $form->input("id",
|
||||||
|
array('id' => 'customer-id',
|
||||||
|
'type' => 'hidden',
|
||||||
|
'value' => 0));
|
||||||
|
|
||||||
|
echo $this->element('form_table',
|
||||||
|
array('class' => "item receipt transaction entry",
|
||||||
|
//'with_name_after' => ':',
|
||||||
|
'field_prefix' => 'Transaction',
|
||||||
|
'fields' => array
|
||||||
|
("stamp" => array('opts' => array('type' => 'text'),
|
||||||
|
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'TransactionStamp\'); return false;">Now</A>',
|
||||||
|
),
|
||||||
|
"comment" => array('opts' => array('size' => 50),
|
||||||
|
),
|
||||||
|
)));
|
||||||
|
|
||||||
|
echo $form->submit('Generate Receipt') . "\n";
|
||||||
?>
|
?>
|
||||||
<input type="hidden" id="customer-id" name="data[customer_id]" value="<?php echo $customer['id']; ?>">
|
|
||||||
|
|
||||||
<fieldset CLASS="payment superset">
|
<fieldset CLASS="payment superset">
|
||||||
<legend>Payments</legend>
|
<legend>Payments</legend>
|
||||||
<input type="hidden" id="payment-id" value="0">
|
<input type="hidden" id="payment-entry-id" value="0">
|
||||||
<div id="payments"></div>
|
<div id="payments"></div>
|
||||||
<fieldset> <legend>
|
<fieldset> <legend>
|
||||||
<a href="#" onClick="addPaymentSource(true); return false;">Add Another Payment</a>
|
<a href="#" onClick="addPaymentSource(true); return false;">Add Another Payment</a>
|
||||||
</legend> </fieldset>
|
</legend> </fieldset>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<?php
|
<?php echo $form->end('Generate Receipt'); ?>
|
||||||
|
|
||||||
echo 'Date: <input id="datepicker" name="data[Transaction][stamp]" type="text" />';
|
<?php /* echo '</DIV>' . "\n"; // End of the dialog DIV */ ?>
|
||||||
echo ' <A HREF="#" ONCLICK="datepickerNow(); return false;">Now</A><BR>' . "\n";
|
|
||||||
echo 'Comment: <input id="comment" name="data[Transaction][comment]" type="text" SIZE=80 /><BR>' . "\n";
|
|
||||||
echo $form->end('Post Payment');
|
|
||||||
|
|
||||||
//echo '</DIV>' . "\n"; // End of the dialog DIV
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
/* <button id="post-payment" class="ui-button ui-state-default ui-corner-all">Create Payment</button> */
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div><H4>Request</H4><div id="request-debug"></div></div>
|
<div><H4>Request</H4><div id="request-debug"></div></div>
|
||||||
<div><H4>Response</H4><div id="response-debug"></div></div>
|
<div><H4>Response</H4><div id="response-debug"></div></div>
|
||||||
<div><H4>Output</H4><div id="output-debug"></div></div>
|
<div><H4>Output</H4><div id="output-debug"></div></div>
|
||||||
<?php
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#datepicker").datepicker({ constrainInput: true,
|
$("#TransactionStamp")
|
||||||
|
.attr('autocomplete', 'off')
|
||||||
|
.datepicker({ constrainInput: true,
|
||||||
numberOfMonths: [1, 1],
|
numberOfMonths: [1, 1],
|
||||||
showCurrentAtPos: 0,
|
showCurrentAtPos: 0,
|
||||||
dateFormat: 'mm/dd/yy' })
|
dateFormat: 'mm/dd/yy' });
|
||||||
//.datepicker('setDate', '+0');
|
|
||||||
;
|
|
||||||
|
|
||||||
<?php if (isset($customer['id'])) { ?>
|
resetForm();
|
||||||
|
|
||||||
|
<?php if (isset($customer['id'])): ?>
|
||||||
$("#customer-id").val(<?php echo $customer['id']; ?>);
|
$("#customer-id").val(<?php echo $customer['id']; ?>);
|
||||||
|
$("#receipt-customer-id").html("<?php echo '#'.$customer['id']; ?>");
|
||||||
|
$("#receipt-customer-name").html("<?php echo $customer['name']; ?>");
|
||||||
updateChargesCaption("<?php echo $customer['name']; ?>",
|
updateChargesCaption("<?php echo $customer['name']; ?>",
|
||||||
<?php echo $charges['balance']; ?>);
|
<?php echo $charges['balance']; ?>
|
||||||
<?php } ?>
|
);
|
||||||
|
onGridState(null, 'hidden');
|
||||||
|
<?php else: ?>
|
||||||
|
onGridState(null, 'visible');
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* $("#dialog").dialog({ */
|
/* $("#dialog").dialog({ */
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php /* -*- mode:PHP -*- */ ?>
|
<?php /* -*- mode:PHP -*- */ ?>
|
||||||
|
|
||||||
<div class="assess input">
|
<div class="invoice input">
|
||||||
<?php
|
<?php
|
||||||
; // Editor alignment
|
; // Editor alignment
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
**********************************************************************
|
**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
*
|
* Grid Setup / Javascript
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$lease_grid_setup = array();
|
$lease_grid_setup = array();
|
||||||
@@ -32,56 +32,27 @@ $lease_grid_setup['onHeaderClick'] = array
|
|||||||
|
|
||||||
// Reset the form
|
// Reset the form
|
||||||
function resetForm() {
|
function resetForm() {
|
||||||
$("#lease-entry-id").val(0);
|
$("#charge-entry-id").val(0);
|
||||||
$("#lease-lease").html("INTERNAL ERROR");
|
|
||||||
|
$("#invoice-lease").html("INTERNAL ERROR");
|
||||||
|
$("#invoice-unit").html("INTERNAL ERROR");
|
||||||
|
$("#invoice-customer").html("INTERNAL ERROR");
|
||||||
|
|
||||||
datepickerNow('charge_date');
|
datepickerNow('charge_date');
|
||||||
$("#through_date").val('');
|
$("#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) {
|
function onRowSelect(grid_id, lease_id) {
|
||||||
// Set the item id that will be returned with the form
|
// Set the item id that will be returned with the form
|
||||||
$("#lease-id").val(lease_id);
|
$("#lease-id").val(lease_id);
|
||||||
|
|
||||||
// Get the item name from the grid
|
// Get the item names from the grid
|
||||||
$("#lease-lease").html('Lease '
|
$("#invoice-lease").html($(grid_id).getCell(lease_id, 'Lease-number'));
|
||||||
+ $(grid_id).getCell(lease_id, 'Lease-number')
|
$("#invoice-unit").html($(grid_id).getCell(lease_id, 'Unit-name'));
|
||||||
+ ' / Unit '
|
$("#invoice-customer").html($(grid_id).getCell(lease_id, 'Customer-name'));
|
||||||
+ $(grid_id).getCell(lease_id, 'Unit-name')
|
|
||||||
);
|
|
||||||
|
|
||||||
|
// Make sure the redirect is up to date, if necessary
|
||||||
if ($("#redirectController").val() == 'leases')
|
if ($("#redirectController").val() == 'leases')
|
||||||
$("#redirect0").val(lease_id);
|
$("#redirect0").val(lease_id);
|
||||||
|
|
||||||
@@ -89,6 +60,7 @@ function onRowSelect(grid_id, lease_id) {
|
|||||||
$("#no-lease").hide();
|
$("#no-lease").hide();
|
||||||
$("#current-lease").show();
|
$("#current-lease").show();
|
||||||
|
|
||||||
|
// Collapse the grid now that the user has selected
|
||||||
$("#leases-list .HeaderButton").click();
|
$("#leases-list .HeaderButton").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,12 +96,17 @@ echo $this->element('leases',
|
|||||||
));
|
));
|
||||||
|
|
||||||
echo ('<H2>' .
|
echo ('<H2>' .
|
||||||
'<SPAN id="current-lease">Lease: <SPAN id="lease-lease"></SPAN></SPAN>' .
|
'<SPAN id="current-lease" style="display:none">' .
|
||||||
'<SPAN id="no-lease">Please select lease</SPAN>' .
|
'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");
|
'</H2>' . "\n");
|
||||||
|
|
||||||
|
echo $form->create(null, array('id' => 'invoice-form',
|
||||||
echo $form->create(null, array('id' => 'assess-form',
|
|
||||||
'url' => array('controller' => 'transactions',
|
'url' => array('controller' => 'transactions',
|
||||||
'action' => 'postInvoice')));
|
'action' => 'postInvoice')));
|
||||||
|
|
||||||
@@ -139,7 +116,7 @@ echo $form->input("Lease.id",
|
|||||||
'value' => 0));
|
'value' => 0));
|
||||||
|
|
||||||
echo $this->element('form_table',
|
echo $this->element('form_table',
|
||||||
array('class' => "item assess entry",
|
array('class' => "item invoice transaction entry",
|
||||||
//'with_name_after' => ':',
|
//'with_name_after' => ':',
|
||||||
'field_prefix' => 'Transaction',
|
'field_prefix' => 'Transaction',
|
||||||
'fields' => array
|
'fields' => array
|
||||||
@@ -159,7 +136,7 @@ echo $this->element('form_table',
|
|||||||
|
|
||||||
echo ('<BR>' . "\n");
|
echo ('<BR>' . "\n");
|
||||||
echo $this->element('form_table',
|
echo $this->element('form_table',
|
||||||
array('class' => "item assess entry",
|
array('class' => "item invoice ledger-entry entry",
|
||||||
//'with_name_after' => ':',
|
//'with_name_after' => ':',
|
||||||
'field_prefix' => 'LedgerEntry.0',
|
'field_prefix' => 'LedgerEntry.0',
|
||||||
'fields' => array
|
'fields' => array
|
||||||
@@ -192,7 +169,7 @@ foreach ($redirect AS $name => $value) {
|
|||||||
'value' => $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'])): ?>
|
<?php if (isset($lease['Lease']['id'])): ?>
|
||||||
$("#lease-id").val(<?php echo $lease['Lease']['id']; ?>);
|
$("#lease-id").val(<?php echo $lease['Lease']['id']; ?>);
|
||||||
$("#lease-lease").html("<?php echo 'Lease #' . $lease['Lease']['number'] . ' / Unit ' . $lease['Unit']['name']; ?>");
|
$("#invoice-lease").html("<?php echo '#'.$lease['Lease']['number']; ?>");
|
||||||
$("#current-lease").show();
|
$("#invoice-unit").html("<?php echo $lease['Unit']['name']; ?>");
|
||||||
$("#no-lease").hide();
|
$("#invoice-customer").html("<?php echo $lease['Customer']['name']; ?>");
|
||||||
|
onGridState(null, 'hidden');
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
$("#current-lease").hide();
|
onGridState(null, 'visible');
|
||||||
$("#no-lease").hide();
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
});
|
});
|
||||||
--></script>
|
--></script>
|
||||||
@@ -139,6 +139,48 @@ function fmtCurrency(amount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Datepicker helpers
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// REVISIT <AP>: 20090617
|
// REVISIT <AP>: 20090617
|
||||||
// I would rather use XML to pass from JS to PHP, but at the
|
// I would rather use XML to pass from JS to PHP, but at the
|
||||||
// moment things were working just fine with serialize, and
|
// moment things were working just fine with serialize, and
|
||||||
|
|||||||
Reference in New Issue
Block a user