diff --git a/site/controllers/maps_controller.php b/site/controllers/maps_controller.php index 0038385..90ae663 100644 --- a/site/controllers/maps_controller.php +++ b/site/controllers/maps_controller.php @@ -2,22 +2,44 @@ class MapsController extends AppController { + /************************************************************************** ************************************************************************** ************************************************************************** - * action: index - * - Generates a list of all site maps + * action: index / all + * - Generate a listing of maps * * REVISIT 20090528: * We'll need to present only those site area maps that correspond * to the users particular site. */ - function index() { - $this->Map->recursive = 0; - $this->set('maps', $this->paginate()); + function index() { $this->all(); } + function all() { $this->jqGridView('All Maps', 'all'); } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * 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); + } + + /************************************************************************** ************************************************************************** ************************************************************************** diff --git a/site/controllers/transactions_controller.php b/site/controllers/transactions_controller.php index 1938b68..70bb925 100644 --- a/site/controllers/transactions_controller.php +++ b/site/controllers/transactions_controller.php @@ -22,8 +22,8 @@ class TransactionsController extends AppController { /************************************************************************** ************************************************************************** ************************************************************************** - * action: index / active / closed / all - * - Generate a listing of leases + * action: index / all + * - Generate a listing of transactions */ function index() { $this->all(); } diff --git a/site/views/elements/maps.ctp b/site/views/elements/maps.ctp index dc475fb..03a09e6 100644 --- a/site/views/elements/maps.ctp +++ b/site/views/elements/maps.ctp @@ -1,59 +1,24 @@ '.__('Maps',true).''; +// Define the table columns +$cols = array(); +$cols['ID'] = array('index' => 'Map.id', 'formatter' => 'id'); +$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'); -$column_class = array(); -foreach (array_intersect($headers, array('ID')) AS $k => $v) { - $column_class[$k] = 'id'; -} -foreach (array_intersect($headers, array('Comment')) AS $k => $v) { - $column_class[$k] = 'slack'; +$jqGrid_options = array('jqGridColumns' => $cols, + 'controller' => 'maps', + 'caption' => isset($caption) ? $caption : null); + +if (isset($maps)) { + $jqGrid_options += array('custom_ids' => + array_map(create_function('$data', + 'return $data["id"];'), + $maps), + 'limit' => 5); } -if (isset($paginator)) { - 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('
' . "\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('
' . "\n"); -} +echo $this->element('jqGrid', $jqGrid_options); diff --git a/site/views/maps/index.ctp b/site/views/maps/index.ctp deleted file mode 100644 index 8660dda..0000000 --- a/site/views/maps/index.ctp +++ /dev/null @@ -1,3 +0,0 @@ -
-element('maps') ?> -