diff --git a/controllers/customers_controller.php b/controllers/customers_controller.php index d233067..87d5b42 100644 --- a/controllers/customers_controller.php +++ b/controllers/customers_controller.php @@ -251,7 +251,7 @@ class CustomersController extends AppController { if ($show_payment) { $this->sidemenu_links[] = array('name' => 'Payment', - 'url' => array('action' => 'payment', + 'url' => array('action' => 'receipt', $id)); } @@ -352,11 +352,11 @@ class CustomersController extends AppController { /************************************************************************** ************************************************************************** ************************************************************************** - * action: payment - * - Sets up the payment entry page for the given customer. + * action: receipt + * - Sets up the receipt entry page for the given customer. */ - function payment($id = null) { + function receipt($id = null) { /* if (!$id) { */ /* $this->Session->setFlash(__('Invalid Item.', true)); */ /* $this->redirect(array('action'=>'index')); */ @@ -379,7 +379,7 @@ class CustomersController extends AppController { $charges = array('balance' => 0, 'entry' => array()); } - $title = 'Payment Entry'; + $title = ($customer['name'] . ': Payment Entry'); $this->set(compact('customer', 'charges', 'title')); } diff --git a/controllers/leases_controller.php b/controllers/leases_controller.php index af24508..3efe50e 100644 --- a/controllers/leases_controller.php +++ b/controllers/leases_controller.php @@ -169,11 +169,11 @@ class LeasesController extends AppController { /************************************************************************** ************************************************************************** ************************************************************************** - * action: assess - * - Assesses charges to the lease + * action: invoice + * - 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 ('first', array @@ -209,7 +209,7 @@ class LeasesController extends AppController { $title = ('Lease #' . $lease['Lease']['number'] . ': ' . $lease['Unit']['name'] . ': ' . - $lease['Customer']['name'] . ': Assess Charges'); + $lease['Customer']['name'] . ': Charge Entry'); $this->set(compact('title', 'lease', 'charge')); } @@ -255,11 +255,11 @@ class LeasesController extends AppController { array('name' => 'Operations', 'header' => true); $this->sidemenu_links[] = - array('name' => 'Assess Rent', 'url' => array('action' => 'assess', + array('name' => 'Assess Rent', 'url' => array('action' => 'invoice', $id, 'rent')); $this->sidemenu_links[] = - array('name' => 'Assess Late Charge', 'url' => array('action' => 'assess', + array('name' => 'Assess Late Charge', 'url' => array('action' => 'invoice', $id, 'late')); if (!isset($lease['Lease']['moveout_date'])) { @@ -270,7 +270,7 @@ class LeasesController extends AppController { $this->sidemenu_links[] = array('name' => 'Payment', 'url' => array('controller' => 'customers', - 'action' => 'payment', + 'action' => 'receipt', $lease['Customer']['id'])); } diff --git a/controllers/transactions_controller.php b/controllers/transactions_controller.php index cc4d32f..bcc80f8 100644 --- a/controllers/transactions_controller.php +++ b/controllers/transactions_controller.php @@ -140,7 +140,7 @@ class TransactionsController extends AppController { } if (!$this->Transaction->addReceipt($this->data, - $this->data['customer_id'])) { + $this->data['Customer']['id'])) { $this->Session->setFlash("RECEIPT FAILED", true); // REVISIT 20090706: // Until we can work out the session problems, diff --git a/controllers/units_controller.php b/controllers/units_controller.php index 58ae644..0d570b7 100644 --- a/controllers/units_controller.php +++ b/controllers/units_controller.php @@ -222,8 +222,9 @@ class UnitsController extends AppController { if (isset($unit['CurrentLease']['id']) && !isset($unit['CurrentLease']['close_date'])) { $this->sidemenu_links[] = - array('name' => 'Payment', 'url' => array('action' => 'payment', - $id)); + array('name' => 'Payment', 'url' => array('controller' => 'customers', + 'action' => 'receipt', + $unit['CurrentLease']['customer_id'])); } // Prepare to render. diff --git a/views/customers/payment.ctp b/views/customers/receipt.ctp similarity index 66% rename from views/customers/payment.ctp rename to views/customers/receipt.ctp index 1ac95c0..33e96a9 100644 --- a/views/customers/payment.ctp +++ b/views/customers/receipt.ctp @@ -1,47 +1,6 @@ -
- -element('table', */ -/* array('class' => 'item transaction detail', */ -/* 'caption' => 'Transaction Detail', */ -/* 'rows' => $rows, */ -/* 'column_class' => array('field', 'value'))); */ - - - -/********************************************************************** - * Transaction Info Box - */ - -?> - - - - +
+ 'function(gridstate) { onGridState("#"+$(this).attr("id"), gridstate); }' + ); // Customer // Outstanding balance @@ -93,11 +56,8 @@ $grid_setup['onSelectRow'] = array //timeout: 3000, }; - // get a clean slate - resetPaymentForm(); - // bind form using 'ajaxForm' - $('#payment-form').ajaxForm(options); + $('#receipt-form').ajaxForm(options); }); // pre-submit callback @@ -132,7 +92,7 @@ $grid_setup['onSelectRow'] = array if (statusText == 'success') { // get a clean slate - //resetPaymentForm(); + //resetForm(); } else { alert('not successful??'); @@ -142,27 +102,20 @@ $grid_setup['onSelectRow'] = array $('#response-debug').html('
'+dump(statusText)+'
'); } - // Reset payment fields - function resetPaymentForm() { - // Get a clean slate for our payments + // Reset the form + function resetForm() { + $('#payment-entry-id').val(0); $('#payments').html(''); - $('#payment-id').val(0); - addPaymentSource(false); - datepickerNow(); - } - function datepickerNow() { - now = new Date(); - $("#datepicker").val($.datepicker.formatDate('mm/dd/yy', now) - + ' ' - + (now.getHours() < 10 ? '0' : '') - + now.getHours() + ':' - + (now.getMinutes() < 10 ? '0' : '') - + now.getMinutes()); + $("#receipt-customer-id").html("INTERNAL ERROR"); + $("#receipt-customer-name").html("INTERNAL ERROR"); + + addPaymentSource(false); + datepickerNow('TransactionStamp'); } function addPaymentSource(flash) { - addDiv('payment-id', 'payment', 'payments', flash, + addDiv('payment-entry-id', 'payment', 'payments', flash, // HTML section '
' + 'Payment #%{id} (%{remove})' + @@ -312,7 +265,6 @@ function updateChargesGrid(idlist, balance) { function updateCharges(id) { var url = 'url(array("controller" => $this->params["controller"], "action" => "unreconciled"))); ?>'; - //url += '/'+$("#customer-id").val(); url += '/'+id; $.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 - $("#customer-id").val(cust_id); + $("#customer-id").val(customer_id); - // Get the customer name from the grid - $("#payment_customer").html($(grid_id).getCell(cust_id, "Customer-name")); + // Get the item names from the grid + $("#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 - $("#payment_customer").html($("#payment_customer a").html()); + // Make sure the redirect is up to date, if necessary + if ($("#redirectController").val() == 'customers') + $("#redirect0").val(customer_id); // Hide the "no customer" message and show the current customer - $("#no_customer").hide(); - $("#current_customer").show(); + $("#no-customer").hide(); + $("#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(); + } + } } --> @@ -356,11 +330,24 @@ function onRowSelect(grid_id, cust_id) { echo $this->element('customers', array('grid_div_id' => 'customers-list', + 'grid_div_class' => 'text-below', 'caption' => ('Select Customer'), 'grid_setup' => $grid_setup, + 'nolinks' => true, + 'limit' => 10, )); +echo ('

' . + '' . + '' . + '

' . "\n"); + echo $this->element('ledger_entries', array('grid_div_id' => 'charge-entries', 'caption' => 'Outstanding Charges', @@ -369,107 +356,72 @@ echo $this->element('ledger_entries', 'limit' => 8, )); -echo ('

' . - '' . - 'Enter new receipt for ' . - '' . (isset($customer['name']) ? $customer['name'] : "") . '' . - '' . - '' . - 'Please select customer' . - '' . - '

' . "\n"); - -echo $form->create(null, array('id' => 'payment-form', +echo $form->create(null, array('id' => 'receipt-form', 'url' => array('controller' => 'transactions', 'action' => 'postReceipt'))); -/*************************************************** - * Post data should look like this: - * - * data => Array - * ( - * [Transaction] => Array - * ( - * stamp => - * through_date => - * due_date => - * comment => - * ) - * - * [LedgerEntry] => Array - * ( - * [0] => Array - * ( - * name => - * amount => - * debit_ledger_id => - * credit_ledger_id => - * comment => - * - * [MonetarySource] => Array - * ( - * name => - * monetary_type_id => - * 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' => 'Now', + ), + "comment" => array('opts' => array('size' => 50), + ), + ))); + +echo $form->submit('Generate Receipt') . "\n"; ?> -
Payments - +
Add Another Payment
-end('Generate Receipt'); ?> -echo 'Date: '; -echo ' Now
' . "\n"; -echo 'Comment:
' . "\n"; -echo $form->end('Post Payment'); - -//echo '
' . "\n"; // End of the dialog DIV -?> - -Create Payment */ -?> +' . "\n"; // End of the dialog DIV */ ?>

Request

Response

Output

- diff --git a/webroot/js/pmgr.js b/webroot/js/pmgr.js index 5b4bde7..0ead35a 100644 --- a/webroot/js/pmgr.js +++ b/webroot/js/pmgr.js @@ -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 : 20090617 // I would rather use XML to pass from JS to PHP, but at the // moment things were working just fine with serialize, and