Improvements to payment and other misc items
This commit is contained in:
@@ -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();
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<table class="table table-striped table-condensed table-hover" id="list-table">
|
||||
<tbody>
|
||||
<?php foreach ($o->items_periods() as $rs) : ?>
|
||||
<tr><th colspan="5"><?php echo StaticList_RecurSchedule::get($rs); ?></th></tr>
|
||||
<?php foreach ($o->items_periods() as $rs) : ?>
|
||||
<thead><tr><th colspan="5"><?php echo StaticList_RecurSchedule::get($rs); ?></th></tr></thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($o->items_periods($rs) as $iio) : ?>
|
||||
<?php if ($iio->service_id) : ?>
|
||||
<tr>
|
||||
@@ -31,6 +31,7 @@
|
||||
<?php endif ?>
|
||||
|
||||
<?php endforeach ?>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</tbody>
|
||||
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
|
Reference in New Issue
Block a user