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'; } } ?>