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:
@@ -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'),
|
||||
isset($contacts[0]['ContactsCustomer']) ? array('Type', 'Active') : array(),
|
||||
array('Comment'));
|
||||
$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");
|
||||
|
||||
Reference in New Issue
Block a user