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

class Pengaturan_reimbursement_m extends CI_Model {
    var $table = 'p_approval_reimbursement';

    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->query("SELECT level_user FROM master_jabatan WHERE id_jabatan = '$id'")->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);
    }
}