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

class Dropdown_menu_preselect extends MY_Controller{

    public function karyawan($id) 
    {
        $data = $this->db->select('id_karyawan, nik, nama_lengkap')
            ->get_where('data_karyawan', ['id_karyawan' => $id])->row();
        echo json_encode([
                'id'   => $data->id_karyawan,
                'text' => $data->nik.' - '.$data->nama_lengkap
        ]);
    }

    public function jabatan($id) 
    {
        $data = $this->db->select('nama, id_jabatan, kode_jabatan')
            ->get_where('master_jabatan', ['id_jabatan' => $id])->row();
        echo json_encode([
                'id'   => $data->id_jabatan,
                'text' => $data->kode_jabatan.' - '.$data->nama
        ]);
    }

    public function cabang($id) 
    {
        $data = $this->db->select('nama, id_cabang, kode')
            ->get_where('master_cabang', ['id_cabang' => $id])->row();
        echo json_encode([
                'id'   => $data->id_cabang,
                'text' => $data->kode.' - '.$data->nama
        ]);
    }

    public function departemen($id) 
    {
        $data = $this->db->select('nama, id_departemen, kode')
            ->get_where('master_departemen', ['id_departemen' => $id])->row();
        echo json_encode([
                'id'   => $data->id_departemen,
                'text' => $data->kode.' - '.$data->nama
        ]);
    }
}
