132 lines
3.4 KiB
PHP
132 lines
3.4 KiB
PHP
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||
|
|
||
|
/**
|
||
|
* This class supports Services
|
||
|
*
|
||
|
* @package ADSL
|
||
|
* @category Models
|
||
|
* @author Deon George
|
||
|
* @copyright (c) 2009-2013 Open Source Billing
|
||
|
* @license http://dev.osbill.net/license.html
|
||
|
*/
|
||
|
class Model_Service_Plugin_Voip extends Model_Service_Plugin {
|
||
|
protected $_table_name = 'service__voip';
|
||
|
protected $_created_column = FALSE;
|
||
|
protected $_updated_column = FALSE;
|
||
|
|
||
|
// Relationships
|
||
|
protected $_has_one = array(
|
||
|
);
|
||
|
|
||
|
protected $_has_many = array(
|
||
|
);
|
||
|
|
||
|
protected $_display_filters = array(
|
||
|
'service_connect_date'=>array(
|
||
|
array('Site::Date',array(':value')),
|
||
|
),
|
||
|
'service_contract_date'=>array(
|
||
|
array('Site::Date',array(':value')),
|
||
|
),
|
||
|
);
|
||
|
|
||
|
protected $_save_message = TRUE;
|
||
|
|
||
|
/** REQUIRED ABSTRACT METHODS **/
|
||
|
|
||
|
public function attributes($variable=NULL) {
|
||
|
return array(
|
||
|
'Service Address'=>$this->service_address ? $this->display('service_address') : 'UNKNOWN',
|
||
|
'Contract Until'=>$this->contract_date_end(TRUE),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public function expire() {
|
||
|
// We'll leave it to the Service record to determine when this service expires
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
public function password() {
|
||
|
return $this->service_password;
|
||
|
}
|
||
|
|
||
|
public function username() {
|
||
|
return $this->service_username;
|
||
|
}
|
||
|
|
||
|
/** LOCAL METHODS **/
|
||
|
|
||
|
/**
|
||
|
* Calculate our contract start and end dates
|
||
|
*/
|
||
|
public function contract_date_start($format=FALSE) {
|
||
|
return $format ? Site::Date($this->service_contract_date) : $this->service_contract_date;
|
||
|
}
|
||
|
|
||
|
public function contract_date_end($format=FALSE) {
|
||
|
$x = strtotime(sprintf('+%s months',12),$this->service_contract_date);
|
||
|
|
||
|
return $format ? Site::Date($x) : $x;
|
||
|
}
|
||
|
|
||
|
public function name($variable=NULL) {
|
||
|
return $this->service_number;
|
||
|
}
|
||
|
|
||
|
public function namesub($variable=NULL) {
|
||
|
return $this->display('service_address');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* If we override the plan that the customers gets (from what the supplier provides).
|
||
|
* @todo This needs to get the plan that was invoiced, not the current plan..
|
||
|
*/
|
||
|
public function plan($month=NULL) {
|
||
|
return is_null($month) ? $this->service->product->plugin() : $this->plandate($month);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* For a particular month, select the PLAN that the user was on
|
||
|
*/
|
||
|
public function plandate($month) {
|
||
|
throw new Kohana_Exception('This function hasnt been written yet.');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return the template variables, used mainly in emailing
|
||
|
*
|
||
|
* @param array Variables that need to be expanded
|
||
|
* @param array Data that was previously calculated
|
||
|
*/
|
||
|
public function template_variables(array $array,array $data=array()) {
|
||
|
$result = array();
|
||
|
|
||
|
$friendly = array(
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Search for services matching a term
|
||
|
*/
|
||
|
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=array()) {
|
||
|
$ao = Auth::instance()->get_user();
|
||
|
|
||
|
$options['key'] = 'id';
|
||
|
$options['object'] = DB::select($this->_table_name.'.id',$this->_table_name.'.service_number')
|
||
|
->from($this->_table_name)
|
||
|
->join('service')
|
||
|
->on('service.id','=',$this->_table_name.'.service_id')
|
||
|
->where('service.account_id','IN',$ao->RTM->customers($ao->RTM))
|
||
|
->and_where('service.active','=',1)
|
||
|
->where_open()
|
||
|
->and_where($this->_table_name.'.service_number','like','%'.$term.'%')
|
||
|
->or_where($this->_table_name.'.service_address','like','%'.$term.'%')
|
||
|
->where_close();
|
||
|
|
||
|
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
|
||
|
}
|
||
|
|
||
|
public function admin_plan() { return 'VOIP'; }
|
||
|
}
|
||
|
?>
|