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

class User_management_model extends CI_Model {

	function __construct()
    {
     parent::__construct();		
	
    }
	
	function get_users($corp_id,$user_type)
	{
		$this->db->select('*');
		$this->db->where('corporation_id',$corp_id);
		$this->db->where('user_type',$user_type);
		$query = $this->db->get('users');
		if($query->num_rows()>0)
		{
			$row = $query->result();
			return $row;
		} 
		else
		{
			return NULL;
		}		
		
	}
	
	function get_admins()
	{
		$this->db->select('*');
		$this->db->where('user_type',2);
		$query = $this->db->get('users');
		if($query->num_rows()>0)
		{
			$row = $query->result();
			return $row;
		} 
		else
		{
			return NULL;
		}
	}
	
	function fetch_user_data($user_id)
	{
		$this->db->where('user_id',$user_id);
		$query = $this->db->get('users');
		if($query->num_rows()==1)
		{
			$row = $query->result_array();
			return $row;
		} 
		else
		{
			return NULL;
		}	
	}
	
	function get_next_of_kin()
	{
		/*$this->db->where('user_id',$user_id);
		$query = $this->db->get('next_of_kin');*/
		$query = $this->db->get('next_of_kin');	
				
	}	

	
	function get_corporation_name($corporation_id)
	{
		$this->db->select('*');
		$this->db->from('corporations');
		$this->db->where('corporation_id',$corporation_id);
		$query = $this->db->get();
		if ($query->num_rows() == 1)
		{
			$row = $query->row_array(); 
			return $row['corporation_name'];  
		}
		else 
			return NULL;
	}
	
	
}
?>