Moved contacts onto jqgrid. Added 'name' and 'longname' formats.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@120 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -230,10 +230,7 @@ class AppController extends Controller {
|
||||
}
|
||||
|
||||
function jqGridDataOrder(&$params, $index, $direction) {
|
||||
if ($direction)
|
||||
$direction = ' ' . $direction;
|
||||
|
||||
return $index ? $index . $direction : null;
|
||||
return $index ? array($index .' '. $direction) : null;
|
||||
}
|
||||
|
||||
function jqGridDataLimit(&$params, $start, $limit) {
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
<?php
|
||||
|
||||
class ContactsController extends AppController {
|
||||
var $paginate = array('limit' => 100,
|
||||
'group' => 'Contact.id',
|
||||
'order' => array('Contact.last_name' => 'ASC',
|
||||
'Contact.first_name' => 'ASC'));
|
||||
|
||||
var $sidemenu_links =
|
||||
array(array('name' => 'Contacts', 'header' => true),
|
||||
//array('name' => 'Current', 'url' => array('controller' => 'contacts', 'action' => 'current')),
|
||||
//array('name' => 'Past', 'url' => array('controller' => 'contacts', 'action' => 'past')),
|
||||
//array('name' => 'All Tenants', 'url' => array('controller' => 'contacts', 'action' => 'tenants')),
|
||||
array('name' => 'All Contacts', 'url' => array('controller' => 'contacts', 'action' => 'all')),
|
||||
);
|
||||
var $sidemenu_links = array();
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
@@ -28,27 +18,32 @@ class ContactsController extends AppController {
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* action: index
|
||||
* - Lists all contacts
|
||||
* action: index / all
|
||||
* - Generate a listing of contacts
|
||||
*/
|
||||
|
||||
function index() {
|
||||
$this->all();
|
||||
}
|
||||
function index() { $this->all(); }
|
||||
function all() { $this->jqGridView('All Contacts', 'all'); }
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* action: all
|
||||
* - Lists all contacts
|
||||
* virtuals: jqGridData
|
||||
* - With the application controller handling the jqGridData action,
|
||||
* these virtual functions ensure that the correct data is passed
|
||||
* to jqGrid.
|
||||
*/
|
||||
|
||||
function all() {
|
||||
$title = 'All Contacts';
|
||||
$this->set('title', $title); $this->set('heading', $title);
|
||||
$this->set('contacts', $this->paginate());
|
||||
$this->render('index');
|
||||
function jqGridDataOrder(&$params, $index, $direction) {
|
||||
$order = parent::jqGridDataOrder($params, $index, $direction);
|
||||
if ($index === 'Contact.last_name') {
|
||||
$order[] = 'Contact.first_name ' . $direction;
|
||||
}
|
||||
if ($index === 'Contact.first_name') {
|
||||
$order[] = 'Contact.last_name ' . $direction;
|
||||
}
|
||||
return $order;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -78,6 +78,17 @@ class CustomersController extends AppController {
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
function jqGridDataOrder(&$params, $index, $direction) {
|
||||
$order = parent::jqGridDataOrder($params, $index, $direction);
|
||||
if ($index === 'PrimaryContact.last_name') {
|
||||
$order[] = 'PrimaryContact.first_name ' . $direction;
|
||||
}
|
||||
if ($index === 'PrimaryContact.first_name') {
|
||||
$order[] = 'PrimaryContact.last_name ' . $direction;
|
||||
}
|
||||
return $order;
|
||||
}
|
||||
|
||||
function jqGridDataRecordCount(&$params, $model, $query) {
|
||||
|
||||
// We don't have a good way to use the query to obtain
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<div class="contacts index">
|
||||
<?php echo $this->element('contacts', array('heading' => '<h2>'.$heading.'</h2>')) ?>
|
||||
</div>
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ $cols = array();
|
||||
$cols['ID'] = array('index' => 'Customer.id', 'formatter' => 'id');
|
||||
if (0) // REVISIT<AP>: Need to figure out how to put this in play
|
||||
$cols['Relationship'] = array('index' => 'ContactsCustomer.type', 'width' => '75');
|
||||
$cols['Name'] = array('index' => 'Customer.name', 'width' => '150');
|
||||
$cols['Last Name'] = array('index' => 'PrimaryContact.last_name', 'width' => '100');
|
||||
$cols['First Name'] = array('index' => 'PrimaryContact.first_name', 'width' => '100');
|
||||
$cols['Name'] = array('index' => 'Customer.name', 'formatter' => 'longname');
|
||||
$cols['Last Name'] = array('index' => 'PrimaryContact.last_name', 'formatter' => 'name');
|
||||
$cols['First Name'] = array('index' => 'PrimaryContact.first_name', 'formatter' => 'name');
|
||||
$cols['Leases'] = array('index' => 'lease_count', 'width' => '60');
|
||||
$cols['Comment'] = array('index' => 'Customer.comment', 'formatter' => 'comment');
|
||||
|
||||
|
||||
@@ -145,6 +145,14 @@ foreach ($jqGridColumns AS &$col) {
|
||||
$default['width'] = 90;
|
||||
$default['align'] = 'center';
|
||||
}
|
||||
elseif ($col['formatter'] === 'name' || $col['formatter'] === 'longname') {
|
||||
$default['width'] = 100;
|
||||
if ($col['formatter'] === 'longname')
|
||||
$default['width'] *= 1.5;
|
||||
|
||||
// No special formatting for name
|
||||
unset($col['formatter']);
|
||||
}
|
||||
elseif ($col['formatter'] === 'comment') {
|
||||
$default['width'] = 300;
|
||||
$default['sortable'] = false;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
$cols = array();
|
||||
$cols['Lease'] = array('index' => 'Lease.number', 'formatter' => 'id');
|
||||
$cols['Unit'] = array('index' => 'Unit.name', 'width' => '50', 'align' => 'center');
|
||||
$cols['Customer'] = array('index' => 'Customer.name', 'width' => '150');
|
||||
$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname');
|
||||
$cols['Signed'] = array('index' => 'Lease.lease_date', 'formatter' => 'date');
|
||||
$cols['Move-In'] = array('index' => 'Lease.movein_date', 'formatter' => 'date');
|
||||
$cols['Move-Out'] = array('index' => 'Lease.moveout_date', 'formatter' => 'date');
|
||||
|
||||
Reference in New Issue
Block a user