Modified table element algorithm to be cleaner and to handle multiple class types. Modified ledger listings to group the charges and associated payment rows with one color. Fixed summary balance data to come from the controller instead of being created in the view. Created an infobox to carry pertinent info in the top right of the view pages.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@43 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -48,17 +48,29 @@ echo $this->element('table',
|
||||
'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('Preference', 'Phone', 'Comment');
|
||||
$headers = array('Phone', 'Preference', 'Comment');
|
||||
$rows = array();
|
||||
foreach($contact['ContactPhone'] AS $phone) {
|
||||
$rows[] = array($phone['ContactsMethod']['preference'] . " / " .
|
||||
$rows[] = array(phone($phone['phone']) .
|
||||
($phone['ext'] ? " x".$phone['ext'] : ""),
|
||||
$phone['ContactsMethod']['preference'] . " / " .
|
||||
$phone['ContactsMethod']['type'] . " / " .
|
||||
$phone['type'],
|
||||
phone($phone['phone']) .
|
||||
($phone['ext'] ? " x".$phone['ext'] : ""),
|
||||
$phone['comment']);
|
||||
}
|
||||
|
||||
@@ -73,12 +85,12 @@ echo $this->element('table',
|
||||
/**********************************************************************
|
||||
* Emails
|
||||
*/
|
||||
$headers = array('Preference', 'Email', 'Comment');
|
||||
$headers = array('Email', 'Preference', 'Comment');
|
||||
$rows = array();
|
||||
foreach($contact['ContactEmail'] AS $email) {
|
||||
$rows[] = array($email['ContactsMethod']['preference'] . " / " .
|
||||
$rows[] = array($email['email'],
|
||||
$email['ContactsMethod']['preference'] . " / " .
|
||||
$email['ContactsMethod']['type'],
|
||||
$email['email'],
|
||||
$email['comment']);
|
||||
}
|
||||
|
||||
@@ -93,17 +105,16 @@ echo $this->element('table',
|
||||
/**********************************************************************
|
||||
* Addresses
|
||||
*/
|
||||
$headers = array('Preference', 'Address', 'Comment');
|
||||
$headers = array('Address', 'Preference', 'Comment');
|
||||
$rows = array();
|
||||
foreach($contact['ContactAddress'] AS $address) {
|
||||
$rows[] = array($address['ContactsMethod']['preference'] . " / " .
|
||||
$address['ContactsMethod']['type'],
|
||||
preg_replace("/\n/", "<BR>\n", $address['address']) . "<BR>\n" .
|
||||
$rows[] = array(preg_replace("/\n/", "<BR>\n", $address['address']) . "<BR>\n" .
|
||||
$address['city'] . ", " .
|
||||
$address['state'] . " " .
|
||||
$address['postcode']
|
||||
. "<BR>\n" . $address['country']
|
||||
,
|
||||
$address['postcode'],
|
||||
//. ? "<BR>\n" . $address['country'],
|
||||
$address['ContactsMethod']['preference'] . " / " .
|
||||
$address['ContactsMethod']['type'],
|
||||
$address['comment']);
|
||||
}
|
||||
|
||||
@@ -121,7 +132,7 @@ echo $this->element('table',
|
||||
$headers = array('Lease', 'Unit', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
|
||||
$rows = array();
|
||||
foreach($contact['Lease'] AS $lease) {
|
||||
$rows[] = array('#'.$lease['id'],
|
||||
$rows[] = array('#'.$lease['number'],
|
||||
$html->link($lease['Unit']['name'],
|
||||
array('controller' => 'units',
|
||||
'action' => 'view',
|
||||
@@ -145,14 +156,13 @@ echo $this->element('table',
|
||||
/**********************************************************************
|
||||
* Ledger History
|
||||
*/
|
||||
$security_deposit = 0;
|
||||
$grand_total = 0;
|
||||
foreach($contact['Lease'] AS $lease) {
|
||||
$headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', '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;
|
||||
@@ -162,29 +172,25 @@ foreach($contact['Lease'] AS $lease) {
|
||||
$charge['comment'],
|
||||
currency($amount),
|
||||
currency($running_total));
|
||||
$row_class[] = 'charge';
|
||||
$row_class[] = array('charge', (++$odd % 2) ? 'oddrow' : 'evnrow');
|
||||
|
||||
foreach ($charge['Receipt'] AS $receipt) {
|
||||
$amount = -1 * $receipt['ChargesReceipt']['amount'];
|
||||
$running_total += $amount;
|
||||
// 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'],
|
||||
'Payment/Receipt',
|
||||
$receipt['comment'],
|
||||
currency($amount),
|
||||
currency($running_total));
|
||||
$row_class[] = 'receipt';
|
||||
$row_class[] = array('receipt', ($odd % 2) ? 'oddrow' : 'evnrow');
|
||||
}
|
||||
}
|
||||
$grand_total += $running_total;
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item ledger list',
|
||||
'caption' => 'Lease #'.$lease['number'].' ('.$lease['Unit']['name'].')',
|
||||
'suppress_alternate_rows' => true,
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'row_class' => $row_class,
|
||||
@@ -192,6 +198,4 @@ foreach($contact['Lease'] AS $lease) {
|
||||
}
|
||||
?>
|
||||
|
||||
<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>
|
||||
|
||||
@@ -8,52 +8,70 @@
|
||||
* @package pmgr
|
||||
*/
|
||||
|
||||
|
||||
// The caller may not have given us a row_class, or may have given
|
||||
// it as a non-array. Ultimately, we want it to be an array with
|
||||
// an entry for each row, where each entry is an array of classes.
|
||||
if (!isset($row_class) || !is_array($row_class))
|
||||
$row_class = array();
|
||||
|
||||
// Same for the column_class, except columns instead of rows.
|
||||
if (!isset($column_class) || !is_array($column_class))
|
||||
$column_class = array();
|
||||
|
||||
// Give a default if not caller supplied.
|
||||
if (!isset($suppress_alternate_rows))
|
||||
$suppress_alternate_rows = false;
|
||||
|
||||
// If we have rows, then we have a table... go to work
|
||||
if (isset($rows) && is_array($rows) && count($rows)) {
|
||||
|
||||
// Prework to get each element of row_class as an
|
||||
// array of classes, lowercased and whitespace free.
|
||||
foreach ($row_class AS &$rca) {
|
||||
if (!is_array($rca))
|
||||
$rca = array($rca);
|
||||
foreach ($rca AS &$rc)
|
||||
$rc = preg_replace("/ /", "-", strtolower($rc));
|
||||
}
|
||||
|
||||
// Same prework for column_class
|
||||
foreach ($column_class AS &$cca) {
|
||||
if (!is_array($cca))
|
||||
$cca = array($cca);
|
||||
foreach ($cca AS &$cc)
|
||||
$cc = preg_replace("/ /", "-", strtolower($cc));
|
||||
}
|
||||
|
||||
// Associate each cell with the appropriate class(es).
|
||||
// NOTE: Very kludgy solution on the row class(es).
|
||||
// I want the row_class to affix to the <tr> tag.
|
||||
// tableCells, however, does not have such ability :-/
|
||||
// Therefore, the row class(es) get replicated to each
|
||||
// cell within the row.
|
||||
|
||||
foreach ($rows AS $r => &$row) {
|
||||
foreach ($row AS $c => $col) {
|
||||
$cell_class = implode(" ", array_merge(isset( $row_class[$r]) ? $row_class[$r] : array(),
|
||||
isset($column_class[$c]) ? $column_class[$c] : array()));
|
||||
if ($cell_class)
|
||||
$row[$c] = array($col, array('class' => $cell_class));
|
||||
}
|
||||
}
|
||||
echo('<DIV CLASS="tdiv"' . "\n");
|
||||
// OK, output the table HTML
|
||||
echo('<TABLE' . (isset($class) ? ' CLASS="'.$class.'"' : '') . '>' . "\n");
|
||||
if (isset($caption))
|
||||
echo(' <CAPTION>' . $caption . '</CAPTION>' . "\n");
|
||||
|
||||
if (isset($row_class) && is_array($row_class)) {
|
||||
foreach ($row_class AS &$rc)
|
||||
$rc = preg_replace("/ /", "-", strtolower($rc));
|
||||
}
|
||||
|
||||
if (isset($column_class) && is_array($column_class)) {
|
||||
foreach ($column_class AS &$cc)
|
||||
$cc = preg_replace("/ /", "-", strtolower($cc));
|
||||
}
|
||||
|
||||
/* if (isset($headers) && is_array($headers)) { */
|
||||
/* foreach ($headers AS $i => $col) { */
|
||||
/* if (!isset($column_class[$i])) */
|
||||
/* continue; */
|
||||
/* $headers[$i] = array($col, array('class' => $column_class[$i])); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
// Very kludgy.
|
||||
// I want the row_class to affix to the <tr> tag.
|
||||
// tableCells, however, does not have such ability :-/
|
||||
foreach ($rows AS $r => &$row) {
|
||||
foreach ($row AS $c => $col) {
|
||||
$colclass = (isset($column_class) && is_array($column_class)) ? $column_class[$c] : '';;
|
||||
$rowclass = (isset($row_class) && is_array($row_class)) ? $row_class[$r] : '';
|
||||
$class = $rowclass . ($colclass ? " " . $colclass : '');
|
||||
if (!$class)
|
||||
continue;
|
||||
$row[$c] = array($col, array('class' => $class));
|
||||
}
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
if (isset($headers) && is_array($headers))
|
||||
echo $html->tableHeaders($headers);
|
||||
echo $html->tableHeaders($headers) . "\n";
|
||||
|
||||
echo("\n");
|
||||
echo $html->tableCells($rows,
|
||||
array('class' => "oddrow"),
|
||||
array('class' => "evnrow"),
|
||||
false, false);
|
||||
echo("\n");
|
||||
$suppress_alternate_rows ? null : array('class' => "oddrow"),
|
||||
$suppress_alternate_rows ? null : array('class' => "evnrow"),
|
||||
false, false) . "\n";
|
||||
|
||||
echo('</TABLE>' . "\n");
|
||||
echo('</DIV' . "\n");
|
||||
}
|
||||
|
||||
@@ -33,13 +33,25 @@ echo $this->element('table',
|
||||
'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
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Lease History
|
||||
*/
|
||||
$headers = array('Lease', 'Tenant', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
|
||||
$rows = array();
|
||||
foreach($unit['Lease'] AS $lease) {
|
||||
$rows[] = array('#'.$lease['id'],
|
||||
$rows[] = array('#'.$lease['number'],
|
||||
$html->link($lease['Contact'][0]['display_name'],
|
||||
array('controller' => 'contacts',
|
||||
'action' => 'view',
|
||||
@@ -63,13 +75,12 @@ echo $this->element('table',
|
||||
/**********************************************************************
|
||||
* Ledger History
|
||||
*/
|
||||
$security_deposit = 0;
|
||||
$grand_total = 0;
|
||||
foreach($unit['Lease'] AS $lease) {
|
||||
$headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total');
|
||||
|
||||
$rows = array();
|
||||
$running_total = 0;
|
||||
$odd = 0;
|
||||
foreach($lease['Charge'] AS $charge) {
|
||||
$amount = $charge['total'];
|
||||
$running_total += $amount;
|
||||
@@ -79,33 +90,30 @@ foreach($unit['Lease'] AS $lease) {
|
||||
$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;
|
||||
// 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'],
|
||||
'Payment/Receipt',
|
||||
$receipt['comment'],
|
||||
currency($amount),
|
||||
currency($running_total));
|
||||
$row_class[] = array('receipt', ($odd % 2) ? 'oddrow' : 'evnrow');
|
||||
}
|
||||
}
|
||||
$grand_total += $running_total;
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item ledger list',
|
||||
'caption' => 'Lease #'.$lease['number'].' ('.$lease['Contact'][0]['display_name'].')',
|
||||
'suppress_alternate_rows' => true,
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'row_class' => $row_class,
|
||||
'column_class' => $headers));
|
||||
}
|
||||
?>
|
||||
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user