git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@64 97e9348a-65ac-dc4b-aefc-98561f571b83
208 lines
6.1 KiB
PHP
208 lines
6.1 KiB
PHP
<?php /* -*- mode:PHP -*- */ ?>
|
|
|
|
<div class="contacts 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);
|
|
}
|
|
|
|
/**********************************************************************
|
|
* Tenant Info
|
|
*/
|
|
|
|
$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_num']
|
|
. ($contact['Contact']['id_state']
|
|
? " - ".$contact['Contact']['id_state']
|
|
: ""))),
|
|
array('Comment', $contact['Contact']['comment']));
|
|
|
|
echo $this->element('table',
|
|
array('class' => 'item contact detail',
|
|
'caption' => 'Tenant Info',
|
|
'rows' => $rows,
|
|
'column_class' => array('field', 'value')));
|
|
|
|
|
|
?>
|
|
<DIV CLASS="infobox contact">
|
|
<DIV CLASS="summary grand deposit">
|
|
Security Deposit: <?php echo currency($outstandingDeposit); ?>
|
|
</DIV>
|
|
<DIV CLASS="summary grand balance">
|
|
Balance: <?php echo currency($outstandingBalance); ?>
|
|
</DIV>
|
|
</DIV>
|
|
<?php
|
|
|
|
|
|
/**********************************************************************
|
|
* 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));
|
|
|
|
|
|
/**********************************************************************
|
|
* Lease History
|
|
*/
|
|
$headers = array('Lease', 'Unit', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
|
|
$rows = array();
|
|
foreach($contact['Lease'] AS $lease) {
|
|
$rows[] = array('#'.$lease['number'],
|
|
$html->link($lease['Unit']['name'],
|
|
array('controller' => 'units',
|
|
'action' => 'view',
|
|
$lease['Unit']['id'])),
|
|
datefmt($lease['lease_date']),
|
|
datefmt($lease['movein_date']),
|
|
datefmt($lease['moveout_date']),
|
|
$lease['amount'],
|
|
$lease['deposit'],
|
|
$lease['comment']);
|
|
}
|
|
|
|
echo $this->element('table',
|
|
array('class' => 'item lease list',
|
|
'caption' => 'Lease History',
|
|
'headers' => $headers,
|
|
'rows' => $rows,
|
|
'column_class' => $headers));
|
|
|
|
|
|
/**********************************************************************
|
|
* Ledger History
|
|
*/
|
|
foreach($contact['Lease'] AS $lease) {
|
|
$headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total');
|
|
|
|
$rows = array();
|
|
$row_class = array();
|
|
$running_total = 0;
|
|
$odd = 0;
|
|
foreach($lease['Charge'] AS $charge) {
|
|
$amount = $charge['total'];
|
|
$running_total += $amount;
|
|
$rows[] = array($html->link('#'.$charge['id'],
|
|
array('controller' => 'charges',
|
|
'action' => 'view',
|
|
$charge['id'])),
|
|
datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
|
|
$charge['ChargeType']['name'],
|
|
$charge['comment'],
|
|
currency($amount),
|
|
currency($running_total));
|
|
$row_class[] = array('charge', (++$odd % 2) ? 'oddrow' : 'evnrow');
|
|
|
|
foreach ($charge['Receipt'] AS $receipt) {
|
|
$amount = -1 * $receipt['ChargesReceipt']['amount'];
|
|
$running_total += $amount;
|
|
$rows[] = array($html->link('#'.$receipt['id'],
|
|
array('controller' => 'receipts',
|
|
'action' => 'view',
|
|
$receipt['id'])),
|
|
' -- ' . datefmt($receipt['stamp']),
|
|
'Payment Applied',
|
|
$receipt['comment'],
|
|
currency($amount),
|
|
currency($running_total));
|
|
$row_class[] = array('receipt', ($odd % 2) ? 'oddrow' : 'evnrow');
|
|
}
|
|
}
|
|
|
|
echo $this->element('table',
|
|
array('class' => 'item ledger list',
|
|
'caption' => 'Lease #'.$lease['number'].' (Unit: '.$lease['Unit']['name'].')',
|
|
'suppress_alternate_rows' => true,
|
|
'headers' => $headers,
|
|
'rows' => $rows,
|
|
'row_class' => $row_class,
|
|
'column_class' => $headers));
|
|
}
|
|
?>
|
|
|
|
</div>
|