Added a receipt controller to verify receipt data
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@60 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
44
views/elements/receipts.ctp
Normal file
44
views/elements/receipts.ctp
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php /* -*- mode:PHP -*- */
|
||||
|
||||
if (isset($heading))
|
||||
echo $heading;
|
||||
else
|
||||
echo '<h2>'.__('Receipts',true).'</h2>';
|
||||
|
||||
$headers_manual = array('Id', 'Timestamp', '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('Timestamp', 'stamp'),
|
||||
$paginator->sort('comment'));
|
||||
} else {
|
||||
$headers = $headers_manual;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
foreach ($receipts as $receipt) {
|
||||
$rows[] = array($html->link($receipt['Receipt']['id'],
|
||||
array('controller' => 'receipts',
|
||||
'action' => 'view',
|
||||
$receipt['Receipt']['id'])),
|
||||
$receipt['Receipt']['stamp'],
|
||||
$receipt['Receipt']['comment']);
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item receipt 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");
|
||||
}
|
||||
3
views/receipts/index.ctp
Normal file
3
views/receipts/index.ctp
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="receipts index">
|
||||
<?php echo $this->element('receipts', array('heading' => '<h2>'.$heading.'</h2>')) ?>
|
||||
</div>
|
||||
109
views/receipts/view.ctp
Normal file
109
views/receipts/view.ctp
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php /* -*- mode:PHP -*- */ ?>
|
||||
|
||||
<div class="receipts 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);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* Receipt Info
|
||||
*/
|
||||
|
||||
$rows = array(array('Timestamp', $receipt['Receipt']['stamp']),
|
||||
array('Comment', $receipt['Receipt']['comment']));
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item receipt detail',
|
||||
'caption' => 'Receipt Info',
|
||||
'rows' => $rows,
|
||||
'column_class' => array('field', 'value')));
|
||||
|
||||
|
||||
?>
|
||||
<DIV CLASS="infobox receipt">
|
||||
<DIV CLASS="summary grand payment">
|
||||
Amount Received: <?php echo currency($paymentAmount); ?>
|
||||
</DIV>
|
||||
<DIV CLASS="summary grand charge">
|
||||
Amount Applied: <?php echo currency($chargeAmount); ?>
|
||||
</DIV>
|
||||
</DIV>
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Payments
|
||||
*/
|
||||
|
||||
$headers = array('ID', 'Type', 'Comment', 'Amount', /*'Total'*/);
|
||||
$rows = array();
|
||||
$running_total = 0;
|
||||
foreach($receipt['Payment'] AS $payment) {
|
||||
$amount = $payment['amount'];
|
||||
$running_total += $amount;
|
||||
$rows[] = array('#'.$payment['id'],
|
||||
$payment['PaymentType']['name'],
|
||||
$payment['comment'],
|
||||
currency($payment['amount']),
|
||||
//currency($running_total)
|
||||
);
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item payment list',
|
||||
'caption' => 'Payments in Receipt',
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers));
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Charges
|
||||
*/
|
||||
|
||||
$headers = array('Date', 'ID', /*'Due',*/ 'Type', 'Lease', 'Comment', 'Amount' /*, 'Tax', 'Subtotal'*/, 'Applied', /*'Total'*/);
|
||||
$rows = array();
|
||||
$running_total = 0;
|
||||
foreach($receipt['Charge'] AS $charge) {
|
||||
$amount = $charge['total'];
|
||||
$running_total += $amount;
|
||||
$rows[] = array(datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
|
||||
'#'.$charge['id'],
|
||||
//datefmt($charge['due_date']),
|
||||
$charge['ChargeType']['name'],
|
||||
'#'.$charge['Lease']['number'],
|
||||
$charge['comment'],
|
||||
//currency($charge['amount']),
|
||||
//currency($charge['tax']),
|
||||
currency($charge['total']),
|
||||
currency($charge['ChargesReceipt']['amount']),
|
||||
//currency($running_total)
|
||||
);
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item charge list',
|
||||
'caption' => 'Charges Applied Towards',
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers));
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user