git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@122 97e9348a-65ac-dc4b-aefc-98561f571b83
80 lines
2.6 KiB
PHP
80 lines
2.6 KiB
PHP
<?php
|
|
|
|
class ContactsController extends AppController {
|
|
|
|
var $sidemenu_links = array();
|
|
|
|
/**************************************************************************
|
|
**************************************************************************
|
|
**************************************************************************
|
|
* override: sideMenuLinks
|
|
* - Generates controller specific links for the side menu
|
|
*/
|
|
function sideMenuLinks() {
|
|
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links);
|
|
}
|
|
|
|
|
|
/**************************************************************************
|
|
**************************************************************************
|
|
**************************************************************************
|
|
* action: index / all
|
|
* - Generate a listing of contacts
|
|
*/
|
|
|
|
function index() { $this->all(); }
|
|
function all() { $this->jqGridView('All Contacts', 'all'); }
|
|
|
|
|
|
/**************************************************************************
|
|
**************************************************************************
|
|
**************************************************************************
|
|
* virtuals: jqGridData
|
|
* - With the application controller handling the jqGridData action,
|
|
* these virtual functions ensure that the correct data is passed
|
|
* to jqGrid.
|
|
*/
|
|
|
|
function jqGridDataOrder(&$params, &$model, $index, $direction) {
|
|
$order = parent::jqGridDataOrder($params, $model, $index, $direction);
|
|
if ($index === 'Contact.last_name') {
|
|
$order[] = 'Contact.first_name ' . $direction;
|
|
}
|
|
if ($index === 'Contact.first_name') {
|
|
$order[] = 'Contact.last_name ' . $direction;
|
|
}
|
|
return $order;
|
|
}
|
|
|
|
|
|
/**************************************************************************
|
|
**************************************************************************
|
|
**************************************************************************
|
|
* action: view
|
|
* - Displays information about a specific contact
|
|
*/
|
|
|
|
function view($id = null) {
|
|
if (!$id) {
|
|
$this->Session->setFlash(__('Invalid Item.', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
|
|
$contact = $this->Contact->find
|
|
('first', array
|
|
('contain' => array
|
|
(// Models
|
|
'ContactPhone',
|
|
'ContactEmail',
|
|
'ContactAddress',
|
|
'Customer'),
|
|
|
|
'conditions' => array('Contact.id' => $id),
|
|
));
|
|
|
|
// Prepare to render.
|
|
$title = $contact['Contact']['display_name'];
|
|
$this->set(compact('contact', 'title'));
|
|
}
|
|
}
|