Moved all grid elements onto the grid helper. Basic testing done, but more testing needs to be done.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@262 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-08 20:40:44 +00:00
parent a88f5829ce
commit 4d123b63f0
22 changed files with 327 additions and 321 deletions

View File

@@ -11,26 +11,13 @@ $cols['Credits'] = array('index' => 'credits', 'formatter' => 'currenc
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
$cols['Comment'] = array('index' => 'Account.comment', 'formatter' => 'comment');
$custom_post_data = compact('nothing');
// Set up search fields if requested by caller
if (isset($searchfields))
$grid->searchFields(array('Name'));
$jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'accounts',
);
$jqGrid_options += compact('grid_div_id', 'grid_id', 'caption', 'grid_setup', 'limit');
if (isset($accounts)) {
$jqGrid_options += array('custom_ids' =>
array_map(create_function('$data',
'return $data["id"];'),
$accounts),
'limit' => 5);
}
else {
$jqGrid_options += array('search_fields' => array('Name'));
}
$jqGrid_options += compact('custom_post_data');
$jqGrid_options['sort_column'] = 'Name';
echo $this->element('jqGrid', $jqGrid_options);
// Render the grid
$grid
->columns($cols)
->sortField('Name')
->defaultFields(array('ID', 'Name'))
->render($this, isset($config) ? $config : null);

View File

@@ -12,19 +12,13 @@ if (0) { // REVISIT<AP>: Need to figure out how to put this in play
}
$cols['Comment'] = array('index' => 'Contact.comment', 'formatter' => 'comment');
$jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'contacts',
'caption' => isset($caption) ? $caption : null);
// Set up search fields if requested by caller
if (isset($searchfields))
$grid->searchFields(array('Last Name', 'First Name'));
if (isset($contacts)) {
$jqGrid_options += array('custom_ids' =>
array_map(create_function('$data',
'return $data["id"];'),
$contacts),
'limit' => 5);
}
else {
$jqGrid_options += array('search_fields' => array('Last Name', 'First Name'));
}
echo $this->element('jqGrid', $jqGrid_options);
// Render the grid
$grid
->columns($cols)
->sortField('Last Name')
->defaultFields(array('ID', 'Last Name', 'First Name'))
->render($this, isset($config) ? $config : null);

View File

@@ -12,24 +12,13 @@ $cols['Leases'] = array('index' => 'lease_count', 'width' =>
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
$cols['Comment'] = array('index' => 'Customer.comment', 'formatter' => 'comment');
$custom_post_data = compact('nothing');
$jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'customers');
$jqGrid_options += compact('action', 'caption',
'grid_div_id', 'grid_div_class', 'grid_id', 'grid_setup',
'nolinks', 'limit');
// Set up search fields if requested by caller
if (isset($searchfields))
$grid->searchFields(array('Last Name', 'First Name'));
if (isset($customers)) {
$jqGrid_options += array('custom_ids' =>
array_map(create_function('$data',
'return $data["id"];'),
$customers),
'limit' => 5);
}
// Not the long term solution here... just for testing
if (isset($searchfields)) {
$jqGrid_options += array('search_fields' => array('Last Name', 'First Name'));
}
echo $this->element('jqGrid', $jqGrid_options);
// Render the grid
$grid
->columns($cols)
->sortField('Name')
->defaultFields(array('ID', 'Name'))
->render($this, isset($config) ? $config : null);

View File

@@ -1,5 +1,33 @@
<?php /* -*- mode:PHP -*- */
// Define the table columns
$cols = array();
$cols['Transaction'] = array('index' => 'Transaction.id', 'formatter' => 'id');
$cols['Entry'] = array('index' => 'LedgerEntry.id', 'formatter' => 'id');
$cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
$cols['Effective'] = array('index' => 'LedgerEntry.effective_date', 'formatter' => 'date');
$cols['Through'] = array('index' => 'LedgerEntry.through_date', 'formatter' => 'date');
$cols['Account'] = array('index' => 'Account.name', 'formatter' => 'name');
$cols['Debit Account'] = array('index' => 'DebitAccount.name', 'formatter' => 'name');
$cols['Credit Account'] = array('index' => 'CreditAccount.name', 'formatter' => 'name');
$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname');
//$cols['Lease'] = array('index' => 'Lease.number', 'formatter' => 'id');
$cols['Unit'] = array('index' => 'Unit.name', 'formatter' => 'name');
$cols['Source'] = array('index' => 'MonetarySource.name', 'formatter' => 'name');
$cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment', 'width'=>150);
$cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency');
$cols['Debit'] = array('index' => 'debit', 'formatter' => 'currency');
$cols['Credit'] = array('index' => 'credit', 'formatter' => 'currency');
$cols['Applied'] = array('index' => "Reconciliation.amount", 'formatter' => 'currency');
$cols['Sub-Total'] = array('index' => 'subtotal', 'formatter' => 'currency', 'sortable' => false);
if (isset($account_ftype) || isset($ledger_id) || isset($account_id) || isset($ar_account)) {
$single_account = true;
$double_account = false;
@@ -36,85 +64,48 @@ if (isset($account_ftype)) {
}
// Define the table columns
$cols = array();
if (0) {
if (isset($notxgroup))
$cols['Entry'] = array('index' => 'LedgerEntry.id', 'formatter' => 'id');
if (!$single_account)
$grid->invalidFields('Account');
if (!$double_account)
$grid->invalidFields(array('Debit Account', 'Credit Account'));
if (!$references)
$grid->invalidFields(array('Customer', 'Lease', 'Unit'));
if ($single_amount)
$grid->invalidFields(array('Debit', 'Credit'));
else
$cols['Transaction'] = array('index' => 'Transaction.id', 'formatter' => 'id');
} else {
$notxgroup = false;
$cols['Transaction'] = array('index' => 'Transaction.id', 'formatter' => 'id');
$cols['Entry'] = array('index' => 'LedgerEntry.id', 'formatter' => 'id');
}
$grid->invalidFields('Amount');
$cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
$cols['Effective'] = array('index' => 'LedgerEntry.effective_date', 'formatter' => 'date');
$cols['Through'] = array('index' => 'LedgerEntry.through_date', 'formatter' => 'date');
if (!$applied_amount)
$grid->invalidFields('Applied');
if ($single_account) {
$cols['Account'] = array('index' => 'Account.name', 'formatter' => 'name');
}
if (!$subtotal_amount)
$grid->invalidFields('Sub-Total');
if ($double_account) {
$cols['Debit Account'] = array('index' => 'DebitAccount.name', 'formatter' => 'name');
$cols['Credit Account'] = array('index' => 'CreditAccount.name', 'formatter' => 'name');
}
if ($references) {
$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname');
//$cols['Lease'] = array('index' => 'Lease.number', 'formatter' => 'id');
$cols['Unit'] = array('index' => 'Unit.name', 'formatter' => 'name');
}
$cols['Source'] = array('index' => 'MonetarySource.name', 'formatter' => 'name');
$cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment', 'width'=>150);
if ($single_amount) {
$cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency');
}
else {
$cols['Debit'] = array('index' => 'debit', 'formatter' => 'currency');
$cols['Credit'] = array('index' => 'credit', 'formatter' => 'currency');
}
if ($applied_amount) {
$cols['Applied'] = array('index' => "Reconciliation.amount", 'formatter' => 'currency');
}
if ($subtotal_amount) {
$cols['Sub-Total'] = array('index' => 'subtotal', 'formatter' => 'currency', 'sortable' => false);
}
$custom_post_data = compact('ledger_id', 'account_id', 'ar_account',
'account_type', 'account_ftype',
'customer_id', 'lease_id', 'transaction_id', 'notxgroup');
$jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'ledger_entries',
);
$jqGrid_options += compact('grid_div_id', 'grid_id', 'caption', 'grid_setup', 'limit');
if (isset($ledger_entries)) {
$jqGrid_options += array('custom_ids' =>
array_map(create_function('$data',
'return $data["id"];'),
$ledger_entries),
'limit' => 10);
}
else {
$jqGrid_options += array('action' => 'ledger',
'limit' => 50);
if (!isset($config['rows'])) {
$config['action'] = 'ledger';
$grid->limit(50);
}
if (isset($reconcile_id)) {
$custom_post_data += compact('reconcile_id');
$jqGrid_options += array('limit' => 5);
$grid->customData(compact('reconcile_id'))->limit(5);
}
$jqGrid_options += compact('custom_post_data');
$jqGrid_options['sort_column'] = 'Date';
echo $this->element('jqGrid', $jqGrid_options);
// Set up search fields if requested by caller
if (isset($searchfields))
$grid->searchFields(array('Customer', 'Unit'));
// Include custom data
$grid->customData(compact('ledger_id', 'account_id', 'ar_account',
'account_type', 'account_ftype',
'customer_id', 'lease_id', 'transaction_id', 'notxgroup'));
// Render the grid
$grid
->columns($cols)
->sortField('Date')
->defaultFields(array('Entry', 'Amount', 'Credit', 'Debit'))
->render($this, isset($config) ? $config : null);

View File

@@ -12,25 +12,13 @@ $cols['Debits'] = array('index' => 'debits', 'formatter' => 'c
$cols['Credits'] = array('index' => 'credits', 'formatter' => 'currency');
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
$custom_post_data = compact('nothing');
$jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'ledgers',
);
$jqGrid_options += compact('grid_div_id', 'grid_id', 'caption', 'grid_setup', 'limit');
// Set up search fields if requested by caller
if (isset($searchfields))
$grid->searchFields(array('Account', 'Comment'));
if (isset($ledgers)) {
$jqGrid_options += array('custom_ids' =>
array_map(create_function('$data',
'return $data["id"];'),
$ledgers),
'limit' => 5);
}
else {
$jqGrid_options += array('search_fields' => array('Account'));
}
$jqGrid_options += compact('custom_post_data');
$jqGrid_options['sort_column'] = 'ID';
$jqGrid_options['sort_order'] = 'DESC';
echo $this->element('jqGrid', $jqGrid_options);
// Render the grid
$grid
->columns($cols)
->sortField('ID', 'DESC')
->defaultFields(array('ID', 'Account'))
->render($this, isset($config) ? $config : null);

View File

@@ -9,16 +9,13 @@ $cols['Width'] = array('index' => 'Map.width', 'width' => '50', 'align
$cols['Depth'] = array('index' => 'Map.depth', 'width' => '50', 'align' => 'right');
$cols['Comment'] = array('index' => 'Map.comment', 'formatter' => 'comment');
$jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'maps',
'caption' => isset($caption) ? $caption : null);
// Set up search fields if requested by caller
if (isset($searchfields))
$grid->searchFields(array('Name'));
if (isset($maps)) {
$jqGrid_options += array('custom_ids' =>
array_map(create_function('$data',
'return $data["id"];'),
$maps),
'limit' => 5);
}
echo $this->element('jqGrid', $jqGrid_options);
// Render the grid
$grid
->columns($cols)
->sortField('Name')
->defaultFields(array('ID', 'Name'))
->render($this, isset($config) ? $config : null);

View File

@@ -7,16 +7,13 @@ $cols['Name'] = array('index' => 'MonetarySource.name', 'formatter'
$cols['Type'] = array('index' => 'MonetaryType.name', 'formatter' => 'name');
$cols['Comment'] = array('index' => 'MonetarySource.comment', 'formatter' => 'comment');
$jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'monetary_sources',
'caption' => isset($caption) ? $caption : null);
// Set up search fields if requested by caller
if (isset($searchfields))
$grid->searchFields(array('ID', 'Name'));
if (isset($monetary_sources)) {
$jqGrid_options += array('custom_ids' =>
array_map(create_function('$data',
'return $data["id"];'),
$monetary_sources),
'limit' => 5);
}
echo $this->element('jqGrid', $jqGrid_options);
// Render the grid
$grid
->columns($cols)
->sortField('ID')
->defaultFields(array('ID', 'Name'))
->render($this, isset($config) ? $config : null);

View File

@@ -8,19 +8,13 @@ $cols['Timestamp'] = array('index' => 'Transaction.stamp', 'formatter' =
$cols['Due'] = array('index' => 'Transaction.due_date', 'formatter' => 'date');
$cols['Comment'] = array('index' => 'Transaction.comment', 'formatter' => 'comment');
$jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'transactions',
'caption' => isset($caption) ? $caption : null);
// Set up search fields if requested by caller
if (isset($searchfields))
$grid->searchFields(array('Due', 'Comment'));
if (isset($transactions)) {
$jqGrid_options += array('custom_ids' =>
array_map(create_function('$data',
'return $data["id"];'),
$transactions),
'limit' => 5);
}
else {
$jqGrid_options += array('search_fields' => array('Due', 'Comment'));
}
echo $this->element('jqGrid', $jqGrid_options);
// Render the grid
$grid
->columns($cols)
->sortField('ID')
->defaultFields(array('ID', 'Timestamp'))
->render($this, isset($config) ? $config : null);

View File

@@ -12,27 +12,13 @@ $cols['Status'] = array('index' => 'Unit.status', 'width' => '75');
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
$cols['Comment'] = array('index' => 'Unit.comment', 'formatter' => 'comment');
// Set up search fields if requested by caller
if (isset($searchfields))
$grid->searchFields(array('Unit', 'Size', 'Status'));
$custom_post_data = compact('nothing');
$jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'units');
$jqGrid_options += compact('action', 'caption',
'grid_div_id', 'grid_div_class', 'grid_id', 'grid_setup',
'nolinks', 'limit');
if (isset($units)) {
$jqGrid_options += array('custom_ids' =>
array_map(create_function('$data',
'return $data["id"];'),
$units),
'limit' => 5);
}
if (isset($searchfields)) {
$jqGrid_options += array('search_fields' => array('Unit', 'Size', 'Status'));
}
$jqGrid_options += compact('custom_post_data');
$jqGrid_options['sort_column'] = 'Sort';
echo $this->element('jqGrid', $jqGrid_options);
// Render the grid
$grid
->columns($cols)
->sortField('Sort')
->defaultFields(array('Sort', 'ID', 'Unit'))
->render($this, isset($config) ? $config : null);