Updated charge, Invoice improvements and other minor fixes

This commit is contained in:
Deon George
2013-09-06 15:39:56 +10:00
parent 2322a802de
commit ab3735914b
52 changed files with 748 additions and 560 deletions

View File

@@ -11,27 +11,11 @@
*/
class Controller_Reseller_Account extends Controller_Account {
protected $secure_actions = array(
'ajaxlist'=>TRUE,
'list'=>TRUE,
'listlog'=>TRUE,
'view'=>TRUE,
);
/**
* Used by AJAX calls to find accounts
* @note list_autocomplete() will limit to authorised accounts
*/
public function action_ajaxlist() {
$result = array();
if (isset($_REQUEST['term']) AND trim($_REQUEST['term']))
$result += ORM::factory('Account')->list_autocomplete($_REQUEST['term']);
$this->auto_render = FALSE;
$this->response->headers('Content-Type','application/json');
$this->response->body(json_encode(array_values($result)));
}
/**
* Show a list of accounts
*/
@@ -138,7 +122,7 @@ class Controller_Reseller_Account extends Controller_Account {
->title(sprintf('Next Invoice Items for Account: %s',$ao->accnum()))
->title_icon('icon-info-sign')
->span(6)
->body($i->render('html','body'));
->body($i->render('html','body',array('noid'=>TRUE)));
}
}
?>

View File

@@ -41,7 +41,7 @@ class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
// @todo To rework
public function after() {
$dc = 'u/welcome/index';
$dc = URL::link('user','welcome/index');
$m = sprintf('%s/%s',Request::current()->directory(),Request::current()->controller());
BreadCrumb::URL(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);

View File

@@ -21,12 +21,12 @@ class Controller_User_Search extends Controller_Search {
$result = array();
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'url','id',array('ACC %s: %s'=>array('id','name(TRUE)')),array(),array('urlprefix'=>'r/account/view/')));
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($_REQUEST['term'],'url','id',array('SVC %s: %s'=>array('id','service_name()')),array(),array('urlprefix'=>'u/service/view/')));
$result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name(TRUE)')),array(),array('urlprefix'=>'u/invoice/view/')));
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'url','id',array('ACC %s: %s'=>array('id','name(TRUE)')),array(),array('urlprefix'=>URL::link('reseller','account/view/'))));
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($_REQUEST['term'],'url','id',array('SVC %s: %s'=>array('id','service_name()')),array(),array('urlprefix'=>URL::link('user','service/view/'))));
$result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name(TRUE)')),array(),array('urlprefix'=>URL::link('user','invoice/view/'))));
foreach (array('Service_Plugin_Adsl','Service_Plugin_Domain','Service_Plugin_Host') as $o)
$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/')));
$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'=>URL::link('user','service/view/'))));
}
$this->response->headers('Content-Type','application/json');

View File

@@ -10,11 +10,17 @@
* @license http://dev.osbill.net/license.html
*/
abstract class Minion_Task extends Kohana_Minion_Task {
protected $_options = array(
protected $_sysoptions = array(
'site'=>NULL,
'id'=>NULL,
'force'=>FALSE,
'verbose'=>FALSE,
);
/**
* Override our __construct so that we can specify options in each class file
*/
protected function __construct() {
// Populate $_accepted_options based on keys from $_options
$this->_accepted_options = array_keys(Arr::merge($this->_sysoptions,$this->_options));
}
}
?>

View File

@@ -14,6 +14,10 @@ class Model_Country extends ORM_OSB {
'currency'=>array('far_key'=>'id'),
);
protected $_sorting = array(
'name'=>'ASC',
);
protected $_form = array('id'=>'id','value'=>'name');
public static function icon() {

View File

@@ -10,6 +10,10 @@
* @license http://dev.osbill.net/license.html
*/
class Model_Currency extends ORM_OSB {
protected $_sorting = array(
'name'=>'ASC',
);
protected $_form = array('id'=>'id','value'=>'name');
}
?>

View File

@@ -10,6 +10,10 @@
* @license http://dev.osbill.net/license.html
*/
class Model_Language extends ORM_OSB {
protected $_sorting = array(
'name'=>'ASC',
);
protected $_form = array('id'=>'id','value'=>'name');
}
?>

View File

@@ -27,6 +27,11 @@ abstract class ORM_OSB extends ORM {
// Our attribute values that need to be stored as serialized
protected $_serialize_column = array();
// If we need to load any sub items on loading this model
protected $_sub_items = array();
protected $_sub_items_load = array();
protected $_sub_items_sorted = FALSE;
// Rules to assist with site ID and getting next record ID for inserts.
public function rules() {
return array(
@@ -101,6 +106,25 @@ abstract class ORM_OSB extends ORM {
return parent::__get($column);
}
/**
* Intercept our object load, so that we can load our subitems
*/
protected function _load_values(array $values) {
parent::_load_values($values);
$sort = FALSE;
if ($this->_loaded AND $this->_sub_items_load AND count($this->_sub_items_load) == 1)
foreach ($this->_sub_items_load as $item => $sort)
$this->_sub_items = $this->$item->find_all()->as_array();
if ($sort) {
Sort::MAsort($this->_sub_items,$sort);
$this->_sub_items_sorted = TRUE;
}
return $this;
}
/**
* If a column is marked to be nullified if it is empty, this is where it is done.
*/
@@ -266,7 +290,7 @@ abstract class ORM_OSB extends ORM {
if ($this->_form AND array_intersect(array('id','value'),$this->_form))
foreach ($this->find_all() as $o)
$result[$o->{$this->_form['id']}] = $o->{$this->_form['value']};
$result[$o->{$this->_form['id']}] = $o->resolve($this->_form['value']);
return $result;
}

View File

@@ -12,8 +12,15 @@
class StaticList_ItemType extends StaticList {
protected function _table() {
return array(
0=>'MAIN', // Line Charge Topic on Invoice, eg: Service Name
5=>'EXCESS', // Excess Service Item, of item 0
0=>_('Product/Service Charge'), // Line Charge Topic on Invoice, eg: Service Name
1=> _('Hardware'),
2=> _('Service Relocation Fee'),
3=> _('Service Change Fee'),
4=> _('Service Connection Fee'),
5=>_('Excess Usage'), // Excess Service Item, of item 0
125=>_('Payment Fee'), // Payment processing fee
126=> _('Rounding'),
127=> _('Late Payment Fee'),
);
}