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

class Onbording_model extends CI_Model
{
    public function departments(){
        $data = $this->db->select("*")
            ->from('department')
            ->get()
            ->result();
        $list[''] = display('select_department');
        $list['all'] = display('all');
        if (!empty($data)) {
            foreach($data as $value)
                $list[$value->dept_id] = $value->department_name;
            return $list;
        } else {
            return false;
        }
    }
    public function designation(){
        $this->db->select('*');
        $this->db->from('position');
        $query = $this->db->get();
        return $data = $query->result();
    }
    public function crate_appointment_letter($data){
        return $this->db->insert('appointment_letter', $data);
    }
    public function view_appointment_letter_model($val){
        return $this->db->select('*')
            ->from('appointment_letter')
            ->where('report_type', $val)
            ->get()
            ->result();
    }
    public function view_appointment_letter_model_join($val){
        return $this->db->select('appointment_letter.*,position.position_name')
            ->from('appointment_letter')
            ->join('position','appointment_letter.pos_id = position.pos_id')
            ->where('report_type', $val)
            ->get()
            ->result();
    }
    public function view_employs(){
        return $this->db->select('*')
            ->from('employee_history')
            ->get()
            ->result();
    }
    public function select_employs($id){
        return $this->db->select('first_name,last_name')
            ->from('employee_history')
            ->where(['employee_id' => $id])
            ->get()
            ->result();
    }
    public function select_designation($id){
        return $this->db->select('position_name')
            ->from('position')
            ->where(['pos_id' => $id])
            ->get()
            ->result();
    }
    public function select_departments($id){
        return $this->db->select('department_name')
            ->from('department')
            ->where(['dept_id' => $id])
            ->get()
            ->result();
    }
}