Check in aother snapshot, since I can now pass complex structures from the view back to the jqGrid data provider

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@105 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-13 07:22:38 +00:00
parent 55dd94681a
commit a49b86898e
2 changed files with 82 additions and 128 deletions

View File

@@ -1,10 +1,6 @@
<?php
class CustomersController extends AppController {
var $paginate = array('limit' => 100,
'group' => 'Customer.id',
'order' => array('Customer.name' => 'ASC'));
var $sidemenu_links =
array(array('name' => 'Tenants', 'header' => true),
array('name' => 'Current', 'url' => array('controller' => 'customers', 'action' => 'current')),
@@ -12,7 +8,7 @@ class CustomersController extends AppController {
array('name' => 'All', 'url' => array('controller' => 'customers', 'action' => 'all')),
);
var $components = array('RequestHandler');
//var $components = array('RequestHandler');
/**************************************************************************
@@ -102,6 +98,7 @@ class CustomersController extends AppController {
function all() {
$title = 'All Customers';
$this->set('title', $title); $this->set('heading', $title);
$this->set('params', $this->params);
$this->render('index');
}
@@ -113,11 +110,19 @@ class CustomersController extends AppController {
* -
*/
function data($fields_str) {
function jqGridData($debug = true) {
/* pr(array('fields' => $fields, */
/* 'explode' => explode(";", $fields_str))); */
$fields = explode(";", $fields_str);
/* $debug=true; */
/* $tf = unserialize($fields); */
/* $tp = unserialize($params); */
/* $fields = array('Customer.id'); */
//$action_params = unserialize($action_params);
//$fields = explode(";", $fields_str);
//$fields=array();
/* foreach (explode(";", $fields_str) AS $i => $field) { */
@@ -130,6 +135,7 @@ class CustomersController extends AppController {
//pr(array('fields' => $fields));
$debug = true;
if (isset($this->passedArgs['debug']))
$debug = $this->passedArgs['debug'];
@@ -146,9 +152,21 @@ class CustomersController extends AppController {
$rows = 20; // rows in the grid - rowNum parameter
$sidx = 'Customer.id'; // sort column - index from colModel
$sord = 'ASC'; // sort order
$fields = array('Customer.id');
if (isset($this->params['url']) && is_array($this->params['url']))
extract($this->params['url']);
if (isset($fields))
$fields = unserialize($fields);
else
$fields = array('Customer.id');
if (isset($params))
$params = unserialize($params);
else
$params = array('action' => 'all');
// calculate the number of rows for the query. We need this for paging the result
$row = $this->Customer->findCount();
@@ -172,12 +190,22 @@ class CustomersController extends AppController {
// typical case is that the user type 0 for the requested page
if($start <0) $start = 0;
$cond = array();
if ($params['action'] == 'current') {
} elseif ($params['action'] == 'past') {
} else {
}
// the actual query for the grid data
$customers = $this->Customer->find
('all',
array('contain' => array
(// Models
/* 'Contact' => */
'PrimaryContact',
/* array(// Models */
/* 'ContactPhone', */
/* 'ContactEmail', */
@@ -221,6 +249,8 @@ class CustomersController extends AppController {
/* echo " <d><![CDATA[{$d}]]></d>\n"; */
/* echo " <named><![CDATA[" . print_r($this->params, true) . "]]></named>\n"; */
/* echo " <passed><![CDATA[" . print_r($this->passedArgs, true) . "]]></passed>\n"; */
/* echo " <params><![CDATA[" . print_r($params, true) . "]]></params>\n"; */
/* echo " <tp><![CDATA[" . print_r($tp, true) . "]]></tp>\n"; */
/* echo " </parms>\n"; */
echo " <page>".$page."</page>\n";
echo " <total>".$total_pages."</total>\n";
@@ -234,6 +264,7 @@ class CustomersController extends AppController {
('$lease', 'return $lease["Unit"]["name"];'),
$customer['CurrentLease']));
echo " <row id='{$customer['Customer']['id']}'>\n";
foreach ($fields AS $field) {
list($tbl, $col) = explode(".", $field);