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:
@@ -38,12 +38,16 @@ class TendersController extends AppController {
|
||||
|
||||
function gridDataTables(&$params, &$model) {
|
||||
return array
|
||||
('contain' => false,
|
||||
('link' =>
|
||||
array('LedgerEntry' =>
|
||||
array('Transaction',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
|
||||
$links['Tender'] = array('id');
|
||||
$links['Tender'] = array('name', 'id');
|
||||
return parent::gridDataPostProcessLinks($params, $model, $records, $links);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<?php
|
||||
class TenderType extends AppModel {
|
||||
|
||||
var $belongsTo = array(
|
||||
'Account',
|
||||
);
|
||||
|
||||
var $hasMany = array(
|
||||
'Tender',
|
||||
);
|
||||
@@ -12,6 +16,7 @@ class TenderType extends AppModel {
|
||||
* function: accountID
|
||||
* - Returns the intended account ID for receipt of the given tender
|
||||
*/
|
||||
|
||||
function accountID($id) {
|
||||
$this->cacheQueries = true;
|
||||
$item = $this->find('first', array
|
||||
@@ -19,7 +24,6 @@ class TenderType extends AppModel {
|
||||
'conditions' => array('TenderType.id' => $id),
|
||||
));
|
||||
$this->cacheQueries = false;
|
||||
//pr(compact('id', 'item'));
|
||||
return $item['TenderType']['account_id'];
|
||||
}
|
||||
|
||||
@@ -31,24 +35,43 @@ class TenderType extends AppModel {
|
||||
* - 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;
|
||||
$accounts = $this->find('all', array
|
||||
('contain' => false,
|
||||
'order' => array('name'),
|
||||
) + (isset($extra) ? $extra : array())
|
||||
);
|
||||
$types = $this->find('all', $query);
|
||||
$this->cacheQueries = false;
|
||||
|
||||
return $accounts;
|
||||
return $types;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: defaultPaymentTypes
|
||||
* - Returns an array of types that can be used for payments
|
||||
* function: paymentTypes
|
||||
* - 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() {
|
||||
@@ -56,4 +79,3 @@ class TenderType extends AppModel {
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -2,15 +2,17 @@
|
||||
|
||||
// Define the table columns
|
||||
$cols = array();
|
||||
$cols['ID'] = array('index' => 'Tender.id', 'formatter' => 'id');
|
||||
$cols['Name'] = array('index' => 'Tender.name', 'formatter' => 'longname');
|
||||
$cols['Comment'] = array('index' => 'Tender.comment', 'formatter' => 'comment');
|
||||
//$cols['ID'] = array('index' => 'Tender.id', 'formatter' => 'id');
|
||||
$cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
|
||||
$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
|
||||
$grid
|
||||
->columns($cols)
|
||||
->sortField('ID')
|
||||
->defaultFields(array('ID', 'Name'))
|
||||
->searchFields(array('ID', 'Name'))
|
||||
->sortField('Date')
|
||||
->defaultFields(array('Date', 'Name', 'Amount'))
|
||||
->searchFields(array('Name'))
|
||||
->render($this, isset($config) ? $config : null,
|
||||
array_diff(array_keys($cols), array()));
|
||||
|
||||
Reference in New Issue
Block a user