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

class Pengaturan_lembur_m extends CI_Model {
    var $table = 'p_approval_lembur';

    public function delete($id=null){
        $this->db->where(array('md5(id)'=>$id));
        $delete =$this->db->delete($this->table);

        return  __response_delete($delete);
    }

    public function get_atasan($id = null, $search = null){
        $level = $this->db->select("level_user")->from("master_jabatan")->where("id_jabatan", $id)->get()->row()->level_user;
        $this->db->select('nama, id_jabatan');
        $this->db->like('nama', $search);
        $this->db->order_by('id_jabatan', 'ASC');
        $this->db->where('level_user', $level);
        $this->db->where('id_jabatan !=', $id);

        $result = $this->db->get('master_jabatan')->result();
        $json = [];
        foreach ($result as $rows) {
            $json[] = ['id'=>$rows->id_jabatan, 'text'=>$rows->nama];
        }
        echo json_encode($json);
    }
}