Moved contacts onto jqgrid. Added 'name' and 'longname' formats.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@120 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -1,74 +1,18 @@
|
||||
<?php /* -*- mode:PHP -*- */
|
||||
|
||||
if (isset($heading))
|
||||
echo $heading;
|
||||
elseif (!isset($caption))
|
||||
echo '<h2>'.__('Contacts',true).'</h2>';
|
||||
|
||||
$headers = array_merge(array('ID', 'Last Name', 'First Name', 'Company'),
|
||||
isset($contacts[0]['ContactsCustomer']) ? array('Type', 'Active') : array(),
|
||||
array('Comment'));
|
||||
|
||||
foreach (array_intersect($headers, array('ID')) AS $k => $v) {
|
||||
$column_class[$k] = 'id';
|
||||
}
|
||||
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
||||
$column_class[$k] = 'comment';
|
||||
// Define the table columns
|
||||
$cols = array();
|
||||
$cols['ID'] = array('index' => 'Contact.id', 'formatter' => 'id');
|
||||
$cols['Last Name'] = array('index' => 'Contact.last_name', 'formatter' => 'name');
|
||||
$cols['First Name'] = array('index' => 'Contact.first_name', 'formatter' => 'name');
|
||||
$cols['Company'] = array('index' => 'Contact.company_name', 'formatter' => 'longname');
|
||||
if (0) { // REVISIT<AP>: Need to figure out how to put this in play
|
||||
$cols['Type'] = array('index' => 'ContactsCustomer.type', 'width' => '75');
|
||||
$cols['Active'] = array('index' => 'ContactsCustomer.active', 'width' => '75');
|
||||
}
|
||||
$cols['Comment'] = array('index' => 'Contact.comment', 'formatter' => 'comment');
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||
|
||||
$headers = array_merge(array($paginator->sort('id'),
|
||||
$paginator->sort('last_name'),
|
||||
$paginator->sort('first_name'),
|
||||
$paginator->sort('company_name')),
|
||||
(isset($contacts[0]['ContactsCustomer'])
|
||||
? array($paginator->sort('type'),
|
||||
$paginator->sort('active'))
|
||||
: array()),
|
||||
array($paginator->sort('comment')));
|
||||
}
|
||||
echo $this->element('jqGrid',
|
||||
array('jqGridColumns' => $cols));
|
||||
|
||||
$rows = array();
|
||||
foreach ($contacts as $contact) {
|
||||
if (isset($contact['Contact']))
|
||||
$contact = $contact['Contact'];
|
||||
|
||||
$rows[] = array_merge(array($html->link($contact['id'],
|
||||
array('controller' => 'contacts',
|
||||
'action' => 'view',
|
||||
$contact['id'])),
|
||||
$html->link($contact['last_name'],
|
||||
array('controller' => 'contacts',
|
||||
'action' => 'view',
|
||||
$contact['id'])),
|
||||
$html->link($contact['first_name'],
|
||||
array('controller' => 'contacts',
|
||||
'action' => 'view',
|
||||
$contact['id'])),
|
||||
$contact['company_name']),
|
||||
(isset($contact['ContactsCustomer'])
|
||||
? array($contact['ContactsCustomer']['type'],
|
||||
$contact['ContactsCustomer']['active'] ? 'Yes' : 'No',
|
||||
$contact['ContactsCustomer']['comment'])
|
||||
: array($contact['comment'])));
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item contact list',
|
||||
'caption' => isset($caption) ? $caption : null,
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $column_class));
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo('<div class="paging">' . "\n");
|
||||
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
|
||||
echo(' | ');
|
||||
echo $paginator->numbers();
|
||||
echo(' | ');
|
||||
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
|
||||
echo('</div>' . "\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user