First pass at listing the customers. Need to figure out how to paginate based on a HABTM relationship.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@22 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -3,6 +3,30 @@
|
|||||||
class ContactsController extends AppController {
|
class ContactsController extends AppController {
|
||||||
var $helpers = array('Html');
|
var $helpers = array('Html');
|
||||||
|
|
||||||
|
var $paginate = array('limit' => 100,
|
||||||
|
'order' => array('Contact.last_name' => 'ASC',
|
||||||
|
'Contact.first_name' => 'ASC'));
|
||||||
|
|
||||||
|
function index() {
|
||||||
|
$this->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
function current() {
|
||||||
|
$this->Contact->recursive = 0;
|
||||||
|
$this->set('contacts', $this->paginate(array('Lease.closed_date IS NULL',
|
||||||
|
//'Contact.'
|
||||||
|
)));
|
||||||
|
$this->render('index');
|
||||||
|
}
|
||||||
|
|
||||||
|
function all() {
|
||||||
|
$this->Contact->recursive = 2;
|
||||||
|
|
||||||
|
//$contacts = $this->paginate();
|
||||||
|
$this->set('contacts', $this->paginate());
|
||||||
|
$this->render('index');
|
||||||
|
}
|
||||||
|
|
||||||
function view($id = null) {
|
function view($id = null) {
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->Session->setFlash(__('Invalid Item.', true));
|
$this->Session->setFlash(__('Invalid Item.', true));
|
||||||
|
|||||||
3
views/contacts/index.ctp
Normal file
3
views/contacts/index.ctp
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<div class="contacts index">
|
||||||
|
<?php echo $this->element('contacts') ?>
|
||||||
|
</div>
|
||||||
74
views/elements/contacts.ctp
Normal file
74
views/elements/contacts.ctp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?php /* -*- mode:PHP -*- */ ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?php
|
||||||
|
if (isset($heading))
|
||||||
|
echo $heading;
|
||||||
|
else
|
||||||
|
echo '<h2>'.__('Contacts',true).'</h2>';
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table cellpadding="0" cellspacing="0">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
{
|
||||||
|
if (isset($paginator)) {
|
||||||
|
echo $paginator->counter(array(
|
||||||
|
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||||
|
|
||||||
|
$rows = array($paginator->sort('id'),
|
||||||
|
$paginator->sort('last_name'),
|
||||||
|
$paginator->sort('first_name'),
|
||||||
|
$paginator->sort('company_name'),
|
||||||
|
//$paginator->sort('unit_id'),
|
||||||
|
$paginator->sort('comment'));
|
||||||
|
} else {
|
||||||
|
$rows = array('Id', 'Last Name', 'First Name', 'Company', 'Comment');
|
||||||
|
}
|
||||||
|
echo $html->tableHeaders($rows);
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
foreach ($contacts as $contact) {
|
||||||
|
/* // REVISIT <AP> 20090528: */
|
||||||
|
/* // The controller really should handle this, but at the moment */
|
||||||
|
/* // it's not clear how. So, let's just cheat. */
|
||||||
|
/* $primary = 0; */
|
||||||
|
/* foreach ($contact['Lease'] AS $lease) { */
|
||||||
|
/* if ($lease['ContactsLease']['type'] != 'ALTERNATE') */
|
||||||
|
/* $primary = 1; */
|
||||||
|
/* } */
|
||||||
|
/* if (!$primary) */
|
||||||
|
/* continue; */
|
||||||
|
|
||||||
|
$rows[] = array($html->link($contact['Contact']['id'],
|
||||||
|
array('controller' => 'contacts',
|
||||||
|
'action' => 'view',
|
||||||
|
$contact['Contact']['id'])),
|
||||||
|
$html->link($contact['Contact']['last_name'],
|
||||||
|
array('controller' => 'contacts',
|
||||||
|
'action' => 'view',
|
||||||
|
$contact['Contact']['id'])),
|
||||||
|
$html->link($contact['Contact']['first_name'],
|
||||||
|
array('controller' => 'contacts',
|
||||||
|
'action' => 'view',
|
||||||
|
$contact['Contact']['id'])),
|
||||||
|
$contact['Contact']['company_name'],
|
||||||
|
$contact['Contact']['comment']);
|
||||||
|
}
|
||||||
|
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
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