' . "\n");
diff --git a/site/views/elements/customers.ctp b/site/views/elements/customers.ctp
index 38cf034..471e203 100644
--- a/site/views/elements/customers.ctp
+++ b/site/views/elements/customers.ctp
@@ -2,10 +2,18 @@
if (isset($heading))
echo $heading;
-else
+elseif (!isset($caption))
echo '
';
-$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('
' . "\n");
diff --git a/site/views/elements/ledger.ctp b/site/views/elements/ledger.ctp
index 4ae5d62..4128277 100644
--- a/site/views/elements/ledger.ctp
+++ b/site/views/elements/ledger.ctp
@@ -1,26 +1,22 @@
'.__('Ledger',true).'';
+
$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('
' . "\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('
' . "\n"); */
-/* } */
-
?>
diff --git a/site/views/elements/ledgers.ctp b/site/views/elements/ledgers.ctp
index 13c4219..4155126 100644
--- a/site/views/elements/ledgers.ctp
+++ b/site/views/elements/ledgers.ctp
@@ -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']));
}
diff --git a/site/views/elements/maps.ctp b/site/views/elements/maps.ctp
index ee148c9..dc475fb 100644
--- a/site/views/elements/maps.ctp
+++ b/site/views/elements/maps.ctp
@@ -2,10 +2,18 @@
if (isset($heading))
echo $heading;
-else
+elseif (!isset($caption))
echo '
'.__('Maps',true).'
';
-$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('
' . "\n");
diff --git a/site/views/elements/transactions.ctp b/site/views/elements/transactions.ctp
index abf2535..556e71b 100644
--- a/site/views/elements/transactions.ctp
+++ b/site/views/elements/transactions.ctp
@@ -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']);
}
diff --git a/site/views/elements/units.ctp b/site/views/elements/units.ctp
index d0f90ee..6376a3c 100644
--- a/site/views/elements/units.ctp
+++ b/site/views/elements/units.ctp
@@ -5,7 +5,15 @@ if (isset($heading))
else
echo '
'.__('Units',true).'
';
-$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('
' . "\n");
diff --git a/site/views/helpers/format.php b/site/views/helpers/format.php
new file mode 100644
index 0000000..4b93bab
--- /dev/null
+++ b/site/views/helpers/format.php
@@ -0,0 +1,66 @@
+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;
+ }
+
+}
diff --git a/site/views/ledgers/view.ctp b/site/views/ledgers/view.ctp
index 63320e3..0cddc40 100644
--- a/site/views/ledgers/view.ctp
+++ b/site/views/ledgers/view.ctp
@@ -5,36 +5,6 @@
'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',
- Ledger Balance:
+ Ledger Balance:
diff --git a/site/views/transactions/view.ctp b/site/views/transactions/view.ctp
index 3a9e87f..4771455 100644
--- a/site/views/transactions/view.ctp
+++ b/site/views/transactions/view.ctp
@@ -3,21 +3,7 @@
element('table',
?>
- Debits:
+ Debits:
- Credits:
+ Credits:
@@ -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)
);
}
diff --git a/site/views/units/view.ctp b/site/views/units/view.ctp
index 5bc79ce..e6b79fe 100644
--- a/site/views/units/view.ctp
+++ b/site/views/units/view.ctp
@@ -3,22 +3,7 @@
element('table',
?>
- Security Deposit:
+ Security Deposit:
- Balance:
+ Balance:
@@ -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']));
/**********************************************************************