Added ability to see the customer when listing transactions

git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@974 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2010-03-30 15:57:54 +00:00
parent 3acdec1458
commit 285c682b1e
2 changed files with 16 additions and 3 deletions

View File

@@ -54,6 +54,12 @@ class TransactionsController extends AppController {
$this->gridView('Deposits'); $this->gridView('Deposits');
} }
function gridView($title, $action = null, $element = null) {
if ($title != 'Deposits')
$this->set('include', array('Customer'));
parent::gridView($title, $action, $element);
}
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
@@ -77,6 +83,7 @@ class TransactionsController extends AppController {
$link = $this->gridDataCountTables($params, $model); $link = $this->gridDataCountTables($params, $model);
$link['link']['StatementEntry'] = array('fields' => array()); $link['link']['StatementEntry'] = array('fields' => array());
$link['link']['DepositTender'] = array('fields' => array()); $link['link']['DepositTender'] = array('fields' => array());
$link['link']['Customer'] = array('fields' => array('id', 'name'));
return $link; return $link;
} }
@@ -101,6 +108,7 @@ class TransactionsController extends AppController {
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
$links['Transaction'] = array('id', 'action' => ($params['action'] == 'deposit' $links['Transaction'] = array('id', 'action' => ($params['action'] == 'deposit'
? 'deposit_slip' : 'view')); ? 'deposit_slip' : 'view'));
$links['Customer'] = array('name');
return parent::gridDataPostProcessLinks($params, $model, $records, $links); return parent::gridDataPostProcessLinks($params, $model, $records, $links);
} }

View File

@@ -1,13 +1,18 @@
<?php /* -*- mode:PHP -*- */ <?php /* -*- mode:PHP -*- */
if (isset($include))
$include = is_array($include) ? $include : array($include);
else
$include = array();
// Define the table columns // Define the table columns
$cols = array(); $cols = array();
$cols['ID'] = array('index' => 'Transaction.id', 'formatter' => 'id'); $cols['ID'] = array('index' => 'Transaction.id', 'formatter' => 'id');
$cols['Type'] = array('index' => 'Transaction.type', 'formatter' => 'enum'); $cols['Type'] = array('index' => 'Transaction.type', 'formatter' => 'enum');
//$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname'); $cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname');
$cols['Timestamp'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); $cols['Timestamp'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
$cols['Amount'] = array('index' => 'Transaction.amount', 'formatter' => 'currency'); $cols['Amount'] = array('index' => 'Transaction.amount', 'formatter' => 'currency');
$cols['entries'] = array('index' => 'entries', 'formatter' => 'number'); $cols['Entries'] = array('index' => 'entries', 'formatter' => 'number');
$cols['Comment'] = array('index' => 'Transaction.comment', 'formatter' => 'comment'); $cols['Comment'] = array('index' => 'Transaction.comment', 'formatter' => 'comment');
// Render the grid // Render the grid
@@ -17,4 +22,4 @@ $grid
->defaultFields(array('ID', 'Timestamp')) ->defaultFields(array('ID', 'Timestamp'))
->searchFields(array('Type', 'Comment')) ->searchFields(array('Type', 'Comment'))
->render($this, isset($config) ? $config : null, ->render($this, isset($config) ? $config : null,
array_diff(array_keys($cols), array('Comment'))); array_merge($include, array_diff(array_keys($cols), array('Customer', 'Comment'))));