Moved ledgers over the jqGrid. Working reasonably well at the moment.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@131 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -91,13 +91,16 @@ class AppController extends Controller {
|
||||
$model = $this->jqGridDataModel($params);
|
||||
|
||||
// Establish the basic query and conditions
|
||||
$query = array_intersect_key($this->jqGridDataTables($params, $model),
|
||||
$query = array_intersect_key($this->jqGridDataCountTables($params, $model),
|
||||
array('link'=>1, 'contain'=>1));
|
||||
$query['conditions'] = $this->jqGridDataConditions($params, $model);
|
||||
|
||||
// Get the number of records prior to pagination
|
||||
$count = $this->jqGridDataRecordCount($params, $model, $query);
|
||||
|
||||
// Get the rest of the tables.
|
||||
$this->jqGridDataExtraTables($params, $model, $query);
|
||||
|
||||
// Verify a few parameters and determine our starting row
|
||||
$limit = $params['rows'];
|
||||
$total = ($count < 0) ? 0 : ceil($count/$limit);
|
||||
@@ -113,6 +116,9 @@ class AppController extends Controller {
|
||||
$query['fields'] = $this->jqGridDataFields($params, $model);
|
||||
$results = $this->jqGridDataRecords($params, $model, $query);
|
||||
|
||||
// Post process the records
|
||||
$this->jqGridRecordsPostProcess($params, $model, $results);
|
||||
|
||||
// Add in any needed hyperlinks
|
||||
$this->jqGridRecordLinks($params, $model, $results, array());
|
||||
|
||||
@@ -181,6 +187,14 @@ class AppController extends Controller {
|
||||
return array('contain' => false);
|
||||
}
|
||||
|
||||
function jqGridDataCountTables(&$params, &$model) {
|
||||
// For backwards compatibility
|
||||
return $this->jqGridDataTables($params, $model);
|
||||
}
|
||||
|
||||
function jqGridDataExtraTables(&$params, &$model, &$query) {
|
||||
}
|
||||
|
||||
function jqGridDataConditions(&$params, &$model) {
|
||||
$searches = array();
|
||||
|
||||
@@ -249,6 +263,16 @@ class AppController extends Controller {
|
||||
return $model->find('all', $query);
|
||||
}
|
||||
|
||||
function jqGridRecordsPostProcess(&$params, &$model, &$records) {
|
||||
$model_alias = $model->alias;
|
||||
|
||||
foreach ($records AS &$record) {
|
||||
// Add the calculated fields (if any), to the model fields
|
||||
if (isset($record[0]))
|
||||
$record[$model_alias] += $record[0];
|
||||
}
|
||||
}
|
||||
|
||||
function jqGridRecordLinks(&$params, &$model, &$records, $links) {
|
||||
foreach ($links AS $table => $fields) {
|
||||
$controller = Inflector::pluralize(strtolower($table));
|
||||
@@ -291,10 +315,6 @@ class AppController extends Controller {
|
||||
$model_alias = $model->alias;
|
||||
|
||||
foreach ($records AS $record) {
|
||||
// Add the calculated fields (if any), to the model fields
|
||||
if (isset($record[0]))
|
||||
$record[$model_alias] += $record[0];
|
||||
|
||||
echo " <row id='{$record[$model_alias]['id']}'>\n";
|
||||
foreach ($params['fields'] AS $field) {
|
||||
if (preg_match("/\./", $field)) {
|
||||
|
||||
Reference in New Issue
Block a user