Finally added a format helper, which has been long intended. There may be still be conversion issues, it hasn't been tested much.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@77 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
* @subpackage cake.app
|
||||
*/
|
||||
class AppController extends Controller {
|
||||
var $helpers = array('Html', 'Number', 'Time');
|
||||
var $helpers = array('Html', 'Format');
|
||||
|
||||
function sideMenuLinks() {
|
||||
return array(
|
||||
|
||||
@@ -5,36 +5,6 @@
|
||||
<?php
|
||||
; // Editor alignment
|
||||
|
||||
function currency($number) {
|
||||
if (!isset($number))
|
||||
return null;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
function comment($comment) {
|
||||
if (isset($comment) && is_array($comment)) {
|
||||
foreach (array_keys($comment) AS $k) {
|
||||
if (!$comment[$k])
|
||||
unset($comment[$k]);
|
||||
}
|
||||
return implode('; ', $comment);
|
||||
}
|
||||
|
||||
return $comment;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
@@ -64,7 +34,7 @@ echo $this->element('table',
|
||||
|
||||
<DIV CLASS="infobox">
|
||||
<DIV CLASS="summary balance">
|
||||
Account Balance: <?php echo currency($balance); ?>
|
||||
Account Balance: <?php echo FormatHelper::currency($balance); ?>
|
||||
</DIV>
|
||||
</DIV>
|
||||
|
||||
|
||||
@@ -3,31 +3,7 @@
|
||||
<div class="contact view">
|
||||
|
||||
<?php
|
||||
|
||||
function currency($number) {
|
||||
if ($number < 0)
|
||||
return "($ " . number_format(-1*$number, 2) . ")";
|
||||
else
|
||||
return "$ " . number_format($number, 2);
|
||||
}
|
||||
|
||||
function phone($phone) {
|
||||
$phone = preg_replace("/\D/", "", $phone);
|
||||
if(strlen($phone) == 7)
|
||||
return preg_replace("/(\d{3})(\d{4})/", "$1-$2", $phone);
|
||||
elseif(strlen($phone) == 10)
|
||||
return preg_replace("/(\d{3})(\d{3})(\d{4})/", "$1-$2-$3", $phone);
|
||||
else
|
||||
return $phone;
|
||||
}
|
||||
|
||||
function datefmt($date) {
|
||||
$date_fmt = 'm/d/Y';
|
||||
return ($date
|
||||
? date_format(date_create($date), $date_fmt)
|
||||
: null);
|
||||
}
|
||||
|
||||
; // Editor alignment
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
@@ -78,7 +54,7 @@ echo $this->element('table',
|
||||
$headers = array('Phone', 'Preference', 'Comment');
|
||||
$rows = array();
|
||||
foreach($contact['ContactPhone'] AS $phone) {
|
||||
$rows[] = array(phone($phone['phone']) .
|
||||
$rows[] = array(FormatHelper::phone($phone['phone']) .
|
||||
($phone['ext'] ? " x".$phone['ext'] : ""),
|
||||
$phone['ContactsMethod']['preference'] . " / " .
|
||||
$phone['ContactsMethod']['type'] . " / " .
|
||||
|
||||
@@ -3,31 +3,7 @@
|
||||
<div class="customer view">
|
||||
|
||||
<?php
|
||||
|
||||
function currency($number) {
|
||||
if ($number < 0)
|
||||
return "($ " . number_format(-1*$number, 2) . ")";
|
||||
else
|
||||
return "$ " . number_format($number, 2);
|
||||
}
|
||||
|
||||
function phone($phone) {
|
||||
$phone = preg_replace("/\D/", "", $phone);
|
||||
if(strlen($phone) == 7)
|
||||
return preg_replace("/(\d{3})(\d{4})/", "$1-$2", $phone);
|
||||
elseif(strlen($phone) == 10)
|
||||
return preg_replace("/(\d{3})(\d{3})(\d{4})/", "$1-$2-$3", $phone);
|
||||
else
|
||||
return $phone;
|
||||
}
|
||||
|
||||
function datefmt($date) {
|
||||
$date_fmt = 'm/d/Y';
|
||||
return ($date
|
||||
? date_format(date_create($date), $date_fmt)
|
||||
: null);
|
||||
}
|
||||
|
||||
; // Editor alignment
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
@@ -53,10 +29,10 @@ echo $this->element('table',
|
||||
?>
|
||||
<DIV CLASS="infobox">
|
||||
<DIV CLASS="summary grand deposit">
|
||||
Security Deposit: <?php echo currency($outstandingDeposit); ?>
|
||||
Security Deposit: <?php echo FormatHelper::currency($outstandingDeposit); ?>
|
||||
</DIV>
|
||||
<DIV CLASS="summary grand balance">
|
||||
Balance: <?php echo currency($outstandingBalance); ?>
|
||||
Balance: <?php echo FormatHelper::currency($outstandingBalance); ?>
|
||||
</DIV>
|
||||
</DIV>
|
||||
|
||||
@@ -80,108 +56,22 @@ echo $this->element('contacts',
|
||||
'contacts' => $customer['Contact']));
|
||||
|
||||
|
||||
/* foreach ($customer['Contact'] AS $contact) { */
|
||||
|
||||
/* /\********************************************************************** */
|
||||
/* * Phones */
|
||||
/* *\/ */
|
||||
/* $headers = array('Phone', 'Preference', 'Comment'); */
|
||||
/* $rows = array(); */
|
||||
/* foreach($contact['ContactPhone'] AS $phone) { */
|
||||
/* $rows[] = array(phone($phone['phone']) . */
|
||||
/* ($phone['ext'] ? " x".$phone['ext'] : ""), */
|
||||
/* $phone['ContactsMethod']['preference'] . " / " . */
|
||||
/* $phone['ContactsMethod']['type'] . " / " . */
|
||||
/* $phone['type'], */
|
||||
/* $phone['comment']); */
|
||||
/* } */
|
||||
|
||||
/* echo $this->element('table', */
|
||||
/* array('class' => 'item phone list', */
|
||||
/* 'caption' => 'Phone', */
|
||||
/* 'headers' => $headers, */
|
||||
/* 'rows' => $rows, */
|
||||
/* 'column_class' => $headers)); */
|
||||
|
||||
|
||||
/* /\********************************************************************** */
|
||||
/* * Emails */
|
||||
/* *\/ */
|
||||
/* $headers = array('Email', 'Preference', 'Comment'); */
|
||||
/* $rows = array(); */
|
||||
/* foreach($contact['ContactEmail'] AS $email) { */
|
||||
/* $rows[] = array($email['email'], */
|
||||
/* $email['ContactsMethod']['preference'] . " / " . */
|
||||
/* $email['ContactsMethod']['type'], */
|
||||
/* $email['comment']); */
|
||||
/* } */
|
||||
|
||||
/* echo $this->element('table', */
|
||||
/* array('class' => 'item email list', */
|
||||
/* 'caption' => 'Email', */
|
||||
/* 'headers' => $headers, */
|
||||
/* 'rows' => $rows, */
|
||||
/* 'column_class' => $headers)); */
|
||||
|
||||
|
||||
/* /\********************************************************************** */
|
||||
/* * Addresses */
|
||||
/* *\/ */
|
||||
/* $headers = array('Address', 'Preference', 'Comment'); */
|
||||
/* $rows = array(); */
|
||||
/* foreach($contact['ContactAddress'] AS $address) { */
|
||||
/* $rows[] = array(preg_replace("/\n/", "<BR>\n", $address['address']) . "<BR>\n" . */
|
||||
/* $address['city'] . ", " . */
|
||||
/* $address['state'] . " " . */
|
||||
/* $address['postcode'], */
|
||||
/* //. ? "<BR>\n" . $address['country'], */
|
||||
/* $address['ContactsMethod']['preference'] . " / " . */
|
||||
/* $address['ContactsMethod']['type'], */
|
||||
/* $address['comment']); */
|
||||
/* } */
|
||||
|
||||
/* echo $this->element('table', */
|
||||
/* array('class' => 'item address list', */
|
||||
/* 'caption' => 'Address', */
|
||||
/* 'headers' => $headers, */
|
||||
/* 'rows' => $rows, */
|
||||
/* 'column_class' => $headers)); */
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Lease History
|
||||
*/
|
||||
$headers = array('Lease', 'Unit', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
|
||||
$rows = array();
|
||||
foreach($customer['Lease'] AS $lease) {
|
||||
$rows[] = array('#'.$lease['number'],
|
||||
$html->link($lease['Unit']['name'],
|
||||
array('controller' => 'units',
|
||||
'action' => 'view',
|
||||
$lease['Unit']['id'])),
|
||||
datefmt($lease['lease_date']),
|
||||
datefmt($lease['movein_date']),
|
||||
datefmt($lease['moveout_date']),
|
||||
$lease['amount'],
|
||||
$lease['deposit'],
|
||||
$lease['comment']);
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item lease list',
|
||||
'caption' => 'Lease History',
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers));
|
||||
echo $this->element('leases',
|
||||
array('caption' => 'Lease History',
|
||||
'leases' => $customer['Lease']));
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Ledger History
|
||||
* Account
|
||||
*/
|
||||
echo $this->element('ledger',
|
||||
array('caption' => 'Ledger History',
|
||||
'transactions' => $customer['Transaction'],
|
||||
'ledger' => array('mix'=>1)));
|
||||
|
||||
echo $this->element('accounts',
|
||||
array('caption' => 'Account',
|
||||
'accounts' => array($customer['Account'])));
|
||||
|
||||
|
||||
/* End "detail supporting" DIV */ ?>
|
||||
</DIV>
|
||||
|
||||
@@ -2,28 +2,17 @@
|
||||
|
||||
if (isset($heading))
|
||||
echo $heading;
|
||||
else
|
||||
elseif (!isset($caption))
|
||||
echo '<h2>'.__('Accounts',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 = array('Name', 'Type', 'Ext. Name', 'Ext. Account', 'Entries', 'Debits', 'Credits', 'Balance', 'Comment');
|
||||
$column_class = array();
|
||||
foreach (array_intersect($column_class, array('Debits', 'Credits', 'Balance')) AS $k => $v) {
|
||||
foreach (array_intersect($headers, array('Debits', 'Credits', '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(
|
||||
@@ -61,15 +50,16 @@ foreach ($accounts as $account) {
|
||||
$account['external_name'],
|
||||
$account['external_account'],
|
||||
$account['entries'],
|
||||
currency($account['debits']),
|
||||
currency($account['credits']),
|
||||
currency($account['balance']),
|
||||
FormatHelper::currency($account['debits']),
|
||||
FormatHelper::currency($account['credits']),
|
||||
FormatHelper::currency($account['balance']),
|
||||
$account['comment'],
|
||||
);
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item account list',
|
||||
'caption' => isset($caption) ? $caption : null,
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $column_class));
|
||||
|
||||
@@ -5,9 +5,17 @@ if (isset($heading))
|
||||
elseif (!isset($caption))
|
||||
echo '<h2>'.__('Contacts',true).'</h2>';
|
||||
|
||||
$headers_manual = array_merge(array('Id', 'Last Name', 'First Name', 'Company'),
|
||||
$headers = array_merge(array('ID', 'Last Name', 'First Name', 'Company'),
|
||||
isset($contacts[0]['ContactsCustomer']) ? array('Type', 'Active') : array(),
|
||||
array('Comment'));
|
||||
|
||||
foreach (array_intersect($headers, array('ID')) AS $k => $v) {
|
||||
$column_class[$k] = 'id';
|
||||
}
|
||||
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
||||
$column_class[$k] = 'comment';
|
||||
}
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||
@@ -21,8 +29,6 @@ if (isset($paginator)) {
|
||||
$paginator->sort('active'))
|
||||
: array()),
|
||||
array($paginator->sort('comment')));
|
||||
} else {
|
||||
$headers = $headers_manual;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
@@ -55,7 +61,7 @@ echo $this->element('table',
|
||||
'caption' => isset($caption) ? $caption : null,
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers_manual));
|
||||
'column_class' => $column_class));
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo('<div class="paging">' . "\n");
|
||||
|
||||
@@ -2,10 +2,18 @@
|
||||
|
||||
if (isset($heading))
|
||||
echo $heading;
|
||||
else
|
||||
elseif (!isset($caption))
|
||||
echo '<h2>'.__('Customers',true).'</h2>';
|
||||
|
||||
$headers_manual = array('Id', 'Name', 'Comment');
|
||||
$headers = array('ID', 'Name', 'Comment');
|
||||
$column_class = array();
|
||||
foreach (array_intersect($headers, array('ID')) AS $k => $v) {
|
||||
$column_class[$k] = 'id';
|
||||
}
|
||||
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
||||
$column_class[$k] = 'comment';
|
||||
}
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo $paginator->counter(array(
|
||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||
@@ -13,8 +21,6 @@ if (isset($paginator)) {
|
||||
$headers = array($paginator->sort('id'),
|
||||
$paginator->sort('name'),
|
||||
$paginator->sort('comment'));
|
||||
} else {
|
||||
$headers = $headers_manual;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
@@ -38,7 +44,7 @@ echo $this->element('table',
|
||||
'caption' => isset($caption) ? $caption : null,
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers_manual));
|
||||
'column_class' => $column_class));
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo('<div class="paging">' . "\n");
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
<?php /* -*- mode:PHP -*- */
|
||||
|
||||
if (isset($heading))
|
||||
echo $heading;
|
||||
elseif (!isset($caption))
|
||||
echo '<h2>'.__('Ledger',true).'</h2>';
|
||||
|
||||
$headers = array('Transaction', 'Entry', 'Date', 'Customer', 'Comment', 'Debit', 'Credit', 'Total');
|
||||
$column_class = $headers;
|
||||
foreach (array_intersect($column_class, array('Transaction', 'Entry')) AS $k => $v) {
|
||||
$column_class = array();
|
||||
foreach (array_intersect($headers, array('Transaction', 'Entry')) AS $k => $v) {
|
||||
$column_class[$k] = array($column_class[$k], 'id');
|
||||
}
|
||||
foreach (array_intersect($column_class, array('Debits', 'Credits', 'Total')) AS $k => $v) {
|
||||
foreach (array_intersect($headers, array('Debit', 'Credit', 'Total')) AS $k => $v) {
|
||||
$column_class[$k] = array($column_class[$k], 'currency');
|
||||
}
|
||||
/* if (isset($paginator)) { */
|
||||
/* echo $paginator->counter(array( */
|
||||
/* 'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true))); */
|
||||
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
||||
$column_class[$k] = 'slack';
|
||||
}
|
||||
|
||||
/* $headers = array($paginator->sort('Transaction', 'transaction_id'), */
|
||||
/* $paginator->sort('entry_id'), */
|
||||
/* $paginator->sort('Date', 'stamp'), */
|
||||
/* $paginator->sort('customer_id'), */
|
||||
/* $paginator->sort('comment'), */
|
||||
/* $paginator->sort('debit'), */
|
||||
/* $paginator->sort('credit'), */
|
||||
/* $paginator->sort('total')); */
|
||||
/* } */
|
||||
|
||||
$rows = array();
|
||||
$running_total = 0;
|
||||
@@ -48,33 +44,23 @@ foreach($entries AS $entry) {
|
||||
array('controller' => 'ledger_entries',
|
||||
'action' => 'view',
|
||||
$entry['id'])),
|
||||
datefmt($transaction['stamp']),
|
||||
FormatHelper::date($transaction['stamp']),
|
||||
$html->link($customer['name'],
|
||||
array('controller' => 'customers',
|
||||
'action' => 'view',
|
||||
$customer['id'])),
|
||||
comment(array($transaction['comment'], $entry['comment'])),
|
||||
currency($debit),
|
||||
currency($credit),
|
||||
currency($running_total)
|
||||
FormatHelper::comment(array($transaction['comment'], $entry['comment'])),
|
||||
FormatHelper::currency($debit),
|
||||
FormatHelper::currency($credit),
|
||||
FormatHelper::currency($running_total)
|
||||
);
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item account ledger list',
|
||||
'caption' => $caption,
|
||||
'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"); */
|
||||
/* } */
|
||||
|
||||
?>
|
||||
|
||||
@@ -11,8 +11,11 @@ $headers = array_merge(array('Name'),
|
||||
: array()),
|
||||
array('Entries', 'Debits', 'Credits', 'Balance', 'Closed', 'Comment'));
|
||||
$column_class = array();
|
||||
foreach (array_intersect($column_class, array('Comment')) AS $k => $v) {
|
||||
$column_class[$k] = 'comment';
|
||||
foreach (array_intersect($headers, array('Debits', 'Credits', 'Balance')) AS $k => $v) {
|
||||
$column_class[$k] = 'currency';
|
||||
}
|
||||
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
||||
$column_class[$k] = 'slack';
|
||||
}
|
||||
|
||||
if (isset($paginator)) {
|
||||
@@ -52,9 +55,9 @@ foreach ($ledgers as $ledger) {
|
||||
$account['id'])))
|
||||
: array()),
|
||||
array($ledger['entries'],
|
||||
currency($ledger['debits']),
|
||||
currency($ledger['credits']),
|
||||
currency($ledger['balance']),
|
||||
FormatHelper::currency($ledger['debits']),
|
||||
FormatHelper::currency($ledger['credits']),
|
||||
FormatHelper::currency($ledger['balance']),
|
||||
$ledger['closed'] ? 'Closed' : 'Open',
|
||||
$ledger['comment']));
|
||||
}
|
||||
|
||||
@@ -2,10 +2,18 @@
|
||||
|
||||
if (isset($heading))
|
||||
echo $heading;
|
||||
else
|
||||
elseif (!isset($caption))
|
||||
echo '<h2>'.__('Maps',true).'</h2>';
|
||||
|
||||
$headers_manual = array('Id', 'Name', 'Area', 'Width', 'Depth', 'Comment');
|
||||
$headers = array('ID', 'Name', 'Area', 'Width', 'Depth', 'Comment');
|
||||
$column_class = array();
|
||||
foreach (array_intersect($headers, array('ID')) AS $k => $v) {
|
||||
$column_class[$k] = 'id';
|
||||
}
|
||||
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)));
|
||||
@@ -16,8 +24,6 @@ if (isset($paginator)) {
|
||||
$paginator->sort('width'),
|
||||
$paginator->sort('depth'),
|
||||
$paginator->sort('comment'));
|
||||
} else {
|
||||
$headers = $headers_manual;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
@@ -40,7 +46,7 @@ echo $this->element('table',
|
||||
array('class' => 'item map list',
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers_manual));
|
||||
'column_class' => $column_class));
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo('<div class="paging">' . "\n");
|
||||
|
||||
@@ -8,7 +8,7 @@ elseif (!isset($caption))
|
||||
$headers = array('Id', 'Timestamp', 'Comment');
|
||||
$column_class = array();
|
||||
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
||||
$column_class[$k] = 'comment';
|
||||
$column_class[$k] = 'slack';
|
||||
}
|
||||
foreach (array_intersect($headers, array('Id')) AS $k => $v) {
|
||||
$column_class[$k] = 'id';
|
||||
@@ -41,9 +41,9 @@ foreach ($transactions as $transaction) {
|
||||
array('controller' => 'customers',
|
||||
'action' => 'view',
|
||||
$customer['id'])),
|
||||
datefmt($transaction['stamp']),
|
||||
datefmt($transaction['through_date']),
|
||||
datefmt($transaction['due_date']),
|
||||
FormatHelper::date($transaction['stamp']),
|
||||
FormatHelper::date($transaction['through_date']),
|
||||
FormatHelper::date($transaction['due_date']),
|
||||
$transaction['comment']);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,15 @@ if (isset($heading))
|
||||
else
|
||||
echo '<h2>'.__('Units',true).'</h2>';
|
||||
|
||||
$headers_manual = array('Id', 'Unit', 'Size', 'Status', 'Comment');
|
||||
$headers = array('ID', 'Unit', 'Size', 'Status', 'Comment');
|
||||
$column_class = array();
|
||||
foreach (array_intersect($headers, array('ID')) AS $k => $v) {
|
||||
$column_class[$k] = 'id';
|
||||
}
|
||||
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)));
|
||||
@@ -15,8 +23,6 @@ if (isset($paginator)) {
|
||||
$paginator->sort('unit_size_id'),
|
||||
$paginator->sort('status'),
|
||||
$paginator->sort('comment'));
|
||||
} else {
|
||||
$headers = $headers_manual;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
@@ -36,9 +42,10 @@ foreach ($units as $unit) {
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item unit list',
|
||||
'caption' => isset($caption) ? $caption : null,
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers_manual));
|
||||
'column_class' => $column_class));
|
||||
|
||||
if (isset($paginator)) {
|
||||
echo('<div class="paging">' . "\n");
|
||||
|
||||
66
views/helpers/format.php
Normal file
66
views/helpers/format.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
class FormatHelper extends AppHelper {
|
||||
|
||||
static $time;
|
||||
static $number;
|
||||
|
||||
function __construct() {
|
||||
App::import('Helper', array('Time', 'Number'));
|
||||
self::$time = new TimeHelper;
|
||||
self::$number = new NumberHelper;
|
||||
}
|
||||
|
||||
function currency($amount) {
|
||||
if (!isset($amount))
|
||||
return null;
|
||||
|
||||
return (isset($amount)
|
||||
? self::$number->currency($amount)
|
||||
: null);
|
||||
|
||||
/* if ($money < 0) */
|
||||
/* return "($ " . number_format(-1*$money, 2) . ")"; */
|
||||
/* else */
|
||||
/* return "$ " . number_format($money, 2); */
|
||||
}
|
||||
|
||||
function date($date) {
|
||||
$date_fmt = 'm/d/Y';
|
||||
return (isset($date)
|
||||
? self::$time->format($date_fmt, $date)
|
||||
//? date_format(date_create($date), $date_fmt)
|
||||
: null);
|
||||
}
|
||||
|
||||
function datetime($datetime) {
|
||||
if (!$date) return null;
|
||||
return self::$time->nice($datetime);
|
||||
}
|
||||
|
||||
function phone($phone) {
|
||||
if (!isset($phone))
|
||||
return null;
|
||||
|
||||
$phone = preg_replace("/\D/", "", $phone);
|
||||
if(strlen($phone) == 7)
|
||||
return preg_replace("/(\d{3})(\d{4})/", "$1-$2", $phone);
|
||||
elseif(strlen($phone) == 10)
|
||||
return preg_replace("/(\d{3})(\d{3})(\d{4})/", "$1-$2-$3", $phone);
|
||||
else
|
||||
return $phone;
|
||||
}
|
||||
|
||||
function comment($comment) {
|
||||
if (isset($comment) && is_array($comment)) {
|
||||
foreach (array_keys($comment) AS $k) {
|
||||
if (!$comment[$k])
|
||||
unset($comment[$k]);
|
||||
}
|
||||
return implode('; ', $comment);
|
||||
}
|
||||
|
||||
return $comment;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,36 +5,6 @@
|
||||
<?php
|
||||
; // Editor alignment
|
||||
|
||||
function currency($number) {
|
||||
if (!isset($number))
|
||||
return null;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
function comment($comment) {
|
||||
if (isset($comment) && is_array($comment)) {
|
||||
foreach (array_keys($comment) AS $k) {
|
||||
if (!$comment[$k])
|
||||
unset($comment[$k]);
|
||||
}
|
||||
return implode('; ', $comment);
|
||||
}
|
||||
|
||||
return $comment;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
@@ -48,7 +18,7 @@ $rows = array(array('ID', $ledger['Ledger']['id']),
|
||||
array('controller' => 'accounts',
|
||||
'action' => 'view',
|
||||
$ledger['Account']['id']))),
|
||||
array('Closed', $ledger['Ledger']['closed']),
|
||||
array('Status', $ledger['Ledger']['closed'] ? 'Closed' : 'Open'),
|
||||
array('Comment', $ledger['Ledger']['comment']));
|
||||
|
||||
echo $this->element('table',
|
||||
@@ -66,7 +36,7 @@ echo $this->element('table',
|
||||
|
||||
<DIV CLASS="infobox">
|
||||
<DIV CLASS="summary balance">
|
||||
Ledger Balance: <?php echo currency($balance); ?>
|
||||
Ledger Balance: <?php echo FormatHelper::currency($balance); ?>
|
||||
</DIV>
|
||||
</DIV>
|
||||
|
||||
|
||||
@@ -3,21 +3,7 @@
|
||||
<div class="transaction 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);
|
||||
}
|
||||
|
||||
; // Editor alignment
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
@@ -44,10 +30,10 @@ echo $this->element('table',
|
||||
?>
|
||||
<DIV CLASS="infobox">
|
||||
<DIV CLASS="summary grand debit">
|
||||
Debits: <?php echo currency($debitAmount); ?>
|
||||
Debits: <?php echo FormatHelper::currency($debitAmount); ?>
|
||||
</DIV>
|
||||
<DIV CLASS="summary grand credit">
|
||||
Credits: <?php echo currency($creditAmount); ?>
|
||||
Credits: <?php echo FormatHelper::currency($creditAmount); ?>
|
||||
</DIV>
|
||||
</DIV>
|
||||
|
||||
@@ -83,8 +69,8 @@ foreach($transaction['LedgerEntry'] AS $entry) {
|
||||
'action' => 'view',
|
||||
$entry['CreditLedger']['id'])),
|
||||
$entry['comment'],
|
||||
currency($entry['amount']),
|
||||
currency($running_total)
|
||||
FormatHelper::currency($entry['amount']),
|
||||
FormatHelper::currency($running_total)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,22 +3,7 @@
|
||||
<div class="unit view">
|
||||
|
||||
<?php
|
||||
|
||||
function currency($amount) {
|
||||
return NumberHelper::currency($amount);
|
||||
}
|
||||
|
||||
function datefmt($date) {
|
||||
if (!$date) return null;
|
||||
$date_fmt = 'm/d/Y';
|
||||
return TimeHelper::format($date_fmt, $date);
|
||||
}
|
||||
|
||||
function datetimefmt($date) {
|
||||
if (!$date) return null;
|
||||
return TimeHelper::nice($date);
|
||||
}
|
||||
|
||||
; // Editor alignment
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
@@ -45,10 +30,10 @@ echo $this->element('table',
|
||||
?>
|
||||
<DIV CLASS="infobox">
|
||||
<DIV CLASS="summary grand deposit">
|
||||
Security Deposit: <?php echo currency($outstandingDeposit); ?>
|
||||
Security Deposit: <?php echo FormatHelper::currency($outstandingDeposit); ?>
|
||||
</DIV>
|
||||
<DIV CLASS="summary grand balance">
|
||||
Balance: <?php echo currency($outstandingBalance); ?>
|
||||
Balance: <?php echo FormatHelper::currency($outstandingBalance); ?>
|
||||
</DIV>
|
||||
</DIV>
|
||||
|
||||
@@ -67,28 +52,10 @@ echo $this->element('table',
|
||||
/**********************************************************************
|
||||
* Lease History
|
||||
*/
|
||||
$headers = array('Lease', 'Tenant', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
|
||||
$rows = array();
|
||||
foreach($unit['Lease'] AS $lease) {
|
||||
$rows[] = array('#'.$lease['number'],
|
||||
$html->link($lease['Customer']['name'],
|
||||
array('controller' => 'customers',
|
||||
'action' => 'view',
|
||||
$lease['Customer']['id'])),
|
||||
datefmt($lease['lease_date']),
|
||||
datefmt($lease['movein_date']),
|
||||
datefmt($lease['moveout_date']),
|
||||
currency($lease['amount']),
|
||||
currency($lease['deposit']),
|
||||
$lease['comment']);
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item lease list',
|
||||
'caption' => 'Lease History',
|
||||
'headers' => $headers,
|
||||
'rows' => $rows,
|
||||
'column_class' => $headers));
|
||||
echo $this->element('leases',
|
||||
array('caption' => 'Lease History',
|
||||
'leases' => $unit['Lease']));
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
Reference in New Issue
Block a user