Update to statements and other minor items

This commit is contained in:
Deon George
2014-02-06 11:03:25 +11:00
parent ae98efa84e
commit 06cbec3a94
16 changed files with 134 additions and 189 deletions

View File

@@ -21,7 +21,7 @@ class Model_Checkout_Notify extends ORM_OSB implements Invoicable {
),
);
public function invoice_item() {
public function invoice_item($item_type) {
return sprintf('Payment Fee: %s',$this->checkout->name);
}

View File

@@ -26,6 +26,7 @@ class Controller_Admin_Service_Domain extends Controller_Domain {
'name()'=>'Domain',
'status'=>'Active',
'suspend_billing'=>'Not Bill',
'external_billing'=>'Ext Bill',
'plugin()->display("domain_expire")'=>'Expire',
'recur_schedule'=>'Billing',
'price(TRUE,TRUE)'=>'Charge',

View File

@@ -36,6 +36,9 @@ class Model_Invoice extends ORM_OSB implements Cartable {
'status'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),
),
'void'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),
),
);
// Items belonging to an invoice

View File

@@ -36,7 +36,7 @@
</div> <!-- /row -->
<div class="row">
<?php echo Form::select('product_id',ORM::factory('Product')->where_active()->list_select(TRUE),NULL,array('label'=>'Product','class'=>'span4','sort'=>TRUE)); ?>
<?php echo Form::select('product_id',ORM::factory('Product')->list_select(TRUE),NULL,array('label'=>'Product','class'=>'span4','sort'=>TRUE)); ?>
</div> <!-- /row -->
</fieldset>

View File

@@ -95,9 +95,10 @@
->data($o->invoice_list())
->columns(array(
'id'=>'ID',
'void'=>'Void',
'date_orig'=>'Date',
'due_date'=>'Due',
'total(TRUE)'=>'Amount',
'total(TRUE)'=>'Amount',
'due(TRUE)'=>'Due',
))
->prepend(array(

View File

@@ -1,87 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides User Statement functions
*
* @package Statement
* @category Controllers/Admin
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Admin_Statement extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'show'=>TRUE,
);
/**
* Show a payments received
*/
public function action_show() {
$ao = ORM::factory('account',$this->request->param('id'));
$ta = array();
foreach ($ao->payment->find_all() as $o) {
if ( ! $o->total())
continue;
$i = count($ta);
$ta[$i]['time'] = $o->date_payment;
$ta[$i]['payment'] = $o;
}
foreach ($ao->invoice->list_active() as $o) {
$i = count($ta);
$ta[$i]['time'] = $o->date_orig;
$ta[$i]['invoice'] = $o;
}
Sort::MAsort($ta,'time');
$t = 0;
$a = 0;
foreach ($ta as $k => $v) {
// If 2 metrics have the same time, we need to increment 1 by a small number so that it doesnt affect the next sorting
if ($a == $v['time']) {
$ta[$k]['time'] += 1;
}
if (isset($v['invoice']))
$t += $v['invoice']->total();
elseif (isset($v['payment']))
$t -= $v['payment']->total();
$ta[$k]['total'] = $t;
$a = $v['time'];
}
Sort::MAsort($ta,'time',1);
$pag = new Pagination(array(
'total_items'=>count($ta),
));
$output = (string)$pag;
$output .= View::factory('statement/user/show'.'/head');
$i = 0;
foreach ($ta as $k => $v) {
if (++$i < $pag->current_first_item())
continue;
elseif ($i > $pag->current_last_item())
break;
$output .= View::factory('statement/user/show/'.'/body')
->set('o',$v)
->set('trc',$i%2 ? 'odd' : 'even');
}
$output .= View::factory('statement/user/show/'.'/foot');
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Transactions For'),$ao->accnum(),$ao->name(TRUE)),
'body'=>$output,
));
}
}
?>

View File

@@ -0,0 +1,76 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Reseller Statement functions
*
* @package Statement
* @category Controllers/Reseller
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Reseller_Statement extends Controller_Statement {
protected $secure_actions = array(
'index'=>TRUE,
'show'=>TRUE,
);
public function action_index() {
if ($x=$this->request->post('aid'))
HTTP::redirect(URL::link('reseller','statement/show/'.$x));
$output = Form::open();
$output .= Form::select('aid',ORM::factory('Account')->where_authorised(Auth::instance()->get_user(),'id')
->order_by('company','ASC')->order_by('last_name','ASC')->order_by('first_name','ASC')->list_select());
$output .= Form::button('submit','Submit',array('class'=>'btn btn-primary'));
$output .= Form::close();
Block::factory()
->title('Select Account')
->title_icon('icon-share')
->body($output);
}
/**
* Show a payments received
*/
public function action_show() {
$ao = ORM::factory('account',$this->request->param('id'));
if (! $ao->loaded() OR ! Auth::instance()->authorised($ao))
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
$result = array();
$total = 0;
foreach ($ao->payment->find_all() as $o) {
$key = $o->date_payment;
while (isset($result[$key]))
$key += 1;
$result[$key] = $o;
$total += Currency::round($o->total());
}
foreach ($ao->invoice->list_active() as $o) {
$key = $o->date_orig;
while (isset($result[$key]))
$key += 1;
$result[$key] = $o;
$total -= Currency::round($o->total());
}
krsort($result);
Block::factory()
->title(sprintf('%s: %s - %s',_('Transactions For'),$ao->accnum(),$ao->name(TRUE)))
->title_icon('icon-tasks')
->body(View::factory('statement/user/show')->set('result',$result)->set('total',$total));
}
}
?>

View File

@@ -9,7 +9,7 @@
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_User_Statement extends Controller_TemplateDefault_User {
class Controller_User_Statement extends Controller_Statement {
protected $secure_actions = array(
'show'=>TRUE,
);
@@ -18,66 +18,37 @@ class Controller_User_Statement extends Controller_TemplateDefault_User {
* Show a payments received
*/
public function action_show() {
$ta = array();
$result = array();
$total = 0;
foreach ($this->ao->payment->find_all() as $o) {
$i = count($ta);
$ta[$i]['time'] = $o->date_payment;
$ta[$i]['payment'] = $o;
$key = $o->date_payment;
while (isset($result[$key]))
$key += 1;
$result[$key] = $o;
$total += Currency::round($o->total());
}
foreach ($this->ao->invoice->list_active() as $o) {
$i = count($ta);
$ta[$i]['time'] = $o->date_orig;
$ta[$i]['invoice'] = $o;
$key = $o->date_orig;
while (isset($result[$key]))
$key += 1;
$result[$key] = $o;
$total -= Currency::round($o->total());
}
Sort::MAsort($ta,'time');
krsort($result);
$t = 0;
$a = 0;
foreach ($ta as $k => $v) {
// If 2 metrics have the same time, we need to increment 1 by a small number so that it doesnt affect the next sorting
if ($a == $v['time']) {
$ta[$k]['time'] += 1;
}
if (isset($v['invoice']))
$t += $v['invoice']->total();
elseif (isset($v['payment']))
$t -= $v['payment']->total();
$ta[$k]['total'] = $t;
$a = $v['time'];
}
Sort::MAsort($ta,'time',1);
$pag = new Pagination(array(
'total_items'=>count($ta),
));
$output = (string)$pag;
$output .= View::factory($this->viewpath().'/head');
$i = 0;
foreach ($ta as $k => $v) {
if (++$i < $pag->current_first_item())
continue;
elseif ($i > $pag->current_last_item())
break;
$output .= View::factory($this->viewpath().'/body')
->set('o',$v)
->set('trc',$i%2 ? 'odd' : 'even');
}
$output .= View::factory($this->viewpath().'/foot');
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Transactions For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>$output,
));
Block::factory()
->title(sprintf('%s: %s - %s',_('Transactions For'),$this->ao->accnum(),$this->ao->name(TRUE)))
->title_icon('icon-tasks')
->body(View::factory('statement/user/show')->set('result',$result)->set('total',$total));
}
}
?>

View File

@@ -1,14 +0,0 @@
<tr class="<?php echo $trc; ?>">
<?php if (isset($o['invoice'])) { ?>
<td><?php echo $o['invoice']->display('date_orig'); ?></td>
<td>Invoice</td>
<td><?php echo HTML::anchor(URL::link('user','invoice/view/'.$o['invoice']->id),$o['invoice']->id()); ?></td>
<td class="right"><?php echo $o['invoice']->total(TRUE); ?></td>
<?php } elseif (isset($o['payment'])) { ?>
<td><?php echo $o['payment']->display('date_payment'); ?></td>
<td>Payment</td>
<td><?php printf('%s - %s',$o['payment']->id,$o['payment']->checkout->display('name')); ?></td>
<td class="right"><?php echo $o['payment']->total(TRUE); ?></td>
<?php } ?>
<td class="right"><?php echo Currency::display($o['total']); ?></td>
</tr>

View File

@@ -1 +0,0 @@
</table>

View File

@@ -1,7 +0,0 @@
<table class="box-left" border="0" id="list-table">
<tr>
<td class="head">Date</td>
<td class="head" colspan="2">Type</td>
<td class="head">Amt</td>
<td class="head">Total</td>
</tr>