'.__('Payments',true).''; */ ?>
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 ('
' . "\n"); echo $this->element('table', array('class' => 'item ledger list', 'caption' => $caption, 'headers' => $headers, 'rows' => $rows, 'row_class' => $row_class, 'column_class' => $headers)); echo ('
' . "\n"); } /********************************************************************** * 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 ('
' . "\n"); echo $this->element('table', array('class' => 'item ledger list', 'caption' => $caption, 'headers' => $headers, 'rows' => $rows, 'row_class' => $row_class, 'column_class' => $headers)); echo ('
' . "\n"); } /* $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'); */ /* } */ /* echo ('
' . "\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 ('
' . "\n"); */ /********************************************************************** * Mixture */ if (isset($ledger['mix'])) { $headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total'); /* $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 ('
' . "\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 ('
' . "\n"); } /********************************************************************** * Match */ if (isset($ledger['match'])) { $headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total'); $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 ('
' . "\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 ('
' . "\n"); }