Modified the filtering behavior; A filter specified as 'Table.field' results in the obvious split (Table, field); 'Table' results in (Table, id); 'field' results in (ModelTable, field). Fixed a bug in the app controller which was allowing 'fields' to leak into the top level of 'link'
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@430 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -309,20 +309,26 @@ class AppController extends Controller {
|
|||||||
foreach ($params['post']['filter'] AS $filter => $value) {
|
foreach ($params['post']['filter'] AS $filter => $value) {
|
||||||
$split = $this->gridDataFilterSplit($params, $model, $filter);
|
$split = $this->gridDataFilterSplit($params, $model, $filter);
|
||||||
|
|
||||||
|
/* pr(array('AppController::gridDataFilterTable' => */
|
||||||
|
/* array('checkpoint' => "Filter split") */
|
||||||
|
/* + compact('split'))); */
|
||||||
|
|
||||||
$table = $this->gridDataFilterTablesTable($params, $model, $split['table']);
|
$table = $this->gridDataFilterTablesTable($params, $model, $split['table']);
|
||||||
if (!$table)
|
if (!$table)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$config = $this->gridDataFilterTablesConfig($params, $model, $split['table']);
|
$config = $this->gridDataFilterTablesConfig($params, $model, $split['table']);
|
||||||
|
|
||||||
/* pr(array('pre-filter-table-config' => */
|
/* pr(array('AppController::gridDataFilterTable' => */
|
||||||
/* array('query[link]' => $query[$link], */
|
/* array('checkpoint' => "Add filter config to query") */
|
||||||
/* 'config' => $config))); */
|
/* + array('query[link]' => $query[$link]) */
|
||||||
|
/* + compact('config'))); */
|
||||||
|
|
||||||
// If the table is already part of the query, append to it
|
// If the table is already part of the query, append to it
|
||||||
if ($table == $model->alias) {
|
if ($table == $model->alias) {
|
||||||
$query[$link] =
|
$query[$link] =
|
||||||
array_merge_recursive($config, $query[$link]);
|
array_merge_recursive(array_diff_key($config, array('fields'=>1)),
|
||||||
|
$query[$link]);
|
||||||
}
|
}
|
||||||
elseif (isset($query[$link][$table])) {
|
elseif (isset($query[$link][$table])) {
|
||||||
$query[$link][$table] =
|
$query[$link][$table] =
|
||||||
@@ -413,13 +419,14 @@ class AppController extends Controller {
|
|||||||
if (preg_match("/\./", $filter)) {
|
if (preg_match("/\./", $filter)) {
|
||||||
list($table, $field) = explode(".", $filter);
|
list($table, $field) = explode(".", $filter);
|
||||||
}
|
}
|
||||||
elseif (preg_match('/^(.*)_(id)$/', $filter, $matches)) {
|
elseif (preg_match('/^[A-Z]/', $filter)) {
|
||||||
list($table, $field) = array_slice($matches, 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$table = $filter;
|
$table = $filter;
|
||||||
$field = null;
|
$field = null;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$table = $model->alias;
|
||||||
|
$field = $filter;
|
||||||
|
}
|
||||||
|
|
||||||
return array('table' => $table, 'field' => $field);
|
return array('table' => $table, 'field' => $field);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class LedgerEntriesController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function gridDataFilterConditionsStatement(&$params, &$model, $table, $key, $value) {
|
function gridDataFilterConditionsStatement(&$params, &$model, $table, $key, $value) {
|
||||||
pr(compact('table', 'key', 'value'));
|
//pr(compact('table', 'key', 'value'));
|
||||||
if ($table == 'Account' && $value == '-AR-')
|
if ($table == 'Account' && $value == '-AR-')
|
||||||
$value = $this->LedgerEntry->Ledger->Account->accountReceivableAccountID();
|
$value = $this->LedgerEntry->Ledger->Account->accountReceivableAccountID();
|
||||||
return parent::gridDataFilterConditionsStatement($params, $model, $table, $key, $value);
|
return parent::gridDataFilterConditionsStatement($params, $model, $table, $key, $value);
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ echo $this->element('ledgers', array
|
|||||||
(// Grid configuration
|
(// Grid configuration
|
||||||
'config' => array
|
'config' => array
|
||||||
('caption' => $account['name'] . " Ledgers",
|
('caption' => $account['name'] . " Ledgers",
|
||||||
'filter' => array('account_id' => $account['id']),
|
'filter' => array('Account.id' => $account['id']),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ echo $this->element('ledger_entries', array
|
|||||||
('grid_div_id' => 'ledger-ledger-entry-list',
|
('grid_div_id' => 'ledger-ledger-entry-list',
|
||||||
'caption' => ("Current Ledger: " .
|
'caption' => ("Current Ledger: " .
|
||||||
"(". $current_ledger['name'] .")"),
|
"(". $current_ledger['name'] .")"),
|
||||||
'filter' => array('ledger_id' => $current_ledger['id']),
|
'filter' => array('Ledger.id' => $current_ledger['id']),
|
||||||
'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Balance'),
|
'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Balance'),
|
||||||
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
||||||
)));
|
)));
|
||||||
@@ -97,7 +97,7 @@ echo $this->element('ledger_entries', array
|
|||||||
('grid_div_id' => 'account-ledger-entry-list',
|
('grid_div_id' => 'account-ledger-entry-list',
|
||||||
'grid_setup' => array('hiddengrid' => true),
|
'grid_setup' => array('hiddengrid' => true),
|
||||||
'caption' => "Entire Ledger",
|
'caption' => "Entire Ledger",
|
||||||
'filter' => array('account_id' => $account['id']),
|
'filter' => array('Account.id' => $account['id']),
|
||||||
'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Balance'),
|
'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Balance'),
|
||||||
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
||||||
)));
|
)));
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ echo $this->element('customers', array
|
|||||||
(// Grid configuration
|
(// Grid configuration
|
||||||
'config' => array
|
'config' => array
|
||||||
('caption' => 'Related Customers',
|
('caption' => 'Related Customers',
|
||||||
'filter' => array('contact_id' => $contact['id']),
|
'filter' => array('Contact.id' => $contact['id']),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ $cols['Comment'] = array('index' => 'Customer.comment', 'formatt
|
|||||||
|
|
||||||
|
|
||||||
// Certain fields are only valid with a particular context
|
// Certain fields are only valid with a particular context
|
||||||
if (!isset($config['filter']['contact_id']) && !isset($config['filter']['Contact.id']))
|
if (!isset($config['filter']['Contact.id']))
|
||||||
$grid->invalidFields('Relationship');
|
$grid->invalidFields('Relationship');
|
||||||
|
|
||||||
// Render the grid
|
// Render the grid
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ echo $this->element('statement_entries', array
|
|||||||
(// Grid configuration
|
(// Grid configuration
|
||||||
'config' => array
|
'config' => array
|
||||||
('caption' => 'Account',
|
('caption' => 'Account',
|
||||||
'filter' => array('lease_id' => $lease['id']),
|
'filter' => array('Lease.id' => $lease['id']),
|
||||||
'include' => array('Through'),
|
'include' => array('Through'),
|
||||||
'exclude' => array('Customer', 'Lease', 'Unit'),
|
'exclude' => array('Customer', 'Lease', 'Unit'),
|
||||||
)));
|
)));
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ echo $this->element('ledger_entries', array
|
|||||||
(// Grid configuration
|
(// Grid configuration
|
||||||
'config' => array
|
'config' => array
|
||||||
('caption' => "Ledger Entries",
|
('caption' => "Ledger Entries",
|
||||||
'filter' => array('ledger_id' => $ledger['id']),
|
'filter' => array('Ledger.id' => $ledger['id']),
|
||||||
'exclude' => array('Ledger', 'Account', 'Amount', 'Cr/Dr', 'Balance'),
|
'exclude' => array('Ledger', 'Account', 'Amount', 'Cr/Dr', 'Balance'),
|
||||||
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
||||||
)));
|
)));
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ echo $this->element('statement_entries', array
|
|||||||
// Grid configuration
|
// Grid configuration
|
||||||
'config' => array
|
'config' => array
|
||||||
('caption' => 'Entries Applied',
|
('caption' => 'Entries Applied',
|
||||||
//'filter' => array('statement_entry_id' => $entry['id']),
|
//'filter' => array('id' => $entry['id']),
|
||||||
'exclude' => array('Entry'),
|
'exclude' => array('Entry'),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ foreach ($depositTypes AS $type) {
|
|||||||
'grid_setup' => array('hiddengrid' => true),
|
'grid_setup' => array('hiddengrid' => true),
|
||||||
'caption' => ('<A HREF="#" ONCLICK="$(\'#'.$grid_div_id.' .HeaderButton\').click();'.
|
'caption' => ('<A HREF="#" ONCLICK="$(\'#'.$grid_div_id.' .HeaderButton\').click();'.
|
||||||
' return false;">Items in '.$type['name'].' Ledger</A>'),
|
' return false;">Items in '.$type['name'].' Ledger</A>'),
|
||||||
'filter' => array('Tender.deposit_transaction_id' => null,
|
'filter' => array('deposit_transaction_id' => null,
|
||||||
'Tender.tender_type_id' => $type['id']),
|
'TenderType.id' => $type['id']),
|
||||||
'exclude' => array('Type'),
|
'exclude' => array('Type'),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ echo $this->element('ledger_entries', array
|
|||||||
(// Grid configuration
|
(// Grid configuration
|
||||||
'config' => array
|
'config' => array
|
||||||
('caption' => "Ledger Entries",
|
('caption' => "Ledger Entries",
|
||||||
'filter' => array('tender_id' => $tender['id']),
|
'filter' => array('Tender.id' => $tender['id']),
|
||||||
'exclude' => array('Tender'),
|
'exclude' => array('Tender'),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ if (0) {
|
|||||||
(
|
(
|
||||||
'grid_div_id' => "tenders-{$type['id']}-list",
|
'grid_div_id' => "tenders-{$type['id']}-list",
|
||||||
'caption' => $type['name'] . ' Items',
|
'caption' => $type['name'] . ' Items',
|
||||||
'filter' => array('Tender.deposit_transaction_id'
|
'filter' => array('deposit_transaction_id'
|
||||||
=> $deposit['Transaction']['id'],
|
=> $deposit['Transaction']['id'],
|
||||||
'Tender.tender_type_id'
|
'TenderType.id'
|
||||||
=> $type['id'],
|
=> $type['id'],
|
||||||
),
|
),
|
||||||
'exclude' => array('Type'),
|
'exclude' => array('Type'),
|
||||||
@@ -57,7 +57,7 @@ else {
|
|||||||
'config' => array
|
'config' => array
|
||||||
(
|
(
|
||||||
'caption' => 'Deposited Items',
|
'caption' => 'Deposited Items',
|
||||||
'filter' => array('Tender.deposit_transaction_id'
|
'filter' => array('deposit_transaction_id'
|
||||||
=> $deposit['Transaction']['id'],
|
=> $deposit['Transaction']['id'],
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ if ($transaction['type'] === 'INVOICE' || $transaction['type'] === 'RECEIPT') {
|
|||||||
'config' => array
|
'config' => array
|
||||||
(
|
(
|
||||||
'caption' => 'Statement Entries',
|
'caption' => 'Statement Entries',
|
||||||
'filter' => array('transaction_id' => $transaction['id']),
|
'filter' => array('Transaction.id' => $transaction['id']),
|
||||||
'exclude' => array('Transaction'),
|
'exclude' => array('Transaction'),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ echo $this->element('ledger_entries', array
|
|||||||
'config' => array
|
'config' => array
|
||||||
(
|
(
|
||||||
'caption' => 'Ledger Entries',
|
'caption' => 'Ledger Entries',
|
||||||
'filter' => array('transaction_id' => $transaction['id'],
|
'filter' => array('Transaction.id' => $transaction['id'],
|
||||||
'Account.id !=' => $account['id']),
|
'Account.id !=' => $account['id']),
|
||||||
'exclude' => array('Transaction'),
|
'exclude' => array('Transaction'),
|
||||||
)));
|
)));
|
||||||
@@ -104,7 +104,7 @@ echo $this->element('ledger_entries', array
|
|||||||
/* 'config' => array */
|
/* 'config' => array */
|
||||||
/* ( */
|
/* ( */
|
||||||
/* 'caption' => 'Deposited Items', */
|
/* 'caption' => 'Deposited Items', */
|
||||||
/* 'filter' => array('Tender.deposit_transaction_id' => $transaction['id']), */
|
/* 'filter' => array('deposit_transaction_id' => $transaction['id']), */
|
||||||
/* ))); */
|
/* ))); */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user