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

class ControllerDataSalery extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();
        check_not_login();
        if ($this->session->userdata('level') != 6) {
            redirect();
        }
        $this->load->library('encrypt');
        $this->load->library('form_validation');
        $this->load->library('mycustom');
        $this->load->library('Notifikasi');
        $this->load->library('pdfgenerator');
        $this->load->model('kabag_marketing/insert_model');
        $this->load->model('kabag_marketing/select_model');
        $this->load->model('kabag_marketing/update_model');
        $this->set_timezone();
    }
    public function set_timezone()
    {
        date_default_timezone_set("Asia/Jakarta");
    }
    public function index()
    {
        $notif                 = $this->notifikasi->notif_kabag_marketing();
        // Data Login
        $data_login            = $this->userlogin->user_login(); // Menampilkan siapa yang login
        $data_id_login         = $this->session->userdata('isloggedin'); // Menampilkan data session
        // Data Isian Konten
        // Query SQL Data atau isi data page 
        // Menampilkan histori gaji karyawan
        $data_gaji = $this->db->get_where('k_gaji', ['login_id' => $data_id_login])->result();
        // echo '<pre>';
        // var_dump($data_id_login);
        // die;
        $data = array(
            // Untuk memanggil halaman sesuai menu
            'folder'              => 'gaji',
            'page'                => 'index',
            'judul'               => 'Histori Gaji Karyawan || Bagian Kabag Marketing',
            'data_id_login'       => $data_id_login,
            'data_login'          => $data_login,
            'notif'               => $notif,
            // Isi data
            'data_gaji'           => $data_gaji
        );
        $this->load->view('kabag_marketing/index', $data);
    }
    // Karyawan GAji
    public function detail($id)
    {
        // NOtifikasi
        $notif                 = $this->notifikasi->notif_kabag_marketing();
        $data_login       = $this->userlogin->user_login('isloggedin');
        $data_id_login    = $this->session->userdata('isloggedin');
        // Query SQL Data atau isi data page
        // Data gaji
        $gaji_id = $this->encrypt->decode($id);
        $data_gaji = $this->db->get_where('k_gaji', ['id' => $gaji_id])->row_array();
        $detail_gaji = $this->db->get_where('k_dgaji', ['gaji_id' => $gaji_id])->result();
        $identitas_karyawan = $this->db->get_where('sistem_login', ['id' => $data_gaji['login_id']])->row_array();
        $detail_identitas = $this->db->get_where('sistem_identitas', ['login_id' => $data_gaji['login_id']])->row_array();
        $data = array(
            // Untuk memanggil halaman sesuai menu
            'folder'              => 'gaji/detail/',
            'page'                => 'index',
            'judul'               => 'Detail Gaji Karyawan || Bagian Kabag Marketing',
            'notif'               => $notif,
            // Isi data
            'data_id_login'       => $data_id_login,
            'data_login'          => $data_login,
            // Data isian konten
            'identitas'           => $identitas_karyawan,
            'gaji'                => $data_gaji,
            'detail_gaji'         => $detail_gaji,
            'detail_identitas'    => $detail_identitas
        );
        $this->load->view('kabag_marketing/index', $data);
    }
}

/* End of file ControllerDataSalery.php and path \application\controllers\kabag_marketing\kelola_data\ControllerDataSalery.php */