diff --git a/application/classes/Config.php b/application/classes/Config.php
index 39318a9e..32c7c434 100644
--- a/application/classes/Config.php
+++ b/application/classes/Config.php
@@ -65,7 +65,7 @@ class Config extends Kohana_Config {
}
public static function date($date) {
- return is_null($date) ? ' ' : date(Company::instance()->date_format(),$date);
+ return is_null($date) ? '' : date(Company::instance()->date_format(),$date);
}
/**
diff --git a/application/classes/Controller/Admin/Welcome.php b/application/classes/Controller/Admin/Welcome.php
index 70da6455..2cdef842 100644
--- a/application/classes/Controller/Admin/Welcome.php
+++ b/application/classes/Controller/Admin/Welcome.php
@@ -89,8 +89,8 @@ class Controller_Admin_Welcome extends Controller_Welcome {
'account->accnum()'=>array('label'=>'Num'),
'account->name()'=>array('label'=>'Account'),
'account->display("status")'=>array('label'=>'Active'),
- 'id'=>array('label'=>'ID','url'=>URL::link('admin','payment/view/')),
- 'total_amt'=>array('label'=>'Total','class'=>'right'),
+ 'id'=>array('label'=>'ID','url'=>URL::link('admin','payment/edit/')),
+ 'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
'balance(TRUE)'=>array('label'=>'Balance','class'=>'right'),
),
array('show_other'=>'balance()')),
diff --git a/application/classes/Controller/User/Search.php b/application/classes/Controller/User/Search.php
index 96c56023..b0698fcf 100644
--- a/application/classes/Controller/User/Search.php
+++ b/application/classes/Controller/User/Search.php
@@ -29,7 +29,6 @@ class Controller_User_Search extends Controller_Search {
$result = Arr::merge($result,ORM::factory($o)->list_autocomplete($_REQUEST['term'],'url','service_id',array('SVC %s: %s'=>array('service_id','service_name()')),array(),array('urlprefix'=>'u/service/view/')));
}
- $this->auto_render = FALSE;
$this->response->headers('Content-Type','application/json');
$this->response->body(json_encode(array_values($result)));
}
diff --git a/application/classes/Kohana.php b/application/classes/Kohana.php
index 4664ef92..49c75692 100644
--- a/application/classes/Kohana.php
+++ b/application/classes/Kohana.php
@@ -34,13 +34,14 @@ abstract class Kohana extends Kohana_Core {
if (! in_array($dir,$dirs) OR PHP_SAPI === 'cli')
return parent::find_file($dir,$file,$ext,$array);
+ $prefixes = array('');
+
// Our search order.
- $prefixes = array(
- sprintf('site/%s/%s/',Config::siteid(),Config::theme()),
- sprintf('site/%s/',Config::siteid()),
- Config::theme().'/',
- '',
- );
+ if (! preg_match('/^theme\//',$file)) {
+ array_unshift($prefixes,Config::theme().'/');
+ array_unshift($prefixes,sprintf('site/%s/',Config::siteid()));
+ array_unshift($prefixes,sprintf('site/%s/%s/',Config::siteid(),Config::theme()));
+ }
foreach ($prefixes as $p)
if ($x = parent::find_file($dir,$p.$file,$ext,$array))
diff --git a/application/classes/Model/Account.php b/application/classes/Model/Account.php
index 892b7ffe..9eccad9a 100644
--- a/application/classes/Model/Account.php
+++ b/application/classes/Model/Account.php
@@ -13,6 +13,7 @@ class Model_Account extends Model_Auth_UserDefault {
// Relationships
protected $_has_many = array(
'user_tokens' => array('model' => 'user_token'),
+ 'service_billing' => array('far_key'=>'id'),
'email_log' => array('far_key'=>'id'),
'group' => array('through' => 'account_group'),
'invoice' => array('far_key'=>'id'),
@@ -132,10 +133,7 @@ class Model_Account extends Model_Auth_UserDefault {
* Return an account name
*/
public function name($withcompany=FALSE) {
- if ($withcompany)
- return sprintf('%s %s%s',$this->first_name,$this->last_name,$this->company ? sprintf(' (%s)',$this->company) : '');
- else
- return sprintf('%s %s',$this->first_name,$this->last_name);
+ return trim(sprintf('%s %s',$this->first_name,$this->last_name).(($withcompany AND $this->company) ? sprintf(' (%s)',$this->company) : ''));
}
/**
diff --git a/application/classes/ORM.php b/application/classes/ORM.php
index a80fa536..10fdfff2 100644
--- a/application/classes/ORM.php
+++ b/application/classes/ORM.php
@@ -31,6 +31,17 @@ abstract class ORM extends Kohana_ORM {
if (! in_array($this->_table_name,ORM::$no_site_id_tables))
$this->where($this->_object_name.'.site_id','=',Company::instance()->site());
+ // Ensure we Cache our queries
+ $caching = FALSE;
+ foreach ($this->_db_pending as $method)
+ if ($method['name'] == 'cached') {
+ $caching = TRUE;
+ break;
+ }
+
+ if (! $caching)
+ $this->cached(Kohana::$config->load('cache.orm.'.$this->_table_name));
+
return parent::_build($type);
}
diff --git a/application/config/cache.php b/application/config/cache.php
new file mode 100644
index 00000000..bb07e690
--- /dev/null
+++ b/application/config/cache.php
@@ -0,0 +1,34 @@
+array(
+ 'account'=>10,
+ 'account_log'=>86400,
+ 'account_group'=>60,
+ 'country'=>86400,
+ 'currency'=>86400,
+ 'invoice'=>60,
+ 'invoice_item'=>60,
+ 'invoice_item_tax'=>60,
+ 'service'=>60,
+ 'group'=>86400,
+ 'language'=>86400,
+ 'payment'=>60,
+ 'payment_item'=>60,
+ 'module'=>86400,
+ 'module_method'=>86400,
+ 'setup'=>86400,
+ ),
+);
+?>
diff --git a/application/media/js/custom.js b/application/media/js/custom.js
index e69de29b..ac8e5ab6 100644
--- a/application/media/js/custom.js
+++ b/application/media/js/custom.js
@@ -0,0 +1,16 @@
+var search = _.debounce(function(url,query,process){
+ $.get(site_url+url,{term: query},function(data) {
+ users = {};
+ userLabels = [];
+
+ _.each(data,function(item,ix,list) {
+ if (_.contains(users,item.label))
+ item.label = item.label + ' #' + item.value;
+
+ userLabels.push(item.label);
+ users[item.label] = item.value;
+ });
+
+ process(userLabels);
+ })
+}, 300);
diff --git a/application/media/js/search.js b/application/media/js/search.js
index adc2fd41..7605033b 100644
--- a/application/media/js/search.js
+++ b/application/media/js/search.js
@@ -2,7 +2,7 @@ $(document).ready(function() {
$("input[name=search-query]").typeahead({
minLength: 2,
source: function (query,process) {
- search (query,process);
+ search('u/search/ajaxlist',query,process);
},
matcher: function () { return true; },
@@ -12,21 +12,3 @@ $(document).ready(function() {
},
});
});
-
-var search = _.debounce(function( query, process ){
- $.get(site_url+"/u/search/ajaxlist", {term: query}, function (data) {
- users = {};
- userLabels = [];
-
- _.each( data, function( item, ix, list ){
- if ( _.contains( users, item.label ) ){
- item.label = item.label + ' #' + item.value;
- }
-
- userLabels.push( item.label );
- users[ item.label ] = item.value;
- });
-
- process( userLabels );
- })
-}, 300);
diff --git a/modules/checkout/classes/Checkout/Plugin/Paypal.php b/modules/checkout/classes/Checkout/Plugin/Paypal.php
index 2daf3b26..6ccaa659 100644
--- a/modules/checkout/classes/Checkout/Plugin/Paypal.php
+++ b/modules/checkout/classes/Checkout/Plugin/Paypal.php
@@ -135,7 +135,7 @@ abstract class Checkout_Plugin_Paypal extends Checkout_Plugin {
}
- $po->add_item($cio->module_item)->alloc_amt = $cno->data['mc_gross_'.$c];
+ $po->old_add_item($cio->module_item)->alloc_amt = $cno->data['mc_gross_'.$c];
break;
diff --git a/modules/export/classes/Export/Plugin/Quicken.php b/modules/export/classes/Export/Plugin/Quicken.php
index 8f6bb934..51a18e39 100644
--- a/modules/export/classes/Export/Plugin/Quicken.php
+++ b/modules/export/classes/Export/Plugin/Quicken.php
@@ -215,7 +215,7 @@ class Export_Plugin_Quicken extends Export_Plugin {
$payment['NAME'] = $po->account->company ? $po->account->company : sprintf('%s %s',$po->account->last_name,$po->account->first_name);
- $payment['MEMO'] = sprintf('Payment for invoice(s) %s (%s)',implode(':',$po->invoices()),$po->checkout->name);
+ $payment['MEMO'] = sprintf('Payment for invoice(s) %s (%s)',$po->invoicelist(),$po->checkout->name);
// @todo Accounts/Payment should be configurable
switch ($po->checkout->plugin) {
diff --git a/modules/host/classes/Controller/Admin/Host.php b/modules/host/classes/Controller/Admin/Host.php
index 8fe3f18f..54739974 100644
--- a/modules/host/classes/Controller/Admin/Host.php
+++ b/modules/host/classes/Controller/Admin/Host.php
@@ -17,8 +17,6 @@ class Controller_Admin_Host extends Controller_TemplateDefault_Admin {
);
public function action_ajaxmanage() {
- $this->auto_render = FALSE;
-
$hso = ORM::factory('Host_Server',$this->request->param('id'));
$k = Session::instance()->get_once('manage_button');
diff --git a/modules/invoice/classes/Model/Invoice.php b/modules/invoice/classes/Model/Invoice.php
index 3ac5f0be..94c02b50 100644
--- a/modules/invoice/classes/Model/Invoice.php
+++ b/modules/invoice/classes/Model/Invoice.php
@@ -39,6 +39,7 @@ class Model_Invoice extends ORM_OSB implements Cartable {
// Items belonging to an invoice
private $invoice_items = array();
+ private $invoice_items_unsorted = TRUE;
/** INTERFACE REQUIREMENTS **/
public function cart_item() {
@@ -52,34 +53,22 @@ class Model_Invoice extends ORM_OSB implements Cartable {
return count(Cart::instance()->get($this->mid(),$this->id));
}
- public function __construct($id = NULL) {
- // Load our Model
- parent::__construct($id);
+ /**
+ * Intercept our object load, so that we can load our subitems
+ */
+ protected function _load_values(array $values) {
+ parent::_load_values($values);
- // Autoload our Sub Items
- if ($this->loaded())
- $this->_load_sub_items();
+ if ($this->_loaded)
+ $this->invoice_items = $this->invoice_item->find_all()->as_array();
return $this;
}
- /**
- * Load our invoice items
- * We need these so that we can calculate totals, etc
- */
- private function _load_sub_items() {
- // Load our sub items
- $this->invoice_items = $this->invoice_item->find_all()->as_array();
- }
-
/**
* Add an item to an invoice
*/
public function add_item(Model_Invoice_Item $iio=NULL) {
- // Just to check if an invoice is called from the DB, that it should have items with it.
- if ($this->loaded() and ! $this->invoice_items)
- throw HTTP_Exception::factory(501,'Need dto load invoice_items?');
-
// @todo This is the old calling of this function, which should be removed
if (is_null($iio)) {
$c = count($this->invoice_items);
@@ -566,10 +555,6 @@ class Model_Invoice extends ORM_OSB implements Cartable {
public function total($format=FALSE) {
$result = 0;
- // @todo - This should be required, but during checkout payment processing $pio->invoice->total() showed no invoice items?
- if ($this->loaded() AND ! count($this->items()))
- $this->_load_sub_items();
-
// This will include charges and credits
foreach ($this->items() as $ito)
$result += $ito->total();
diff --git a/modules/invoice/views/invoice/user/view/body.php b/modules/invoice/views/invoice/user/view/body.php
index 8f0bee7c..09fed5e1 100644
--- a/modules/invoice/views/invoice/user/view/body.php
+++ b/modules/invoice/views/invoice/user/view/body.php
@@ -1,8 +1,8 @@
-
- items_periods() as $rs) : ?>
- |
+ items_periods() as $rs) : ?>
+ |
+
items_periods($rs) as $iio) : ?>
service_id) : ?>
@@ -31,6 +31,7 @@
-
-
+
+
+
diff --git a/modules/payment/classes/Controller/Admin/Payment.php b/modules/payment/classes/Controller/Admin/Payment.php
index 07793691..8f5eae24 100644
--- a/modules/payment/classes/Controller/Admin/Payment.php
+++ b/modules/payment/classes/Controller/Admin/Payment.php
@@ -9,229 +9,195 @@
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
-class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
+class Controller_Admin_Payment extends Controller_Payment {
protected $secure_actions = array(
'add'=>TRUE,
'addbulk'=>TRUE,
- 'list'=>TRUE,
- 'view'=>TRUE,
- 'ajaxlist'=>FALSE,
- 'autoitemlist'=>FALSE,
+ 'ajaxitemlist'=>TRUE,
+ 'ajaxlist'=>TRUE,
+ 'edit'=>TRUE,
);
+ public function action_add() {
+ Block::factory()
+ ->type('form-horizontal')
+ ->title('Add/View Payment')
+ ->title_icon('icon-wrench')
+ ->body($this->add_edit());
+ }
+
+ public function action_addbulk() {
+ $output = '';
+
+ if ($_POST AND isset($_POST['payer'])) {
+ $c = Kohana::classname('Payment_Bulk_'.$_POST['payer']);
+ $o = new $c();
+
+ $output .= (! $_FILES) ? $o->form() : $o->process();
+
+ // We dont know what sort of payment type yet
+ } else {
+ $output .= Form::open();
+ $output .= Form::select('payer',$this->templates());
+ $output .= Form::button('submit','Submit',array('class'=>'btn btn-primary'));
+ $output .= Form::close();
+ }
+
+ Block::factory()
+ ->title('Bulk Payments Received')
+ ->title_icon('icon-share')
+ ->body($output);
+ }
+
+ /**
+ * Return rendered invoices paid by this payment, and outstanding invoices
+ */
+ public function action_ajaxitemlist() {
+ $invoices = array();
+
+ // Get our invoices paid by this payment ID
+ $po = ORM::factory('Payment',isset($_REQUEST['pid']) ? $_REQUEST['pid'] : NULL);
+
+ // Get all our other outstanding invoices
+ foreach (ORM::factory('Account',$_REQUEST['key'])->invoices_due() as $io) {
+ $pio = $po->payment_item;
+ $pio->invoice_id = $io->id;
+
+ $po->add_item($pio);
+ }
+
+ $this->response->body(View::factory('payment/admin/ajaxitemlist')
+ ->set('o',$po));
+ }
+
public function action_ajaxlist() {
$result = array();
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
- $result += ORM::factory('Account')->list_autocomplete($_REQUEST['term']);
- $result += ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'account_id');
+ $result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'id','id',array('ACC %s: %s'=>array('id','name(TRUE)'))));
+ $result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'id','account_id',array('INV %s: %s'=>array('id','account->name(TRUE)'))));
}
- $this->auto_render = FALSE;
$this->response->headers('Content-Type','application/json');
$this->response->body(json_encode(array_values($result)));
}
- 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($this->viewpath().'/head');
- $this->auto_render = FALSE;
-
- $i = 0;
- $list = array();
- if (isset($_REQUEST['pid']))
- foreach (ORM::factory('Payment',$_REQUEST['pid'])->items() as $pio) {
- $output .= View::factory($this->viewpath().'/body')
- ->set('trc',$i++%2 ? 'odd' : 'even')
- ->set('pio',$pio)
- ->set('io',$pio->invoice);
-
- // Remember the invoices we have listed
- array_push($list,$pio->invoice_id);
- }
-
- foreach (ORM::factory('Account',$_REQUEST['key'])->invoices_due() as $io)
- // Only list invoices not yet listed
- if (! in_array($io->id,$list))
- $output .= View::factory($this->viewpath().'/body')
- ->set('trc',$i++%2 ? 'odd' : 'even')
- ->set('pio',ORM::factory('Payment_Item'))
- ->set('io',$io);
-
- // @todo Need the JS to add up the payment allocation before submission
- $output .= View::factory($this->viewpath().'/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'=>URL::link('admin','payment/view/')),
- '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'=>URL::link('admin','payment/view'),
- )),
- ));
- }
-
- private function add_view($id=NULL,$output='') {
+ private function add_edit($id=NULL,$output='') {
$po = ORM::factory('Payment',$id);
if ($_POST) {
// Update our invoice payment items
if (isset($_POST['payment_item']) AND count($_POST['payment_item']))
- foreach ($_POST['payment_item'] as $k=>$v)
- $po->add_item($k)->alloc_amt = is_numeric($v) ? $v : 0;
+ foreach ($_POST['payment_item'] as $k=>$v) {
+ $pio = $po->payment_item;
+ $pio->invoice_id = $k;
+ $pio->alloc_amt = is_numeric($v) ? $v : 0;
+
+ $po->add_item($pio);
+ }
// Entry updated
if ($po->values($_POST)->check() AND $po->save())
- SystemMessage::add(array(
- 'title'=>'Payment Recorded',
- 'type'=>'info',
- 'body'=>'Payment successfully recorded.',
- ));
+ SystemMessage::factory()
+ ->title('Record updated')
+ ->type('success')
+ ->body(_('Your Payment record has been recorded/updated.'));
}
- $output .= Form::open();
- $output .= View::factory('payment/admin/add_view')
- ->set('po',$po);;
- $output .= Form::submit('submit','submit',array('class'=>'form_button'));
- $output .= Form::close();
+ Script::factory()
+ ->type('file')
+ ->data('media/theme/bootstrap/vendor/datepicker/js/bootstrap-datepicker.js');
- 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::factory()
+ ->type('file')
+ ->data('media/theme/bootstrap/vendor/datepicker/css/datepicker.css');
- Style::add(array(
- 'type'=>'file',
- 'data'=>'media/js/jquery.ui/css/smoothness/jquery-ui-1.8.16.custom.css',
- ));
+ Script::factory()
+ ->type('stdin')
+ ->data('
+$(document).ready(function() {
+ var nowTemp = new Date();
+ var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
- Script::add(array(
- 'type'=>'file',
- 'data'=>'media/js/jquery-ui-1.8.16.custom.min.js',
- ));
+ $("#date_payment_label").datepicker({
+ autoclose : true,
+ endDate : now,
+ format : "dd-mm-yyyy",
+ todayBtn : true,
+ }).on("hide",function(ev) {
+ $("input[name=date_payment]").val(ev.date.valueOf());
+ });
- 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::link('admin','payment/ajaxlist',TRUE).'",
- 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::link('admin','payment/autoitemlist',TRUE).'",
- timeout: 2000,
- error: function(x) {
- alert("Failed to submit");
- },
- success: function(data) {
- $("div[id=items]").replaceWith(data);
- }
- });
- }
- });
- });'
- ));
+ $("input[name=account_id_label]").typeahead({
+ minLength: 2,
+ source: function (query,process) {
+ search("a/payment/ajaxlist",query,process);
+ },
- if ($po->loaded()) {
- Script::add(array('type'=>'stdin','data'=>'
- $(document).ready(function() {
- $("div[id=items]").load("'.URL::link('admin','payment/autoitemlist',TRUE).'", {key: "'.$po->account_id.'", pid: "'.$po->id.'" });
- });'
- ));
- }
+ matcher: function () { return true; },
- return $output;
+ updater: function (item) {
+ $("input[name=account_id]").val(users[item]);
+
+ // Send the request and update sub category dropdown
+ $.ajax({
+ type: "GET",
+ data: "key="+users[item],
+ dataType: "html",
+ cache: false,
+ url: "'.URL::link('admin','payment/ajaxitemlist',TRUE).'",
+ timeout: 2000,
+ error: function(x) {
+ alert("Failed to submit");
+ },
+ success: function(data) {
+ $("div[id=items]").replaceWith(data);
+ }
+ });
+
+ return item;
+ },
+
+ });
+});
+ ');
+
+ if ($po->loaded())
+ Script::factory()
+ ->type('stdin')
+ ->data('
+$(document).ready(function() {
+ $("div[id=items]").load("'.URL::link('admin','payment/ajaxitemlist',TRUE).'", {key: "'.$po->account_id.'", pid: "'.$po->id.'" });
+});
+ ');
+
+ return View::factory('payment/admin/add_edit')
+ ->set('o',$po);
}
- public function action_add() {
- Block::add(array(
- 'title'=>_('Add Payments Received'),
- 'body'=>$this->add_view(),
- ));
- }
-
- public function action_view() {
+ public function action_edit() {
list($id,$output) = Table::page(__METHOD__);
- Block::add(array(
- 'title'=>sprintf('%s: %s',_('View Payments Received'),$id),
- 'body'=>$this->add_view($id,$output),
- ));
+ Block::factory()
+ ->type('form-horizontal')
+ ->title(sprintf('%s: %s',_('View Payments Received'),$id))
+ ->title_icon('icon-wrench')
+ ->body($this->add_edit($id,$output));
}
- public function action_addbulk() {
- // @todo This needs to come from the DB.
- $supported = array(
- 'ezypay'=>'Ezypay',
- );
+ /**
+ * List our availale Buik Payment Methods
+ */
+ private function templates() {
+ $template_path = 'classes/Payment/Bulk';
+ $result = array();
- $output = '';
-
- if ($_POST AND isset($_POST['payer'])) {
- $c = sprintf('Payment_Bulk_%s',ucfirst($_POST['payer']));
- $o = new $c();
-
- if (! $_FILES) {
- $output .= $o->form();
-
- } else {
-
- $output .= $o->process();
- }
-
- // We dont know what sort of payment type yet
- } else {
- $output .= Form::open();
- $output .= Form::select('payer',$supported);
- $output .= Form::submit('submit','submit',array('class'=>'form_button'));
- $output .= Form::close();
+ foreach (Kohana::list_files($template_path) as $file => $path) {
+ $file = strtoupper(preg_replace('/.php$/','',str_replace($template_path.'/','',$file)));
+ $result[$file] = $file;
}
- Block::add(array(
- 'title'=>_('Bulk Payments Received'),
- 'body'=>$output,
- ));
+ return $result;
}
}
?>
diff --git a/modules/payment/classes/Controller/Reseller/Payment.php b/modules/payment/classes/Controller/Reseller/Payment.php
new file mode 100644
index 00000000..7f990950
--- /dev/null
+++ b/modules/payment/classes/Controller/Reseller/Payment.php
@@ -0,0 +1,42 @@
+TRUE,
+ );
+
+ /**
+ * Show a list of payments
+ */
+ public function action_list() {
+ Block::factory()
+ ->title('Customer Payments')
+ ->title_icon('icon-th-list')
+ ->body(Table::factory()
+ ->page_items(50)
+ ->data(ORM::factory('Payment')->where('account_id','IN',$this->ao->RTM->customers($this->ao->RTM))->find_all())
+ ->columns(array(
+ 'id'=>'ID',
+ 'date_payment'=>'Date',
+ 'checkout->display("name")'=>'Method',
+ 'balance(TRUE)'=>'Balance',
+ 'invoicelist()'=>'Invoices',
+ 'account->accnum()'=>'Cust ID',
+ 'account->name()'=>'Customer',
+ ))
+ ->prepend(array(
+ //'id'=>array('url'=>URL::link('reseller','payment/view/')), //@todo To Implement
+ ))
+ );
+ }
+}
+?>
diff --git a/modules/payment/classes/Controller/User/Payment.php b/modules/payment/classes/Controller/User/Payment.php
index a1859bbe..95da0030 100644
--- a/modules/payment/classes/Controller/User/Payment.php
+++ b/modules/payment/classes/Controller/User/Payment.php
@@ -9,33 +9,30 @@
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
-class Controller_User_Payment extends Controller_TemplateDefault_User {
+class Controller_User_Payment extends Controller_Payment {
protected $secure_actions = array(
'list'=>TRUE,
);
/**
- * Show a payments received
+ * Show payments received
*/
public function action_list() {
- Block::add(array(
- 'title'=>sprintf('%s: %s - %s',_('Payments Received For'),$this->ao->accnum(),$this->ao->name(TRUE)),
- 'body'=>Table::display(
- $this->ao->payment->find_all(),
- 25,
- array(
- 'id'=>array('label'=>'ID'),
- 'date_payment'=>array('label'=>'Date'),
- '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'=>'list',
- )),
- ));
+ Block::factory()
+ ->title(sprintf('%s: %s - %s',_('Payments Received For'),$this->ao->accnum(),$this->ao->name(TRUE)))
+ ->title_icon('icon-th-list')
+ ->body(Table::factory()
+ ->page_items(50)
+ ->data($this->ao->payment->find_all())
+ ->columns(array(
+ 'id'=>'ID',
+ 'date_payment'=>'Date',
+ 'checkout->display("name")'=>'Method',
+ 'total(TRUE)'=>'Total',
+ 'balance(TRUE)'=>'Balance',
+ 'invoicelist()'=>'Invoices',
+ ))
+ );
}
}
?>
diff --git a/modules/payment/classes/Model/Payment.php b/modules/payment/classes/Model/Payment.php
index fb05d657..09156c35 100644
--- a/modules/payment/classes/Model/Payment.php
+++ b/modules/payment/classes/Model/Payment.php
@@ -11,14 +11,14 @@
*/
class Model_Payment extends ORM_OSB {
// Relationships
+ protected $_belongs_to = array(
+ 'account'=>array(),
+ 'checkout'=>array('foreign_key'=>'checkout_id'),
+ );
protected $_has_many = array(
'payment_item'=>array('far_key'=>'id'),
'invoice'=>array('through'=>'payment_item'),
);
- protected $_belongs_to = array(
- 'account'=>array(),
- 'checkout'=>array('foreign_key'=>'checkout_plugin_id'),
- );
protected $_sorting = array(
'date_payment'=>'DESC'
@@ -31,6 +31,9 @@ class Model_Payment extends ORM_OSB {
'date_payment'=>array(
array('Config::date',array(':value')),
),
+ 'fees_amt'=>array(
+ array('Currency::display',array(':value')),
+ ),
'total_amt'=>array(
array('Currency::display',array(':value')),
),
@@ -38,33 +41,34 @@ class Model_Payment extends ORM_OSB {
// Items belonging to an invoice
private $payment_items = array();
+ private $payment_items_unsorted = TRUE;
- public function __construct($id = NULL) {
- // Load our model.
- parent::__construct($id);
+ /**
+ * Intercept our object load, so that we can load our subitems
+ */
+ protected function _load_values(array $values) {
+ parent::_load_values($values);
- // Load our sub items
- if ($this->loaded())
+ if ($this->_loaded)
$this->payment_items = $this->payment_item->find_all()->as_array();
+
+ return $this;
}
/**
- * Add an item to this payment
- *
- * @param $inv number, to allocate payment to an invoice
+ * Add an item to an payment
*/
- public function add_item($invnum) {
- // Find our id, if it exists
+ public function add_item(Model_Payment_Item $p=NULL) {
+ $this->payment_items_unsorted = TRUE;
+
+ // Make sure this payment item for an invoice is not already in the list
foreach ($this->payment_items as $pio)
- if ($pio->invoice_id == $invnum)
+ if ($pio->invoice_id == $p->invoice_id)
return $pio;
- // New Item
- $c = count($this->payment_items);
- $this->payment_items[$c] = ORM::factory('Payment_Item');
- $this->payment_items[$c]->invoice_id = $invnum;
+ array_push($this->payment_items,$p);
- return $this->payment_items[$c];
+ return $p;
}
/**
@@ -80,14 +84,15 @@ class Model_Payment extends ORM_OSB {
}
/**
- * Find all items that are exportable.
- *
- * @param int $start List payments that were modified this many days ago
+ * Calculate there refund amount
*/
- public function export($start) {
- return ORM::factory('Payment')
- ->where('date_payment','>=',time()-$start*86400)
- ->find_all();
+ public function credit($format=FALSE) {
+ $result = 0;
+
+ foreach ($this->items('CREDIT') as $pio)
+ $result += $pio->alloc_amt*-1;
+
+ return $format ? Currency::display($result) : $result;
}
/**
@@ -112,6 +117,11 @@ class Model_Payment extends ORM_OSB {
* @see payment_items
*/
public function items($type='ALL') {
+ if ($this->payment_items_unsorted) {
+ Sort::MAsort($this->payment_items,'invoice_id');
+ $this->payment_items_unsorted = FALSE;
+ }
+
$result = array();
foreach ($this->payment_items as $pio) {
@@ -119,7 +129,7 @@ class Model_Payment extends ORM_OSB {
switch ($type) {
case 'ALLOC':
- if ($pio->alloc_amt > 0)
+ if ($pio->alloc_amt >= 0)
$return = TRUE;
break;
@@ -142,13 +152,73 @@ class Model_Payment extends ORM_OSB {
}
/**
- * Show the total amount of a payment.
+ * Save a record and payment_items
+ */
+ 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();
+
+ // If a user modified this payment, we'll update the source to their ID.
+ if ($ao = Auth::instance()->get_user())
+ $this->source_id = $ao->id;
+
+ $this->ip = Request::$client_ip;
+
+ // Make sure we dont over allocate
+ $msg = '';
+ foreach ($items as $pio)
+ // Only need to check items that ave actually changed.
+ if ($pio->changed() AND ($x=$pio->original_values()))
+ if (($x = $pio->alloc_amt-$pio->invoice->due()-$x['alloc_amt']) > 0)
+ $msg .= ($msg ? ' ' : '').sprintf('Invoice %s over allocated by %3.2f.',$pio->invoice_id,$x);
+
+ if (($x=$this->balance()) < 0)
+ $msg .= ($msg ? ' ' : '').sprintf('Payment over allocated by %3.2f.',-$x);
+
+ if ($msg) {
+ SystemMessage::factory()
+ ->title('Record NOT updated')
+ ->type('warning')
+ ->body($msg);
+
+ return FALSE;
+ }
+
+ // Save the payment
+ parent::save($validation);
+
+ // Need to save the associated items and their taxes
+ if (! $this->changed() OR $this->saved()) {
+ foreach ($items as $pio) {
+ // Skip applying 0 payments to invoices.
+ if (! $pio->changed() OR (Currency::round($pio->alloc_amt) == 0 AND ! $pio->loaded()))
+ continue;
+
+ $pio->payment_id = $this->id;
+
+ // @todo Mark payment as cancelled and write a memo, then...
+ if (! $pio->check())
+ throw HTTP_Exception::factory(501,'Problem saving payment_item for invoice :invoice - Failed check()',array(':invoice'=>$pio->invoice_id));
+
+ $pio->save();
+
+ // @todo Mark payment as cancelled and write a memo, then...
+ if (! $pio->saved())
+ throw HTTP_Exception::factory(501,'Problem saving payment_item for invoice :invoice - Failed save()',array(':invoice'=>$pio->invoice_id));
+ }
+
+ } else {
+ throw HTTP_Exception::factory(501,'Problem saving payment :id - Failed save()',array(':id'=>$this->id));
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * Reduce the total by the amount of credits returned.
*/
public function total($format=FALSE) {
- $result = $this->total_amt;
-
- foreach ($this->items('CREDIT') as $pio)
- $result += $pio->alloc_amt;
+ $result = $this->total_amt - $this->credit();
return $format ? Currency::display($result) : Currency::round($result);
}
@@ -156,18 +226,22 @@ class Model_Payment extends ORM_OSB {
/** LIST FUNCTIONS **/
public function list_unapplied() {
- return array();
- $pi = array();
+ $pid = array();
- // @todo database suffix needs to be dynamically calculated
- foreach (DB::Query(Database::SELECT,
- sprintf('SELECT A.id AS id,A.total_amt as total_amt FROM ab_%s A LEFT JOIN ab_%s B ON (A.site_id=B.site_id AND A.id=B.payment_id) WHERE (A.refund_status=0 OR A.refund_status IS NULL) GROUP BY A.id HAVING ROUND(SUM(IFNULL(B.alloc_amt,0)),2)!=A.total_amt ORDER BY account_id,payment_id','payment','payment_item'))
- ->execute() as $values) {
+ // We cant use ORM for this complex SQL
+ $db = Database::instance();
- array_push($pi,$values['id']);
- }
+ $sql = 'SELECT A.id as id, A.total_amt, ROUND(SUM(IF(IFNULL(B.alloc_amt,0)<0,IFNULL(B.alloc_amt,0)*-1,IFNULL(B.alloc_amt,0))),2) as ALLOC';
+ $sql .= ' FROM :prefix_payment A ';
+ $sql .= ' RIGHT JOIN :prefix_payment_item B ON (A.site_id=B.site_id AND A.id=B.payment_id)';
+ $sql .= ' WHERE A.site_id=:site_id';
+ $sql .= ' GROUP BY A.id';
+ $sql .= ' HAVING round(A.total_amt-ALLOC,2) <> 0';
- return $this->where('id','IN',$pi)->order_by('account_id')->find_all();
+ foreach ($db->query(Database::SELECT,__($sql,array(':prefix_'=>$db->table_prefix(),':site_id'=>Config::siteid()))) as $values)
+ array_push($pid,$values['id']);
+
+ return $this->where('id','IN',$pid)->order_by('account_id')->find_all();
}
public function list_recent_table() {
@@ -196,73 +270,5 @@ class Model_Payment extends ORM_OSB {
'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();
-
- // @todo This should not be mandatory - or there should be a source for non-users (automatic postings)
- $this->source_id = Auth::instance()->get_user() ? Auth::instance()->get_user()->id : 1;
- $this->ip = Request::$client_ip;
-
- // Make sure we dont over allocate
- $t = 0;
- $msg = '';
- foreach ($items as $pio) {
- // Only need to check items that ave actually changed.
- if ($pio->changed()) {
- $old_pio = ORM::factory('Payment_Item',$pio->id);
-
- if (($it = $pio->invoice->due()+ORM::factory('Payment_Item',$pio->id)->alloc_amt-$pio->alloc_amt) < 0)
- $msg .= ($msg ? ' ' : '').sprintf('Invoice %s over allocated by %3.2f.',$pio->invoice_id,$it);
- }
-
- $t += $pio->alloc_amt;
- }
-
- if ($t > (float)$this->total_amt)
- $msg .= ($msg ? ' ' : '').sprintf('Payment over allocated by %3.2f.',$t-$this->total_amt);
-
- if ($msg) {
- SystemMessage::add(array(
- 'title'=>'Payment NOT Recorded',
- 'type'=>'warning',
- 'body'=>$msg,
- ));
-
- return FALSE;
- }
-
- // Save the payment
- parent::save($validation);
-
- // Need to save the associated items and their taxes
- if (! $this->changed() OR $this->saved()) {
- foreach ($items as $pio) {
- // Skip applying 0 payments to invoices.
- if (Currency::round($pio->alloc_amt) == 0 AND ! $pio->loaded())
- continue;
-
- $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;
- }
}
?>
diff --git a/modules/payment/classes/Model/Payment/Item.php b/modules/payment/classes/Model/Payment/Item.php
index b1255b00..1f5002d1 100644
--- a/modules/payment/classes/Model/Payment/Item.php
+++ b/modules/payment/classes/Model/Payment/Item.php
@@ -11,12 +11,17 @@
*/
class Model_Payment_Item extends ORM_OSB {
// Relationships
+ protected $_belongs_to = array(
+ 'payment'=>array(),
+ );
protected $_has_one = array(
'invoice'=>array('far_key'=>'invoice_id','foreign_key'=>'id'),
);
- protected $_belongs_to = array(
- 'payment'=>array(),
+ protected $_display_filters = array(
+ 'alloc_amt'=>array(
+ array('Currency::display',array(':value')),
+ ),
);
}
?>
diff --git a/modules/payment/classes/Payment/Bulk/Ezypay.php b/modules/payment/classes/Payment/Bulk/Ezypay.php
index a6fea85a..f27a1a07 100644
--- a/modules/payment/classes/Payment/Bulk/Ezypay.php
+++ b/modules/payment/classes/Payment/Bulk/Ezypay.php
@@ -10,24 +10,11 @@
* @license http://dev.osbill.net/license.html
*/
class Payment_Bulk_Ezypay {
- public function form() {
- $result = '';
+ private function file($name) {
+ $result = array();
- $result .= Form::open(NULL,array('enctype'=>'multipart/form-data'));
- $result .= Form::hidden('payer',$_POST['payer']);
- $result .= View::factory('payment/admin/addbulk/ezypay');
- $result .= Form::submit('submit','submit',array('class'=>'form_button'));
- $result .= Form::close();
-
- return $result;
- }
-
- public function process() {
- $payments = array();
-
- // Process payment
- $file = file_get_contents($_FILES['payment']['tmp_name']);
- $file = preg_split("/[\r]?[\n]+/",$file);
+ // Process file
+ $file = preg_split("/[\r]?[\n]+/",file_get_contents($_FILES[$name]['tmp_name']));
$i = 0;
foreach ($file as $line) {
@@ -37,8 +24,33 @@ class Payment_Bulk_Ezypay {
// Trim our whitespace on the end of the line.
$line = preg_replace("/\s+$/",'',$line);
- $array = explode("\t",$line);
+ array_push($result,explode("\t",$line));
+ }
+ return $result;
+ }
+
+ /**
+ * The input form to capture the required files
+ */
+ public function form() {
+ $result = '';
+
+ $result .= Form::open(NULL,array('enctype'=>'multipart/form-data','class'=>'form-horizontal'));
+ $result .= View::factory('payment/admin/addbulk/ezypay');
+ $result .= Form::close();
+
+ return $result;
+ }
+
+ /**
+ * Process the uploaded files
+ */
+ public function process() {
+ // Process payment
+ $payments = array();
+
+ foreach ($this->file('payment') as $line => $array) {
// Field 4 has our account reference
if (preg_match('/^'.Company::instance()->site(TRUE).'-/',$array[4]) AND $array[10] == 'Cleared') {
$aid = preg_replace('/^'.Company::instance()->site(TRUE).'-/','',$array[4]);
@@ -46,62 +58,59 @@ class Payment_Bulk_Ezypay {
$po = ORM::factory('Payment');
$po->account_id = $aid;
$po->total_amt = $array[7];
- $po->notes = $array[2].':'.$array[3];
+ $po->checkout_data = array('transid'=>$array[2].':'.$array[3]);
$po->date_payment = strtotime(str_replace('/','-',$array[8]));
+ $sbo = $po->account->service_billing->where('plugin_data','=',$array[3])->find();
+ if (! $sbo->loaded())
+ throw HTTP_Exception::factory(501,'No Service Billing Data for :aid (:pd)?',array(':aid'=>$aid,':pd'=>$array[3]));
+
+ $po->checkout_id = $sbo->checkout_id;
+
$payments[$array[3]] = $po;
}
}
- $file = file_get_contents($_FILES['transaction']['tmp_name']);
- $file = preg_split("/[\r]?[\n]+/",$file);
-
- $i = 0;
- foreach ($file as $line) {
- // Line 0 is our header
- if ($i++ == 0 OR ! trim($line))
- continue;
-
- // Trim our whitespace on the end of the line.
- $line = preg_replace("/\s+$/",'',$line);
- $array = explode("\t",$line);
-
+ foreach ($this->file('transaction') as $line => $array) {
// If we dont have a payment item for this fee, we'll continue.
if (! isset($payments[$array[3]]))
continue;
- // Our commission fees
- // @todo This should be in a config file
+ // Our commission fees, which appear has Type 1 or 15
if (in_array($array[9],array(1,15)))
$payments[$array[3]]->fees_amt = (float)$array[7];
-
- // @todo Hack - since the reports dont show how the payment was made.
- // @todo Put this in a config file, in the mean time.
- if ($array[7] == 1.05)
- $payments[$array[3]]->checkout_id = 2;
- else
- $payments[$array[3]]->checkout_id = 4;
}
- $result = '';
- $result .= View::Factory('payment/admin/addbulk/ezypay/head');
-
$total = $fees = 0;
foreach ($payments as $po) {
$po->save();
+ if (! $po->saved())
+ throw HTTP_Exception::factory(501,'Failed to Save Payment for :aid (:pd)?',array(':aid'=>$po->account_id,':pd'=>$po->checkout_data['transid']));
+
$total += $po->total_amt;
$fees += $po->fees_amt;
-
- $result .= View::Factory('payment/admin/addbulk/ezypay/body')
- ->set('o',$po);
}
- $result .= View::Factory('payment/admin/addbulk/ezypay/foot')
- ->set('total',$total)
- ->set('fees',$fees);;
+ $output = Table::factory()
+ ->data($payments)
+ ->columns(array(
+ 'id'=>'ID',
+ 'date_payment'=>'Date',
+ 'checkout->display("name")'=>'Method',
+ 'total_amt'=>'Amount',
+ 'fees_amt'=>'Fees',
+ 'account->accnum()'=>'Cust ID',
+ 'account->name()'=>'Customer',
+ ))
+ ->prepend(array(
+ 'id'=>array('url'=>URL::link('admin','payment/view/')),
+ ));
- return $result;
+ return View::factory('payment/admin/addbulk/ezypay_processed')
+ ->set('table',$output)
+ ->set('fee',$fees)
+ ->set('total',$total);
}
}
?>
diff --git a/modules/payment/views/payment/admin/add_edit.php b/modules/payment/views/payment/admin/add_edit.php
new file mode 100644
index 00000000..de8fce3c
--- /dev/null
+++ b/modules/payment/views/payment/admin/add_edit.php
@@ -0,0 +1,23 @@
+
+
+
+
+
+
|
+ 'btn btn-primary')); ?>
+
+
diff --git a/modules/payment/views/payment/admin/add_view.php b/modules/payment/views/payment/admin/add_view.php
deleted file mode 100644
index f11a1a21..00000000
--- a/modules/payment/views/payment/admin/add_view.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
- Payment Date |
- date_payment); ?> |
-
-
- Account |
- account_id); ?> |
-
-
- Method |
- list_select(),$po->checkout_id,array('label'=>'Payment Method','required')); ?> |
-
-
- Amount |
- total()); ?> |
-
-
- Fees |
- fees_amt); ?> |
-
-
- Notes |
- notes); ?> |
-
-
- |
-
-
- |
-
-
diff --git a/modules/payment/views/payment/admin/addbulk/ezypay.php b/modules/payment/views/payment/admin/addbulk/ezypay.php
index ac570294..50c7838c 100644
--- a/modules/payment/views/payment/admin/addbulk/ezypay.php
+++ b/modules/payment/views/payment/admin/addbulk/ezypay.php
@@ -1,13 +1,13 @@
-
-
- Ezypay Payment |
-
-
- Payment File (BillDetails) |
- |
-
-
- Transaction File (AddItems) |
- |
-
-
+
+
+
+
+ 'btn btn-primary')); ?>
+
+
diff --git a/modules/payment/views/payment/admin/addbulk/ezypay/body.php b/modules/payment/views/payment/admin/addbulk/ezypay/body.php
deleted file mode 100644
index 065de117..00000000
--- a/modules/payment/views/payment/admin/addbulk/ezypay/body.php
+++ /dev/null
@@ -1,7 +0,0 @@
-
- id),$o->display('id')); ?> |
- display('date_payment'); ?> |
- display('total_amt'); ?> |
- display('fees_amt'); ?> |
- display('notes'); ?> |
-
diff --git a/modules/payment/views/payment/admin/addbulk/ezypay/foot.php b/modules/payment/views/payment/admin/addbulk/ezypay/foot.php
deleted file mode 100644
index 2c77b4bb..00000000
--- a/modules/payment/views/payment/admin/addbulk/ezypay/foot.php
+++ /dev/null
@@ -1,6 +0,0 @@
-
- |
- |
- |
-
-
diff --git a/modules/payment/views/payment/admin/addbulk/ezypay/head.php b/modules/payment/views/payment/admin/addbulk/ezypay/head.php
deleted file mode 100644
index 53a4ee6d..00000000
--- a/modules/payment/views/payment/admin/addbulk/ezypay/head.php
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- Payment ID |
- Date Payment |
- Amount |
- Fees |
- Transaction ID |
-
diff --git a/modules/payment/views/payment/admin/addbulk/ezypay_processed.php b/modules/payment/views/payment/admin/addbulk/ezypay_processed.php
new file mode 100644
index 00000000..7c78ccc3
--- /dev/null
+++ b/modules/payment/views/payment/admin/addbulk/ezypay_processed.php
@@ -0,0 +1,18 @@
+
+
+
+
+
+
Total
+
+
+ Fees
+
+
+ Payments
+
+
+
+
diff --git a/modules/payment/views/payment/admin/ajaxitemlist.php b/modules/payment/views/payment/admin/ajaxitemlist.php
new file mode 100644
index 00000000..8ac9802e
--- /dev/null
+++ b/modules/payment/views/payment/admin/ajaxitemlist.php
@@ -0,0 +1,33 @@
+
+
+
+
+ Invoice |
+ Date Issue |
+ Date Due |
+ Total |
+ Payments |
+ Due |
+ Alloc |
+
+
+
+ items('ALLOC') as $pio) : ?>
+
+ invoice_id),$pio->invoice->id()); ?> |
+ invoice->display('date_orig'); ?> |
+ invoice->display('due_date'); ?> |
+ invoice->total(TRUE); ?> |
+ invoice->payments_total(TRUE); ?> |
+ invoice->due(TRUE); ?> |
+ invoice_id.']',$pio->display('alloc_amt'),array('class'=>'span1','nocg'=>TRUE,'tabindex'=>++$c)); ?> |
+
+
+
+
+ Unapplied |
+ balance(TRUE),array('class'=>'span1','nocg'=>TRUE,'disabled'=>'disabled')); ?> |
+
+
+
+
diff --git a/modules/payment/views/payment/admin/autoitemlist/body.php b/modules/payment/views/payment/admin/autoitemlist/body.php
deleted file mode 100644
index 1b802f5c..00000000
--- a/modules/payment/views/payment/admin/autoitemlist/body.php
+++ /dev/null
@@ -1,9 +0,0 @@
-
- id),$io->id()); ?> |
- display('date_orig'); ?> |
- display('due_date'); ?> |
- total(TRUE); ?> |
- payments_total(TRUE); ?> |
- due(TRUE); ?> |
- id.']',$pio->alloc_amt); ?> |
-
diff --git a/modules/payment/views/payment/admin/autoitemlist/foot.php b/modules/payment/views/payment/admin/autoitemlist/foot.php
deleted file mode 100644
index 79ee84d9..00000000
--- a/modules/payment/views/payment/admin/autoitemlist/foot.php
+++ /dev/null
@@ -1,7 +0,0 @@
-
- |
- Unapplied |
- 'disabled')); ?> |
-
-
-
diff --git a/modules/payment/views/payment/admin/autoitemlist/head.php b/modules/payment/views/payment/admin/autoitemlist/head.php
deleted file mode 100644
index aa4e9465..00000000
--- a/modules/payment/views/payment/admin/autoitemlist/head.php
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Invoice |
- Date Issue |
- Date Due |
- Total |
- Payments |
- Due |
- Alloc |
-
diff --git a/modules/service/classes/Controller/User/Service.php b/modules/service/classes/Controller/User/Service.php
index b192b276..de8d5204 100644
--- a/modules/service/classes/Controller/User/Service.php
+++ b/modules/service/classes/Controller/User/Service.php
@@ -20,8 +20,6 @@ class Controller_User_Service extends Controller_Service {
* This ajax functions obtains the manage button login/password for this service
*/
public function action_ajaxmanage() {
- $this->auto_render = FALSE;
-
$so = ORM::factory('Service',$this->request->param('id'));
$k = Session::instance()->get_once('manage_button');
$amo = $so->plugin(isset($_REQUEST['t']) ? $_REQUEST['t'] : '');
diff --git a/modules/statement/classes/Controller/User/Statement.php b/modules/statement/classes/Controller/User/Statement.php
index e48174cc..09d43e00 100644
--- a/modules/statement/classes/Controller/User/Statement.php
+++ b/modules/statement/classes/Controller/User/Statement.php
@@ -45,7 +45,7 @@ class Controller_User_Statement extends Controller_TemplateDefault_User {
if (isset($v['invoice']))
$t += $v['invoice']->total();
elseif (isset($v['payment']))
- $t -= $v['payment']->total_amt;
+ $t -= $v['payment']->total();
$ta[$k]['total'] = $t;
$a = $v['time'];