Enabled Search, Improved Navbar, Fixed Application Authorisation and some other minor fixes

This commit is contained in:
Deon George
2013-05-08 19:00:47 +10:00
parent 364cb58b7b
commit ce17247db6
27 changed files with 877 additions and 67 deletions

View File

@@ -394,5 +394,26 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
return View::factory('service/user/plugin/adsl/table_traffic')
->set('traffic',$this->traffic_month((! is_null($month) AND trim($month)) ? strtotime($month.'-01') : NULL,FALSE));
}
/**
* Search for services matching a term
*/
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
// We only show invoice numbers.
if (! is_numeric($term))
return 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($this->_table_name.'.service_number','like','%'.$term.'%');
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
}
}
?>

View File

@@ -79,12 +79,12 @@ class Controller_Admin_Charge extends Controller_TemplateDefault_Admin {
Style::add(array(
'type'=>'file',
'data'=>'js/jquery.ui/css/smoothness/jquery-ui-1.8.16.custom.css',
'data'=>'media/js/jquery.ui/css/smoothness/jquery-ui-1.8.16.custom.css',
));
Script::add(array(
'type'=>'file',
'data'=>'js/jquery-ui-1.8.16.custom.min.js',
'data'=>'media/js/jquery-ui-1.8.16.custom.min.js',
));
Script::add(array('type'=>'stdin','data'=>'

View File

@@ -15,6 +15,9 @@ class Model_Checkout extends ORM_OSB {
'payment'=>array(),
);
protected $_sorting = array('name'=>'ASC');
protected $_form = array('id'=>'id','value'=>'name');
/**
* Calcuale the fee for this checkout method
*

View File

@@ -79,5 +79,26 @@ class Model_Service_Plugin_Domain extends Model_Service_Plugin {
public function manage_dns_button() {
return $this->service_plugin_host->manage_button('service_plugin_host');
}
/**
* Search for services matching a term
*/
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
// We only show domain names.
if (is_numeric($term))
return array();
$ao = Auth::instance()->get_user();
$options['key'] = 'id';
$options['object'] = DB::select($this->_table_name.'.id',$this->_table_name.'.domain_name')
->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($this->_table_name.'.domain_name','like','%'.$term.'%');
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
}
}
?>

View File

@@ -114,7 +114,7 @@ class Email_Template {
foreach ($this->components as $component) {
if ($this->etto->loaded()) {
$s = $this->etto->resolve($this->email_data['variables'],$component);
$s = $this->etto->rresolve($this->email_data['variables'],$component);
switch ($component) {
case 'message_html':

View File

@@ -32,7 +32,7 @@ class Model_Email_Log extends ORM_OSB {
if (! $this->data OR ! ($this->email_template_translate->variables($column)))
return $this->email_template_translate->display($column);
else
return $this->email_template_translate->resolve($this->data,$column);
return $this->email_template_translate->rresolve($this->data,$column);
}
}
?>

View File

@@ -28,7 +28,7 @@ class Model_Email_Template_Translate extends ORM_OSB {
return $results;
}
public function resolve($data,$column) {
public function rresolve($data,$column) {
$output = $this->display($column);
foreach ($this->variables($column) as $k => $v)

View File

@@ -75,5 +75,26 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
return ($this->username_value() AND $this->password_value() AND $a=$this->host_server->plugin()) ? $a->manage_button($this,$t) : '';
}
/**
* Search for services matching a term
*/
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
// We only show domain names.
if (is_numeric($term))
return array();
$ao = Auth::instance()->get_user();
$options['key'] = 'id';
$options['object'] = DB::select($this->_table_name.'.id',$this->_table_name.'.domain_name')
->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($this->_table_name.'.domain_name','like','%'.$term.'%');
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
}
}
?>

View File

@@ -529,25 +529,25 @@ class Model_Invoice extends ORM_OSB implements Cartable {
/**
* Search for invoices matching a term
*/
public function list_autocomplete($term,$index='id') {
$result = array();
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
// We only show invoice numbers.
if (! is_numeric($term))
return array();
if (is_numeric($term)) {
$this->clear();
$value = 'account->name(TRUE)';
$ao = Auth::instance()->get_user();
// Build our where clause
$this->where('id','like','%'.$term.'%');
$this->clear();
$this->where_active();
// @todo This should limit the results so that users dont see other users services.
foreach ($this->find_all() as $o)
$result[$o->$index] = array(
'value'=>$o->$index,
'label'=>sprintf('INV %s: %s',$o->id,Table::resolve($o,$value)),
);
}
// Build our where clause
$this->where_open()
->where('id','like','%'.$term.'%')
->where_close();
return $result;
// Restrict results to authorised accounts
array_push($limit,array('account_id','IN',$ao->RTM->customers($ao->RTM)));
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
}
private function _list_due() {

View File

@@ -126,12 +126,12 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
Style::add(array(
'type'=>'file',
'data'=>'js/jquery.ui/css/smoothness/jquery-ui-1.8.16.custom.css',
'data'=>'media/js/jquery.ui/css/smoothness/jquery-ui-1.8.16.custom.css',
));
Script::add(array(
'type'=>'file',
'data'=>'js/jquery-ui-1.8.16.custom.min.js',
'data'=>'media/js/jquery-ui-1.8.16.custom.min.js',
));
Script::add(array('type'=>'stdin','data'=>'

View File

@@ -12,7 +12,7 @@
</tr>
<tr>
<td>Method</td>
<td><?php echo StaticList_Module::form('checkout_plugin_id','checkout',$po->checkout_plugin_id,'id','name',array('status'=>'=:1'),TRUE,array('class'=>'form_button'));?></td>
<td><?php echo Form::select('checkout_plugin_id',ORM::factory('Checkout')->list_select(),$po->checkout_plugin_id,array('label'=>'Payment Method','required')); ?></td>
</tr>
<tr>
<td>Amount</td>

View File

@@ -178,31 +178,25 @@ class Model_Service extends ORM_OSB {
/**
* Search for services matching a term
*/
public function list_autocomplete($term,$index='id',array $limit=array()) {
$result = array();
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
// We only show invoice numbers.
if (! is_numeric($term))
return array();
$ao = Auth::instance()->get_user();
$this->clear();
$this->where_active();
$value = 'service_name()';
// Build our where clause
$this->where_open()
->where('id','like','%'.$term.'%')
->where_close();
->where('id','like','%'.$term.'%')
->where_close();
foreach ($limit as $w) {
list($k,$s,$v) = $w;
// Restrict results to authorised accounts
array_push($limit,array('account_id','IN',$ao->RTM->customers($ao->RTM)));
$this->and_where($k,$s,$v);
}
foreach ($this->find_all() as $o)
$result[$o->$index] = array(
'value'=>$o->$index,
'label'=>sprintf('SVC %s: %s',$o->id,Table::resolve($o,$value)),
);
return $result;
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
}
public function list_bylistgroup($cat) {