Files
pmgr/views/contacts/view.ctp

153 lines
4.4 KiB
PHP

<?php /* -*- mode:PHP -*- */ ?>
<div class="contact view">
<?php
function currency($number) {
if ($number < 0)
return "($ " . number_format(-1*$number, 2) . ")";
else
return "$ " . number_format($number, 2);
}
function phone($phone) {
$phone = preg_replace("/\D/", "", $phone);
if(strlen($phone) == 7)
return preg_replace("/(\d{3})(\d{4})/", "$1-$2", $phone);
elseif(strlen($phone) == 10)
return preg_replace("/(\d{3})(\d{3})(\d{4})/", "$1-$2-$3", $phone);
else
return $phone;
}
function datefmt($date) {
$date_fmt = 'm/d/Y';
return ($date
? date_format(date_create($date), $date_fmt)
: null);
}
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Contact Detail Main Section
*/
$rows = array(array('Name', $contact['Contact']['display_name']),
array('Company', $contact['Contact']['company_name']),
array('SSN', $contact['Contact']['id_federal']),
array('ID', ($contact['Contact']['id_local']
. ($contact['Contact']['id_local']
? " - ".$contact['Contact']['id_local_state']
: ""))),
array('Comment', $contact['Contact']['comment']));
echo $this->element('table',
array('class' => 'item contact detail',
'caption' => 'Contact Details',
'rows' => $rows,
'column_class' => array('field', 'value')));
/**********************************************************************
* Contact Info Box
*/
?>
<DIV CLASS="infobox">
</DIV>
<DIV CLASS="detail supporting">
<?php
; // Editor alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Supporting Elements Section
*/
/**********************************************************************
* Phones
*/
$headers = array('Phone', 'Preference', 'Comment');
$rows = array();
foreach($contact['ContactPhone'] AS $phone) {
$rows[] = array(phone($phone['phone']) .
($phone['ext'] ? " x".$phone['ext'] : ""),
$phone['ContactsMethod']['preference'] . " / " .
$phone['ContactsMethod']['type'] . " / " .
$phone['type'],
$phone['comment']);
}
echo $this->element('table',
array('class' => 'item phone list',
'caption' => 'Phone',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
/**********************************************************************
* Emails
*/
$headers = array('Email', 'Preference', 'Comment');
$rows = array();
foreach($contact['ContactEmail'] AS $email) {
$rows[] = array($email['email'],
$email['ContactsMethod']['preference'] . " / " .
$email['ContactsMethod']['type'],
$email['comment']);
}
echo $this->element('table',
array('class' => 'item email list',
'caption' => 'Email',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
/**********************************************************************
* Addresses
*/
$headers = array('Address', 'Preference', 'Comment');
$rows = array();
foreach($contact['ContactAddress'] AS $address) {
$rows[] = array(preg_replace("/\n/", "<BR>\n", $address['address']) . "<BR>\n" .
$address['city'] . ", " .
$address['state'] . " " .
$address['postcode'],
//. ? "<BR>\n" . $address['country'],
$address['ContactsMethod']['preference'] . " / " .
$address['ContactsMethod']['type'],
$address['comment']);
}
echo $this->element('table',
array('class' => 'item address list',
'caption' => 'Address',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
/**********************************************************************
* Customers
*/
echo $this->element('customers', array('heading' => '',
'caption' => 'Related Customers',
'customers' => $contact['Customer']));
/* End "detail supporting" DIV */ ?>
</DIV>
</div>