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/site@118 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-14 19:50:09 +00:00
parent 67d640b1a0
commit 92d8387e8c
10 changed files with 260 additions and 254 deletions

View File

@@ -1,10 +1,6 @@
<?php
class LeasesController extends AppController {
var $paginate = array
('limit' => 100,
'group' => 'Lease.id',
'order' => array('Lease.movein_date' => 'DESC'));
var $sidemenu_links =
array(array('name' => 'Leases', 'header' => true),
@@ -28,24 +24,52 @@ class LeasesController extends AppController {
/**************************************************************************
**************************************************************************
**************************************************************************
* action: index
* - Lists current leases
* action: index / active / closed / all
* - Generate a listing of leases
*/
function index() {
$this->active();
}
function index() { $this->all(); }
function active() { $this->jqGridView('Active Leases'); }
function closed() { $this->jqGridView('Closed Leases'); }
function all() { $this->jqGridView('All Leases'); }
/**************************************************************************
**************************************************************************
**************************************************************************
* action: active
* - Lists all active leases
* virtuals: jqGridData
* - With the application controller handling the jqGridData action,
* these virutal functions ensure that the correct data is passed
* to jqGrid.
*/
function active() {
$leases = $this->paginate(array('Lease.close_date IS NULL'));
function jqGridDataSetup(&$params) {
parent::jqGridDataSetup($params);
if (!isset($params['action']))
$params['action'] = 'all';
}
function jqGridDataTables(&$params) {
return array
('link' => array('Unit' => array('fields' => array('Unit.name')),
'Customer' => array('fields' => array('Customer.name'))));
}
function jqGridDataConditions(&$params) {
$conditions = parent::jqGridDataConditions($params);
if ($params['action'] === 'active') {
$conditions[] = 'Lease.close_date IS NULL';
}
elseif ($params['action'] === 'closed') {
$conditions[] = 'Lease.close_date IS NOT NULL';
}
return $conditions;
}
function jqGridDataRecords(&$params, $model, $query) {
$leases = parent::jqGridDataRecords($params, $model, $query);
// Get the balance on each lease.
foreach ($leases AS &$lease) {
@@ -53,56 +77,7 @@ class LeasesController extends AppController {
$lease['Lease']['balance'] = $stats['Account']['Ledger']['balance'];
}
$title = 'Active Leases';
$this->set('title', $title); $this->set('heading', $title);
$this->set('leases', $leases);
$this->render('index');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: closed
* - Lists all closed (inactive) leases
*/
function closed() {
$leases = $this->paginate(array('Lease.close_date IS NOT NULL'));
// Get the balance on each lease.
foreach ($leases AS &$lease) {
$stats = $this->Lease->stats($lease['Lease']['id']);
$lease['Lease']['balance'] = $stats['Account']['Ledger']['balance'];
}
$title = 'Past Leases';
$this->set('title', $title); $this->set('heading', $title);
$this->set('leases', $leases);
$this->render('index');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: all
* - Lists all leases
*/
function all() {
$leases = $this->paginate();
// Get the balance on each lease.
foreach ($leases AS &$lease) {
$stats = $this->Lease->stats($lease['Lease']['id']);
$lease['Lease']['balance'] = $stats['Account']['Ledger']['balance'];
}
$title = 'All Leases';
$this->set('title', $title); $this->set('heading', $title);
$this->set('leases', $leases);
$this->render('index');
return $leases;
}