element('table', array('class' => 'item contact detail', 'caption' => 'Tenant Info', 'rows' => $rows, 'column_class' => array('field', 'value'))); /********************************************************************** * Phones */ $headers = array('Preference', 'Phone', 'Comment'); $rows = array(); foreach($contact['ContactPhone'] AS $phone) { $rows[] = array($phone['ContactsMethod']['preference'] . " / " . $phone['ContactsMethod']['type'] . " / " . $phone['type'], phone($phone['phone']) . ($phone['ext'] ? " x".$phone['ext'] : ""), $phone['comment']); } echo $this->element('table', array('class' => 'item phone list', 'caption' => 'Phone', 'headers' => $headers, 'rows' => $rows, 'column_class' => $headers)); /********************************************************************** * Emails */ $headers = array('Preference', 'Email', 'Comment'); $rows = array(); foreach($contact['ContactEmail'] AS $email) { $rows[] = array($email['ContactsMethod']['preference'] . " / " . $email['ContactsMethod']['type'], $email['email'], $email['comment']); } echo $this->element('table', array('class' => 'item email list', 'caption' => 'Email', 'headers' => $headers, 'rows' => $rows, 'column_class' => $headers)); /********************************************************************** * Addresses */ $headers = array('Preference', 'Address', 'Comment'); $rows = array(); foreach($contact['ContactAddress'] AS $address) { $rows[] = array($address['ContactsMethod']['preference'] . " / " . $address['ContactsMethod']['type'], preg_replace("/\n/", "
\n", $address['address']) . "
\n" . $address['city'] . ", " . $address['state'] . " " . $address['postcode'] . "
\n" . $address['country'] , $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['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 $this->element('table', array('class' => 'item lease list', 'caption' => 'Lease History', 'headers' => $headers, 'rows' => $rows, 'column_class' => $headers)); /********************************************************************** * 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; foreach($lease['Charge'] AS $charge) { $amount = $charge['total']; $running_total += $amount; $rows[] = array(datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']), '#'.$charge['id'], $charge['ChargeType']['name'], $charge['comment'], currency($amount), currency($running_total)); $row_class[] = 'charge'; 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'; } } $grand_total += $running_total; echo $this->element('table', array('class' => 'item ledger list', 'caption' => 'Lease #'.$lease['number'].' ('.$lease['Unit']['name'].')', 'headers' => $headers, 'rows' => $rows, 'row_class' => $row_class, 'column_class' => $headers)); } ?>

Total Security Deposit:

Outstanding Balance: