Updated charge, Invoice improvements and other minor fixes
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
*/
|
||||
class Controller_Admin_Service extends Controller_Service {
|
||||
protected $secure_actions = array(
|
||||
'ajaxlist'=>TRUE,
|
||||
'ajaxjson_traffic'=>TRUE,
|
||||
'adslstat'=>TRUE,
|
||||
'listadslbilling'=>TRUE,
|
||||
@@ -25,22 +24,6 @@ class Controller_Admin_Service extends Controller_Service {
|
||||
'view'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_ajaxlist() {
|
||||
$result = array();
|
||||
|
||||
$result += ORM::factory('Service')->list_autocomplete(
|
||||
isset($_REQUEST['term']) ? $_REQUEST['term'] : '',
|
||||
'id',
|
||||
'id',
|
||||
array('SVC %s: %s'=>array('id','service_name(TRUE)')),
|
||||
isset($_REQUEST['aid']) ? array(array('account_id','=',$_REQUEST['aid'])) : array()
|
||||
);
|
||||
|
||||
$this->auto_render = FALSE;
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
$this->response->body(json_encode(array_values($result)));
|
||||
}
|
||||
|
||||
public function action_ajaxjson_traffic() {
|
||||
$result = array();
|
||||
$svs = ORM::factory('Service')->list_bylistgroup('ADSL');
|
||||
@@ -54,7 +37,6 @@ class Controller_Admin_Service extends Controller_Service {
|
||||
|
||||
$google->sdata(array('yr'=>'services'),array('services'=>$data['svs']));
|
||||
|
||||
$this->auto_render = FALSE;
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
$this->response->body($google->json());
|
||||
}
|
||||
@@ -538,7 +520,7 @@ class Controller_Admin_Service extends Controller_Service {
|
||||
if (is_null($bt))
|
||||
$bt = $iio->date_start;
|
||||
|
||||
$pdata = Period::details($iio->recurring_schedule,$a ? NULL : $iio->product->price_recurr_weekday,$bt,TRUE);
|
||||
$pdata = Period::details($iio->recurring_schedule,$a ? NULL : $iio->product->price_recurr_weekday,$bt,TRUE,TRUE);
|
||||
|
||||
switch ($iio->recurring_schedule) {
|
||||
case 1:
|
||||
|
@@ -46,6 +46,8 @@ class Model_Service extends ORM_OSB {
|
||||
),
|
||||
);
|
||||
|
||||
protected $_form = array('id'=>'id','value'=>'service_name()');
|
||||
|
||||
/**
|
||||
* Get the additional charges associated with this service
|
||||
*/
|
||||
@@ -63,11 +65,11 @@ class Model_Service extends ORM_OSB {
|
||||
|
||||
if ($unprocessed)
|
||||
$x->where_open()
|
||||
->where('processed','IS',NULL)
|
||||
->or_where('processed','=',FALSE)
|
||||
->where_close();
|
||||
->where('processed','IS',NULL)
|
||||
->or_where('processed','=',FALSE)
|
||||
->where_close();
|
||||
|
||||
return $x->find_all();
|
||||
return $x->and_where('void','IS',NULL)->find_all();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,9 +134,24 @@ class Model_Service extends ORM_OSB {
|
||||
* Show the date we are invoiced to
|
||||
*/
|
||||
public function invoiced_to($format=FALSE) {
|
||||
$x = $this->invoice_item->order_by('date_stop','DESC')->limit(1)->find();
|
||||
$iio = $this->last_invoice_item()
|
||||
->limit(1);
|
||||
|
||||
return $format ? $x->display('date_stop') : $x->date_stop;
|
||||
$iio->find();
|
||||
|
||||
$x = (! $iio->loaded() AND $this->date_next_invoice) ? $this->date_next_invoice-86400 : $iio->date_stop;
|
||||
|
||||
return $format ? Config::date($x) : $x;
|
||||
}
|
||||
|
||||
private function last_invoice_item() {
|
||||
return ORM::factory('Invoice_Item')->join('invoice')
|
||||
->on('invoice.id','=','invoice_item.invoice_id')
|
||||
->on('invoice.status','=',1)
|
||||
->on('invoice_item.service_id','=',$this)
|
||||
->on('invoice_item.item_type','=',0)
|
||||
->on('invoice_item.void','is','null')
|
||||
->order_by('date_stop','DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,7 +167,7 @@ class Model_Service extends ORM_OSB {
|
||||
public function paid_to($format=FALSE) {
|
||||
$x = NULL;
|
||||
|
||||
foreach ($this->invoice_item->order_by('date_stop','DESC')->order_by('date_orig','DESC')->find_all() as $iio)
|
||||
foreach ($this->last_invoice_item()->order_by('date_orig','DESC')->find_all() as $iio)
|
||||
if ($iio->invoice->due() == 0) {
|
||||
$x = $iio;
|
||||
break;
|
||||
@@ -203,7 +220,7 @@ class Model_Service extends ORM_OSB {
|
||||
$x = $this->product->keyget('price_group',$this->recur_schedule);
|
||||
|
||||
// @todo This index shouldnt be hard coded.
|
||||
$p = $this->price ? $this->price : $x[$this->price_group]['price_base'];
|
||||
$p = ! is_null($this->price) ? $this->price : $x[$this->price_group]['price_base'];
|
||||
|
||||
if ($tax)
|
||||
$p = Tax::add($p);
|
||||
@@ -250,7 +267,7 @@ class Model_Service extends ORM_OSB {
|
||||
*/
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
|
||||
// We only show service numbers.
|
||||
if (! is_numeric($term))
|
||||
if (! is_numeric($term) AND (! $limit))
|
||||
return array();
|
||||
|
||||
$ao = Auth::instance()->get_user();
|
||||
|
@@ -47,7 +47,7 @@ abstract class Model_Service_Plugin extends ORM_OSB {
|
||||
abstract public function password_value();
|
||||
|
||||
public function manage_button() {
|
||||
if (! $this->service->status)
|
||||
if (! $this->service->status OR $this->service->expiring())
|
||||
return FALSE;
|
||||
|
||||
static $k = '';
|
||||
|
Reference in New Issue
Block a user