I'm still in the middle of moving onto a ledger based system. However, I'm am now changing how transactions and entries relate back to the customer. I'll be using a ledger for each lease (for rent, late charges, security deposits, etc), and a ledger for each customer (for POS, non-specific deposits such as reservations or covering mulitple units, bad debt writeoff, and possibly customer credits, when not obviously lease specific). This coming change might not be in the right direction, so I want to capture the work as is right now. This change set is not fully functional. Many operations do work, but there are obviously transaction problems with units and customers.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@71 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-06 20:18:56 +00:00
parent ce24abc812
commit 677458e942
52 changed files with 2367 additions and 1469 deletions

3
views/accounts/index.ctp Normal file
View File

@@ -0,0 +1,3 @@
<div class="accounts index">
<?php echo $this->element('accounts', array('heading' => '<h2>'.$heading.'</h2>')) ?>
</div>

95
views/accounts/view.ctp Normal file
View File

@@ -0,0 +1,95 @@
<?php /* -*- mode:PHP -*- */ ?>
<div class="account view">
<?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;
}
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Account Detail Main Section
*/
$rows = array(array('ID', $account['Account']['id']),
array('Name', $account['Account']['name']),
array('Type', $account['Account']['type']),
array('External Name', $account['Account']['external_name']),
array('External Account', $account['Account']['external_account']),
array('Comment', $account['Account']['comment']));
echo $this->element('table',
array('class' => 'item account detail',
'caption' => 'Account Detail',
'rows' => $rows,
'column_class' => array('field', 'value')));
/**********************************************************************
* Account Info Box
*/
?>
<DIV CLASS="infobox">
<DIV CLASS="summary balance">
Account Balance: <?php echo currency($balance); ?>
</DIV>
</DIV>
<DIV CLASS="detail supporting">
<?php
; // Editor alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Supporting Elements Section
*/
/**********************************************************************
* Ledger
*/
echo $this->element('ledgers',
array('caption' => $account['Account']['name'] . " Ledgers",
'ledgers' => $account['Ledger']));
/* End "detail supporting" DIV */ ?>
</DIV>
</div>

View File

@@ -1,3 +0,0 @@
<div class="charges index">
<?php echo $this->element('charges', array('heading' => '<h2>'.$heading.'</h2>')) ?>
</div>

View File

@@ -1,87 +0,0 @@
<?php /* -*- mode:PHP -*- */ ?>
<div class="charges 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);
}
/**********************************************************************
* Charge Info
*/
$rows = array(array('ID', $charge['Charge']['id']),
array('Date', datefmt($charge['Charge']['charge_date'])),
array('Through', datefmt($charge['Charge']['charge_to_date'])),
array('Due', datefmt($charge['Charge']['due_date'])),
array('Type', $charge['ChargeType']['name']),
array('Lease', '#'.$charge['Lease']['number']),
array('Amount', currency($charge['Charge']['amount'])),
array('Tax', currency($charge['Charge']['tax'])),
array('Total', currency($charge['Charge']['total'])),
array('Comment', $charge['Charge']['comment']));
echo $this->element('table',
array('class' => 'item charge detail',
'caption' => 'Charge Info',
'rows' => $rows,
'column_class' => array('field', 'value')));
?>
<DIV CLASS="infobox charge">
<DIV CLASS="summary grand payment">
Amount Received: <?php echo currency($paymentAmount); ?>
</DIV>
<DIV CLASS="summary grand balance">
Amount Owing: <?php echo currency($balanceAmount); ?>
</DIV>
</DIV>
<?php
/**********************************************************************
* Receipts
*/
$headers = array('ID', 'Timestamp', 'Comment', 'Applied', 'Balance');
$rows = array();
$running_total = $charge['Charge']['total'];
foreach($charge['Receipt'] AS $receipt) {
$amount = $receipt['ChargesReceipt']['amount'];
$running_total -= $amount;
$rows[] = array($html->link('#'.$receipt['id'],
array('controller' => 'receipts',
'action' => 'view',
$receipt['id'])),
datefmt($receipt['stamp']),
$receipt['comment'],
currency($receipt['ChargesReceipt']['amount']),
currency($running_total)
);
}
echo $this->element('table',
array('class' => 'item receipt list',
'caption' => 'Receipts towards Charge',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
?>
</div>

View File

@@ -1,6 +1,6 @@
<?php /* -*- mode:PHP -*- */ ?>
<div class="contacts view">
<div class="contact view">
<?php
@@ -28,36 +28,48 @@ function datefmt($date) {
: null);
}
/**********************************************************************
* Tenant Info
**********************************************************************
**********************************************************************
**********************************************************************
* Contact Detail Main Section
*/
$rows = array(array('Name', $contact['Contact']['display_name']),
array('Company', $contact['Contact']['company_name']),
array('SSN', $contact['Contact']['id_federal']),
array('ID', ($contact['Contact']['id_num']
. ($contact['Contact']['id_state']
? " - ".$contact['Contact']['id_state']
array('ID', ($contact['Contact']['id_local']
. ($contact['Contact']['id_local']
? " - ".$contact['Contact']['id_local_state']
: ""))),
array('Comment', $contact['Contact']['comment']));
echo $this->element('table',
array('class' => 'item contact detail',
'caption' => 'Tenant Info',
'caption' => 'Contact Details',
'rows' => $rows,
'column_class' => array('field', 'value')));
/**********************************************************************
* Contact Info Box
*/
?>
<DIV CLASS="infobox contact">
<DIV CLASS="summary grand deposit">
Security Deposit: <?php echo currency($outstandingDeposit); ?>
</DIV>
<DIV CLASS="summary grand balance">
Balance: <?php echo currency($outstandingBalance); ?>
</DIV>
<DIV CLASS="infobox">
</DIV>
<DIV CLASS="detail supporting">
<?php
; // Editor alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Supporting Elements Section
*/
/**********************************************************************
@@ -127,77 +139,14 @@ echo $this->element('table',
/**********************************************************************
* Lease History
* Customers
*/
$headers = array('Lease', 'Unit', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
$rows = array();
foreach($contact['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('customers', array('heading' => '',
'caption' => 'Related Customers',
'customers' => $contact['Customer']));
/**********************************************************************
* Ledger History
*/
foreach($contact['Lease'] AS $lease) {
$headers = array(/*'Charge/Receipt'*/'Charge', 'Date', 'Through', 'Type', 'Comment', 'Amount', 'Balance', 'Total');
$rows = array();
$row_class = array();
$running_total = 0;
$odd = 0;
foreach($lease['Charge'] AS $charge) {
$amount = $charge['total'];
$balance = $amount;
foreach ($charge['Receipt'] AS $receipt)
$balance -= $receipt['ChargesReceipt']['amount'];
$running_total += $balance;
$rows[] = array($html->link('#'.$charge['id'],
array('controller' => 'charges',
'action' => 'view',
$charge['id'])),
datefmt($charge['charge_date']),
datefmt($charge['charge_to_date']),
$charge['ChargeType']['name'],
$charge['comment'],
currency($amount),
currency($balance),
//currency($amount - $paid));
currency($running_total));
$row_class[] = array('charge', (++$odd % 2) ? 'oddrow' : 'evnrow');
}
echo $this->element('table',
array('class' => 'item ledger list',
'caption' => 'Lease #'.$lease['number'].' (Unit: '.$lease['Unit']['name'].')',
'suppress_alternate_rows' => true,
'headers' => $headers,
'rows' => $rows,
'row_class' => $row_class,
'column_class' => $headers));
}
?>
/* End "detail supporting" DIV */ ?>
</DIV>
</div>

View File

@@ -0,0 +1,3 @@
<div class="customers index">
<?php echo $this->element('customers', array('heading' => '<h2>'.$heading.'</h2>')) ?>
</div>

189
views/customers/view.ctp Normal file
View File

@@ -0,0 +1,189 @@
<?php /* -*- mode:PHP -*- */ ?>
<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);
}
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Customer Detail Main Section
*/
$rows = array(array('Name', $customer['Customer']['name']),
array('Comment', $customer['Customer']['comment']));
echo $this->element('table',
array('class' => 'item customer detail',
'caption' => 'Tenant Info',
'rows' => $rows,
'column_class' => array('field', 'value')));
/**********************************************************************
* Customer Info Box
*/
?>
<DIV CLASS="infobox">
<DIV CLASS="summary grand deposit">
Security Deposit: <?php echo currency($outstandingDeposit); ?>
</DIV>
<DIV CLASS="summary grand balance">
Balance: <?php echo currency($outstandingBalance); ?>
</DIV>
</DIV>
<DIV CLASS="detail supporting">
<?php
; // Editor alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Supporting Elements Section
*/
/**********************************************************************
* Contacts
*/
echo $this->element('contacts',
array('caption' => 'Customer 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));
/**********************************************************************
* Ledger History
*/
echo $this->element('ledger',
array('caption' => 'Ledger History',
'transactions' => $customer['Transaction'],
'ledger' => array('mix'=>1)));
/* End "detail supporting" DIV */ ?>
</DIV>
</div>

View File

@@ -0,0 +1,85 @@
<?php /* -*- mode:PHP -*- */
if (isset($heading))
echo $heading;
else
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) {
$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)));
$headers = array($paginator->sort('name'),
$paginator->sort('type'),
$paginator->sort('Ext. Name', 'external_name'),
$paginator->sort('Ext. Account', 'external_account'),
$paginator->sort('entries'),
$paginator->sort('debits'),
$paginator->sort('credits'),
$paginator->sort('balance'),
$paginator->sort('comment'));
}
$rows = array();
foreach ($accounts as $account) {
$extra = null;
if (isset($account[0])) {
$extra = $account[0];
unset($account[0]);
}
if (isset($account['Account']))
$account = $account['Account'];
if (isset($extra))
$account = array_merge($account, $extra);
$rows[] = array($html->link($account['name'],
array('controller' => 'accounts',
'action' => 'view',
$account['id'])),
$account['type'],
$account['external_name'],
$account['external_account'],
$account['entries'],
currency($account['debits']),
currency($account['credits']),
currency($account['balance']),
$account['comment'],
);
}
echo $this->element('table',
array('class' => 'item account list',
'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");
}

View File

@@ -1,68 +0,0 @@
<?php /* -*- mode:PHP -*- */
if (isset($heading))
echo $heading;
else
echo '<h2>'.__('Charges',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_manual = array('ID', 'Date', 'Due', 'Type', 'Lease', 'Amount', 'Comment');
if (isset($paginator)) {
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
$headers = array($paginator->sort('id'),
$paginator->sort('Date', 'charge_date'),
$paginator->sort('Due', 'due_date'),
$paginator->sort('Type', 'charge_type'),
$paginator->sort('Lease', 'number'),
$paginator->sort('total'),
$paginator->sort('comment'));
} else {
$headers = $headers_manual;
}
$rows = array();
foreach ($charges as $charge) {
$rows[] = array($html->link($charge['Charge']['id'],
array('controller' => 'charges',
'action' => 'view',
$charge['Charge']['id'])),
datefmt($charge['Charge']['charge_date']),
datefmt($charge['Charge']['due_date']),
$charge['ChargeType']['name'],
'#'.$charge['Lease']['number'],
currency($charge['Charge']['total']),
$charge['Charge']['comment'],
);
}
echo $this->element('table',
array('class' => 'item charge list',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers_manual));
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");
}

View File

@@ -2,44 +2,57 @@
if (isset($heading))
echo $heading;
else
elseif (!isset($caption))
echo '<h2>'.__('Contacts',true).'</h2>';
$headers_manual = array('Id', 'Last Name', 'First Name', 'Company', 'Comment');
$headers_manual = array_merge(array('Id', 'Last Name', 'First Name', 'Company'),
isset($contacts[0]['ContactsCustomer']) ? array('Type', 'Active') : array(),
array('Comment'));
if (isset($paginator)) {
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
$headers = array($paginator->sort('id'),
$paginator->sort('last_name'),
$paginator->sort('first_name'),
$paginator->sort('company_name'),
//$paginator->sort('unit_id'),
$paginator->sort('comment'));
$headers = array_merge(array($paginator->sort('id'),
$paginator->sort('last_name'),
$paginator->sort('first_name'),
$paginator->sort('company_name')),
(isset($contacts[0]['ContactsCustomer'])
? array($paginator->sort('type'),
$paginator->sort('active'))
: array()),
array($paginator->sort('comment')));
} else {
$headers = $headers_manual;
}
$rows = array();
foreach ($contacts as $contact) {
$rows[] = array($html->link($contact['Contact']['id'],
array('controller' => 'contacts',
'action' => 'view',
$contact['Contact']['id'])),
$html->link($contact['Contact']['last_name'],
array('controller' => 'contacts',
'action' => 'view',
$contact['Contact']['id'])),
$html->link($contact['Contact']['first_name'],
array('controller' => 'contacts',
'action' => 'view',
$contact['Contact']['id'])),
$contact['Contact']['company_name'],
$contact['Contact']['comment']);
if (isset($contact['Contact']))
$contact = $contact['Contact'];
$rows[] = array_merge(array($html->link($contact['id'],
array('controller' => 'contacts',
'action' => 'view',
$contact['id'])),
$html->link($contact['last_name'],
array('controller' => 'contacts',
'action' => 'view',
$contact['id'])),
$html->link($contact['first_name'],
array('controller' => 'contacts',
'action' => 'view',
$contact['id'])),
$contact['company_name']),
(isset($contact['ContactsCustomer'])
? array($contact['ContactsCustomer']['type'],
$contact['ContactsCustomer']['active'],
$contact['ContactsCustomer']['comment'])
: array($contact['comment'])));
}
echo $this->element('table',
array('class' => 'item contact list',
'caption' => isset($caption) ? $caption : null,
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers_manual));

View File

@@ -3,46 +3,39 @@
if (isset($heading))
echo $heading;
else
echo '<h2>'.__('Receipts',true).'</h2>';
echo '<h2>'.__('Customers',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_manual = array('Id', 'Timestamp', 'Comment');
$headers_manual = array('Id', 'Name', 'Comment');
if (isset($paginator)) {
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
$headers = array($paginator->sort('id'),
$paginator->sort('Timestamp', 'stamp'),
$paginator->sort('name'),
$paginator->sort('comment'));
} else {
$headers = $headers_manual;
}
$rows = array();
foreach ($receipts as $receipt) {
$rows[] = array($html->link($receipt['Receipt']['id'],
array('controller' => 'receipts',
foreach ($customers as $customer) {
if (isset($customer['Customer']))
$customer = $customer['Customer'];
$rows[] = array($html->link($customer['id'],
array('controller' => 'customers',
'action' => 'view',
$receipt['Receipt']['id'])),
datefmt($receipt['Receipt']['stamp']),
$receipt['Receipt']['comment']);
$customer['id'])),
$html->link($customer['name'],
array('controller' => 'customers',
'action' => 'view',
$customer['id'])),
$customer['comment']);
}
echo $this->element('table',
array('class' => 'item receipt list',
array('class' => 'item customer list',
'caption' => isset($caption) ? $caption : null,
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers_manual));

View File

@@ -1,314 +1,80 @@
<?php /* -*- mode:PHP -*- */
/* if (isset($heading)) */
/* echo $heading; */
/* else */
/* echo '<h2>'.__('Payments',true).'</h2>'; */
?>
<div class="ledger collection">
<!-- <span class="title">$caption</span> -->
<?php
; // Alignment purposes only
// Charges Only
// Payments Only
// Mixture of both (by date)
// Match both (payments match charges)
/**********************************************************************
* Charges Only
*/
if (isset($ledger['charges'])) {
$headers = array('Charge', 'Date', 'Through', 'Type', 'Comment', 'Amount', 'Balance', 'Total');
$rows = array();
$row_class = array();
$running_total = 0;
foreach($lease['Charge'] AS $charge) {
$amount = $charge['total'];
$balance = $amount;
foreach ($charge['Receipt'] AS $receipt)
$balance -= $receipt['ChargesReceipt']['amount'];
$running_total += $balance;
$rows[] = array($html->link('#'.$charge['id'],
array('controller' => 'charges',
'action' => 'view',
$charge['id'])),
datefmt($charge['charge_date']),
datefmt($charge['charge_to_date']),
$charge['ChargeType']['name'],
$charge['comment'],
currency($amount),
currency($balance),
//currency($amount - $paid));
currency($running_total));
$row_class[] = 'charge';
}
echo ('<div class="ledger history charges">' . "\n");
echo $this->element('table',
array('class' => 'item ledger list',
'caption' => $caption,
'headers' => $headers,
'rows' => $rows,
'row_class' => $row_class,
'column_class' => $headers));
echo ('</div>' . "\n");
$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[$k] = array($column_class[$k], 'id');
}
/**********************************************************************
* Receipts Only
*/
if (isset($ledger['receipts'])) {
$headers = array('Receipt', 'Date', 'Comment', 'Amount', 'Balance', 'Total');
$receipts = array();
foreach ($lease['Charge'] AS $charge) {
foreach($charge['Receipt'] AS $receipt) {
if (!isset($receipts[$receipt['id']])) {
$receipts[$receipt['id']] = $receipt;
$receipts[$receipt['id']]['amount'] = 0;
$receipts[$receipt['id']]['charge'] = 0;
foreach($receipt['Payment'] AS $payment)
$receipts[$receipt['id']]['amount'] += $payment['amount'];
unset($receipts[$receipt['id']]['ChargesReceipt']);
unset($receipts[$receipt['id']]['Payment']);
}
$receipts[$receipt['id']]['charge'] += $receipt['ChargesReceipt']['amount'];
}
}
usort($receipts,
create_function('$a, $b',
'$adate = TimeHelper::toUnix(isset($a["charge_date"]) ? $a["charge_date"] : $a["stamp"]); ' .
'$bdate = TimeHelper::toUnix(isset($b["charge_date"]) ? $b["charge_date"] : $b["stamp"]); ' .
'return strcmp($adate, $bdate);')
);
$rows = array();
$row_class = array();
$running_total = 0;
foreach ($receipts AS $receipt) {
$amount = $receipt['amount'];
$balance = $amount - $receipt['charge'];
$running_total += $balance;
$rows[] = array($html->link('#'.$receipt['id'],
array('controller' => 'receipts',
'action' => 'view',
$receipt['id'])),
datefmt($receipt['stamp']),
$receipt['comment'],
currency($amount),
currency($balance),
currency($running_total));
$row_class[] = 'receipt';
}
echo ('<div class="ledger history receipts">' . "\n");
echo $this->element('table',
array('class' => 'item ledger list',
'caption' => $caption,
'headers' => $headers,
'rows' => $rows,
'row_class' => $row_class,
'column_class' => $headers));
echo ('</div>' . "\n");
foreach (array_intersect($column_class, array('Debits', 'Credits', '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))); */
/* $headers = array('Receipt', 'Date', 'Comment', 'Amount', 'Balance', 'Total'); */
/* $rows = array(); */
/* $row_class = array(); */
/* $running_total = 0; */
/* $odd = 0; */
/* foreach($lease['Receipt'] AS $charge) { */
/* $amount = $charge['total']; */
/* $balance = $amount; */
/* foreach ($charge['Receipt'] AS $receipt) */
/* $balance -= $receipt['ChargesReceipt']['amount']; */
/* $running_total += $balance; */
/* $charge_amount = 0; */
/* $payment_amount = 0; */
/* foreach($receipt['Charge'] AS $charge) */
/* $charge_amount += $charge['ChargesReceipt']['amount']; */
/* foreach($receipt['Payment'] AS $payment) */
/* $payment_amount += $payment['amount']; */
/* foreach ($charge['Receipt'] AS $receipt) { */
/* $amount = -1 * $receipt['ChargesReceipt']['amount']; */
/* $running_total += $amount; */
/* $rows[] = array($html->link('#'.$receipt['id'], */
/* array('controller' => 'receipts', */
/* 'action' => 'view', */
/* $receipt['id'])), */
/* datefmt($receipt['stamp']), */
/* $receipt['comment'], */
/* currency($amount), */
/* currency($running_total)); */
/* $row_class[] = array('receipt', ($odd % 2) ? 'oddrow' : 'evnrow'); */
/* } */
/* $rows[] = array($html->link('#'.$charge['id'], */
/* array('controller' => 'charges', */
/* 'action' => 'view', */
/* $charge['id'])), */
/* datefmt($charge['charge_date']), */
/* datefmt($charge['charge_to_date']), */
/* $charge['ChargeType']['name'], */
/* $charge['comment'], */
/* currency($amount), */
/* currency($balance), */
/* //currency($amount - $paid)); */
/* currency($running_total)); */
/* $row_class[] = array('charge', (++$odd % 2) ? 'oddrow' : 'evnrow'); */
/* $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')); */
/* } */
/* echo ('<div class="ledger history charges">' . "\n"); */
/* echo $this->element('table', */
/* array('class' => 'item ledger list', */
/* 'caption' => $caption */
/* 'suppress_alternate_rows' => true, */
/* 'headers' => $headers, */
/* 'rows' => $rows, */
/* 'row_class' => $row_class, */
/* 'column_class' => $headers)); */
/* echo ('</div>' . "\n"); */
$rows = array();
$running_total = 0;
foreach($entries AS $entry) {
$transaction = $entry['Transaction'];
$customer = $entry['Customer'];
$credit = $debit = null;
$running_total += $entry['balance'];
/**********************************************************************
* Mixture
*/
if (isset($entry['debit']))
$debit = $entry['debit'];
if (isset($entry['credit']))
$credit = $entry['credit'];
if (isset($ledger['mix'])) {
$headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total');
// Now that we've extracted top level 'entry' data
// move our variable to the meat of 'LedgerEntry' for clarity
$entry = $entry['LedgerEntry'];
/* $mix = array_merge($lease['Charge'], $receipts); */
/* usort($mix, */
/* create_function('$a, $b', */
/* '$adate = TimeHelper::toUnix(isset($a["charge_date"]) ? $a["charge_date"] : $a["stamp"]); ' . */
/* '$bdate = TimeHelper::toUnix(isset($b["charge_date"]) ? $b["charge_date"] : $b["stamp"]); ' . */
/* 'return strcmp($adate, $bdate);') */
/* ); */
$rows = array();
$row_class = array();
$running_total = 0;
foreach ($transactions AS $transaction) {
$transaction_date = datefmt($transaction['stamp']);
if (isset($transaction['through_date']))
$transaction_date .= ' - '. datefmt($transaction['through_date']);
$comment = $transaction['comment'];
foreach ($transaction['Entry'] AS $entry) {
if ($entry['DebitAccount']['name'] === 'A/R') {
$name = $entry['CreditAccount']['name'];
$amount = $entry['amount'];
$class = 'charge';
}
elseif ($entry['CreditAccount']['name'] === 'A/R') {
$name = 'Payment';
$amount = -1 * $entry['amount'];
$class = 'payment';
}
else
continue;
$running_total += $amount;
$rows[] = array($html->link('#'.$transaction['id'],
array('controller' => 'transactions',
'action' => 'view',
$transaction['id'])),
$transaction_date,
$name,
$comment,
currency($amount),
currency($running_total));
$row_class[] = $class;
}
}
echo ('<div class="ledger history mix">' . "\n");
echo $this->element('table',
array('class' => 'item ledger list',
'caption' => $caption,
//'suppress_alternate_rows' => true,
'headers' => $headers,
'rows' => $rows,
'row_class' => $row_class,
'column_class' => $headers));
echo ('</div>' . "\n");
$rows[] = array($html->link('#'.$transaction['id'],
array('controller' => 'transactions',
'action' => 'view',
$transaction['id'])),
$html->link('#'.$entry['id'],
array('controller' => 'ledger_entries',
'action' => 'view',
$entry['id'])),
datefmt($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)
);
}
/**********************************************************************
* Match
*/
echo $this->element('table',
array('class' => 'item account ledger list',
'caption' => $caption,
'headers' => $headers,
'rows' => $rows,
'column_class' => $column_class));
if (isset($ledger['match'])) {
$headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total');
/* 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"); */
/* } */
$rows = array();
$row_class = array();
$running_total = 0;
$odd = 0;
foreach($lease['Charge'] AS $charge) {
$amount = $charge['total'];
$running_total += $amount;
$rows[] = array($html->link('#'.$charge['id'],
array('controller' => 'charges',
'action' => 'view',
$charge['id'])),
datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
$charge['ChargeType']['name'],
$charge['comment'],
currency($amount),
currency($running_total));
$row_class[] = array('charge', (++$odd % 2) ? 'oddrow' : 'evnrow');
foreach ($charge['Receipt'] AS $receipt) {
$amount = -1 * $receipt['ChargesReceipt']['amount'];
$running_total += $amount;
$rows[] = array($html->link('#'.$receipt['id'],
array('controller' => 'receipts',
'action' => 'view',
$receipt['id'])),
' -- ' . datefmt($receipt['stamp']),
'Payment Applied',
$receipt['comment'],
currency($amount),
currency($running_total));
$row_class[] = array('receipt', ($odd % 2) ? 'oddrow' : 'evnrow');
}
}
echo ('<div class="ledger history match">' . "\n");
echo $this->element('table',
array('class' => 'item ledger list',
'caption' => $caption,
'suppress_alternate_rows' => true,
'headers' => $headers,
'rows' => $rows,
'row_class' => $row_class,
'column_class' => $headers));
echo ('</div>' . "\n");
}
?>

View File

@@ -0,0 +1,77 @@
<?php /* -*- mode:PHP -*- */
if (isset($heading))
echo $heading;
elseif (!isset($caption))
echo '<h2>'.__('Ledgers',true).'</h2>';
$headers = array_merge(array('Name'),
(isset($ledgers[0]['Account'])
? array('Account')
: 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';
}
if (isset($paginator)) {
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
$headers = array_merge(array($paginator->sort('name')),
(isset($ledgers[0]['Account'])
? array($paginator->sort('Account', 'Account.name'))
: array()),
array($paginator->sort('entries'),
$paginator->sort('debits'),
$paginator->sort('credits'),
$paginator->sort('balance'),
$paginator->sort('closed'),
$paginator->sort('comment')));
}
$rows = array();
foreach ($ledgers as $ledger) {
if (isset($ledger[0]))
$ledger = array_merge($ledger[0], array_diff_key($ledger, array(0=>1)));
if (isset($ledger['Ledger']))
$ledger = array_merge($ledger['Ledger'], array_diff_key($ledger, array('Ledger'=>1)));
if (isset($ledger['Account']))
$account = $ledger['Account'];
$rows[] = array_merge(array($html->link($ledger['name'],
array('controller' => 'ledgers',
'action' => 'view',
$ledger['id']))),
(isset($ledger['Account'])
? array($html->link($account['name'],
array('controller' => 'accounts',
'action' => 'view',
$account['id'])))
: array()),
array($ledger['entries'],
currency($ledger['debits']),
currency($ledger['credits']),
currency($ledger['balance']),
$ledger['closed'] ? 'Closed' : 'Open',
$ledger['comment']));
}
echo $this->element('table',
array('class' => 'item ledger list',
'caption' => isset($caption) ? $caption : null,
'headers' => $headers,
'rows' => $rows,
'column_class' => $column_class));
if (isset($paginator)) {
echo('<div class="paging">' . "\n");
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
echo(' | ');
echo $paginator->numbers();
echo(' | ');
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
echo('</div>' . "\n");
}

View File

@@ -1,67 +0,0 @@
<?php /* -*- mode:PHP -*- */
if (isset($heading))
echo $heading;
else
echo '<h2>'.__('Payments',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_manual = array('ID', 'Type', 'Receipt', 'Amount', 'Comment');
if (isset($paginator)) {
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
$headers = array($paginator->sort('id'),
$paginator->sort('Type', 'payment_type'),
$paginator->sort('Receipt', 'receipt_id'),
$paginator->sort('amount'),
$paginator->sort('comment'));
} else {
$headers = $headers_manual;
}
$rows = array();
foreach ($payments as $payment) {
$rows[] = array($html->link($payment['Payment']['id'],
array('controller' => 'payments',
'action' => 'view',
$payment['Payment']['id'])),
$payment['PaymentType']['name'],
$html->link('#'.$payment['Receipt']['id'],
array('controller' => 'receipts',
'action' => 'view',
$payment['Receipt']['id'])),
currency($payment['Payment']['amount']),
$payment['Payment']['comment'],
);
}
echo $this->element('table',
array('class' => 'item payment list',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers_manual));
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");
}

View File

@@ -32,7 +32,7 @@ if (isset($rows) && is_array($rows) && count($rows)) {
if (!is_array($rca))
$rca = array($rca);
foreach ($rca AS &$rc)
$rc = preg_replace("/ /", "-", strtolower($rc));
$rc = preg_replace("/ /", "-", preg_replace('/\./', '', strtolower($rc)));
}
// Same prework for column_class
@@ -40,7 +40,7 @@ if (isset($rows) && is_array($rows) && count($rows)) {
if (!is_array($cca))
$cca = array($cca);
foreach ($cca AS &$cc)
$cc = preg_replace("/ /", "-", strtolower($cc));
$cc = preg_replace("/ /", "-", preg_replace('/\./', '', strtolower($cc)));
}
// Associate each cell with the appropriate class(es).

View File

@@ -0,0 +1,65 @@
<?php /* -*- mode:PHP -*- */
if (isset($heading))
echo $heading;
elseif (!isset($caption))
echo '<h2>'.__('Transactions',true).'</h2>';
$headers = array('Id', 'Timestamp', 'Comment');
$column_class = array();
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
$column_class[$k] = 'comment';
}
foreach (array_intersect($headers, array('Id')) AS $k => $v) {
$column_class[$k] = 'id';
}
if (isset($paginator)) {
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
$headers = array($paginator->sort('id'),
$paginator->sort('customer_id'),
$paginator->sort('Timestamp', 'stamp'),
$paginator->sort('Through', 'through_date'),
$paginator->sort('Due', 'due_date'),
$paginator->sort('comment'));
}
$rows = array();
foreach ($transactions as $transaction) {
$customer = $transaction['Customer'];
if (isset($transaction['Transaction']))
$transaction = $transaction['Transaction'];
$rows[] = array($html->link('#'.$transaction['id'],
array('controller' => 'transactions',
'action' => 'view',
$transaction['id'])),
$html->link($customer['name'],
array('controller' => 'customers',
'action' => 'view',
$customer['id'])),
datefmt($transaction['stamp']),
datefmt($transaction['through_date']),
datefmt($transaction['due_date']),
$transaction['comment']);
}
echo $this->element('table',
array('class' => 'item transaction list',
'caption' => isset($caption) ? $caption : null,
'headers' => $headers,
'rows' => $rows,
'column_class' => $column_class));
if (isset($paginator)) {
echo('<div class="paging">' . "\n");
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
echo(' | ');
echo $paginator->numbers();
echo(' | ');
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
echo('</div>' . "\n");
}

14
views/ledgers/index.ctp Normal file
View File

@@ -0,0 +1,14 @@
<div class="ledgers index">
<?php
function currency($number) {
if (!isset($number))
return null;
if ($number < 0)
return "($ " . number_format(-1*$number, 2) . ")";
else
return "$ " . number_format($number, 2);
}
?>
<?php echo $this->element('ledgers', array('heading' => '<h2>'.$heading.'</h2>')) ?>
</div>

98
views/ledgers/view.ctp Normal file
View File

@@ -0,0 +1,98 @@
<?php /* -*- mode:PHP -*- */ ?>
<div class="ledger view">
<?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;
}
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Ledger Detail Main Section
*/
$rows = array(array('ID', $ledger['Ledger']['id']),
array('Name', $ledger['Ledger']['name']),
array('Account', $html->link($ledger['Account']['name'],
array('controller' => 'accounts',
'action' => 'view',
$ledger['Account']['id']))),
array('Closed', $ledger['Ledger']['closed']),
array('Comment', $ledger['Ledger']['comment']));
echo $this->element('table',
array('class' => 'item ledger detail',
'caption' => 'Ledger Detail',
'rows' => $rows,
'column_class' => array('field', 'value')));
/**********************************************************************
* Ledger Info Box
*/
?>
<DIV CLASS="infobox">
<DIV CLASS="summary balance">
Ledger Balance: <?php echo currency($balance); ?>
</DIV>
</DIV>
<DIV CLASS="detail supporting">
<?php
; // Editor alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Supporting Elements Section
*/
/**********************************************************************
* Ledger
*/
echo $this->element('ledger',
array('caption' => $ledger['Ledger']['name'],
'ledger' => array('id' => $ledger['Ledger']['id'],
'type' => $ledger['Account']['type']),
'entries' => $ledger['LedgerEntry']));
/* End "detail supporting" DIV */ ?>
</DIV>
</div>

View File

@@ -1,3 +0,0 @@
<div class="payments index">
<?php echo $this->element('payments', array('heading' => '<h2>'.$heading.'</h2>')) ?>
</div>

View File

@@ -1,43 +0,0 @@
<?php /* -*- mode:PHP -*- */ ?>
<div class="payments 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);
}
/**********************************************************************
* Payment Info
*/
$rows = array(array('ID', $payment['Payment']['id']),
array('Type', $payment['PaymentType']['name']),
array('Receipt', $html->link('#'.$payment['Receipt']['id'],
array('controller' => 'receipts',
'action' => 'view',
$payment['Receipt']['id']))),
array('Amount', currency($payment['Payment']['amount'])),
array('Comment', $payment['Payment']['comment']));
echo $this->element('table',
array('class' => 'item payment detail',
'caption' => 'Payment Info',
'rows' => $rows,
'column_class' => array('field', 'value')));
?>
</div>

View File

@@ -1,3 +0,0 @@
<div class="receipts index">
<?php echo $this->element('receipts', array('heading' => '<h2>'.$heading.'</h2>')) ?>
</div>

View File

@@ -1,116 +0,0 @@
<?php /* -*- mode:PHP -*- */ ?>
<div class="receipts 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);
}
/**********************************************************************
* Receipt Info
*/
$rows = array(array('ID', $receipt['Receipt']['id']),
array('Timestamp', datefmt($receipt['Receipt']['stamp'])),
array('Comment', $receipt['Receipt']['comment']));
echo $this->element('table',
array('class' => 'item receipt detail',
'caption' => 'Receipt Info',
'rows' => $rows,
'column_class' => array('field', 'value')));
?>
<DIV CLASS="infobox receipt">
<DIV CLASS="summary grand payment">
Amount Received: <?php echo currency($paymentAmount); ?>
</DIV>
<DIV CLASS="summary grand charge">
Amount Applied: <?php echo currency($chargeAmount); ?>
</DIV>
</DIV>
<?php
/**********************************************************************
* Payments
*/
$headers = array('ID', 'Type', 'Comment', 'Amount', 'Total');
$rows = array();
$running_total = 0;
foreach($receipt['Payment'] AS $payment) {
$amount = $payment['amount'];
$running_total += $amount;
$rows[] = array($html->link('#'.$payment['id'],
array('controller' => 'payments',
'action' => 'view',
$payment['id'])),
$payment['PaymentType']['name'],
$payment['comment'],
currency($payment['amount']),
currency($running_total)
);
}
echo $this->element('table',
array('class' => 'item payment list',
'caption' => 'Payments in Receipt',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
/**********************************************************************
* Charges
*/
$headers = array('ID', 'Date', /*'Due',*/ 'Type', 'Lease', 'Comment', 'Amount' /*, 'Tax', 'Subtotal'*/, 'Applied', /*'Total'*/);
$rows = array();
$running_total = 0;
foreach($receipt['Charge'] AS $charge) {
$amount = $charge['total'];
$running_total += $amount;
$rows[] = array($html->link('#'.$charge['id'],
array('controller' => 'charges',
'action' => 'view',
$charge['id'])),
datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
//datefmt($charge['due_date']),
$charge['ChargeType']['name'],
'#'.$charge['Lease']['number'],
$charge['comment'],
//currency($charge['amount']),
//currency($charge['tax']),
currency($charge['total']),
currency($charge['ChargesReceipt']['amount']),
//currency($running_total)
);
}
echo $this->element('table',
array('class' => 'item charge list',
'caption' => 'Charges Applied Towards',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
?>
</div>

View File

@@ -0,0 +1,13 @@
<div class="transactions index">
<?php
function datefmt($date) {
$date_fmt = 'm/d/Y';
return ($date
? date_format(date_create($date), $date_fmt)
: null);
}
?>
<?php echo $this->element('transactions', array('heading' => '<h2>'.$heading.'</h2>')) ?>
</div>

102
views/transactions/view.ctp Normal file
View File

@@ -0,0 +1,102 @@
<?php /* -*- mode:PHP -*- */ ?>
<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);
}
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Transaction Detail Main Section
*/
$rows = array(array('ID', $transaction['Transaction']['id']),
array('Timestamp', datefmt($transaction['Transaction']['stamp'])),
array('Comment', $transaction['Transaction']['comment']));
echo $this->element('table',
array('class' => 'item transaction detail',
'caption' => 'Transaction Info',
'rows' => $rows,
'column_class' => array('field', 'value')));
/**********************************************************************
* Transaction Info Box
*/
?>
<DIV CLASS="infobox">
<DIV CLASS="summary grand debit">
Debits: <?php echo currency($debitAmount); ?>
</DIV>
<DIV CLASS="summary grand credit">
Credits: <?php echo currency($creditAmount); ?>
</DIV>
</DIV>
<DIV CLASS="detail supporting">
<?php
; // Editor alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Supporting Elements Section
*/
/**********************************************************************
* Entries
*/
$headers = array('Name', 'Debit', 'Credit', 'Comment', 'Amount', 'Total');
$rows = array();
$running_total = 0;
foreach($transaction['LedgerEntry'] AS $entry) {
$amount = $entry['amount'];
$running_total += $amount;
$rows[] = array($entry['name'],
$html->link($entry['DebitLedger']['name'],
array('controller' => 'ledgers',
'action' => 'view',
$entry['DebitLedger']['id'])),
$html->link($entry['CreditLedger']['name'],
array('controller' => 'ledgers',
'action' => 'view',
$entry['CreditLedger']['id'])),
$entry['comment'],
currency($entry['amount']),
currency($running_total)
);
}
echo $this->element('table',
array('class' => 'item entry list',
'caption' => 'Entries in Transaction',
'headers' => $headers,
'rows' => $rows,
'column_class' => $headers));
/* End "detail supporting" DIV */ ?>
</DIV>
</div>

View File

@@ -1,6 +1,6 @@
<?php /* -*- mode:PHP -*- */ ?>
<div class="units view">
<div class="unit view">
<?php
@@ -9,17 +9,22 @@ function 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);
}
/**********************************************************************
* Unit Info
**********************************************************************
**********************************************************************
**********************************************************************
* Unit Detail Main Section
*/
$rows = array(array('Name', $unit['Unit']['name']),
@@ -33,8 +38,12 @@ echo $this->element('table',
'column_class' => array('field', 'value')));
/**********************************************************************
* Unit Info Box
*/
?>
<DIV CLASS="infobox unit">
<DIV CLASS="infobox">
<DIV CLASS="summary grand deposit">
Security Deposit: <?php echo currency($outstandingDeposit); ?>
</DIV>
@@ -42,7 +51,17 @@ echo $this->element('table',
Balance: <?php echo currency($outstandingBalance); ?>
</DIV>
</DIV>
<DIV CLASS="detail supporting">
<?php
; // Editor alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Supporting Elements Section
*/
/**********************************************************************
@@ -52,10 +71,10 @@ $headers = array('Lease', 'Tenant', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'De
$rows = array();
foreach($unit['Lease'] AS $lease) {
$rows[] = array('#'.$lease['number'],
$html->link($lease['Contact'][0]['display_name'],
array('controller' => 'contacts',
$html->link($lease['Customer']['name'],
array('controller' => 'customers',
'action' => 'view',
$lease['Contact'][0]['id'])),
$lease['Customer']['id'])),
datefmt($lease['lease_date']),
datefmt($lease['movein_date']),
datefmt($lease['moveout_date']),
@@ -76,12 +95,15 @@ echo $this->element('table',
* Ledger History
*/
foreach($unit['Lease'] AS $lease) {
$caption = 'Lease #'.$lease['number'].' (Tenant: '.$lease['Contact'][0]['display_name'].')';
pr($lease);
$caption = 'Lease #'.$lease['number'].' (Tenant: '.$lease['Customer']['name'].')';
echo $this->element('ledger',
array('lease' => $lease,
'caption' => $caption,
'ledger' => array('charges'=>1, 'receipts'=>1, 'match'=>1, 'zmix'=>1)));
array('caption' => $caption,
'entries' => $lease['Customer']['Transaction'],
'ledger' => array('mix'=>1)));
}
?>
/* End "detail supporting" DIV */ ?>
</DIV>
</div>