Very, very early snapshot. Some models are working, and I have a controller for testing. Everything is subject to change. I _do_ have a working tenant ledger though, so it's worth a snapshot.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@15 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-05-28 05:49:03 +00:00
parent 1ca704157b
commit 47af64aefe
13 changed files with 600 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
<?php /* -*- mode:PHP -*- */ ?>
<div class="contacts view">
<h2><?php __('Contact'); ?></h2>
<?php
function currency($number) {
if ($number < 0) {
return "($ " . number_format(-1*$number, 2) . ")";
} else {
return "$ " . number_format($number, 2);
}
}
$rows = array();
foreach($tenant['Contact'] AS $col => $val) {
$rows[] = array(array($col, 'width=1%'), $val);
}
echo('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Tenant Info</CAPTION>' . "\n");
echo $html->tableCells($rows, null, array('class' => "altrow"));
echo('</table>' . "\n");
$grand_total = 0;
foreach($tenant['Lease'] AS $lease) {
$headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total');
$rows = array();
$running_total = 0;
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'),
'#'.$charge['id'],
$charge['ChargeType']['name'],
$charge['comment'],
currency($amount),
currency($running_total));
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,
'#'.$receipt['id'],
'Receipt',
$receipt['comment'],
currency($amount),
currency($running_total));
}
}
$grand_total += $running_total;
echo('<table cellpadding="0" cellspacing="0">' . "\n");
echo(' <CAPTION>Lease #'.$lease['number'].' (Unit '.$lease['Unit']['name'].')</CAPTION>' . "\n");
echo $html->tableHeaders($headers);
echo $html->tableCells($rows, null, array('class' => "altrow"));
echo('</table>' . "\n");
}
?>
<DIV ALIGN=RIGHT><H3>Grand Total: <?php echo currency($grand_total); ?></H3></DIV>
</div>

View File

@@ -0,0 +1,53 @@
<?php /* -*- mode:PHP -*- */ ?>
<div class="ledgers view">
<h2><?php __('Ledgers'); ?></h2>
<?php
foreach($ledgers AS $ledger) {
foreach ($ledger AS $tablename => $table) {
if (array_key_exists(0, $table)) {
// Horizontal table (multiple items)
$headers = array_keys($table[0]);
//$rows = array_map('array_values', $table);
$rows = array();
//echo("<PRE>table:\n"); print_r($table); echo("</PRE>\n");
foreach ($table as $row) {
//echo("<PRE>row:\n"); print_r($row); echo("</PRE>\n");
$rows[] = array_values($row);
}
}
else {
// Vertical table (one item)
$headers = array('Field', 'Value');
$rows = array();
foreach ($table as $col => $val) {
$rows[] = array($col, $val);
}
}
foreach($rows AS &$row) {
foreach ($row AS &$cell) {
if (is_array($cell))
$cell = "&lt;ARRAY&gt;";
}
}
//echo("<PRE>headers:\n"); print_r($headers); echo("</PRE>\n");
//echo("<PRE>rows:\n"); print_r($rows); echo("</PRE>\n");
?>
<table cellpadding="0" cellspacing="0">
<CAPTION><?php echo $tablename ?></CAPTION>
<?php
echo $html->tableHeaders($headers);
echo $html->tableCells($rows, null, array('class' => "altrow"));
?>
</table>
<?php
}
}
?>
</div>

View File

@@ -0,0 +1,58 @@
<div class="ledgers view">
<h2><?php __('Ledgers'); ?></h2>
<table cellpadding="0" cellspacing="0">
<?php
if (isset($paginator)) {
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
$cells = array($paginator->sort('id'),
$paginator->sort('charge_type_id'),
$paginator->sort('lease_id'),
$paginator->sort('charge_date'),
$paginator->sort('charge_to_date'),
$paginator->sort('due_date'),
$paginator->sort('amount'),
$paginator->sort('tax'),
$paginator->sort('total'),
$paginator->sort('comment'));
} else {
$cells = array('Id', 'Type', 'Lease', 'Date', 'Through', 'Due', 'Amount', 'Tax', 'Total', 'Comment');
}
echo $html->tableHeaders($cells);
$cells = array();
foreach ($ledgers as $ledger) {
$cells[] = array($html->link($ledger['Charge']['id'],
array('controller' => 'transactions',
'action' => 'view',
$ledger['Charge']['id'])),
$ledger['Charge']['charge_type_id'],
$ledger['Charge']['lease_id'],
$ledger['Charge']['charge_date'],
$ledger['Charge']['charge_to_date'],
$ledger['Charge']['due_date'],
$ledger['Charge']['amount'],
$ledger['Charge']['tax'],
$ledger['Charge']['total'],
$ledger['Charge']['comment']);
}
echo $html->tableCells($cells, null, array('class' => "altrow"));
?>
</table>
<?php
if (isset($paginator)) {
echo('<div class="paging">' . "\n");
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
echo(' | ');
echo $paginator->numbers();
echo(' | ');
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
echo('</div>' . "\n");
}
?>
</DIV>