0% found this document useful (0 votes)
9 views3 pages

Admin Dashboard Filter

Uploaded by

adarsha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Admin Dashboard Filter

Uploaded by

adarsha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

public function user($page = 1)

{
$data['page_title'] = $this->lang->line('user_page_title');
$data['page_heading'] = $this->lang->line('user_page_heading');
$data['adminPage'] = $this->lang->line('users');
$rp = 20;
$where = '';
$status = $this->input->get('active_inactive');
$data['activeInactive'] = $this->input->get('active_inactive');
$partnerId = $this->input->get('partnerId');
if ($partnerId) {
$where .= " partner_id = ".$partnerId;
}
// for the new values in dropdown use a diff query
if ($status == 'paying' || $status == 'in_trial' || $status == 'dormant') {
if ($this->input->get('search_text')) {
$search_text = stripslashes($this->input->get('search_text'));
if ($partnerId) {
$where .= " AND ";
}
$where .= " (tbl_users.first_name like '".$search_text."%' ||
tbl_users.last_name like '".$search_text."%' || tbl_users.email like '".
$search_text."%' || tbl_users.id='".$search_text."') AND";
}
$total = $this->adminmodel->get_users_modecheck($status, 1, '',
$where);
$start = (($page - 1) * $rp);
$url = 'admin/dashboard/user';
$data['pg'] = $this->general_model->paging($page, $rp, $total, $url);
$page_limit = " LIMIT $start,$rp ";
$data['page'] = $page;
$data['userRow'] = $this->adminmodel->get_users_modecheck($status, '',
$page_limit, $where);
} else {
$whereAnd = " AND ";
if ($status == 'active') {
if ($partnerId) {
$where .= " AND ";
}
$where .= " status='1' ";
} elseif ($status == 'inactive') {
if ($partnerId) {
$where .= " AND ";
}
$where .= " status='0' ";
} elseif ($status == 'all') {
$whereAnd = "";
} elseif ($status == 'sub_ac') {
if ($partnerId) {
$where .= " AND ";
}
$where .= ' (access_id != 0 OR parent_id != 0 OR access_id != 1)';
$data['activeInactive'] = 'sub_ac';
} elseif ($status == 'parent') {
if ($partnerId) {
$where .= " AND ";
}
$where .= ' (access_id = 0 OR parent_id = 0 OR parent_id is
null )';
} else {
if ($partnerId) {
$where .= " AND ";
}
$where .= ' (access_id = 0 OR parent_id = 0 OR parent_id is null OR
access_id = 1)';
}
$search_text = '';
if ($this->input->get('search_text')) {
$search_text = stripslashes($this->input->get('search_text'));
if ($where && ($partnerId || $status)) {
$where .= " AND ";
}
$where .= " (tbl_users.first_name like '".$search_text."%' ||
tbl_users.last_name like '".$search_text."%' || tbl_users.email like '".
$search_text."%' || tbl_users.id='".$search_text."')";
}
$total = $this->adminmodel->get_users($where, '', '', 1);
$start = (($page - 1) * $rp);
$url = 'admin/dashboard/user';
$data['pg'] = $this->general_model->paging($page, $rp, $total, $url);
$page_limit = " LIMIT $start,$rp ";
$data['page'] = $page;
$order_by = 'first_name';
if ($status == 'llogin') {
$order_by = 'last_login desc';
$data['activeInactive'] = 'llogin';
}
$data['userRow'] = $this->adminmodel->get_users($where, $order_by,
$page_limit);
}
// do search with business name
if ($search_text && !($data['userRow'])) {
$total = $this->adminmodel->get_users_businessname($search_text, 1);
$start = (($page - 1) * $rp);
$url = 'admin/dashboard/user';
$data['pg'] = $this->general_model->paging($page, $rp, $total, $url);
$page_limit = " LIMIT $start,$rp ";
$data['page'] = $page;
$data['userRow'] = $this->adminmodel-
>get_users_businessname($search_text, '', $page_limit);
}
$nwhere = ' AND (access_id = 0 OR parent_id = 0 OR access_id = 1)';
if (!$search_text) {
$this->session->unset_userdata('searchresult');
}
$data['totalActive'] = $this->adminmodel->get_users(" status='1'".$nwhere,
'', '', 1);
$data['totalInactive'] = $this->adminmodel->get_users(" status='0'".
$nwhere, '', '', 1);
$data['currentCount'] = $total;

foreach($data['userRow'] as $row){
$row->parentRow = "";
if($row->parent_id){
$parentRow = $this->general_db_model-
>getById('tbl_users',array('id'=>$row->parent_id),1,'first_name,last_name,id');
$row->parentRowId = $parentRow->id;
$row->parentName = $parentRow->first_name.' '.$parentRow-
>last_name;
}
$currencyRow = $this->general_db_model-
>getById('tbl_currency',array('currency_id'=>$row->currency_id));
if($currencyRow){
$row->currency = $currencyRow->currency;
}else {
$row->currency = 'AUD';
}
}
$this->load->model('admin/partners_model');
$data['partners'] = $this->partners_model->getPartners('',
'first_name,last_name');
$data['partnerId'] = $partnerId;
$this->template->load('default/partialAdmin/index',
'default/partialAdmin/user_management', $data);
}

You might also like