diff --git a/controllers/transactions_controller.php b/controllers/transactions_controller.php index d54b2eb..1938b68 100644 --- a/controllers/transactions_controller.php +++ b/controllers/transactions_controller.php @@ -1,14 +1,10 @@ 100, - 'group' => 'Transaction.id', - 'order' => array('Transaction.stamp' => 'ASC')); var $sidemenu_links = - array(array('name' => 'Transactions', 'header' => true), - array('name' => 'Cleared', 'url' => array('controller' => 'transactions', 'action' => 'cleared')), - array('name' => 'Unresolved', 'url' => array('controller' => 'transactions', 'action' => 'unresolved')), + array(array('name' => 'Transactions', 'header' => true), + array('name' => 'All', 'url' => array('controller' => 'transactions', 'action' => 'all')), ); @@ -26,61 +22,26 @@ class TransactionsController extends AppController { /************************************************************************** ************************************************************************** ************************************************************************** - * action: index - * - Lists all transactions + * action: index / active / closed / all + * - Generate a listing of leases */ - function index() { - $this->all(); - } + function index() { $this->all(); } + function all() { $this->jqGridView('All Transactions', 'all'); } /************************************************************************** ************************************************************************** ************************************************************************** - * action: cleared - * - Lists cleared transactions + * virtuals: jqGridData + * - With the application controller handling the jqGridData action, + * these virtual functions ensure that the correct data is passed + * to jqGrid. */ - function cleared() { - $this->all(); - } - - - /************************************************************************** - ************************************************************************** - ************************************************************************** - * action: unresolved - * - Lists unresolved transactions - */ - - function unresolved() { - $this->all(); - } - - - - /************************************************************************** - ************************************************************************** - ************************************************************************** - * action: all - * - Lists all transactions - */ - - function all() { - $this->paginate = array_merge - ($this->paginate, - array('link' => - array(// Models - 'Customer', - 'LedgerEntry' => array('DebitLedger', 'CreditLedger') - ), - )); - - $title = 'All Transactions'; - $this->set('title', $title); $this->set('heading', $title); - $this->set('transactions', $this->paginate()); - $this->render('index'); + function jqGridRecordLinks(&$params, &$model, &$records, $links) { + $links['Transaction'] = array('id'); + return parent::jqGridRecordLinks($params, $model, $records, $links); } diff --git a/views/elements/jqGrid.ctp b/views/elements/jqGrid.ctp index 9a8069c..aba1b41 100644 --- a/views/elements/jqGrid.ctp +++ b/views/elements/jqGrid.ctp @@ -130,6 +130,9 @@ foreach ($jqGridColumns AS &$col) { elseif ($col['formatter'] === 'comment') { $default['width'] = 300; $default['sortable'] = false; + + // No special formatting for comment + unset($col['formatter']); } } diff --git a/views/elements/transactions.ctp b/views/elements/transactions.ctp index 556e71b..cfcd6c3 100644 --- a/views/elements/transactions.ctp +++ b/views/elements/transactions.ctp @@ -1,65 +1,27 @@ '.__('Transactions',true).''; +// 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('