Moved transaction listings to jqGrid, and fixed a bug in the jqGrid element wrt. comment columns
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@136 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -1,65 +1,27 @@
|
||||
<?php /* -*- mode:PHP -*- */
|
||||
|
||||
if (isset($heading))
|
||||
echo $heading;
|
||||
elseif (!isset($caption))
|
||||
echo '<h2>'.__('Transactions',true).'</h2>';
|
||||
// Define the table columns
|
||||
$cols = array();
|
||||
$cols['ID'] = array('index' => 'Transaction.id', 'formatter' => 'id');
|
||||
//$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname');
|
||||
$cols['Timesamp'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
|
||||
$cols['Through'] = array('index' => 'Transaction.through_date', 'formatter' => 'date');
|
||||
$cols['Due'] = array('index' => 'Transaction.due_date', 'formatter' => 'date');
|
||||
$cols['Comment'] = array('index' => 'Transaction.comment', 'formatter' => 'comment');
|
||||
|
||||
$headers = array('Id', 'Timestamp', 'Comment');
|
||||
$column_class = array();
|
||||
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
||||
$column_class[$k] = 'slack';
|
||||
$jqGrid_options = array('jqGridColumns' => $cols,
|
||||
'controller' => 'transactions',
|
||||
'caption' => isset($caption) ? $caption : null);
|
||||
|
||||
if (isset($transactions)) {
|
||||
$jqGrid_options += array('custom_ids' =>
|
||||
array_map(create_function('$data',
|
||||
'return $data["id"];'),
|
||||
$transactions),
|
||||
'limit' => 5);
|
||||
}
|
||||
foreach (array_intersect($headers, array('Id')) AS $k => $v) {
|
||||
$column_class[$k] = 'id';
|
||||
else {
|
||||
$jqGrid_options += array('search_fields' => array('Due', 'Comment'));
|
||||
}
|
||||
|
||||
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('customer_id'),
|
||||
$paginator->sort('Timestamp', 'stamp'),
|
||||
$paginator->sort('Through', 'through_date'),
|
||||
$paginator->sort('Due', 'due_date'),
|
||||
$paginator->sort('comment'));
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
foreach ($transactions as $transaction) {
|
||||
$customer = $transaction['Customer'];
|
||||
|
||||
if (isset($transaction['Transaction']))
|
||||
$transaction = $transaction['Transaction'];
|
||||
|
||||
$rows[] = array($html->link('#'.$transaction['id'],
|
||||
array('controller' => 'transactions',
|
||||
'action' => 'view',
|
||||
$transaction['id'])),
|
||||
$html->link($customer['name'],
|
||||
array('controller' => 'customers',
|
||||
'action' => 'view',
|
||||
$customer['id'])),
|
||||
FormatHelper::date($transaction['stamp']),
|
||||
FormatHelper::date($transaction['through_date']),
|
||||
FormatHelper::date($transaction['due_date']),
|
||||
$transaction['comment']);
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item transaction 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");
|
||||
}
|
||||
echo $this->element('jqGrid', $jqGrid_options);
|
||||
|
||||
Reference in New Issue
Block a user