Updated Login to use lnapp, and minor update to Invoice

This commit is contained in:
Deon George
2016-08-17 22:30:12 +10:00
parent 07de13f678
commit c1cc6b6f69
10 changed files with 107 additions and 148 deletions

View File

@@ -185,24 +185,34 @@ class Model_Invoice extends ORM implements Cartable {
$result = array();
$lo = $this->account->language;
foreach ($this->subitems() as $iio) {
// We only summarise item_type=0
if (! $iio->item_type == 0)
continue;
$track['p'] = $track = array();
foreach ($this->items_render() as $key => $items) {
switch ($key) {
case 's':
$last = '';
foreach ($items as $iio) {
if ($iio->product) {
$p = $iio->product->name($lo);
if ($iio->product) {
$p = $iio->title($lo);
}
if (! isset($result[$p])) {
$result[$p]['quantity'] = 0;
$result[$p]['subtotal'] = 0;
}
if (! isset($result[$p])) {
$result[$p]['quantity'] = 0;
$result[$p]['subtotal'] = 0;
}
$result[$p]['quantity']++;
$result[$p]['subtotal'] += $iio->subtotal();
$result[$p]['quantity']++;
$result[$p]['subtotal'] += $iio->subtotal();
}
break;
case 'other':
break;
}
}
ksort($result);
return $result;
}

View File

@@ -170,6 +170,9 @@ class Model_Invoice_Item extends ORM {
if (! $this->isValid())
return sprintf('Record Error [%s-%s]',$this->item_type,$this->id);
if (is_null($variable) OR ! $variable instanceof Model_Language)
$variable = Site::language();
switch ($this->item_type) {
case 0:
case 2:
@@ -278,6 +281,25 @@ class Model_Invoice_Item extends ORM {
return $result;
}
public function title(Model_Language $lo) {
if (! $this->isValid())
return 'Record Error';
switch ($this->item_type) {
case 0:
case 2:
case 3:
case 4:
return $this->product->name($lo);
case 5:
return $this->_module()->name($lo);
case 124:
return StaticList_ItemType::get($this->item_type);
default:
return 'Unknown';
}
}
public function total($format=FALSE) {
$result = $this->void ? 0 : $this->subtotal()+$this->tax()-$this->discount();