Moved units onto jqGrid. Also generalized the jqGridSetup (now jqGridView) function and moved it into the app controller.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@117 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-14 05:33:30 +00:00
parent 5fab94011b
commit f6ca79d1a9
5 changed files with 100 additions and 153 deletions

View File

@@ -1,58 +1,17 @@
<?php /* -*- mode:PHP -*- */
if (isset($heading))
echo $heading;
else
echo '<h2>'.__('Units',true).'</h2>';
// Define the table columns
$cols = array();
$cols['ID'] = array('index' => 'Unit.id', 'width' => '30', 'align' => 'center');
$cols['Unit'] = array('index' => 'Unit.name', 'width' => '50', 'align' => 'left');
$cols['Size'] = array('index' => 'UnitSize.name', 'width' => '75', 'align' => 'left');
$cols['Status'] = array('index' => 'Unit.status', 'width' => '75', 'align' => 'left');
$cols['Comment'] = array('index' => 'Unit.comment', 'width' => '400', 'align' => 'left');
$headers = array('ID', 'Unit', 'Size', 'Status', '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';
}
// Some of the columns should not be sortable
foreach (array_intersect_key($cols, array('Comment'=>1)) AS $k => $v)
$cols[$k]['sortable'] = false;
if (isset($paginator)) {
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
echo $this->element('jqGrid',
array('jqGridColumns' => $cols));
$headers = array($paginator->sort('id'),
$paginator->sort('Unit', 'name'),
$paginator->sort('unit_size_id'),
$paginator->sort('status'),
$paginator->sort('comment'));
}
$rows = array();
foreach ($units as $unit) {
$rows[] = array($html->link($unit['Unit']['id'],
array('controller' => 'units',
'action' => 'view',
$unit['Unit']['id'])),
$html->link($unit['Unit']['name'],
array('controller' => 'units',
'action' => 'view',
$unit['Unit']['id'])),
$unit['UnitSize']['name'],
$unit['Unit']['status'],
$unit['Unit']['comment']);
}
echo $this->element('table',
array('class' => 'item unit list',
'caption' => isset($caption) ? $caption : null,
'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");
}