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

class TestModel extends CI_Model{



	public function getEmployeeInfoProcessing($company_id) {

		$this->db->select("SHA1(employee_id) as employee_id, patient_tracking_no,CONCAT(patient_tracking_no,' - ',firstname,' ',lastname) as full_name");
		$this->db->where('company_id',$company_id);
		$query = $this->db->get('hcs_employee');

		echo json_encode($query->result_array());
	}   

	public function getOneEmployeeInfoProcessing($id,$company_id){
		$result=$this->getIDProcessing($id);
		$employee_id=$result->employee_id;
		$this->db->select("SHA1(employee_id) as employee_id,firstname, lastname, gender, employee_number, payroll_number, date_of_birth, address, contact_no, email,post_code,IFNULL(driving_license,'N/A') as driving_license,IFNULL(passport,'N/A') as passport,nin");
		$this->db->where('employee_id',$employee_id);
		$this->db->where('company_id',$company_id);
		$query = $this->db->get('hcs_employee');

		echo json_encode($query->row());
	} 

	public function getIDProcessing($id) {
        $this->db->select("employee_id");
        $this->db->where('sha1(employee_id)',$id);
        $query = $this->db->get('hcs_employee');
        return $query->row();
    }

    public function getPatientTrackingNo($company_id){
    	$this->db->select('*');
    	$this->db->where('company_id',$company_id);
		$this->db->from('hcs_employee');
		$this->db->limit(1);
		$this->db->order_by('employee_id','DESC');
		$query=$this->db->get();
		if($query->num_rows() >0){
			$row=$query->row();
			$patient_tracking_no=$row->patient_tracking_no+1;
		}
		else{
			$patient_tracking_no=0;
		}
    	return $patient_tracking_no;
    }


}