diff --git a/controllers/customers_controller.php b/controllers/customers_controller.php index 88523d4..d0a1238 100644 --- a/controllers/customers_controller.php +++ b/controllers/customers_controller.php @@ -148,6 +148,8 @@ class CustomersController extends AppController { $this->sidemenu_links[] = array('name' => 'Operations', 'header' => true); + $this->sidemenu_links[] = + array('name' => 'Payment', 'url' => array('action' => 'payment', $id)); $this->sidemenu_links[] = array('name' => 'Move-Out', 'url' => array('controller' => 'units', 'action' => 'move-out')); @@ -172,12 +174,12 @@ class CustomersController extends AppController { /* $this->redirect(array('action'=>'index')); */ /* } */ - if ($this->RequestHandler->isPost()) { - pr($this->data); - //$this->redirect(array('action'=>'index')); - $customer = $this->data; - } - elseif (isset($id)) { +/* if ($this->RequestHandler->isPost()) { */ +/* pr($this->data); */ +/* //$this->redirect(array('action'=>'index')); */ +/* $customer = $this->data; */ +/* } */ + if (isset($id)) { $customer = $this->Customer->details($id); unset($customer['deposits']['Entries']); } diff --git a/views/customers/payment.ctp b/views/customers/payment.ctp index b3c2b88..78151bb 100644 --- a/views/customers/payment.ctp +++ b/views/customers/payment.ctp @@ -52,8 +52,38 @@ * */ +$grid_setup = array(); + +if (isset($customer['Customer']['id'])) + $grid_setup['hiddengrid'] = true; + +$grid_setup['onSelectRow'] = array + ('--special' => + 'function(ids) { if (ids != null)' . + ' {' . + // Set the customer id that will be returned with the form + ' $("#customer-id").val(ids);' . + // Get the customer name from the grid + ' $("#payment_customer").html($("#"+$(this).attr("id"))' . + ' .getCell(ids, "Customer-name"));' . + // Replace that with just the text portion of the hyperlink + ' $("#payment_customer").html("Receipt for "+ $("#payment_customer a").html());' . + ' } }' + ); + +/* $grid_setup['loadComplete'] = array */ +/* ('--special' => */ +/* 'function() { ' . */ +/* //' $("#"+$(this).attr("id")).setSelection($("#customer-id").val());' . */ +/* ' $(\'#customers-list-jqGrid\').setSelection($(\'#customer-id\').val());' . */ +/* ' $("#"+$(this).attr("id")).setCaption("Hello");' . */ +/* ' alert("Loaded");' . */ +/* ' }' */ +/* ); */ + + //pr($customer); -echo ("

" . $customer['Customer']['name'] . "

\n"); +//echo ('Get grid code
'); // Customer // Outstanding balance @@ -63,8 +93,6 @@ echo ("

" . $customer['Customer']['name'] . "

\n"); // How to apply (even split, oldest charges first, etc) -echo $form->create(null, array('id' => 'payment-form', 'action' => 'payment')); - ?> +' . "\n"; + +echo $this->element('customers', + array('caption' => 'Select Customer', + 'limit' => 7, + 'grid_setup' => $grid_setup, + )); + +echo ('

' . + (isset($customer['Customer']['id']) + ? 'Receipt for ' . $customer['Customer']['name'] + : 'Please select customer') . + '

' . "\n"); + + //echo $form->create(null, array('id' => 'payment-form', 'action' => 'other')); + echo $form->create(null, array('id' => 'payment-form', 'url' => 'http://localhost/vars.php')); +?> + +
Payments @@ -264,13 +327,22 @@ function switchPaymentType(paymentid, type) { inputs(); -echo '
' . "\n"; -echo $form->end('Send'); +echo 'Date:
' . "\n"; +echo 'Comment:
' . "\n"; +echo $form->end('Post Payment'); +//echo '' . "\n"; // End of the dialog DIV ?> + Clear Debug Output -
+Create Payment */ +?> + + +

Request

+

Response

+

Output

@@ -278,7 +350,35 @@ echo $form->end('Send'); diff --git a/views/elements/customers.ctp b/views/elements/customers.ctp index 895f0eb..4cfa0e3 100644 --- a/views/elements/customers.ctp +++ b/views/elements/customers.ctp @@ -12,8 +12,10 @@ $cols['Leases'] = array('index' => 'lease_count', 'width' => $cols['Comment'] = array('index' => 'Customer.comment', 'formatter' => 'comment'); $jqGrid_options = array('jqGridColumns' => $cols, - 'controller' => 'customers', - 'caption' => isset($caption) ? $caption : null); + 'controller' => 'customers'); + +// User requested options have priority +$jqGrid_options += compact('caption', 'grid_setup', 'limit'); if (isset($customers)) { $jqGrid_options += array('custom_ids' => @@ -22,7 +24,9 @@ if (isset($customers)) { $customers), 'limit' => 5); } -else { + +// Not the long term solution here... just for testing +if (isset($searchfields)) { $jqGrid_options += array('search_fields' => array('Last Name', 'First Name')); } diff --git a/views/elements/jqGrid.ctp b/views/elements/jqGrid.ctp index fcc53d1..f41e985 100644 --- a/views/elements/jqGrid.ctp +++ b/views/elements/jqGrid.ctp @@ -39,6 +39,8 @@ if (!isset($grid_id)) if (!isset($search_fields)) $search_fields = array(); +if (!isset($grid_setup)) + $grid_setup = array(); // Do some prework to bring in the appropriate libraries $imgpath = '/pmgr/site/css/jqGrid/basic/images'; @@ -139,10 +141,35 @@ foreach ($jqGridColumns AS &$col) { $col = array_merge($default, $col); } +// Set the default sort column reset($jqGridColumns); $sortname = current($jqGridColumns); $sortname = $sortname['index']; +// Configure the grid setup, giving priority to user defined parameters +$jqGrid_setup = array_merge + (array('mtype' => 'GET', + 'datatype' => 'xml', + 'url' => $url, + 'postData' => $postData, + 'colNames' => array_keys($jqGridColumns), + 'colModel' => array('--special' => $jqGridColumns), + 'height' => $height, + 'rowNum' => $limit, + 'rowList' => $limitOptions, + 'sortname' => $sortname, + 'caption' => $caption, + 'imgpath' => $imgpath, + 'viewrecords' => true, + 'pager' => $grid_id.'-pager', + + 'loadComplete' => array('--special' => "function() {url=jQuery('#{$grid_id}').getGridParam('url');url=url.replace(/\/debug.*$/,'?'); pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('Grid Query
');}"), + 'loadError' => array('--special' => "function(xhr,st,err) {url=jQuery('#{$grid_id}').getGridParam('url');url=url.replace(/\/debug.*$/,'?'); pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('Grid Error Query
');}"), + + ), + $grid_setup + ); +//pr(compact('grid_setup', 'jqGrid_setup')); // OK, now that everything is in place, get out of PHP mode, // and add the javascript code (along with a touch of HTML) @@ -165,27 +192,7 @@ jQuery(document).ready(function(){ } jQuery('#').jqGrid( - 'GET', - 'datatype' => 'xml', - 'url' => $url, - 'postData' => $postData, - 'colNames' => array_keys($jqGridColumns), - 'colModel' => array('--special' => $jqGridColumns), - 'height' => $height, - 'rowNum' => $limit, - 'rowList' => $limitOptions, - 'sortname' => $sortname, - 'caption' => $caption, - 'imgpath' => $imgpath, - 'viewrecords' => true, - 'pager' => $grid_id.'-pager', - - 'loadComplete' => array('--special' => "function() {url=jQuery('#{$grid_id}').getGridParam('url');url=url.replace(/\/debug.*$/,'?'); pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('Grid Query
');}"), - 'loadError' => array('--special' => "function(xhr,st,err) {url=jQuery('#{$grid_id}').getGridParam('url');url=url.replace(/\/debug.*$/,'?'); pd=jQuery('#{$grid_id}').getPostData();$.each(pd,function(i){ url+=i+'='+escape(pd[i])+'&'; }); jQuery('#{$grid_id}-query').html('Grid Error Query
');}"), - //'toolbar' => array(true,"bottom"), - )); ?> + ).navGrid('#-pager', { view:false, edit:false, diff --git a/webroot/css/layout.css b/webroot/css/layout.css index 0b23087..74b1272 100644 --- a/webroot/css/layout.css +++ b/webroot/css/layout.css @@ -212,7 +212,7 @@ form div.submit { border: 0; clear: both; margin-top: 10px; - margin-left: 140px; +/* margin-left: 140px; */ } /************************************************************