Files
pmgr/views/elements/leases.ctp
abijah 970b2ad202 Added lease and ledger_entry controllers/views. Minor bugfixes as well.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@85 97e9348a-65ac-dc4b-aefc-98561f571b83
2009-06-10 08:53:22 +00:00

86 lines
2.8 KiB
PHP

<?php /* -*- mode:PHP -*- */
if (isset($heading))
echo $heading;
elseif (!isset($caption))
echo '<h2>'.__('Leases',true).'</h2>';
$headers = array_merge(array('Lease'),
isset($leases[0]['Unit'])
? array('Unit')
: array('Customer'),
array('Signed', 'Move-In', 'Move-Out', 'Balance', 'Comment'));
$column_class = array();
foreach (array_intersect($headers, array('Lease', 'Unit')) AS $k => $v) {
$column_class[$k] = 'id';
}
foreach (array_intersect($headers, array('Balance')) AS $k => $v) {
$column_class[$k] = 'currency';
}
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
$column_class[$k] = 'slack';
}
if (isset($paginator)) {
echo $paginator->counter(array('format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
$headers = array_merge(array($paginator->sort('Lease')),
isset($leases[0]['Unit'])
? array($paginator->sort('Unit', 'Unit.id'))
: array($paginator->sort('Customer.id')),
array($paginator->sort('Signed', 'lease_date'),
$paginator->sort('Move-In', 'movein_date'),
$paginator->sort('Move-Out', 'moveout_date'),
$paginator->sort('balance'),
$paginator->sort('comment')));
}
$rows = array();
foreach($leases AS $lease) {
$unit = $customer = null;
if (isset($lease['Unit']))
$unit = $lease['Unit'];
else
$customer = $lease['Customer'];
if (isset($lease['Lease']))
$lease = $lease['Lease'];
$rows[] = array_merge(array($html->link('#'.$lease['number'],
array('controller' => 'leases',
'action' => 'view',
$lease['id']))),
isset($unit)
? array($html->link($unit['name'],
array('controller' => 'units',
'action' => 'view',
$unit['id'])))
: array($html->link($customer['name'],
array('controller' => 'customers',
'action' => 'view',
$customer['id']))),
array(FormatHelper::date($lease['lease_date']),
FormatHelper::date($lease['movein_date']),
FormatHelper::date($lease['moveout_date']),
FormatHelper::currency($lease['balance']),
$lease['comment']));
}
echo $this->element('table',
array('class' => 'item lease list',
'caption' => isset($caption) ? $caption : null,
'headers' => $headers,
'rows' => $rows,
'column_class' => $column_class));
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");
}