More use of list_active(), setup ajax actions that are check to be ajax
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
|
||||
// @todo This "module" menu items should belong in the module dir.
|
||||
protected $secure_actions = array(
|
||||
'autolist'=>FALSE, // @todo To Change
|
||||
'ajaxlist'=>FALSE, // @todo To Change
|
||||
'adslstat'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
'listbycheckout'=>TRUE,
|
||||
@@ -31,23 +31,17 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
|
||||
'view'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_autolist() {
|
||||
public function action_ajaxlist() {
|
||||
$return = array();
|
||||
|
||||
$s = ORM::factory('service')->where_active();
|
||||
if (isset($_REQUEST['aid']))
|
||||
$s = $s->where('account_id','=',$_REQUEST['aid']);
|
||||
|
||||
// @todo This should limit the results so that users dont see other users services.
|
||||
foreach ($s->find_all() as $so)
|
||||
array_push($return,array(
|
||||
'value'=>$so->id,
|
||||
'text'=>sprintf('%s: %s',$so->id,$so->service_name()),
|
||||
));
|
||||
$return += ORM::factory('service')->list_autocomplete(
|
||||
isset($_REQUEST['term']) ? $_REQUEST['term'] : '',
|
||||
'id',
|
||||
isset($_REQUEST['aid']) ? array(array('account_id','=',$_REQUEST['aid'])) : array());
|
||||
|
||||
$this->auto_render = FALSE;
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
$this->response->body(json_encode($return));
|
||||
$this->response->body(json_encode(array_values($return)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +78,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
|
||||
// @todo This needs to be configurable
|
||||
$go = ORM::factory('group',array('name'=>'Personal'));
|
||||
|
||||
foreach (ORM::factory('account')->where('status','=',1)->find_all() as $ao)
|
||||
foreach (ORM::factory('account')->list_active() as $ao)
|
||||
if ($ao->has_any('group',array($go)))
|
||||
foreach ($ao->service->list_active() as $so)
|
||||
if (! $so->service_billing->checkout_plugin_id)
|
||||
|
@@ -54,7 +54,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
|
||||
// @todo This needs to be configurable
|
||||
$go = ORM::factory('group',array('name'=>'Personal'));
|
||||
|
||||
foreach (ORM::factory('account')->where('status','=',1)->find_all() as $ao)
|
||||
foreach (ORM::factory('account')->list_active() as $ao)
|
||||
if ($ao->has_any('group',array($go)))
|
||||
foreach ($this->filter($ao->service->list_active(),$this->ao->affiliate->id,'name()') as $so)
|
||||
if (! $so->service_billing->checkout_plugin_id)
|
||||
|
@@ -143,6 +143,36 @@ class Model_Service extends ORMOSB {
|
||||
|
||||
/** LIST FUNCTIONS **/
|
||||
|
||||
/**
|
||||
* Search for services matching a term
|
||||
*/
|
||||
public function list_autocomplete($term,$index='id',array $limit=array()) {
|
||||
$return = array();
|
||||
|
||||
$this->clear();
|
||||
$this->where_active();
|
||||
$value = 'service_name()';
|
||||
|
||||
// Build our where clause
|
||||
$this->where_open()
|
||||
->where('id','like','%'.$term.'%')
|
||||
->where_close();
|
||||
|
||||
foreach ($limit as $w) {
|
||||
list($k,$s,$v) = $w;
|
||||
|
||||
$this->and_where($k,$s,$v);
|
||||
}
|
||||
|
||||
foreach ($this->find_all() as $o)
|
||||
$return[$o->$index] = array(
|
||||
'value'=>$o->$index,
|
||||
'label'=>sprintf('SVC %s: %s',$o->id,Table::resolve($o,$value)),
|
||||
);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function list_bylistgroup($cat) {
|
||||
$result = array();
|
||||
|
||||
|
Reference in New Issue
Block a user