Added the charges controller and views. Fixed a couple minor bugs found with receipts.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@62 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
3
views/charges/index.ctp
Normal file
3
views/charges/index.ctp
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="charges index">
|
||||
<?php echo $this->element('charges', array('heading' => '<h2>'.$heading.'</h2>')) ?>
|
||||
</div>
|
||||
84
views/charges/view.ctp
Normal file
84
views/charges/view.ctp
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php /* -*- mode:PHP -*- */ ?>
|
||||
|
||||
<div class="charges view">
|
||||
|
||||
<?php
|
||||
|
||||
function currency($number) {
|
||||
if ($number < 0)
|
||||
return "($ " . number_format(-1*$number, 2) . ")";
|
||||
else
|
||||
return "$ " . number_format($number, 2);
|
||||
}
|
||||
|
||||
function datefmt($date) {
|
||||
$date_fmt = 'm/d/Y';
|
||||
return ($date
|
||||
? date_format(date_create($date), $date_fmt)
|
||||
: null);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* Charge Info
|
||||
*/
|
||||
|
||||
$rows = array(array('ID', $charge['Charge']['id']),
|
||||
array('Date', datefmt($charge['Charge']['charge_date'])),
|
||||
array('Through', datefmt($charge['Charge']['charge_to_date'])),
|
||||
array('Due', datefmt($charge['Charge']['due_date'])),
|
||||
array('Type', $charge['ChargeType']['name']),
|
||||
array('Lease', '#'.$charge['Lease']['number']),
|
||||
array('Amount', currency($charge['Charge']['amount'])),
|
||||
array('Tax', currency($charge['Charge']['tax'])),
|
||||
array('Total', currency($charge['Charge']['total'])),
|
||||
array('Comment', $charge['Charge']['comment']));
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item charge detail',
|
||||
'caption' => 'Charge Info',
|
||||
'rows' => $rows,
|
||||
'column_class' => array('field', 'value')));
|
||||
|
||||
|
||||
?>
|
||||
<DIV CLASS="infobox charge">
|
||||
<DIV CLASS="summary grand payment">
|
||||
Amount Received: <?php echo currency($paymentAmount); ?>
|
||||
</DIV>
|
||||
<DIV CLASS="summary grand balance">
|
||||
Amount Owing: <?php echo currency($balanceAmount); ?>
|
||||
</DIV>
|
||||
</DIV>
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Receipts
|
||||
*/
|
||||
|
||||
$headers = array('ID', 'Timestamp', 'Comment', 'Applied');
|
||||
$rows = array();
|
||||
$running_total = 0;
|
||||
foreach($charge['Receipt'] AS $receipt) {
|
||||
$amount = $receipt['ChargesReceipt']['amount'];
|
||||
$running_total += $amount;
|
||||
$rows[] = array('#'.$receipt['id'],
|
||||
datefmt($receipt['stamp']),
|
||||
$receipt['comment'],
|
||||
currency($receipt['ChargesReceipt']['amount']),
|
||||
//currency($running_total)
|
||||
);
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item receipt list',
|
||||
'caption' => 'Receipts towards Charge',
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers));
|
||||
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
68
views/elements/charges.ctp
Normal file
68
views/elements/charges.ctp
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php /* -*- mode:PHP -*- */
|
||||
|
||||
if (isset($heading))
|
||||
echo $heading;
|
||||
else
|
||||
echo '<h2>'.__('Charges',true).'</h2>';
|
||||
|
||||
function currency($number) {
|
||||
if ($number < 0)
|
||||
return "($ " . number_format(-1*$number, 2) . ")";
|
||||
else
|
||||
return "$ " . number_format($number, 2);
|
||||
}
|
||||
|
||||
function datefmt($date) {
|
||||
$date_fmt = 'm/d/Y';
|
||||
return ($date
|
||||
? date_format(date_create($date), $date_fmt)
|
||||
: null);
|
||||
}
|
||||
|
||||
$headers_manual = array('ID', 'Date', 'Due', 'Type', 'Lease', 'Amount', 'Comment');
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||
|
||||
$headers = array($paginator->sort('id'),
|
||||
$paginator->sort('Date', 'charge_date'),
|
||||
$paginator->sort('Due', 'due_date'),
|
||||
$paginator->sort('Type', 'charge_type'),
|
||||
$paginator->sort('Lease', 'number'),
|
||||
$paginator->sort('total'),
|
||||
$paginator->sort('comment'));
|
||||
} else {
|
||||
$headers = $headers_manual;
|
||||
}
|
||||
|
||||
|
||||
$rows = array();
|
||||
foreach ($charges as $charge) {
|
||||
$rows[] = array($html->link($charge['Charge']['id'],
|
||||
array('controller' => 'charges',
|
||||
'action' => 'view',
|
||||
$charge['Charge']['id'])),
|
||||
datefmt($charge['Charge']['charge_date']),
|
||||
datefmt($charge['Charge']['due_date']),
|
||||
$charge['ChargeType']['name'],
|
||||
'#'.$charge['Lease']['number'],
|
||||
currency($charge['Charge']['total']),
|
||||
$charge['Charge']['comment'],
|
||||
);
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item charge list',
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers_manual));
|
||||
|
||||
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");
|
||||
}
|
||||
@@ -5,6 +5,20 @@ if (isset($heading))
|
||||
else
|
||||
echo '<h2>'.__('Receipts',true).'</h2>';
|
||||
|
||||
function currency($number) {
|
||||
if ($number < 0)
|
||||
return "($ " . number_format(-1*$number, 2) . ")";
|
||||
else
|
||||
return "$ " . number_format($number, 2);
|
||||
}
|
||||
|
||||
function datefmt($date) {
|
||||
$date_fmt = 'm/d/Y';
|
||||
return ($date
|
||||
? date_format(date_create($date), $date_fmt)
|
||||
: null);
|
||||
}
|
||||
|
||||
$headers_manual = array('Id', 'Timestamp', 'Comment');
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
@@ -23,7 +37,7 @@ foreach ($receipts as $receipt) {
|
||||
array('controller' => 'receipts',
|
||||
'action' => 'view',
|
||||
$receipt['Receipt']['id'])),
|
||||
$receipt['Receipt']['stamp'],
|
||||
datefmt($receipt['Receipt']['stamp']),
|
||||
$receipt['Receipt']['comment']);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ function datefmt($date) {
|
||||
* Receipt Info
|
||||
*/
|
||||
|
||||
$rows = array(array('Timestamp', $receipt['Receipt']['stamp']),
|
||||
$rows = array(array('ID', $receipt['Receipt']['id']),
|
||||
array('Timestamp', datefmt($receipt['Receipt']['stamp'])),
|
||||
array('Comment', $receipt['Receipt']['comment']));
|
||||
|
||||
echo $this->element('table',
|
||||
|
||||
Reference in New Issue
Block a user