<?php defined('BASEPATH') OR exit('No direct script access allowed');

class EmployeeGroupModel extends CI_Model {

    function __construct()
    {
        parent::__construct();
        date_default_timezone_set('Asia/Hong_Kong');
        
    }
    function getAllEmployeeGroup() {
        // $this->db->from('mas_employee_group');
        $this->db->from('mas_rbac_roles');

        $query = $this->db->get();
        return $query->result();
    }
    function getBannerAll()
    {
        
        $this->db->from('frontendUsers');
        // $this->db->where(array('show' => 1));
        // $this->db->order_by('rank');
        $query = $this->db->get();
        return $query->result();
    }


    function checking(){

    	$userid = $this->session->userdata('userid');
    	$username = $this->session->userdata('username');
    	$fullName = $this->session->userdata('fullName');
    	$logged_in = $this->session->userdata('logged_in');
    	$secret = $this->session->userdata('secret');
    	$usertype = $this->session->userdata('usertype');

    	$passLogin=false;
    	if($usertype=="frontenduser"){
    		if($logged_in==false){
    			return false;
    		}
    		if(empty($userid)){
    			return false;
    		}
    		if(empty($secret)){
    			return false;
    		}
    		$this->db->where('id',$userid);
        	$this->db->where('secret',$secret);
        	if($this->db->get('frontendUsers')->row_array()){
        		$passLogin=true;
        		return true;
        	}	
        	else{
        		return false;
        	}

    	}//if($usertype=="frontenduser"){
    	if($usertype=="backenduser"){
    	    if($logged_in==false){
    			return false;
    		}
    		if(empty($userid)){
    			return false;
    		}
    		if(empty($secret)){
    			return false;
    		}
    		$this->db->where('id',$userid);
        	$this->db->where('secret',$secret);
        	if($this->db->get('adminUsers')->row_array()){
        		$passLogin=true;
        		return true;
        	}	
        	else{
        		return false;
        	}
    	
    	}
    }
 }