Changed how tables are layed out (since I was repeatedly duplicating code in many places) by adding a table element to be used wherever we need a table. This could probably have been a helper instead of an element, but it's not clear to me why one should be chosen over the other, and I already know how to quickly add an element (I think the real choice resides in whether you need a collection of helper functions, or you just want to drop in a chunk of html, i.e. a helper element). Also, a major revamp to the style sheets as well, although more work is clearly needed.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@42 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-05-30 15:56:41 +00:00
parent 2a4b8079fb
commit c041174b0c
10 changed files with 452 additions and 535 deletions

View File

@@ -31,87 +31,88 @@ function datefmt($date) {
/**********************************************************************
* Tenant Info
*/
echo('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Tenant Info</CAPTION>' . "\n");
echo $html->tableCells(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'])),
null, array('class' => "altrow"), false, false);
echo('</table>' . "\n");
$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')));
/**********************************************************************
* Phones
*/
$headers = array('Location', 'Preference', 'Type', 'Phone', 'Extension', 'Comment');
$headers = array('Preference', 'Phone', 'Comment');
$rows = array();
foreach($contact['ContactPhone'] AS $phone) {
$rows[] = array($phone['ContactsMethod']['type'],
$phone['ContactsMethod']['preference'],
$rows[] = array($phone['ContactsMethod']['preference'] . " / " .
$phone['ContactsMethod']['type'] . " / " .
$phone['type'],
phone($phone['phone']),
$phone['ext'],
phone($phone['phone']) .
($phone['ext'] ? " x".$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");
}
echo $this->element('table',
array('class' => 'item phone list',
'caption' => 'Phone',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
/**********************************************************************
* Emails
*/
$headers = array('Location', 'Preference', 'Email', 'Comment');
$headers = array('Preference', 'Email', 'Comment');
$rows = array();
foreach($contact['ContactEmail'] AS $email) {
$rows[] = array($email['ContactsMethod']['type'],
$email['ContactsMethod']['preference'],
$rows[] = array($email['ContactsMethod']['preference'] . " / " .
$email['ContactsMethod']['type'],
$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");
}
echo $this->element('table',
array('class' => 'item email list',
'caption' => 'Email',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
/**********************************************************************
* Addresses
*/
$headers = array('Location', 'Preference', 'Address', 'City', 'State', 'Zip', 'Country', 'Comment');
$headers = array('Preference', 'Address', 'Comment');
$rows = array();
foreach($contact['ContactAddress'] AS $address) {
$rows[] = array($address['ContactsMethod']['type'],
$address['ContactsMethod']['preference'],
$address['address'],
$address['city'],
$address['state'],
$address['postcode'],
$address['country'],
$rows[] = array($address['ContactsMethod']['preference'] . " / " .
$address['ContactsMethod']['type'],
preg_replace("/\n/", "<BR>\n", $address['address']) . "<BR>\n" .
$address['city'] . ", " .
$address['state'] . " " .
$address['postcode']
. "<BR>\n" . $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");
}
echo $this->element('table',
array('class' => 'item address list',
'caption' => 'Address',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
/**********************************************************************
@@ -133,11 +134,12 @@ foreach($contact['Lease'] AS $lease) {
$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");
echo $this->element('table',
array('class' => 'item lease list',
'caption' => 'Lease History',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
/**********************************************************************
@@ -149,6 +151,7 @@ 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'];
@@ -159,6 +162,7 @@ foreach($contact['Lease'] AS $lease) {
$charge['comment'],
currency($amount),
currency($running_total));
$row_class[] = 'charge';
foreach ($charge['Receipt'] AS $receipt) {
$amount = -1 * $receipt['ChargesReceipt']['amount'];
@@ -173,16 +177,18 @@ foreach($contact['Lease'] AS $lease) {
$receipt['comment'],
currency($amount),
currency($running_total));
$row_class[] = 'receipt';
}
}
$grand_total += $running_total;
echo('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Lease #'.$lease['number'].' ('.$lease['Unit']['name'].')</CAPTION>' . "\n");
echo $html->tableHeaders($headers);
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
echo('</table>' . "\n");
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));
}
?>