More Standardisation work.
This commit is contained in:
@@ -87,7 +87,7 @@ class Model_ADSL_Supplier_Plan extends ORM_OSB {
|
||||
/**
|
||||
* ADSL Plan Name
|
||||
*/
|
||||
public function name() {
|
||||
public function name($variable=NULL) {
|
||||
return sprintf('%s: %s',$this->product_id,$this->product_desc);
|
||||
}
|
||||
|
||||
|
@@ -41,7 +41,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public function name() {
|
||||
public function name($variable=NULL) {
|
||||
return $this->service_number;
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
/**
|
||||
* Search for services matching a term
|
||||
*/
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=array()) {
|
||||
$ao = Auth::instance()->get_user();
|
||||
|
||||
$options['key'] = 'id';
|
||||
@@ -444,6 +444,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
->join('service')
|
||||
->on('service.id','=',$this->_table_name.'.service_id')
|
||||
->where('service.account_id','IN',$ao->RTM->customers($ao->RTM))
|
||||
->and_where('service.status','=',1)
|
||||
->where_open()
|
||||
->and_where($this->_table_name.'.service_number','like','%'.$term.'%')
|
||||
->or_where($this->_table_name.'.service_address','like','%'.$term.'%')
|
||||
|
@@ -21,7 +21,7 @@ class Task_Adsl_Trafficalert extends Minion_Task {
|
||||
// @todo Pick up services that are no longer active, but were inactive < 30 days ago.
|
||||
foreach (ORM::factory('Service')->list_byplugin('ADSL') as $so) {
|
||||
if (Minion_CLI::options('verbose'))
|
||||
echo $so->service_name()."\n";
|
||||
echo $so->name()."\n";
|
||||
|
||||
if (! $data=$so->plugin()->traffic_report())
|
||||
continue;
|
||||
|
@@ -21,7 +21,7 @@ class Task_Adsl_Trafficcharge extends Minion_Task {
|
||||
// @todo Pick up services that are no longer active, but were inactive < 30 days ago.
|
||||
foreach (ORM::factory('Service')->list_byplugin('ADSL') as $so) {
|
||||
if (Minion_CLI::options('verbose'))
|
||||
echo $so->service_name()."\n";
|
||||
echo $so->name()."\n";
|
||||
|
||||
if ($x=$so->plugin()->traffic_excess($date)) {
|
||||
$po = $so->plugin()->plan();
|
||||
|
@@ -30,11 +30,11 @@ class Controller_Reseller_Charge extends Controller_Charge {
|
||||
$result = array();
|
||||
|
||||
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
|
||||
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'id','id',array('ACC %s: %s'=>array('id','name(TRUE)'))));
|
||||
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($_REQUEST['term'],'account_id','id',array('ACC %s: %s (%s)'=>array('account_id','account->name()','name()'))));
|
||||
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'id','id',array('%s: %s'=>array('refnum()','name()'))));
|
||||
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($_REQUEST['term'],'account_id','id',array('%s: %s (%s)'=>array('account->refnum()','account->name()','name()'))));
|
||||
|
||||
foreach (array('Service_Plugin_Adsl','Service_Plugin_Domain','Service_Plugin_Host') as $o)
|
||||
$result = Arr::merge($result,ORM::factory($o)->list_autocomplete($_REQUEST['term'],'account_id','service->account_id',array('ACC %s: %s (%s)'=>array('service->account_id','service->account->name()','name()'))));
|
||||
$result = Arr::merge($result,ORM::factory($o)->list_autocomplete($_REQUEST['term'],'account_id','service->account_id',array('%s: %s (%s)'=>array('service->account->refnum()','service->account->name()','service->name()'))));
|
||||
}
|
||||
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
@@ -45,7 +45,7 @@ class Controller_Reseller_Charge extends Controller_Charge {
|
||||
$result = array();
|
||||
|
||||
if (isset($_REQUEST['key']) AND trim($_REQUEST['key']))
|
||||
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete('','id','id',array('SVC %s: %s'=>array('id','service_name()')),array(array('account_id','=',$_REQUEST['key']))));
|
||||
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete('','id','id',array('%s: %s'=>array('refnum(TRUE)','name()')),array(array('account_id','=',$_REQUEST['key']))));
|
||||
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
$this->response->body(json_encode(array_values($result)));
|
||||
@@ -104,6 +104,7 @@ $(document).ready(function() {
|
||||
alert("Failed to submit");
|
||||
},
|
||||
success: function(data) {
|
||||
$("select[name=service_id]").empty();
|
||||
$.each(data, function(i, j){
|
||||
var row = "<option value=\"" + j.value + "\">" + j.label + "</option>";
|
||||
$(row).appendTo("select[name=service_id]");
|
||||
|
@@ -79,6 +79,13 @@ class Model_Charge extends ORM_OSB implements Invoicable {
|
||||
}
|
||||
}
|
||||
|
||||
/** REQUIRED ABSTRACT METHODS **/
|
||||
public function namesub($variable=NULL) {
|
||||
return sprintf('%d@%2.2f - %s (%s)',$this->quantity,$this->amount,($this->description ? ' '.$this->description : '').($this->attributes ? ' ['.join('|',$this->attributes).']' : ''),$this->display('date_charge'));
|
||||
}
|
||||
|
||||
/** LOCAL METHODS **/
|
||||
|
||||
/**
|
||||
* Return the Invoice Item object for this charge
|
||||
*/
|
||||
|
@@ -23,7 +23,7 @@
|
||||
<?php echo Form::input('description',$o->description,array('label'=>'Description','placeholder'=>'Any notes about this charge?')); ?>
|
||||
|
||||
<!-- @todo Use JS to dynamically add more lines as required -->
|
||||
<?php $i=0; foreach ($o->attributes as $key => $value) :
|
||||
<?php $i=0; if ($o->attributes) foreach ($o->attributes as $key => $value) :
|
||||
echo Form::input("attributes[$key]",$value,array('label'=>$key));
|
||||
$i++;
|
||||
endforeach ?>
|
||||
|
@@ -41,7 +41,7 @@ class Model_Service_Plugin_Domain extends Model_Service_Plugin {
|
||||
return $this->domain_expire;
|
||||
}
|
||||
|
||||
public function name() {
|
||||
public function name($variable=NULL) {
|
||||
return sprintf('%s.%s',$this->display('domain_name'),$this->tld->display('name'));
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class Model_Service_Plugin_Domain extends Model_Service_Plugin {
|
||||
* Search for services matching a term
|
||||
* @todo This search doesnt pick up the TLD of domain names
|
||||
*/
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=array()) {
|
||||
// We only show domain names.
|
||||
if (is_numeric($term))
|
||||
return array();
|
||||
@@ -87,6 +87,7 @@ class Model_Service_Plugin_Domain extends Model_Service_Plugin {
|
||||
->join('service')
|
||||
->on('service.id','=',$this->_table_name.'.service_id')
|
||||
->where('service.account_id','IN',$ao->RTM->customers($ao->RTM))
|
||||
->and_where('service.status','=',1)
|
||||
->and_where($this->_table_name.'.domain_name','like','%'.$term.'%');
|
||||
|
||||
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
|
||||
|
@@ -22,7 +22,7 @@ class Controller_User_Email extends Controller_Email {
|
||||
$this->meta->title = 'Email List';
|
||||
|
||||
Block::factory()
|
||||
->title(sprintf(_('System Emails Sent for %s: %s'),$this->ao->refnum(),$this->ao->name(TRUE)))
|
||||
->title(sprintf(_('System Emails Sent for %s: %s'),$this->ao->refnum(),$this->ao->name()))
|
||||
->title_icon($this->icon)
|
||||
->body(View::factory('email/user/list')->set('o',$this->ao->email_log->find_all()));
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ class Model_Email_Template extends ORM_OSB {
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
|
||||
public function name() {
|
||||
public function name($variable=NULL) {
|
||||
return ! is_null($this->description) ? $this->description : $this->name;
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
|
||||
return $this->host_expire;
|
||||
}
|
||||
|
||||
public function name() {
|
||||
public function name($variable=NULL) {
|
||||
return sprintf('%s.%s',$this->display('domain_name'),$this->tld->display('name'));
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
|
||||
/**
|
||||
* Search for services matching a term
|
||||
*/
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=array()) {
|
||||
// We only show domain names.
|
||||
if (is_numeric($term))
|
||||
return array();
|
||||
@@ -88,6 +88,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
|
||||
->join('service')
|
||||
->on('service.id','=',$this->_table_name.'.service_id')
|
||||
->where('service.account_id','IN',$ao->RTM->customers($ao->RTM))
|
||||
->and_where('service.status','=',1)
|
||||
->and_where($this->_table_name.'.domain_name','like','%'.$term.'%');
|
||||
|
||||
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
|
||||
|
@@ -26,13 +26,15 @@ class Controller_User_Invoice extends Controller_Invoice {
|
||||
if (! $io->loaded() OR ! Auth::instance()->authorised($io->account))
|
||||
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
|
||||
|
||||
// Log the download
|
||||
$imo = $io->invoice_memo;
|
||||
$imo->invoice_id = $io->id;
|
||||
$imo->account_id = $this->ao->id;
|
||||
$imo->type = 'download';
|
||||
$imo->memo = 'Invoice Downloaded.';
|
||||
$imo->save();
|
||||
if (! $this->ao->isAdmin()) {
|
||||
// Log the download
|
||||
$imo = $io->invoice_memo;
|
||||
$imo->invoice_id = $io->id;
|
||||
$imo->account_id = $this->ao->id;
|
||||
$imo->type = 'download';
|
||||
$imo->memo = 'Invoice Downloaded.';
|
||||
$imo->save();
|
||||
}
|
||||
|
||||
$this->response->body(Invoice::instance($io)->render('pdf','all',array('download'=>sprintf('%s.pdf',$io->refnum()))));
|
||||
$this->response->headers(array('Content-Type' => 'application/pdf'));
|
||||
|
@@ -547,7 +547,7 @@ class Model_Invoice extends ORM_OSB implements Cartable {
|
||||
/**
|
||||
* Search for invoices matching a term
|
||||
*/
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=array()) {
|
||||
// We only show invoice numbers.
|
||||
if (! is_numeric($term))
|
||||
return array();
|
||||
|
@@ -36,6 +36,46 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
'tax'=>array(),
|
||||
);
|
||||
|
||||
/**
|
||||
* Invoice Item Types
|
||||
*/
|
||||
private $_item_type = array(
|
||||
0=>'Product/Service Charge', // Line Charge Topic on Invoice, eg: Service Name, must have corresponding SERVICE_ID
|
||||
1=>'Hardware',
|
||||
2=>'Service Relocation Fee', // Must have corresponding SERVICE_ID
|
||||
3=>'Service Change Fee', // Must have corresponding SERVICE_ID
|
||||
4=>'Service Connection Fee', // Must have corresponding SERVICE_ID
|
||||
5=>'Excess Usage', // Excess Service Item, of item 0, must have corresponding SERVICE_ID
|
||||
6=>'Service Cancellation Fee', // Must have corresponding SERVICE_ID
|
||||
7=>'Extra Product/Service Charge', // Service Billing in advance, Must have corresponding SERVICE_ID
|
||||
8=>'Product Addition', // Additional Product Customisation, Must have corresponding SERVICE_ID
|
||||
9=>'Module Charge', // Must have corresponding SERVICE_ID
|
||||
120=>'Credit/Debit Transfer', // SERVICE_ID is NULL, MODULE_ID is NULL, MODULE_REF is NULL : INVOICE_ID is NOT NULL
|
||||
124=>'Late Payment Fee', // SERVICE_ID is NULL, MODULE_ID = CHECKOUT MODULE,
|
||||
125=>'Payment Fee', // SERVICE_ID is NULL, MODULE_ID = CHECKOUT MODULE, MODULE_REF = CHECKOUT NAME
|
||||
126=>'Other', // MODEL_ID should be a module
|
||||
127=>'Rounding', // SERVICE_ID is NULL, MODULE_ID is NULL, MODULE_REF is NULL
|
||||
);
|
||||
|
||||
/** REQUIRED ABSTRACT METHODS **/
|
||||
|
||||
public function name($variable=NULL) {
|
||||
switch ($this->item_type) {
|
||||
default:
|
||||
return sprintf('Unknown [%s]',$this->id);
|
||||
}
|
||||
}
|
||||
|
||||
public function titleline() {
|
||||
return in_array($this->item_type,[0,120,124,125,126,127]);
|
||||
}
|
||||
|
||||
/** LOCAL METHODS **/
|
||||
|
||||
public function _types() {
|
||||
return $this->_item_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add tax to our item
|
||||
*
|
||||
@@ -85,7 +125,7 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
switch ($this->item_type) {
|
||||
// Service Charges
|
||||
case 0:
|
||||
return ((! $this->service_id OR $this->product_id OR $this->charge_id OR $this->product_name OR ! $this->recurring_schedule OR ! $this->date_start OR ! $this->date_stop) ? '+ ' : '').$ii.' '.$this->period();
|
||||
return ((! $this->service_id OR $this->product_id OR $this->product_name OR ! $this->recurring_schedule OR ! $this->date_start OR ! $this->date_stop) ? '+ ' : '').$ii.' '.$this->period();
|
||||
case 1:
|
||||
// @todo
|
||||
return $this->product_name;
|
||||
@@ -95,10 +135,10 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
return ((! $this->service_id OR $this->product_id OR $this->charge_id OR $this->product_name OR $this->recurring_schedule OR ! $this->date_start OR ! $this->date_stop) ? '+ ' : '').$ii;
|
||||
return ((! $this->service_id OR $this->product_id OR $this->product_name OR $this->recurring_schedule OR ! $this->date_start OR ! $this->date_stop) ? '+ ' : '').$ii;
|
||||
|
||||
case 7:
|
||||
return ((! $this->service_id OR $this->product_id OR $this->charge_id OR $this->product_name OR ! $this->date_start OR ! $this->date_stop) ? '+ ' : '').$ii.' '.$this->period();
|
||||
return ((! $this->service_id OR $this->product_id OR $this->product_name OR ! $this->date_start OR ! $this->date_stop) ? '+ ' : '').$ii.' '.$this->period();
|
||||
|
||||
case 8:
|
||||
return $this->product_name;
|
||||
@@ -112,10 +152,7 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
|
||||
// @todo DB records to fix.
|
||||
default:
|
||||
if ($this->charge_id)
|
||||
return '*'.($ii ? $ii : $this->charge->description).' '.$this->period();
|
||||
else
|
||||
throw HTTP_Exception::factory(501,'Unable to render invoice item :id',array(':id'=>$this->id));
|
||||
throw HTTP_Exception::factory(501,'Unable to render invoice item :id',array(':id'=>$this->id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +239,7 @@ class Model_Invoice_Item extends ORM_OSB {
|
||||
*/
|
||||
public function title() {
|
||||
if ($this->service_id AND $this->module_id AND method_exists($this->module(),'invoice_title'))
|
||||
return $this->module_ref ? sprintf('%s: %s',$this->module()->invoice_title(),$this->service->name()) : $this->service->name();
|
||||
return $this->service->name(); #$this->module_ref ? sprintf('%s: %s',$this->module()->invoice_title(),$this->service->name()) : $this->service->name();
|
||||
elseif ($x=$this->module() AND ($x instanceof Model_Charge) AND $x->product_id)
|
||||
return $x->product->title().' '.$this->service->name();
|
||||
elseif ($this->product_id)
|
||||
|
Submodule modules/lnapp updated: c57e166834...4bbf00a3d1
@@ -74,8 +74,8 @@ class Controller_Admin_Payment extends Controller_Payment {
|
||||
$result = array();
|
||||
|
||||
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
|
||||
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'id','id',array('ACC %s: %s'=>array('id','name(TRUE)'))));
|
||||
$result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'id','account_id',array('INV %s: %s'=>array('id','account->name(TRUE)'))));
|
||||
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'id','id',array('ACC %s: %s'=>array('id','name()'))));
|
||||
$result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'id','account_id',array('INV %s: %s'=>array('id','account->name()'))));
|
||||
}
|
||||
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
|
@@ -21,7 +21,7 @@ class Controller_User_Payment extends Controller_Payment {
|
||||
$this->meta->title = 'Payments Received';
|
||||
|
||||
Block::factory()
|
||||
->title(sprintf('%s: %s - %s',_('Payments Received For'),$this->ao->refnum(),$this->ao->name(TRUE)))
|
||||
->title(sprintf('%s: %s - %s',_('Payments Received For'),$this->ao->refnum(),$this->ao->name()))
|
||||
->title_icon($this->icon)
|
||||
->body(View::factory('payment/user/list')->set('o',$this->ao->payment->find_all()));
|
||||
}
|
||||
|
@@ -13,6 +13,8 @@
|
||||
* + price_type: 0=One Time, 1=Recurring, 2=Trial
|
||||
*/
|
||||
class Model_Product extends ORM_OSB implements Invoicable {
|
||||
private $_pto = NULL;
|
||||
|
||||
protected $_has_many = array(
|
||||
'invoice'=>array('through'=>'invoice_item'),
|
||||
'service'=>array('far_key'=>'id'),
|
||||
@@ -55,7 +57,31 @@ class Model_Product extends ORM_OSB implements Invoicable {
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
|
||||
// Our required Interface Methods
|
||||
/** REQUIRED ABSTRACT METHODS **/
|
||||
|
||||
public function name($variable=NULL) {
|
||||
if (! $variable instanceof Model_Language)
|
||||
throw HTTP_Exception::factory(500,'Call to :method incorrect',array(':method'=>__METHOD__));
|
||||
|
||||
$pto = $this->_pto($variable);
|
||||
|
||||
return (! $pto->loaded() OR ! $pto->name) ? sprintf('Unknown: [%s]',$this->id) : $pto->name;
|
||||
}
|
||||
|
||||
public function namesub($variable=NULL) {
|
||||
if (! $variable instanceof Model_Language)
|
||||
throw HTTP::Exception(500,'Call to :method incorrect',array(':method'=>__METHOD__));
|
||||
|
||||
$pto = $this->_pto($variable);
|
||||
|
||||
return (! $pto->loaded() OR ! $pto->description_short) ? sprintf('Unknown: [%s]',$this->id) : $pto->description_short;
|
||||
}
|
||||
|
||||
public function refnum($short=FALSE) {
|
||||
return ($short ? '' : sprintf('%02s-',Site::id())).sprintf('%04s',$this->id);
|
||||
}
|
||||
|
||||
/** REQUIRED INTERFACE METHODS **/
|
||||
|
||||
public function invoice_item($item_type) {
|
||||
switch ($item_type) {
|
||||
@@ -73,7 +99,7 @@ class Model_Product extends ORM_OSB implements Invoicable {
|
||||
return $this->title();
|
||||
}
|
||||
|
||||
// Our local methods
|
||||
/** LOCAL METHODS **/
|
||||
|
||||
// Our database index for pricing values
|
||||
private $_price_options = array(
|
||||
@@ -81,6 +107,25 @@ class Model_Product extends ORM_OSB implements Invoicable {
|
||||
'setup'=>'price_setup',
|
||||
);
|
||||
|
||||
/**
|
||||
* Return the translated langauge object
|
||||
*/
|
||||
private function _pto(Model_Language $lo) {
|
||||
if (! $this->_pto) {
|
||||
|
||||
// First try the called langauge.
|
||||
$pto = $this->translate->where('language_id','=',$lo->id)->find();
|
||||
|
||||
// Second try the called langauge.
|
||||
if (! $pto->loaded())
|
||||
$pto = $this->translate->where('language_id','=',Company::instance()->language()->id)->find();
|
||||
|
||||
$this->_pto = $pto;
|
||||
}
|
||||
|
||||
return $this->_pto;
|
||||
}
|
||||
|
||||
public function cost($annual=FALSE) {
|
||||
return $this->plugin() ? $this->plugin()->cost($annual) : 0;
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ class Model_Product_Category extends ORM_OSB {
|
||||
return $x->loaded() ? $x->display('description') : 'No Description';
|
||||
}
|
||||
|
||||
public function name() {
|
||||
public function name($variable=NULL) {
|
||||
$x = $this->translate();
|
||||
|
||||
return $x->loaded() ? $x->display('name') : 'No Name';
|
||||
|
@@ -64,7 +64,7 @@ class Controller_Reseller_Service extends Controller_Service {
|
||||
->data($svs)
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'service_name()'=>'Service',
|
||||
'name()'=>'Service',
|
||||
'recur_schedule'=>'Billing',
|
||||
'price(TRUE,TRUE)'=>'Price',
|
||||
'account->refnum()'=>'Cust ID',
|
||||
|
@@ -59,7 +59,7 @@ class Controller_User_Service extends Controller_Service {
|
||||
->set('o',$so);
|
||||
|
||||
Block::factory()
|
||||
->title(sprintf('%s: %s',$so->id(),$so->service_name()))
|
||||
->title(sprintf('%s: %s',$so->id(),$so->name()))
|
||||
->title_icon('fa fa-server')
|
||||
->body($output);
|
||||
}
|
||||
|
@@ -13,6 +13,8 @@
|
||||
* + queue: PROVISION (to be provisioned)
|
||||
*/
|
||||
class Model_Service extends ORM_OSB {
|
||||
private $_plugin = NULL;
|
||||
|
||||
// Relationships
|
||||
protected $_has_one = array(
|
||||
'service_billing'=>array('far_key'=>'account_billing_id','foreign_key'=>'id'),
|
||||
@@ -79,11 +81,41 @@ class Model_Service extends ORM_OSB {
|
||||
'price_override',
|
||||
);
|
||||
|
||||
protected $_form = array('id'=>'id','value'=>'service_name()');
|
||||
protected $_form = array('id'=>'id','value'=>'name()');
|
||||
|
||||
// Cache our calls to our plugins
|
||||
public static $plugin = array();
|
||||
|
||||
/** REQUIRED ABSTRACT METHODS **/
|
||||
|
||||
/**
|
||||
* Display the service product name
|
||||
*/
|
||||
public function name($variable=NULL) {
|
||||
if (! $variable instanceOf Model_Language)
|
||||
$variable = Company::instance()->language();
|
||||
|
||||
return $this->product->name($variable).(($x=$this->namesub($variable)) ? ': '.$x : '');
|
||||
}
|
||||
|
||||
public function namesub($variable=NULL) {
|
||||
return is_null($plugin=$this->_plugin()) ? '' : $plugin->name($variable);
|
||||
}
|
||||
|
||||
public function refnum($short=FALSE) {
|
||||
return ($short ? '' : sprintf('%02s-',Site::id())).sprintf('%05s',$this->id);
|
||||
}
|
||||
|
||||
/** LOCAL METHODS **/
|
||||
|
||||
private function _plugin() {
|
||||
if (! $this->_plugin AND $this->product->prod_plugin_file) {
|
||||
$this->_plugin = ORM::factory(Kohana::classname(sprintf('Service_Plugin_%s',$this->product->prod_plugin_file)),array('service_id'=>$this->id));
|
||||
}
|
||||
|
||||
return $this->_plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the additional charges associated with this service
|
||||
*/
|
||||
@@ -200,13 +232,6 @@ class Model_Service extends ORM_OSB {
|
||||
->order_by('date_stop','DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the service product name
|
||||
*/
|
||||
public function name() {
|
||||
return is_null($plugin=$this->plugin()) ? $this->product->title() : $plugin->name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date that an item has been paid to
|
||||
*/
|
||||
@@ -270,13 +295,6 @@ class Model_Service extends ORM_OSB {
|
||||
return $this->service_change->where_active()->where_open()->and_where('complete','!=',1)->or_where('complete','IS',null)->where_close()->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a descriptive name for this service
|
||||
*/
|
||||
public function service_name($chars=NULL) {
|
||||
return HTML::abbr(is_null($x=$this->plugin()) ? $this->name() : $x->service_name(),$chars);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the service charge
|
||||
*/
|
||||
@@ -323,7 +341,7 @@ class Model_Service extends ORM_OSB {
|
||||
/**
|
||||
* Search for services matching a term
|
||||
*/
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=array()) {
|
||||
// We only show service numbers.
|
||||
if (! is_numeric($term) AND (! $limit))
|
||||
return array();
|
||||
@@ -364,7 +382,7 @@ class Model_Service extends ORM_OSB {
|
||||
if ($so->product->prod_plugin_file == $cat)
|
||||
array_push($result,$so);
|
||||
|
||||
Sort::MASort($result,'service_name()');
|
||||
Sort::MASort($result,array('name()'));
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
19
modules/service/views/service/list.php
Normal file
19
modules/service/views/service/list.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<!-- o = Array of Model_Service -->
|
||||
<?php echo Table::factory()
|
||||
->jssort('service')
|
||||
->data($o)
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'name()'=>'Service',
|
||||
'plugin()->expire(TRUE)'=>'Expire',
|
||||
'recur_schedule'=>'Billing',
|
||||
'price(TRUE,TRUE)'=>'Price',
|
||||
'account->refnum()'=>'Cust ID',
|
||||
'account->name()'=>'Customer',
|
||||
'date_next_invoice'=>'Next Invoice',
|
||||
'due(TRUE)'=>'Due Invoices',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('user','service/view/')),
|
||||
));
|
||||
?>
|
@@ -4,7 +4,7 @@
|
||||
->data($o)
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'service_name()'=>'Service',
|
||||
'name()'=>'Service',
|
||||
'recur_schedule'=>'Billing',
|
||||
'price(TRUE,TRUE)'=>'Price',
|
||||
'charges(TRUE,TRUE)'=>'Charges',
|
||||
|
15
modules/service/views/service/user/list.php
Normal file
15
modules/service/views/service/user/list.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<!-- o = Array of Model_Service -->
|
||||
<?php echo Table::factory()
|
||||
->data($o)
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'name()'=>'Service',
|
||||
'recur_schedule'=>'Billing',
|
||||
'price(TRUE,TRUE)'=>'Price',
|
||||
'status'=>'Active',
|
||||
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('user','service/view/')),
|
||||
));
|
||||
?>
|
@@ -3,7 +3,7 @@
|
||||
->data($o)
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'service_name()'=>'Service',
|
||||
'name()'=>'Service',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('user','service/view/')),
|
||||
|
@@ -3,10 +3,13 @@
|
||||
->data($o)
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'service_name(59)'=>'Service',
|
||||
'name()'=>'Service',
|
||||
'expire(TRUE)'=>'Date',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('user','service/view/')),
|
||||
))
|
||||
->postproc(array(
|
||||
'name()'=>array('trim'=>60),
|
||||
));
|
||||
?>
|
||||
|
@@ -3,10 +3,13 @@
|
||||
->data($o)
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'service_name(60)'=>'Service',
|
||||
'name()'=>'Service',
|
||||
'date_end'=>'Date',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('user','service/view/')),
|
||||
))
|
||||
->postproc(array(
|
||||
'name()'=>array('trim'=>60),
|
||||
));
|
||||
?>
|
||||
|
@@ -39,7 +39,7 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
|
||||
return $this->_so->get_valid_to($format);
|
||||
}
|
||||
|
||||
public function name() {
|
||||
public function name($variable=NULL) {
|
||||
return ($this->cert AND $this->ca->loaded()) ? sprintf('%s:%s',$this->ca->subject(),$this->display('cert')) : $this->display('csr');
|
||||
}
|
||||
|
||||
|
@@ -70,7 +70,7 @@ class Controller_Reseller_Statement extends Controller_Statement {
|
||||
krsort($result);
|
||||
|
||||
Block::factory()
|
||||
->title(sprintf('%s: %s - %s',_('Transactions For'),$ao->refnum(),$ao->name(TRUE)))
|
||||
->title(sprintf('%s: %s - %s',_('Transactions For'),$ao->refnum(),$ao->name()))
|
||||
->title_icon('icon-tasks')
|
||||
->body(View::factory('statement/user/show')->set('result',$result)->set('total',$total));
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ class Controller_User_Statement extends Controller_Statement {
|
||||
krsort($result);
|
||||
|
||||
Block::factory()
|
||||
->title(sprintf('%s: %s - %s',_('Transactions For'),$this->ao->refnum(),$this->ao->name(TRUE)))
|
||||
->title(sprintf('%s: %s - %s',_('Transactions For'),$this->ao->refnum(),$this->ao->name()))
|
||||
->title_icon('icon-tasks')
|
||||
->body(View::factory('statement/user/show')->set('result',$result)->set('total',$total));
|
||||
}
|
||||
|
Reference in New Issue
Block a user