Added more information to the tender grid, and a new query to return depositable types

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@409 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-29 02:41:50 +00:00
parent 95f43f07bf
commit 3a6964c4bf
3 changed files with 47 additions and 19 deletions

View File

@@ -38,12 +38,16 @@ class TendersController extends AppController {
function gridDataTables(&$params, &$model) { function gridDataTables(&$params, &$model) {
return array return array
('contain' => false, ('link' =>
array('LedgerEntry' =>
array('Transaction',
),
),
); );
} }
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
$links['Tender'] = array('id'); $links['Tender'] = array('name', 'id');
return parent::gridDataPostProcessLinks($params, $model, $records, $links); return parent::gridDataPostProcessLinks($params, $model, $records, $links);
} }

View File

@@ -1,6 +1,10 @@
<?php <?php
class TenderType extends AppModel { class TenderType extends AppModel {
var $belongsTo = array(
'Account',
);
var $hasMany = array( var $hasMany = array(
'Tender', 'Tender',
); );
@@ -12,6 +16,7 @@ class TenderType extends AppModel {
* function: accountID * function: accountID
* - Returns the intended account ID for receipt of the given tender * - Returns the intended account ID for receipt of the given tender
*/ */
function accountID($id) { function accountID($id) {
$this->cacheQueries = true; $this->cacheQueries = true;
$item = $this->find('first', array $item = $this->find('first', array
@@ -19,7 +24,6 @@ class TenderType extends AppModel {
'conditions' => array('TenderType.id' => $id), 'conditions' => array('TenderType.id' => $id),
)); ));
$this->cacheQueries = false; $this->cacheQueries = false;
//pr(compact('id', 'item'));
return $item['TenderType']['account_id']; return $item['TenderType']['account_id'];
} }
@@ -31,24 +35,43 @@ class TenderType extends AppModel {
* - Returns an array of types that can be used for payments * - Returns an array of types that can be used for payments
*/ */
function paymentTypes($extra = null) { function paymentTypes($query = null) {
$this->queryInit($query);
$query['order'][] = 'name';
$this->cacheQueries = true; $this->cacheQueries = true;
$accounts = $this->find('all', array $types = $this->find('all', $query);
('contain' => false,
'order' => array('name'),
) + (isset($extra) ? $extra : array())
);
$this->cacheQueries = false; $this->cacheQueries = false;
return $accounts; return $types;
} }
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* function: defaultPaymentTypes * function: paymentTypes
* - Returns an array of types that can be used for payments * - Returns an array of types that can be deposited
*/
function depositTypes($query = null) {
$this->queryInit($query);
$query['order'][] = 'name';
$query['conditions'][] = array('tillable' => true);
$this->cacheQueries = true;
$types = $this->find('all', $query);
$this->cacheQueries = false;
return $types;
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: defaultPaymentType
* - Returns the ID of the default payment type
*/ */
function defaultPaymentType() { function defaultPaymentType() {
@@ -56,4 +79,3 @@ class TenderType extends AppModel {
} }
} }
?>

View File

@@ -2,15 +2,17 @@
// Define the table columns // Define the table columns
$cols = array(); $cols = array();
$cols['ID'] = array('index' => 'Tender.id', 'formatter' => 'id'); //$cols['ID'] = array('index' => 'Tender.id', 'formatter' => 'id');
$cols['Name'] = array('index' => 'Tender.name', 'formatter' => 'longname'); $cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
$cols['Comment'] = array('index' => 'Tender.comment', 'formatter' => 'comment'); $cols['Name'] = array('index' => 'Tender.name', 'formatter' => 'longname');
$cols['Comment'] = array('index' => 'Tender.comment', 'formatter' => 'comment');
$cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency');
// Render the grid // Render the grid
$grid $grid
->columns($cols) ->columns($cols)
->sortField('ID') ->sortField('Date')
->defaultFields(array('ID', 'Name')) ->defaultFields(array('Date', 'Name', 'Amount'))
->searchFields(array('ID', 'Name')) ->searchFields(array('Name'))
->render($this, isset($config) ? $config : null, ->render($this, isset($config) ? $config : null,
array_diff(array_keys($cols), array())); array_diff(array_keys($cols), array()));