<?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') != 7) {
            redirect();
        }
        $this->load->library('encrypt');
        $this->load->library('form_validation');
        $this->load->library('mycustom');
        $this->load->model('marketing/insert_model');
        $this->load->model('marketing/select_model');
        $this->load->model('marketing/update_model');
        $this->set_timezone();
    }
    public function set_timezone()
    {
        date_default_timezone_set("Asia/Jakarta");
    }

    public function index()
    {
        // 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 Marketing',
            'data_id_login'       => $data_id_login,
            'data_login'          => $data_login,
            // Isi data
            'data_gaji'           => $data_gaji
        );
        $this->load->view('marketing/index', $data);
    }
    // Karyawan GAji
    public function detail($id)
    {
        // NOtifikasi
        $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 Marketing',
            // 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('marketing/index', $data);
    }
}

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