Virajsinh

filter_data_role_wise_DataTable

Nov 12th, 2019
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1.     if($this->session->userdata('role') == "Admin")
  2.     {
  3.         $role_wise = "";
  4.     }elseif($this->session->userdata('role') == "CompanyAdmin"){
  5.         $role_wise = "AND company_id = ".$this->session->userdata('company_id');
  6.     }else{
  7.         $role_wise = "AND company_id = ".$this->session->userdata('company_id')." AND created_by = ".$this->session->userdata('created_by')." OR created_by = ".$this->session->userdata('id');
  8.     }
  9.  
  10.         $sQuery = "SELECT SQL_CALC_FOUND_ROWS " . str_replace(" , ", " ", implode(", ", $aColumns)) . "
  11.        FROM tbl_users
  12.        $sWhere ".$role_wise."
  13.        $sOrder
  14.        $sLimit
  15.        ";
  16.  
  17.     $aColumns = array(
  18.         '(SELECT IFNULL((SELECT name FROM tbl_company WHERE id=company_id),"not found")) AS company_by_name',
  19.     );
  20.         '(SELECT IFNULL((SELECT CONCAT_WS(" ", first_name, last_name) FROM tbl_users WHERE id=tbl_tasks.created_by),"not found")) AS created_by_name',
  21.  
  22.     $whereColumns = array(
  23.         '(SELECT IFNULL((SELECT name FROM tbl_company WHERE id=company_id),"not found"))',
  24.         '(SELECT IFNULL((SELECT CONCAT_WS(" ", first_name, last_name) FROM tbl_users WHERE id=tbl_tasks.created_by),"not found"))',
  25.     );
Add Comment
Please, Sign In to add comment