Moved map listings to jqGrid, and fixed cut/paste error in the comments of the transactions controller.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@137 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-15 21:34:35 +00:00
parent af32d88605
commit dfb0d90246
4 changed files with 48 additions and 64 deletions

View File

@@ -2,22 +2,44 @@
class MapsController extends AppController { class MapsController extends AppController {
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* action: index * action: index / all
* - Generates a list of all site maps * - Generate a listing of maps
* *
* REVISIT <AP> 20090528: * REVISIT <AP> 20090528:
* We'll need to present only those site area maps that correspond * We'll need to present only those site area maps that correspond
* to the users particular site. * to the users particular site.
*/ */
function index() { function index() { $this->all(); }
$this->Map->recursive = 0; function all() { $this->jqGridView('All Maps', 'all'); }
$this->set('maps', $this->paginate());
/**************************************************************************
**************************************************************************
**************************************************************************
* virtuals: jqGridData
* - With the application controller handling the jqGridData action,
* these virtual functions ensure that the correct data is passed
* to jqGrid.
*/
function jqGridDataTables(&$params, &$model) {
return array
('link' => array('SiteArea' => array('fields' => array('SiteArea.id', 'SiteArea.name')),
),
);
} }
function jqGridRecordLinks(&$params, &$model, &$records, $links) {
$links['Map'] = array('id');
return parent::jqGridRecordLinks($params, $model, $records, $links);
}
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************

View File

@@ -22,8 +22,8 @@ class TransactionsController extends AppController {
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* action: index / active / closed / all * action: index / all
* - Generate a listing of leases * - Generate a listing of transactions
*/ */
function index() { $this->all(); } function index() { $this->all(); }

View File

@@ -1,59 +1,24 @@
<?php /* -*- mode:PHP -*- */ <?php /* -*- mode:PHP -*- */
if (isset($heading)) // Define the table columns
echo $heading; $cols = array();
elseif (!isset($caption)) $cols['ID'] = array('index' => 'Map.id', 'formatter' => 'id');
echo '<h2>'.__('Maps',true).'</h2>'; $cols['Name'] = array('index' => 'Map.name', 'formatter' => 'longname');
$cols['Site Area'] = array('index' => 'SiteArea.name', 'formatter' => 'longname');
$cols['Width'] = array('index' => 'Map.width', 'width' => '50', 'align' => 'right');
$cols['Depth'] = array('index' => 'Map.depth', 'width' => '50', 'align' => 'right');
$cols['Comment'] = array('index' => 'Map.comment', 'formatter' => 'comment');
$headers = array('ID', 'Name', 'Area', 'Width', 'Depth', 'Comment'); $jqGrid_options = array('jqGridColumns' => $cols,
$column_class = array(); 'controller' => 'maps',
foreach (array_intersect($headers, array('ID')) AS $k => $v) { 'caption' => isset($caption) ? $caption : null);
$column_class[$k] = 'id';
} if (isset($maps)) {
foreach (array_intersect($headers, array('Comment')) AS $k => $v) { $jqGrid_options += array('custom_ids' =>
$column_class[$k] = 'slack'; array_map(create_function('$data',
'return $data["id"];'),
$maps),
'limit' => 5);
} }
if (isset($paginator)) { echo $this->element('jqGrid', $jqGrid_options);
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
$headers = array($paginator->sort('id'),
$paginator->sort('name'),
$paginator->sort('site_area_id'),
$paginator->sort('width'),
$paginator->sort('depth'),
$paginator->sort('comment'));
}
$rows = array();
foreach ($maps as $map) {
$rows[] = array($html->link($map['Map']['id'],
array('controller' => 'maps',
'action' => 'view',
$map['Map']['id'])),
$html->link($map['Map']['name'],
array('controller' => 'maps',
'action' => 'view',
$map['Map']['id'])),
$map['SiteArea']['name'],
$map['Map']['width'] / 12,
$map['Map']['depth'] / 12,
$map['Map']['comment']);
}
echo $this->element('table',
array('class' => 'item map list',
'headers' => $headers,
'rows' => $rows,
'column_class' => $column_class));
if (isset($paginator)) {
echo('<div class="paging">' . "\n");
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
echo(' | ');
echo $paginator->numbers();
echo(' | ');
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
echo('</div>' . "\n");
}

View File

@@ -1,3 +0,0 @@
<div class="maps index">
<?php echo $this->element('maps') ?>
</div>