Modified contact grids to use display_name, and the contact model to take company name into account if no other fields will work for display name.
git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@762 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -50,7 +50,7 @@ class ContactsController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
|
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
|
||||||
$links['Contact'] = array('last_name', 'first_name');
|
$links['Contact'] = array('display_name');
|
||||||
return parent::gridDataPostProcessLinks($params, $model, $records, $links);
|
return parent::gridDataPostProcessLinks($params, $model, $records, $links);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,14 +41,15 @@ class Contact extends AppModel {
|
|||||||
function saveContact($id, $data) {
|
function saveContact($id, $data) {
|
||||||
|
|
||||||
// Establish a display name if not already given
|
// Establish a display name if not already given
|
||||||
if (!$data['Contact']['display_name'])
|
if (!$data['Contact']['display_name'] &&
|
||||||
|
$data['Contact']['first_name'] && $data['Contact']['last_name'])
|
||||||
$data['Contact']['display_name'] =
|
$data['Contact']['display_name'] =
|
||||||
(($data['Contact']['first_name'] &&
|
$data['Contact']['last_name'] . ', ' . $data['Contact']['first_name'];
|
||||||
$data['Contact']['last_name'])
|
|
||||||
? $data['Contact']['last_name'] . ', ' . $data['Contact']['first_name']
|
foreach (array('last_name', 'first_name', 'company_name') AS $fld) {
|
||||||
: ($data['Contact']['first_name']
|
if (!$data['Contact']['display_name'] && $data['Contact'][$fld])
|
||||||
? $data['Contact']['first_name']
|
$data['Contact']['display_name'] = $data['Contact'][$fld];
|
||||||
: $data['Contact']['last_name']));
|
}
|
||||||
|
|
||||||
// Save the contact data
|
// Save the contact data
|
||||||
$this->create();
|
$this->create();
|
||||||
|
|||||||
@@ -17,16 +17,17 @@ if (isset($contact['Contact']))
|
|||||||
$contact = $contact['Contact'];
|
$contact = $contact['Contact'];
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$rows[] = array('First Name', $contact['first_name']);
|
$rows[] = array('Display Name', $contact['display_name']);
|
||||||
$rows[] = array('Middle Name', $contact['middle_name']);
|
$rows[] = array('First Name', $contact['first_name']);
|
||||||
$rows[] = array('Last Name', $contact['last_name']);
|
$rows[] = array('Middle Name', $contact['middle_name']);
|
||||||
$rows[] = array('Company', $contact['company_name']);
|
$rows[] = array('Last Name', $contact['last_name']);
|
||||||
$rows[] = array('SSN', $contact['id_federal']);
|
$rows[] = array('Company', $contact['company_name']);
|
||||||
$rows[] = array('ID', ($contact['id_local']
|
$rows[] = array('SSN', $contact['id_federal']);
|
||||||
. ($contact['id_local']
|
$rows[] = array('ID', ($contact['id_local']
|
||||||
? " - ".$contact['id_local_state']
|
. ($contact['id_local']
|
||||||
: "")));
|
? " - ".$contact['id_local_state']
|
||||||
$rows[] = array('Comment', $contact['comment']);
|
: "")));
|
||||||
|
$rows[] = array('Comment', $contact['comment']);
|
||||||
|
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
array('class' => 'item contact detail',
|
array('class' => 'item contact detail',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// Define the table columns
|
// Define the table columns
|
||||||
$cols = array();
|
$cols = array();
|
||||||
$cols['Relationship'] = array('index' => 'ContactsCustomer.type', 'formatter' => 'enum');
|
$cols['Relationship'] = array('index' => 'ContactsCustomer.type', 'formatter' => 'enum');
|
||||||
|
$cols['Name'] = array('index' => 'Contact.display_name', 'formatter' => 'longname');
|
||||||
$cols['Last Name'] = array('index' => 'Contact.last_name', 'formatter' => 'longname');
|
$cols['Last Name'] = array('index' => 'Contact.last_name', 'formatter' => 'longname');
|
||||||
$cols['First Name'] = array('index' => 'Contact.first_name', 'formatter' => 'longname');
|
$cols['First Name'] = array('index' => 'Contact.first_name', 'formatter' => 'longname');
|
||||||
$cols['Company'] = array('index' => 'Contact.company_name', 'formatter' => 'longname');
|
$cols['Company'] = array('index' => 'Contact.company_name', 'formatter' => 'longname');
|
||||||
|
|||||||
Reference in New Issue
Block a user