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
|
* @subpackage cake.app
|
||||||
*/
|
*/
|
||||||
class AppController extends Controller {
|
class AppController extends Controller {
|
||||||
var $helpers = array('Html', 'Number', 'Time');
|
var $helpers = array('Html', 'Format');
|
||||||
|
|
||||||
function sideMenuLinks() {
|
function sideMenuLinks() {
|
||||||
return array(
|
return array(
|
||||||
|
|||||||
@@ -5,36 +5,6 @@
|
|||||||
<?php
|
<?php
|
||||||
; // Editor alignment
|
; // 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="infobox">
|
||||||
<DIV CLASS="summary balance">
|
<DIV CLASS="summary balance">
|
||||||
Account Balance: <?php echo currency($balance); ?>
|
Account Balance: <?php echo FormatHelper::currency($balance); ?>
|
||||||
</DIV>
|
</DIV>
|
||||||
</DIV>
|
</DIV>
|
||||||
|
|
||||||
|
|||||||
@@ -3,31 +3,7 @@
|
|||||||
<div class="contact view">
|
<div class="contact view">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
; // Editor alignment
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -78,7 +54,7 @@ echo $this->element('table',
|
|||||||
$headers = array('Phone', 'Preference', 'Comment');
|
$headers = array('Phone', 'Preference', 'Comment');
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach($contact['ContactPhone'] AS $phone) {
|
foreach($contact['ContactPhone'] AS $phone) {
|
||||||
$rows[] = array(phone($phone['phone']) .
|
$rows[] = array(FormatHelper::phone($phone['phone']) .
|
||||||
($phone['ext'] ? " x".$phone['ext'] : ""),
|
($phone['ext'] ? " x".$phone['ext'] : ""),
|
||||||
$phone['ContactsMethod']['preference'] . " / " .
|
$phone['ContactsMethod']['preference'] . " / " .
|
||||||
$phone['ContactsMethod']['type'] . " / " .
|
$phone['ContactsMethod']['type'] . " / " .
|
||||||
|
|||||||
@@ -3,31 +3,7 @@
|
|||||||
<div class="customer view">
|
<div class="customer view">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
; // Editor alignment
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -53,10 +29,10 @@ echo $this->element('table',
|
|||||||
?>
|
?>
|
||||||
<DIV CLASS="infobox">
|
<DIV CLASS="infobox">
|
||||||
<DIV CLASS="summary grand deposit">
|
<DIV CLASS="summary grand deposit">
|
||||||
Security Deposit: <?php echo currency($outstandingDeposit); ?>
|
Security Deposit: <?php echo FormatHelper::currency($outstandingDeposit); ?>
|
||||||
</DIV>
|
</DIV>
|
||||||
<DIV CLASS="summary grand balance">
|
<DIV CLASS="summary grand balance">
|
||||||
Balance: <?php echo currency($outstandingBalance); ?>
|
Balance: <?php echo FormatHelper::currency($outstandingBalance); ?>
|
||||||
</DIV>
|
</DIV>
|
||||||
</DIV>
|
</DIV>
|
||||||
|
|
||||||
@@ -80,108 +56,22 @@ echo $this->element('contacts',
|
|||||||
'contacts' => $customer['Contact']));
|
'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
|
* Lease History
|
||||||
*/
|
*/
|
||||||
$headers = array('Lease', 'Unit', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
|
echo $this->element('leases',
|
||||||
$rows = array();
|
array('caption' => 'Lease History',
|
||||||
foreach($customer['Lease'] AS $lease) {
|
'leases' => $customer['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));
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Ledger History
|
* Account
|
||||||
*/
|
*/
|
||||||
echo $this->element('ledger',
|
|
||||||
array('caption' => 'Ledger History',
|
echo $this->element('accounts',
|
||||||
'transactions' => $customer['Transaction'],
|
array('caption' => 'Account',
|
||||||
'ledger' => array('mix'=>1)));
|
'accounts' => array($customer['Account'])));
|
||||||
|
|
||||||
|
|
||||||
/* End "detail supporting" DIV */ ?>
|
/* End "detail supporting" DIV */ ?>
|
||||||
</DIV>
|
</DIV>
|
||||||
|
|||||||
@@ -2,28 +2,17 @@
|
|||||||
|
|
||||||
if (isset($heading))
|
if (isset($heading))
|
||||||
echo $heading;
|
echo $heading;
|
||||||
else
|
elseif (!isset($caption))
|
||||||
echo '<h2>'.__('Accounts',true).'</h2>';
|
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');
|
$headers = array('Name', 'Type', 'Ext. Name', 'Ext. Account', 'Entries', 'Debits', 'Credits', 'Balance', 'Comment');
|
||||||
$column_class = array();
|
$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';
|
$column_class[$k] = 'currency';
|
||||||
}
|
}
|
||||||
|
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
||||||
|
$column_class[$k] = 'slack';
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($paginator)) {
|
if (isset($paginator)) {
|
||||||
echo $paginator->counter(array(
|
echo $paginator->counter(array(
|
||||||
@@ -61,15 +50,16 @@ foreach ($accounts as $account) {
|
|||||||
$account['external_name'],
|
$account['external_name'],
|
||||||
$account['external_account'],
|
$account['external_account'],
|
||||||
$account['entries'],
|
$account['entries'],
|
||||||
currency($account['debits']),
|
FormatHelper::currency($account['debits']),
|
||||||
currency($account['credits']),
|
FormatHelper::currency($account['credits']),
|
||||||
currency($account['balance']),
|
FormatHelper::currency($account['balance']),
|
||||||
$account['comment'],
|
$account['comment'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
array('class' => 'item account list',
|
array('class' => 'item account list',
|
||||||
|
'caption' => isset($caption) ? $caption : null,
|
||||||
'headers' => $headers,
|
'headers' => $headers,
|
||||||
'rows' => $rows,
|
'rows' => $rows,
|
||||||
'column_class' => $column_class));
|
'column_class' => $column_class));
|
||||||
|
|||||||
@@ -5,9 +5,17 @@ if (isset($heading))
|
|||||||
elseif (!isset($caption))
|
elseif (!isset($caption))
|
||||||
echo '<h2>'.__('Contacts',true).'</h2>';
|
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(),
|
isset($contacts[0]['ContactsCustomer']) ? array('Type', 'Active') : array(),
|
||||||
array('Comment'));
|
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)) {
|
if (isset($paginator)) {
|
||||||
echo $paginator->counter(array(
|
echo $paginator->counter(array(
|
||||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
||||||
@@ -21,8 +29,6 @@ if (isset($paginator)) {
|
|||||||
$paginator->sort('active'))
|
$paginator->sort('active'))
|
||||||
: array()),
|
: array()),
|
||||||
array($paginator->sort('comment')));
|
array($paginator->sort('comment')));
|
||||||
} else {
|
|
||||||
$headers = $headers_manual;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
@@ -55,7 +61,7 @@ echo $this->element('table',
|
|||||||
'caption' => isset($caption) ? $caption : null,
|
'caption' => isset($caption) ? $caption : null,
|
||||||
'headers' => $headers,
|
'headers' => $headers,
|
||||||
'rows' => $rows,
|
'rows' => $rows,
|
||||||
'column_class' => $headers_manual));
|
'column_class' => $column_class));
|
||||||
|
|
||||||
if (isset($paginator)) {
|
if (isset($paginator)) {
|
||||||
echo('<div class="paging">' . "\n");
|
echo('<div class="paging">' . "\n");
|
||||||
|
|||||||
@@ -2,10 +2,18 @@
|
|||||||
|
|
||||||
if (isset($heading))
|
if (isset($heading))
|
||||||
echo $heading;
|
echo $heading;
|
||||||
else
|
elseif (!isset($caption))
|
||||||
echo '<h2>'.__('Customers',true).'</h2>';
|
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)) {
|
if (isset($paginator)) {
|
||||||
echo $paginator->counter(array(
|
echo $paginator->counter(array(
|
||||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
'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'),
|
$headers = array($paginator->sort('id'),
|
||||||
$paginator->sort('name'),
|
$paginator->sort('name'),
|
||||||
$paginator->sort('comment'));
|
$paginator->sort('comment'));
|
||||||
} else {
|
|
||||||
$headers = $headers_manual;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
@@ -38,7 +44,7 @@ echo $this->element('table',
|
|||||||
'caption' => isset($caption) ? $caption : null,
|
'caption' => isset($caption) ? $caption : null,
|
||||||
'headers' => $headers,
|
'headers' => $headers,
|
||||||
'rows' => $rows,
|
'rows' => $rows,
|
||||||
'column_class' => $headers_manual));
|
'column_class' => $column_class));
|
||||||
|
|
||||||
if (isset($paginator)) {
|
if (isset($paginator)) {
|
||||||
echo('<div class="paging">' . "\n");
|
echo('<div class="paging">' . "\n");
|
||||||
|
|||||||
@@ -1,26 +1,22 @@
|
|||||||
<?php /* -*- mode:PHP -*- */
|
<?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');
|
$headers = array('Transaction', 'Entry', 'Date', 'Customer', 'Comment', 'Debit', 'Credit', 'Total');
|
||||||
$column_class = $headers;
|
$column_class = array();
|
||||||
foreach (array_intersect($column_class, array('Transaction', 'Entry')) AS $k => $v) {
|
foreach (array_intersect($headers, array('Transaction', 'Entry')) AS $k => $v) {
|
||||||
$column_class[$k] = array($column_class[$k], 'id');
|
$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');
|
$column_class[$k] = array($column_class[$k], 'currency');
|
||||||
}
|
}
|
||||||
/* if (isset($paginator)) { */
|
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
||||||
/* echo $paginator->counter(array( */
|
$column_class[$k] = 'slack';
|
||||||
/* 'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true))); */
|
}
|
||||||
|
|
||||||
/* $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();
|
$rows = array();
|
||||||
$running_total = 0;
|
$running_total = 0;
|
||||||
@@ -48,33 +44,23 @@ foreach($entries AS $entry) {
|
|||||||
array('controller' => 'ledger_entries',
|
array('controller' => 'ledger_entries',
|
||||||
'action' => 'view',
|
'action' => 'view',
|
||||||
$entry['id'])),
|
$entry['id'])),
|
||||||
datefmt($transaction['stamp']),
|
FormatHelper::date($transaction['stamp']),
|
||||||
$html->link($customer['name'],
|
$html->link($customer['name'],
|
||||||
array('controller' => 'customers',
|
array('controller' => 'customers',
|
||||||
'action' => 'view',
|
'action' => 'view',
|
||||||
$customer['id'])),
|
$customer['id'])),
|
||||||
comment(array($transaction['comment'], $entry['comment'])),
|
FormatHelper::comment(array($transaction['comment'], $entry['comment'])),
|
||||||
currency($debit),
|
FormatHelper::currency($debit),
|
||||||
currency($credit),
|
FormatHelper::currency($credit),
|
||||||
currency($running_total)
|
FormatHelper::currency($running_total)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
array('class' => 'item account ledger list',
|
array('class' => 'item account ledger list',
|
||||||
'caption' => $caption,
|
'caption' => isset($caption) ? $caption : null,
|
||||||
'headers' => $headers,
|
'headers' => $headers,
|
||||||
'rows' => $rows,
|
'rows' => $rows,
|
||||||
'column_class' => $column_class));
|
'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()),
|
||||||
array('Entries', 'Debits', 'Credits', 'Balance', 'Closed', 'Comment'));
|
array('Entries', 'Debits', 'Credits', 'Balance', 'Closed', 'Comment'));
|
||||||
$column_class = array();
|
$column_class = array();
|
||||||
foreach (array_intersect($column_class, array('Comment')) AS $k => $v) {
|
foreach (array_intersect($headers, array('Debits', 'Credits', 'Balance')) AS $k => $v) {
|
||||||
$column_class[$k] = 'comment';
|
$column_class[$k] = 'currency';
|
||||||
|
}
|
||||||
|
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
||||||
|
$column_class[$k] = 'slack';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($paginator)) {
|
if (isset($paginator)) {
|
||||||
@@ -52,9 +55,9 @@ foreach ($ledgers as $ledger) {
|
|||||||
$account['id'])))
|
$account['id'])))
|
||||||
: array()),
|
: array()),
|
||||||
array($ledger['entries'],
|
array($ledger['entries'],
|
||||||
currency($ledger['debits']),
|
FormatHelper::currency($ledger['debits']),
|
||||||
currency($ledger['credits']),
|
FormatHelper::currency($ledger['credits']),
|
||||||
currency($ledger['balance']),
|
FormatHelper::currency($ledger['balance']),
|
||||||
$ledger['closed'] ? 'Closed' : 'Open',
|
$ledger['closed'] ? 'Closed' : 'Open',
|
||||||
$ledger['comment']));
|
$ledger['comment']));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,18 @@
|
|||||||
|
|
||||||
if (isset($heading))
|
if (isset($heading))
|
||||||
echo $heading;
|
echo $heading;
|
||||||
else
|
elseif (!isset($caption))
|
||||||
echo '<h2>'.__('Maps',true).'</h2>';
|
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)) {
|
if (isset($paginator)) {
|
||||||
echo $paginator->counter(array(
|
echo $paginator->counter(array(
|
||||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
'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('width'),
|
||||||
$paginator->sort('depth'),
|
$paginator->sort('depth'),
|
||||||
$paginator->sort('comment'));
|
$paginator->sort('comment'));
|
||||||
} else {
|
|
||||||
$headers = $headers_manual;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
@@ -40,7 +46,7 @@ echo $this->element('table',
|
|||||||
array('class' => 'item map list',
|
array('class' => 'item map list',
|
||||||
'headers' => $headers,
|
'headers' => $headers,
|
||||||
'rows' => $rows,
|
'rows' => $rows,
|
||||||
'column_class' => $headers_manual));
|
'column_class' => $column_class));
|
||||||
|
|
||||||
if (isset($paginator)) {
|
if (isset($paginator)) {
|
||||||
echo('<div class="paging">' . "\n");
|
echo('<div class="paging">' . "\n");
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ elseif (!isset($caption))
|
|||||||
$headers = array('Id', 'Timestamp', 'Comment');
|
$headers = array('Id', 'Timestamp', 'Comment');
|
||||||
$column_class = array();
|
$column_class = array();
|
||||||
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
|
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) {
|
foreach (array_intersect($headers, array('Id')) AS $k => $v) {
|
||||||
$column_class[$k] = 'id';
|
$column_class[$k] = 'id';
|
||||||
@@ -41,9 +41,9 @@ foreach ($transactions as $transaction) {
|
|||||||
array('controller' => 'customers',
|
array('controller' => 'customers',
|
||||||
'action' => 'view',
|
'action' => 'view',
|
||||||
$customer['id'])),
|
$customer['id'])),
|
||||||
datefmt($transaction['stamp']),
|
FormatHelper::date($transaction['stamp']),
|
||||||
datefmt($transaction['through_date']),
|
FormatHelper::date($transaction['through_date']),
|
||||||
datefmt($transaction['due_date']),
|
FormatHelper::date($transaction['due_date']),
|
||||||
$transaction['comment']);
|
$transaction['comment']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,15 @@ if (isset($heading))
|
|||||||
else
|
else
|
||||||
echo '<h2>'.__('Units',true).'</h2>';
|
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)) {
|
if (isset($paginator)) {
|
||||||
echo $paginator->counter(array(
|
echo $paginator->counter(array(
|
||||||
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
|
'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('unit_size_id'),
|
||||||
$paginator->sort('status'),
|
$paginator->sort('status'),
|
||||||
$paginator->sort('comment'));
|
$paginator->sort('comment'));
|
||||||
} else {
|
|
||||||
$headers = $headers_manual;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
@@ -36,9 +42,10 @@ foreach ($units as $unit) {
|
|||||||
|
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
array('class' => 'item unit list',
|
array('class' => 'item unit list',
|
||||||
|
'caption' => isset($caption) ? $caption : null,
|
||||||
'headers' => $headers,
|
'headers' => $headers,
|
||||||
'rows' => $rows,
|
'rows' => $rows,
|
||||||
'column_class' => $headers_manual));
|
'column_class' => $column_class));
|
||||||
|
|
||||||
if (isset($paginator)) {
|
if (isset($paginator)) {
|
||||||
echo('<div class="paging">' . "\n");
|
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
|
<?php
|
||||||
; // Editor alignment
|
; // 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',
|
array('controller' => 'accounts',
|
||||||
'action' => 'view',
|
'action' => 'view',
|
||||||
$ledger['Account']['id']))),
|
$ledger['Account']['id']))),
|
||||||
array('Closed', $ledger['Ledger']['closed']),
|
array('Status', $ledger['Ledger']['closed'] ? 'Closed' : 'Open'),
|
||||||
array('Comment', $ledger['Ledger']['comment']));
|
array('Comment', $ledger['Ledger']['comment']));
|
||||||
|
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
@@ -66,7 +36,7 @@ echo $this->element('table',
|
|||||||
|
|
||||||
<DIV CLASS="infobox">
|
<DIV CLASS="infobox">
|
||||||
<DIV CLASS="summary balance">
|
<DIV CLASS="summary balance">
|
||||||
Ledger Balance: <?php echo currency($balance); ?>
|
Ledger Balance: <?php echo FormatHelper::currency($balance); ?>
|
||||||
</DIV>
|
</DIV>
|
||||||
</DIV>
|
</DIV>
|
||||||
|
|
||||||
|
|||||||
@@ -3,21 +3,7 @@
|
|||||||
<div class="transaction view">
|
<div class="transaction view">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
; // Editor alignment
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -44,10 +30,10 @@ echo $this->element('table',
|
|||||||
?>
|
?>
|
||||||
<DIV CLASS="infobox">
|
<DIV CLASS="infobox">
|
||||||
<DIV CLASS="summary grand debit">
|
<DIV CLASS="summary grand debit">
|
||||||
Debits: <?php echo currency($debitAmount); ?>
|
Debits: <?php echo FormatHelper::currency($debitAmount); ?>
|
||||||
</DIV>
|
</DIV>
|
||||||
<DIV CLASS="summary grand credit">
|
<DIV CLASS="summary grand credit">
|
||||||
Credits: <?php echo currency($creditAmount); ?>
|
Credits: <?php echo FormatHelper::currency($creditAmount); ?>
|
||||||
</DIV>
|
</DIV>
|
||||||
</DIV>
|
</DIV>
|
||||||
|
|
||||||
@@ -83,8 +69,8 @@ foreach($transaction['LedgerEntry'] AS $entry) {
|
|||||||
'action' => 'view',
|
'action' => 'view',
|
||||||
$entry['CreditLedger']['id'])),
|
$entry['CreditLedger']['id'])),
|
||||||
$entry['comment'],
|
$entry['comment'],
|
||||||
currency($entry['amount']),
|
FormatHelper::currency($entry['amount']),
|
||||||
currency($running_total)
|
FormatHelper::currency($running_total)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,22 +3,7 @@
|
|||||||
<div class="unit view">
|
<div class="unit view">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
; // Editor alignment
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -45,10 +30,10 @@ echo $this->element('table',
|
|||||||
?>
|
?>
|
||||||
<DIV CLASS="infobox">
|
<DIV CLASS="infobox">
|
||||||
<DIV CLASS="summary grand deposit">
|
<DIV CLASS="summary grand deposit">
|
||||||
Security Deposit: <?php echo currency($outstandingDeposit); ?>
|
Security Deposit: <?php echo FormatHelper::currency($outstandingDeposit); ?>
|
||||||
</DIV>
|
</DIV>
|
||||||
<DIV CLASS="summary grand balance">
|
<DIV CLASS="summary grand balance">
|
||||||
Balance: <?php echo currency($outstandingBalance); ?>
|
Balance: <?php echo FormatHelper::currency($outstandingBalance); ?>
|
||||||
</DIV>
|
</DIV>
|
||||||
</DIV>
|
</DIV>
|
||||||
|
|
||||||
@@ -67,28 +52,10 @@ echo $this->element('table',
|
|||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Lease History
|
* 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',
|
echo $this->element('leases',
|
||||||
array('class' => 'item lease list',
|
array('caption' => 'Lease History',
|
||||||
'caption' => 'Lease History',
|
'leases' => $unit['Lease']));
|
||||||
'headers' => $headers,
|
|
||||||
'rows' => $rows,
|
|
||||||
'column_class' => $headers));
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user