Added preliminary support for units. The queries are giving me a heck of a time, so I've cheated in some places. For the most part though, it's working. Also, something went wrong with svn, and view/contacts/view.ctp was not right (a checkin seems to have been omitted on it). This checking brings it up to date.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@28 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-05-28 11:26:09 +00:00
parent 54c7287ee4
commit 7805e4d229
7 changed files with 439 additions and 17 deletions

View File

@@ -6,22 +6,145 @@
<?php
function currency($number) {
if ($number < 0) {
if ($number < 0)
return "($ " . number_format(-1*$number, 2) . ")";
} else {
else
return "$ " . number_format($number, 2);
}
}
$rows = array();
foreach($tenant['Contact'] AS $col => $val) {
$rows[] = array(array($col, 'width=1%'), $val);
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
*/
echo('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Tenant Info</CAPTION>' . "\n");
echo $html->tableCells($rows, null, array('class' => "altrow"));
echo $html->tableCells(array(array('Name', $tenant['Contact']['display_name']),
array('Company', $tenant['Contact']['company_name']),
array('SSN', $tenant['Contact']['id_federal']),
array('ID', $tenant['Contact']['id_num']
. ($tenant['Contact']['id_state']
? " - ".$tenant['Contact']['id_state']
: "")),
array('Comment', $tenant['Contact']['comment'])),
null, array('class' => "altrow"), false, false);
echo('</table>' . "\n");
/**********************************************************************
* Phones
*/
$headers = array('Location', 'Preference', 'Type', 'Phone', 'Extension', 'Comment');
$rows = array();
foreach($tenant['ContactPhone'] AS $phone) {
$rows[] = array($phone['ContactsMethod']['type'],
$phone['ContactsMethod']['preference'],
$phone['type'],
phone($phone['phone']),
$phone['ext'],
$phone['comment']);
}
if (count($rows)) {
echo('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Phone</CAPTION>' . "\n");
echo $html->tableHeaders($headers);
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
echo('</table>' . "\n");
}
/**********************************************************************
* Emails
*/
$headers = array('Location', 'Preference', 'Email', 'Comment');
$rows = array();
foreach($tenant['ContactEmail'] AS $email) {
$rows[] = array($email['ContactsMethod']['type'],
$email['ContactsMethod']['preference'],
$email['email'],
$email['comment']);
}
if (count($rows)) {
echo('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Email</CAPTION>' . "\n");
echo $html->tableHeaders($headers);
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
echo('</table>' . "\n");
}
/**********************************************************************
* Addresses
*/
$headers = array('Location', 'Preference', 'Address', 'City', 'State', 'Zip', 'Country', 'Comment');
$rows = array();
foreach($tenant['ContactAddress'] AS $address) {
$rows[] = array($address['ContactsMethod']['type'],
$address['ContactsMethod']['preference'],
$address['address'],
$address['city'],
$address['state'],
$address['postcode'],
$address['country'],
$address['comment']);
}
if (count($rows)) {
echo('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Address</CAPTION>' . "\n");
echo $html->tableHeaders($headers);
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
echo('</table>' . "\n");
}
/**********************************************************************
* Lease History
*/
$headers = array('Lease', 'Unit', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
$rows = array();
foreach($tenant['Lease'] AS $lease) {
$rows[] = array('#'.$lease['id'],
$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('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Lease History</CAPTION>' . "\n");
echo $html->tableHeaders($headers);
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
echo('</table>' . "\n");
/**********************************************************************
* Ledger History
*/
$security_deposit = 0;
$grand_total = 0;
foreach($tenant['Lease'] AS $lease) {
$headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total');
@@ -31,8 +154,7 @@ foreach($tenant['Lease'] AS $lease) {
foreach($lease['Charge'] AS $charge) {
$amount = $charge['total'];
$running_total += $amount;
$rows[] = array(date_format(date_create($charge['charge_date']), 'm-d-Y') . ' - ' .
date_format(date_create($charge['charge_to_date']), 'm-d-Y'),
$rows[] = array(datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
'#'.$charge['id'],
$charge['ChargeType']['name'],
$charge['comment'],
@@ -42,10 +164,13 @@ foreach($tenant['Lease'] AS $lease) {
foreach ($charge['Receipt'] AS $receipt) {
$amount = -1 * $receipt['ChargesReceipt']['amount'];
$running_total += $amount;
$rows[] = array(' -- ' .date_format(date_create($receipt['stamp']), 'm-d-Y'),
//null,
// REVISIT <AP> 20090527:
// Using hardcoded value for security deposit... can't be good!
if ($charge['charge_type_id'] == 1)
$security_deposit += $receipt['ChargesReceipt']['amount'];
$rows[] = array(' -- ' . datefmt($receipt['stamp']),
'#'.$receipt['id'],
'Receipt',
'Payment/Receipt',
$receipt['comment'],
currency($amount),
currency($running_total));
@@ -54,13 +179,14 @@ foreach($tenant['Lease'] AS $lease) {
$grand_total += $running_total;
echo('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Lease #'.$lease['number'].' (Unit '.$lease['Unit']['name'].')</CAPTION>' . "\n");
echo(' <CAPTION>Lease #'.$lease['number'].' ('.$lease['Unit']['name'].')</CAPTION>' . "\n");
echo $html->tableHeaders($headers);
echo $html->tableCells($rows, null, array('class' => "altrow"));
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
echo('</table>' . "\n");
}
?>
<DIV ALIGN=RIGHT><H3>Grand Total: <?php echo currency($grand_total); ?></H3></DIV>
<DIV ALIGN=RIGHT><H3>Total Security Deposit: <?php echo currency($security_deposit); ?></H3></DIV>
<DIV ALIGN=RIGHT><H3>Outstanding Balance: <?php echo currency($grand_total); ?></H3></DIV>
</div>