Added Payment, other minor fixes

This commit is contained in:
Deon George
2011-12-20 16:46:10 +11:00
parent c8fd44f844
commit a40ce27a16
31 changed files with 452 additions and 1280 deletions

View File

@@ -1,33 +0,0 @@
<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @subpackage Modules:Invoice
*/
/**
* The main AgileBill Payment Class
*
* @package AgileBill
*/
$auth_methods = array (
);
?>

View File

@@ -0,0 +1,204 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides payment capabilities.
*
* @package OSB
* @subpackage Payment
* @category Controllers/Admin
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'add'=>TRUE,
'list'=>TRUE,
'autocomplete'=>FALSE,
'autoitemlist'=>FALSE,
);
public function action_autocomplete() {
// We are only available via an ajax call.
if (! Request::current()->is_ajax())
die();
$return = array();
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
$return += ORM::factory('account')->list_autocomplete($_REQUEST['term']);
$return += ORM::factory('invoice')->list_autocomplete($_REQUEST['term'],'account_id');
}
$this->auto_render = FALSE;
$this->response->headers('Content-Type','application/json');
$this->response->body(json_encode(array_values($return)));
}
public function action_autoitemlist() {
// We are only available via an ajax call.
if (! Request::current()->is_ajax() OR ! isset($_REQUEST['key']) OR ! trim($_REQUEST['key']))
die();
$output = View::factory('payment/admin/item/list_head');
$this->auto_render = FALSE;
$i = 0;
if (isset($_REQUEST['pid']))
foreach (ORM::factory('payment_item')->where('payment_id','=',$_REQUEST['pid'])->find_all() as $pio)
$output .= View::factory('payment/admin/item/list_body')
->set('trc',$i++%2 ? 'odd' : 'even')
->set('pio',$pio)
->set('io',$pio->invoice);
foreach (ORM::factory('account',$_REQUEST['key'])->invoices_due() as $io)
$output .= View::factory('payment/admin/item/list_body')
->set('trc',$i++%2 ? 'odd' : 'even')
->set('io',$io);
// @todo Need the JS to add up the payment allocation before submission
$output .= View::factory('payment/admin/item/list_foot')
->set('trc',$i++%2 ? 'odd' : 'even');
$this->response->body($output);
}
/**
* Show a list of invoices
*/
public function action_list() {
Block::add(array(
'title'=>_('Customer Payments'),
'body'=>Table::display(
ORM::factory('payment')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'admin/payment/add/'),
'date_payment'=>array('label'=>'Date'),
'account->accnum()'=>array('class'=>'right'),
'account->name()'=>array('label'=>'Account'),
'checkout->display("name")'=>array('label'=>'Method'),
'total_amt'=>array('label'=>'Total','class'=>'right'),
'balance(TRUE)'=>array('label'=>'Balance','class'=>'right'),
'invoicelist()'=>array('label'=>'Invoices'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'admin/payment/add',
)),
));
}
public function action_add() {
$output = '';
if (! $id = $this->request->param('id')) {
if (isset($_POST['id']) AND is_array($_POST['id']))
Table::post('payment_view','id');
list($id,$output) = Table::page('payment_view');
} else {
$id = $this->request->param('id');
}
$po = ORM::factory('payment',$id);
if ($_POST) {
if (isset($_POST['payment_item']) AND count($_POST['payment_item'])) {
foreach ($_POST['payment_item'] as $k=>$v) {
$pio = $po->add_item();
$pio->invoice_id = $k;
$pio->alloc_amt = $v;
}
}
if ($po->changed()) {
// Entry updated
if (! $po->values($_POST)->check() OR ! $po->save())
throw new Kohana_Exception('Unable to save payment');
else
SystemMessage::add(array(
'title'=>'Payment Recorded',
'type'=>'info',
'body'=>'Payment successfully recorded.',
));
}
}
$output .= Form::open();
$output .= View::factory('payment/admin/add')
->set('po',$po);;
$output .= Form::submit('submit','submit',array('class'=>'form_button'));
$output .= Form::close();
Style::add(array(
'type'=>'stdin',
'data'=>'.ui-autocomplete-loading { background: white url("'.URL::site('media/img/ui-anim_basic_16x16.gif').'") right center no-repeat; }'
));
Style::add(array(
'type'=>'file',
'data'=>'js/jquery.ui/css/smoothness/jquery-ui-1.8.16.custom.css',
));
Script::add(array(
'type'=>'file',
'data'=>'js/jquery-ui-1.8.16.custom.min.js',
));
Script::add(array('type'=>'stdin','data'=>'
$(document).ready(function() {
$("input[name=date_payment]").datepicker({
dateFormat: "@",
showOtherMonths: true,
selectOtherMonths: true,
showButtonPanel: true,
beforeShow: function(data) {
if (data.value)
data.value = data.value*1000;
},
onClose: function(data) {
$("input[name=date_payment]").val(data/1000);
}
});
$("input[name=account_id]").autocomplete({
source: "'.URL::site('admin/payment/autocomplete').'",
minLength: 2,
change: function(event,ui) {
// Send the request and update sub category dropdown
$.ajax({
type: "GET",
data: "key="+$(this).val(),
dataType: "html",
cache: false,
url: "'.URL::site('admin/payment/autoitemlist').'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("div[id=items]").replaceWith(data);
}
});
}
});
});'
));
if ($po->loaded()) {
Script::add(array('type'=>'stdin','data'=>'
$(document).ready(function() {
$("div[id=items]").load("'.URL::site('admin/payment/autoitemlist').'", {key: "'.$po->account_id.'", pid: "'.$po->id.'" });
});'
));
}
Block::add(array(
'title'=>_('Add Payments Received'),
'body'=>$output,
));
}
}
?>

View File

@@ -1,10 +1,10 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports OSB exporting by rending the exportable items.
* This class supports OSB payments.
*
* @package OSB
* @subpackage Export
* @subpackage Payment
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
@@ -34,6 +34,34 @@ class Model_Payment extends ORMOSB {
),
);
// Items belonging to an invoice
private $payment_items = array();
/**
* Return a list of invoice items for this payment.
*/
public function items() {
// If we havent been changed, we'll load the records from the DB.
if ($this->loaded() AND ! $this->_changed)
return $this->payment_item->order_by('invoice_id')->find_all()->as_array();
else
return $this->payment_items;
}
/**
* Add an item to an invoice
*/
public function add_item() {
if ($this->loaded() and ! $this->payment_items)
throw new Kohana_Exception('Need to load payment_items?');
$c = count($this->payment_items);
$this->payment_items[$c] = ORM::factory('payment_item');
return $this->payment_items[$c];
}
/**
* Find all items that are exportable.
*
@@ -103,7 +131,7 @@ class Model_Payment extends ORMOSB {
return $css.Table::display(
$this->limit(10)->find_all(),
25,
array(
array(
'id'=>array('label'=>'ID'),
'date_payment'=>array('label'=>'Date'),
'checkout->display("name")'=>array('label'=>'Method'),
@@ -111,9 +139,45 @@ class Model_Payment extends ORMOSB {
'balance(TRUE)'=>array('label'=>'Balance','class'=>'right'),
'invoicelist()'=>array('label'=>'Invoices'),
),
array(
array(
'type'=>'list',
));
}
public function save(Validation $validation = NULL) {
// Our items will be clobbered once we save the object, so we need to save it here.
$items = $this->items();
$this->source_id = Auth::instance()->get_user()->id;
$this->ip = Request::$client_ip;
// @todo Need validation, if there is an overbalance in payment_items or if an invoice is overpaid.
// Save the payment
parent::save($validation);
// Need to save the associated items and their taxes
if ($this->saved()) {
foreach ($items as $pio) {
$pio->payment_id = $this->id;
if (! $pio->check()) {
// @todo Mark payment as cancelled and write a memo, then...
throw new Kohana_Exception('Problem saving payment_item for invoice :invoice - Failed check()',array(':invoice'=>$invoice->id));
}
$pio->save();
if (! $pio->saved()) {
// @todo Mark payment as cancelled and write a memo, then...
throw new Kohana_Exception('Problem saving payment_item for invoice :invoice - Failed save()',array(':invoice'=>$invoice->id));
}
}
} else
throw new Kohana_Exception('Couldnt save payment for some reason?');
return TRUE;
}
}
?>

View File

@@ -1,241 +0,0 @@
<?php
/**
* osBilling - Open Billing Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Originally authored by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
* @license http://www.gnu.org/licenses/
* @package AgileBill
* @subpackage Modules:Payment
*/
/**
* The main AgileBill Payment Class
*
* @package AgileBill
* @subpackage Modules:Payment
*/
class payment extends OSB_module {
public function allocate($VAR) { return $this->tmAllocate($VAR); }
/**
* Template Method to support the allocation of payments to invoices
*
* @uses payment_item
* @uses invoice
*/
public function tmAllocate($VAR) {
$db = DB();
$invoices = array();
include_once(PATH_MODULES.'payment_item/payment_item.inc.php');
$pi = new payment_item;
include_once(PATH_MODULES.'invoice/invoice.inc.php');
$io = new Invoice;
# Get our payment information
$payment = $this->sPaymentsBal($VAR['payment_id']);
# If this payment has been allocated to some invoices, collect those details
$payment_items = $pi->sPaymentAllocation($VAR['payment_id']);
foreach ($io->sInvoicesBal($payment['account_id']) as $index => $details) {
$invoices[$index] = $details;
# Get additional information on the invoices to be displayed.
$invoices[$index]['id'] = $index;
$invoices[$index]['_C'] = sprintf('row%s',$i++%2 ? 1 : 2);
if (isset($payment_items[$index])) {
$invoices[$index]['alloc_amt'] = $payment_items[$index];
unset($payment_items[$index]);
}
}
# Left over payment_items are fully paid invoices
if (count($payment_items)) {
foreach ($io->sInvoicesAcc($payment['account_id'],array_keys($payment_items)) as $index => $details) {
$invoices[$index] = $details;
# Get additional information on the invoices to be displayed.
$invoices[$index]['id'] = $index;
$invoices[$index]['_C'] = sprintf('row%s',$i++%2 ? 1 : 2);
$invoices[$index]['alloc_amt'] = $payment_items[$index];
}
}
# Sort the entries
ksort($invoices);
global $smarty;
$smarty->assign('invoices',$invoices);
$smarty->assign('results',count($invoices));
}
/**
* Compare the billed_amt with the payments, and auto fix when the allocation is not correct
*/
public function taskAuditPaymentItems() {
$db = DB();
$rs = $db->Execute(sprintf('SELECT A.id,A.account_id,A.billed_amt,A.total_amt,IFNULL(A.credit_amt,0) as credit_amt,ROUND(SUM(IFNULL(B.alloc_amt,0)),4) AS alloc_amt FROM %sinvoice A LEFT OUTER JOIN %spayment_item B ON (A.id=B.invoice_id) WHERE A.site_id=%s GROUP BY A.id HAVING A.billed_amt != alloc_amt',AGILE_DB_PREFIX,AGILE_DB_PREFIX,DEFAULT_SITE));
if ($rs && $rs->RecordCount()) {
while (! $rs->EOF) {
$db->Execute(sqlUpdate('invoice',array('billed_amt'=>$rs->fields['alloc_amt']),array('where'=>array('id'=>$rs->fields['id']))));
# Add a memo
$db->Execute(sqlInsert($db,'invoice_memo',array('date_orig'=>time(),'invoice_id'=>$rs->fields['id'],'account_id'=>$rs->fields['account_id'],'type'=>'audit','memo'=>sprintf('Payments applied to this invoice have been changed, due to over allocation, was: %3.2f, payments applied: %3.2f, credits applied: %3.2f',$rs->fields['billed_amt'],$rs->fields['alloc_amt'],$rs->fields['credit_amt']))));
$rs->MoveNext();
}
}
}
public function ListUnbalanced($VAR) { return $this->tmListUnbalanced($VAR); }
/**
* List all invoices that are out of balance with the payment tables.
*
* @return void
*/
public function tmListUnbalanced() {
global $smarty;
$db = DB();
$smart = array();
$counter = 0;
$rs = $db->Execute(sprintf('SELECT B.payment_id AS id,A.account_id,B.invoice_id,A.billed_amt,A.total_amt,IFNULL(A.credit_amt,0) as credit_amt,B.payment_id,ROUND(SUM(IFNULL(B.alloc_amt,0)),4) AS alloc_amt,A.date_orig FROM %sinvoice A LEFT OUTER JOIN %spayment_item B ON (A.id=B.invoice_id) WHERE A.site_id=%s GROUP BY A.id HAVING A.billed_amt != alloc_amt OR A.total_amt < A.billed_amt ORDER BY A.account_id,A.id',AGILE_DB_PREFIX,AGILE_DB_PREFIX,DEFAULT_SITE));
if ($rs && $rs->RecordCount()) {
while (! $rs->EOF) {
$rs->fields['_C'] = ++$counter%s ? 'row1' : 'row2';
array_push($smart,$rs->fields);
$rs->MoveNext();
}
}
$smarty->assign('results',count($smart));
$smarty->assign('limit',count($smart));
$smarty->assign('search_show',$smart);
}
public function ListUnallocated($VAR) { return $this->tmListUnallocated($VAR); }
/**
* Return payments that still have unallocated balances
*
* @return void
* @uses invoice
*/
public function tmListUnallocated($VAR) {
global $smarty;
require_once(PATH_MODULES.'invoice/invoice.inc.php');
$io = new invoice;
$accounts = $io->sAccountsBal();
$smart = array();
$counter = 0;
foreach ($this->sPaymentsBal() as $payment) {
$payment['_C'] = ++$counter%s ? 'row1' : 'row2';
$payment['balance'] = $payment['total_amt']-$payment['alloc_amt'];
$payment['acct_bal'] = isset($accounts[$payment['account_id']]) ? $accounts[$payment['account_id']] : 0;
array_push($smart,$payment);
}
$smarty->assign('results',count($smart));
$smarty->assign('limit',count($smart));
$smarty->assign('search_show',$smart);
}
public function ListInvoicesBalance($VAR) { return $this->tmListInvoicesBalance($VAR); }
public function tmListInvoicesBalance($VAR) {
global $smarty;
$smart = array();
$counter = 0;
foreach ($this->sAccountsBal() as $account_id => $invoices) {
foreach ($invoices as $index => $values) {
$smart[$index] = $values;
$smart[$index]['_C'] = ++$counter%s ? 'row1' : 'row2';
}
}
$smarty->assign('results',count($smart));
$smarty->assign('limit',count($smart));
$smarty->assign('search_show',$smart);
}
/**
* Return a list of payments with an unallocated balance
*
* @param $payment_id Return only this payment ID, otherwise return all payment IDs.
* @return array Payments with a unallocated balance
*/
public function sPaymentsBal($payment_id=null) {
static $sPaymentsBal = array();
if (! count($sPaymentsBal) || (! is_null($payment_id) && ! isset($sPaymentsBal[$payment_id]))) {
$db = &DB();
$rs = $db->Execute(sprintf('SELECT A.id,A.account_id,A.total_amt,ROUND(SUM(IFNULL(B.alloc_amt,0)),4) AS alloc_amt,A.date_orig FROM %spayment A LEFT OUTER JOIN %spayment_item B ON (B.payment_id=A.id) WHERE A.site_id=%s GROUP BY (A.id) HAVING %s alloc_amt != A.total_amt ORDER BY A.account_id',
AGILE_DB_PREFIX,AGILE_DB_PREFIX,DEFAULT_SITE,is_null($payment_id) ? '' : sprintf('A.id=%s OR',$payment_id)));
if ($rs && $rs->RecordCount()) {
while (! $rs->EOF) {
$sPaymentsBal[$rs->fields['id']]['id'] = $rs->fields['id'];
$sPaymentsBal[$rs->fields['id']]['account_id'] = $rs->fields['account_id'];
$sPaymentsBal[$rs->fields['id']]['total_amt'] = $rs->fields['total_amt'];
$sPaymentsBal[$rs->fields['id']]['alloc_amt'] = $rs->fields['alloc_amt'];
$sPaymentsBal[$rs->fields['id']]['date_orig'] = $rs->fields['date_orig'];
$rs->MoveNext();
}
}
}
return (is_null($payment_id) ? $sPaymentsBal : (isset($sPaymentsBal[$payment_id]) ? $sPaymentsBal[$payment_id] : array()));
}
/**
* Return a list of invoices with unbalanced payments
*
* @param $account_id Return invoices with unbalanced payments for an account, otherwise return all accounts
* @return array Invoices with unbalanced payments
*/
public function sAccountsBal($account_id) {
static $sAccountsBal = array();
if (! count($sAccountsBal) || (! is_null($account_id) && ! isset($sAccountsBal[$account_id]))) {
$db = &DB();
$rs = $db->Execute(sprintf('SELECT A.id,A.account_id,A.total_amt,A.billed_amt,IFNULL(A.credit_amt,0) as credit_amt,ROUND(SUM(IFNULL(B.alloc_amt,0)),4) AS alloc_amt,A.date_orig,B.payment_id FROM %sinvoice A INNER JOIN %spayment_item B ON (B.invoice_id=A.id) WHERE A.site_id=%s GROUP BY (A.id) HAVING %s A.total_amt!=alloc_amt+credit_amt ORDER BY A.account_id,A.id',
AGILE_DB_PREFIX,AGILE_DB_PREFIX,DEFAULT_SITE,is_null($account_id) ? '' : sprintf('A.account_id=%s AND',$account_id)));
if ($rs && $rs->RecordCount()) {
while (! $rs->EOF) {
$sAccountsBal[$rs->fields['account_id']][$rs->fields['id']]['id'] = $rs->fields['payment_id'];
$sAccountsBal[$rs->fields['account_id']][$rs->fields['id']]['invoice_id'] = $rs->fields['id'];
$sAccountsBal[$rs->fields['account_id']][$rs->fields['id']]['account_id'] = $rs->fields['account_id'];
$sAccountsBal[$rs->fields['account_id']][$rs->fields['id']]['total_amt'] = $rs->fields['total_amt'];
$sAccountsBal[$rs->fields['account_id']][$rs->fields['id']]['alloc_amt'] = $rs->fields['alloc_amt'];
$sAccountsBal[$rs->fields['account_id']][$rs->fields['id']]['date_orig'] = $rs->fields['date_orig'];
$rs->MoveNext();
}
}
}
return (is_null($account_id) ? $sAccountsBal : (isset($sAccountsBal[$account_id]) ? $sAccountsBal[$account_id] : array()));
}
}
?>

View File

@@ -1,248 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<!-- Module name -->
<module>payment</module>
<!-- Module supporting database table -->
<table>payment</table>
<!-- Module dependancy(s) (module wont install if these modules are not yet installed) -->
<dependancy>invoice</dependancy>
<!-- DB cache in seconds -->
<cache>0</cache>
<!-- Default order_by field for SQL queries -->
<order_by>date_orig</order_by>
<!-- Default SQL limit for SQL queries -->
<limit>25</limit>
<!-- Schema version (used to determine if the schema has change during upgrades) -->
<version>1</version>
<!-- Database indexes -->
<index>
</index>
<!-- Database fields -->
<field>
<!-- Record ID -->
<id>
<display>Payment</display>
<index>1</index>
<type>I4</type>
<unique>1</unique>
</id>
<!-- Site ID -->
<site_id>
<index>1</index>
<type>I4</type>
</site_id>
<!-- Date record created -->
<date_orig>
<convert>date-now</convert>
<display>Date Created</display>
<type>I8</type>
</date_orig>
<!-- Date record updated -->
<date_last>
<convert>date-now</convert>
<display>Date Updated</display>
<type>I8</type>
</date_last>
<!-- The account this payment belongs to -->
<account_id>
<asso_table>account</asso_table>
<asso_field>first_name,last_name</asso_field>
<type>I8</type>
<validate>any</validate>
</account_id>
<!-- Date Payment -->
<date_payment>
<convert>date-time</convert>
<display>Payment Date</display>
<type>I8</type>
</date_payment>
<!-- Checkout plugin for this payment -->
<checkout_plugin_id>
<asso_table>checkout</asso_table>
<asso_field>name</asso_field>
<display>Checkout Plugin</display>
<type>I4</type>
<validate>any</validate>
</checkout_plugin_id>
<!-- Checkout plugin data -->
<checkout_plugin_data>
<type>C(255)</type>
<convert>array</convert>
</checkout_plugin_data>
<!-- Gross payment amount (local currency) -->
<total_amt>
<type>F</type>
<validate>float</validate>
</total_amt>
<!-- Payment Fees (local currency) -->
<fees_amt>
<type>F</type>
</fees_amt>
<!-- The local currency for this payment -->
<billed_currency_id>
<type>I4</type>
</billed_currency_id>
<!-- The amount in billed_currency that was made -->
<actual_total_amt>
<type>F</type>
</actual_total_amt>
<!-- The currency this payment was paid -->
<actual_billed_currency_id>
<type>I4</type>
</actual_billed_currency_id>
<!-- Payment has been refunded when STATUS = 1 -->
<refund_status>
<display>Refund Status</display>
<type>L</type>
</refund_status>
<!-- Account who made payment -->
<source_id>
<asso_table>account</asso_table>
<asso_field>username</asso_field>
<display>Source</display>
<type>I8</type>
<validate>any</validate>
</source_id>
<!-- Whether payment has been cleared -->
<pending_status>
<display>Pending</display>
<type>L</type>
</pending_status>
<!-- IP Address of Client -->
<notes>
<type>X</type>
</notes>
<!-- IP Address of Client -->
<ip>
<type>C(32)</type>
</ip>
</field>
<!-- Methods for this class, and the fields they have access to, if applicable -->
<method>
<add>account_id,date_payment,checkout_plugin_id,total_amt,fees_amt,notes,source_id</add>
<update>account_id,date_payment,checkout_plugin_id,total_amt,fees_amt,notes,pending_status</update>
<search>id,account_id,date_payment,checkout_plugin_id,total_amt,source_id</search>
<view>id,date_orig,account_id,date_payment,checkout_plugin_id,total_amt,fees_amt,notes,source_id</view>
</method>
<!-- Method triggers -->
<trigger></trigger>
<!-- Template page display titles -->
<title>
<view>Payment</view>
</title>
<!-- Template helpers -->
<tpl>
<search_show>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<account_id>
<field>account_id</field>
</account_id>
<source_id>
<field>source_id</field>
</source_id>
<checkout_plugin_id>
<field>checkout_plugin_id</field>
</checkout_plugin_id>
<date_payment>
<field>date_payment</field>
<type>date</type>
</date_payment>
<total_amt>
<field>total_amt</field>
<type>currency</type>
</total_amt>
</search_show>
<user_search_show>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<id>
<field>id</field>
</id>
<date_payment>
<field>date_orig</field>
<type>date</type>
</date_payment>
<total_amt>
<field>total_amt</field>
<type>currency</type>
</total_amt>
</user_search_show>
<ListUnallocated>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<id>
<field>id</field>
</id>
<account_id>
<field>account_id</field>
</account_id>
<date_payment>
<field>date_orig</field>
<type>date</type>
</date_payment>
<total_amt>
<field>total_amt</field>
<type>currency</type>
</total_amt>
<alloc_amt>
<field>alloc_amt</field>
<type>currency</type>
</alloc_amt>
<balance>
<field>balance</field>
<type>currency</type>
</balance>
<acct_bal>
<field>acct_bal</field>
</acct_bal>
</ListUnallocated>
<ListUnbalanced>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<id>
<field>id</field>
</id>
<account_id>
<field>account_id</field>
</account_id>
<invoice_id>
<field>invoice_id</field>
</invoice_id>
<date_payment>
<field>date_orig</field>
<type>date</type>
</date_payment>
<total_amt>
<field>total_amt</field>
<type>currency</type>
</total_amt>
<billed_amt>
<field>billed_amt</field>
<type>currency</type>
</billed_amt>
<alloc_amt>
<field>alloc_amt</field>
<type>currency</type>
</alloc_amt>
</ListUnbalanced>
</tpl>
</construct>

View File

@@ -1,61 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<!-- Tree Menu Module Properties -->
<module_properties>
<!-- MODULE Dependancy, this module wont be installed if the dependant modules dont exist -->
<dependancy></dependancy>
<!-- Translated display to use on the tree -->
<display>Payment</display>
<!-- Display a module in the menu tree -->
<menu_display>1</menu_display>
<!-- MODULE Name -->
<name>payment</name>
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
<notes><![CDATA[This module records payments to invoices]]></notes>
<!-- MODULE Parent, the parent node in the tree -->
<parent>invoice</parent>
<!-- SUB Modules to install with this one -->
<sub_modules></sub_modules>
<!-- MODULE Type (core|base), core modules cannot be deleted, unrecognised types are ignored. -->
<type></type>
</module_properties>
<!-- Tree Menu & Module Methods to load, they will be assigned the group permissions on install time, as selected by the user. -->
<module_method>
<add>
<display>Add</display>
<menu_display>1</menu_display>
<name>add</name>
<notes><![CDATA[Add records]]></notes>
</add>
<delete>
<name>delete</name>
<notes><![CDATA[Delete records]]></notes>
</delete>
<search>
<display>List</display>
<menu_display>1</menu_display>
<name>search</name>
<notes><![CDATA[List records]]></notes>
<page><![CDATA[core:search&module=%%&_next_page_one=view]]></page>
</search>
<search_form>
<display>Search</display>
<menu_display>1</menu_display>
<name>search_form</name>
<notes><![CDATA[Search for records]]></notes>
</search_form>
<search_show>
<name>search_show</name>
<notes><![CDATA[Show the results of a search]]></notes>
</search_show>
<update>
<name>update</name>
<notes><![CDATA[Update a record]]></notes>
</update>
<view>
<name>view</name>
<notes><![CDATA[View a record]]></notes>
</view>
</module_method>
</install>

View File

@@ -0,0 +1,35 @@
<table width="100%" border="0">
<tr>
<td>
<table class="box-full">
<tr>
<td style="width: 25%;">Payment Date</td>
<td style="width: 75%;"><?php echo Form::input('date_payment',$po->date_payment); ?></td>
</tr>
<tr>
<td>Account</td>
<td><?php echo Form::input('account_id',$po->account_id); ?></td>
</tr>
<tr>
<td>Method</td>
<td><?php echo StaticList_Module::form('checkout_plugin_id','checkout',$po->checkout_plugin_id,'id','name',array('active'=>'=:1'),TRUE,array('class'=>'form_button'));?></td>
</tr>
<tr>
<td>Amount</td>
<td><?php echo Form::input('total_amt',$po->total_amt); ?></td>
</tr>
<tr>
<td>Fees</td>
<td><?php echo Form::input('fees_amt',$po->fees_amt); ?></td>
</tr>
<tr>
<td>Notes</td>
<td><?php echo Form::input('notes',$po->notes); ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><div id='items'></div></td>
</tr>
</table>

View File

@@ -0,0 +1,9 @@
<tr class="<?php echo $trc; ?>">
<td><?php echo $io->id(); ?></td>
<td><?php echo $io->display('date_orig'); ?></td>
<td><?php echo $io->display('due_date'); ?></td>
<td><?php echo $io->total(TRUE); ?></td>
<td><?php echo $io->payments_total(TRUE); ?></td>
<td><?php echo $io->due(TRUE); ?></td>
<td><?php echo Form::input('payment_item['.$io->id.']',$pio->alloc_amt); ?></td>
</tr>

View File

@@ -0,0 +1,7 @@
<tr class="<?php echo $trc; ?>">
<td colspan="5">&nbsp;</td>
<td class="head">Unapplied</td>
<td><?php echo Form::input('invoice_item[excess]','',array('disabled'=>'disabled')); ?></td>
</tr>
</table>
</div>

View File

@@ -0,0 +1,11 @@
<div id="items">
<table class="box-full">
<tr>
<td class="head">Invoice</td>
<td class="head">Date Issue</td>
<td class="head">Date Due</td>
<td class="head">Total</td>
<td class="head">Payments</td>
<td class="head">Due</td>
<td class="head">Alloc</td>
</tr>