<?php 

class Model_users extends CI_Model {
	
	public function logIn() {
		
		$this->db->where('email', $this->input->post('email'));
		$this->db->where('password',md5($this->input->post('password')));
		
		$query = $this->db->get('zamestnanec');	
		if ($query->num_rows() == 1) {			
			return true;
		} else {
			return false;
		}
	}
	
	public function checkActivity(){
		$sql = 'SELECT zamestnanec.Status FROM zamestnanec WHERE zamestnanec.Email="'.$this->input->post('email').'"';
		$query = $this->db->query($sql)->row();
		if ($query->Status==3){
			return FALSE;	
		}else{
			return TRUE;
		}
	}
	
	public function existEmail(){
		$this->db->where('email', $this->input->post('email_generate'));	
		$query = $this->db->get('zamestnanec');	
		if ($query->num_rows() == 1) {			
			return true;
		} else {
			return false;
		}
	}
	public function what_type() {
		
		$this->db->select('ID_TYP_Z');
		$this->db->where('email',$this->input->post('email'));
		$query = $this->db->get('zamestnanec');
		return $query->row()->ID_TYP_Z;			
	}
	
	public function get_employee_number() {
		$this->db->select('ID_ZAM');
		$this->db->where('email',$this->input->post('email'));
		$query = $this->db->get('zamestnanec');
		return $query->row()->ID_ZAM;
	}
	
	public function get_name() {
		$this->db->select('Meno');
		$this->db->where('email',$this->input->post('email'));
		$query = $this->db->get('zamestnanec');
		return $query->row()->Meno;
	}
	
	public function get_last_name() {
		$this->db->select('Priezvisko');
		$this->db->where('email',$this->input->post('email'));
		$query = $this->db->get('zamestnanec');
		return $query->row()->Priezvisko;
	}
	
	public function getManagerTypeId() {
		$this->db->select('ID_TYP_Z');
		$this->db->where('ID_TYP_Z', 1);
		$query = $this->db->get('typ_zamestnanca');
		return $query->row()->ID_TYP_Z;
	}
	
	public function getLeadEmployeeTypeId() {
		$this->db->select('ID_TYP_Z');
		$this->db->where('ID_TYP_Z', 2);
		$query = $this->db->get('typ_zamestnanca');
		return $query->row()->ID_TYP_Z;
	}
	
	public function getDriverTypeId() {
		$this->db->select('ID_TYP_Z');
		$this->db->where('ID_TYP_Z', 3);
		$query = $this->db->get('typ_zamestnanca');
		return $query->row()->ID_TYP_Z;
	}
	
	public function getEmployeeTypeId() {
		$this->db->select('ID_TYP_Z');
		$this->db->where('ID_TYP_Z', 4);
		$query = $this->db->get('typ_zamestnanca');
		return $query->row()->ID_TYP_Z;
	}
}