Made the app controller include the action by default. Added virtual callouts for data order and limit. Changed fields to use formatting, including a custom format for currency and id. Added a function for auto conversion from PHP variables to javascript. Fixed some minor bugs in the controllers already converted to jqGrid. Moved leases onto jqGrid.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@118 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-14 19:50:09 +00:00
parent f6ca79d1a9
commit c90830d41a
10 changed files with 260 additions and 254 deletions

View File

@@ -1,9 +1,6 @@
<?php
class UnitsController extends AppController {
var $paginate = array('limit' => 100,
'group' => 'Unit.id',
'order' => array('Unit.sort_order' => 'ASC'));
var $sidemenu_links =
array(array('name' => 'Units', 'header' => true),
@@ -28,15 +25,15 @@ class UnitsController extends AppController {
/**************************************************************************
**************************************************************************
**************************************************************************
* action: index / current / past / all
* - Creates a list of tenants
* action: index / unavailable / vacant / occupied / all
* - Generate a listing of units
*/
function index() { $this->all(); }
function unavailable() { $this->jqGridView('unavailable', 'Unavailable Units'); }
function vacant() { $this->jqGridView('vacant', 'Vacant Units'); }
function occupied() { $this->jqGridView('occupied', 'Occupied Units'); }
function all() { $this->jqGridView('all', 'All Units'); }
function unavailable() { $this->jqGridView('Unavailable Units'); }
function vacant() { $this->jqGridView('Vacant Units'); }
function occupied() { $this->jqGridView('Occupied Units'); }
function all() { $this->jqGridView('All Units', 'all'); }
/**************************************************************************
@@ -89,40 +86,13 @@ class UnitsController extends AppController {
return $conditions;
}
function zzjqGridDataRecordCount(&$params, $model, $query) {
// We don't have a good way to use the query to obtain
// our count. The problem is that we're relying on the
// group by for the query, which will destroy the count,
// whether we omit the group by or leave it in.
// So, build a fresh query for counting.
$query['conditions'] = parent::jqGridDataConditions($params);
$count = $model->find('count',
array_merge(array('link' => array_diff_key($query['link'],
array('CurrentLease'=>1))),
array_diff_key($query, array('link'=>1))));
if ($params['action'] === 'all')
return $count;
$query['conditions'][] = 'CurrentLease.id IS NULL';
$count_past = $model->find('count', $query);
// Since we can't easily count 'current' directly, we
// can quickly derive it since 'current' customers
// are mutually exclusive to 'past' customers.
if ($params['action'] == 'current')
$count = $count - $count_past;
elseif ($params['action'] == 'past') {
$count = $count_past;
function jqGridDataOrder(&$params, $index, $direction) {
if ($index === 'Unit.name') {
$index = 'Unit.sort_order';
}
return $count;
return parent::jqGridDataOrder($params, $index, $direction);
}
/**************************************************************************
**************************************************************************
**************************************************************************