diff --git a/controllers/contacts_controller.php b/controllers/contacts_controller.php index 5e1ccdc..a721839 100644 --- a/controllers/contacts_controller.php +++ b/controllers/contacts_controller.php @@ -142,7 +142,26 @@ class ContactsController extends AppController { $contact = $this->Contact->read(null, $id); $title = $contact['Contact']['display_name']; - $this->set(compact('contact', 'title')); + + $outstanding_deposit = 0; + $outstanding_balance = 0; + foreach($contact['Lease'] AS $lease) { + foreach($lease['Charge'] AS $charge) { + $outstanding_balance += $charge['total']; + foreach ($charge['Receipt'] AS $receipt) { + $outstanding_balance -= $receipt['ChargesReceipt']['amount']; + // REVISIT 20090530: + // Using hardcoded value for security deposit... + // That can't be good! + if ($charge['charge_type_id'] == 1) + $outstanding_deposit += $receipt['ChargesReceipt']['amount']; + } + } + } + + $this->set(compact('contact', 'title', 'mytstval', + 'outstanding_balance', + 'outstanding_deposit')); } } diff --git a/controllers/units_controller.php b/controllers/units_controller.php index 63fe664..a184efa 100644 --- a/controllers/units_controller.php +++ b/controllers/units_controller.php @@ -125,18 +125,26 @@ class UnitsController extends AppController { $unit = $this->Unit->read(null, $id); $title = 'Unit ' . $unit['Unit']['name']; - $this->set(compact('unit', 'title')); -/* $this->Unit->id = $id; */ -/* if ($id !== null && $id !== false) { */ -/* $this->Unit->data = $this->Unit->find('first', */ -/* array('conditions' => array( */ -/* $this->Unit->alias . '.' . $this->Unit->primaryKey => $id, */ -/* 'ContactsLease.type = "TENANT"' */ -/* ) */ -/* )); */ -/* $this->set('unit', $this->Unit->data); */ -/* } */ + $outstanding_deposit = 0; + $outstanding_balance = 0; + foreach($unit['Lease'] AS $lease) { + foreach($lease['Charge'] AS $charge) { + $outstanding_balance += $charge['total']; + foreach ($charge['Receipt'] AS $receipt) { + $outstanding_balance -= $receipt['ChargesReceipt']['amount']; + // REVISIT 20090530: + // Using hardcoded value for security deposit... + // That can't be good! + if ($charge['charge_type_id'] == 1) + $outstanding_deposit += $receipt['ChargesReceipt']['amount']; + } + } + } + + $this->set(compact('unit', 'title', + 'outstanding_balance', + 'outstanding_deposit')); } } diff --git a/views/contacts/view.ctp b/views/contacts/view.ctp index d91fdd2..9209167 100644 --- a/views/contacts/view.ctp +++ b/views/contacts/view.ctp @@ -48,17 +48,29 @@ echo $this->element('table', 'column_class' => array('field', 'value'))); +?> +
+
+ Security Deposit: +
+
+ Balance: +
+
+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/", "
\n", $address['address']) . "
\n" . + $rows[] = array(preg_replace("/\n/", "
\n", $address['address']) . "
\n" . $address['city'] . ", " . $address['state'] . " " . - $address['postcode'] - . "
\n" . $address['country'] - , + $address['postcode'], + //. ? "
\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 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) { } ?> -

Total Security Deposit:

-

Outstanding Balance:

diff --git a/views/elements/table.ctp b/views/elements/table.ctp index 31fb7fd..fdb973f 100644 --- a/views/elements/table.ctp +++ b/views/elements/table.ctp @@ -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 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('
' . "\n"); if (isset($caption)) echo(' ' . $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 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('' . "\n"); + echo('element('table', 'column_class' => array('field', 'value'))); +?> +
+
+ Security Deposit: +
+
+ Balance: +
+
+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 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)); } ?> -

Total Security Deposit:

-

Outstanding Balance:

diff --git a/webroot/css/layout.css b/webroot/css/layout.css index e4a6999..7574d43 100644 --- a/webroot/css/layout.css +++ b/webroot/css/layout.css @@ -24,11 +24,12 @@ td#pagecolumn { padding-left: 4mm; } table caption { text-align: left; font-size: 120%; font-weight: bold; - margin-bottom: 0.5em; + padding-bottom: 0.5em; } -table.item caption { margin-top: 1em; } -table.detail caption { margin-top: 0; } +table.item { margin-bottom: 1.5em; } +/* table.item caption { margin-top: 1em; } */ +/* table.detail caption { margin-top: 0; } */ /************************************************************ @@ -38,7 +39,7 @@ table.detail caption { margin-top: 0; } table.item th , table.item td { padding: 0.1em 0.4em 0.1em 0.4em; } -table.item { white-space: nowrap; } +table.item td { white-space: nowrap; } /* table.item { border-spacing: 0 0; /\*IE*\/border-collapse: collapse; empty-cells: show } */ table.item { border-spacing: 0 0; empty-cells: show } table.item { border:1px solid #ccc; @@ -49,7 +50,7 @@ table.item th { background: #f2f2f2; border-top: 1px solid #fff; border-left: 1px solid #fff; border-right: 1px solid #ccc; -/* text-align: center; */ + text-align: center; } table.item td { border-right: 1px solid #ccc; } @@ -58,29 +59,66 @@ tr.evnrow { background: #f4f4f4; } /************************************************************ ************************************************************ - * Formatting for item listings + * Item table formats */ -/** Item listing width and borders **/ -table.list { width : 100%; } -table.detail { width : 60%; } +/* Item listing width and borders */ +table.detail { width : 60%; } +table.list { width : 100%; } -/** Column to which any extra real estate should be allocated **/ -/* table.list.view td#referer , */ -/* table.list.browser td#web_browser , */ -/* table.list.tracker td#url , */ -table.list td.comment { width: 99%; } -table.detail td.field { width: 10em } +/* Text alignment exceptions */ +table.list td.id { text-align: center; } -/** Text alignment exceptions **/ -table.list td.id { text-align: center; } +/* White spacing exceptions */ +td.comment { white-space: normal; } -/** White spacing exceptions **/ -table.list td.comment { white-space: normal; } +/* Detail Tables (such as Tenant Info, Unit Info, etc) */ +table.detail { float: left; } +table.detail td.field { width: 10em; } -/* table.detail td {word-wrap : normal} */ +/* List Tables (listing multiple items of one type) */ +table.list { clear: both; } -table.list.ledger td.date.receipt { padding-left: 1em } +/* Contact methods */ +table.list.phone td.preference , +table.list.email td.preference , +table.list.address td.preference { width: 18em; } +table.list.phone td.phone , +table.list.email td.email , +table.list.address td.address { width: 15em; } +table.list.phone td.comment , +table.list.email td.comment , +table.list.address td.comment { width: auto; } + +/* Leases */ +table.list.lease td.comment { width : 99%; } + +/* Ledger Entries */ +table.list.ledger td { border-top : 1px dashed #ccc; } +table.list.ledger td.date.receipt { padding-left: 1em; } +table.list.ledger td.evnrow { background: #f4f4f4; } +table.list.ledger td.comment { width : 99%; } + + +/************************************************************ + ************************************************************ + * Pertinent Information Box + * These floating boxes appear on the detail pages, + * providing the most pertinent / important information + * for the given view. + */ + +div.infobox { float: right; + width: 39%; + margin-top: 1.5em; + } + +div.summary { color: #993; + font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; + font-size: 125%; + text-align: right; + margin-bottom: 0.2em; + } /************************************************************ @@ -101,7 +139,7 @@ a { font-weight: bold; } a:hover { - color: #f00; + color: #00f; text-decoration:none; } a img { @@ -113,14 +151,13 @@ h1, h2, h3, h4 { } h1 { - background:#fff; color: #003d4c; font-size: 100%; margin: 0.1em 0; } h2 { - background:#fff; - color: #e32; +/* color: #e32; */ + color: #993; font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; font-size: 190%; margin-bottom: 0.3em; @@ -128,8 +165,7 @@ h2 { h3 { color: #993; font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; - font-size: 165%; - padding-top: 1.5em; +/* font-size: 165%; */ } h4 { color: #993;