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

class ControllerProfile extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();
        //validasi jika user belum login
        check_not_login();
        if ($this->session->userdata('level') != 2) {
            redirect();
        }
        $this->set_timezone();
        $this->load->library('encrypt');
        $this->load->library('form_validation');
        $this->load->library('Mycustom');
        $this->load->library('pdfgenerator');
        $this->load->library('Notifikasi');
        $this->load->model('bagian_manager/insert_model');
        $this->load->model('bagian_manager/select_model');
        $this->load->model('bagian_manager/update_model');
        $this->set_timezone();
    }
    public function set_timezone()
    {
        date_default_timezone_set("Asia/Jakarta");
    }
    public function index()
    {
        // NOtifikasi
        $notif = $this->notifikasi->notif_manager();
        $data_login                = $this->userlogin->user_login('isloggedin');
        $data_id_login             = $this->session->userdata('isloggedin');
        // End Notifikasi
        $login_id                  = $data_id_login;
        $data_login_karyawan       = $this->db->get_where('sistem_login', ['id' => $login_id])->row_array();
        $date_role_level           = $this->db->get_where('sistem_role_level', ['id' => $data_login_karyawan['role_id']])->row_array();
        $data_identitas            = $this->db->get_where('sistem_identitas', ['login_id' => $data_login_karyawan['id']])->row_array();
        $data_alamat               = $this->db->get_where('sistem_alamat', ['id' => $data_identitas['alamat_id']])->row_array();
        $data_kotkab               = $this->select_model->vd_kotkab();
        // echo '<pre>';
        // var_dump($login_id);
        // die;
        $data = array(
            // Untuk memanggil halaman sesuai menu
            'folder'            => 'identitas/profile',
            'page'              => 'index',
            'judul'             => 'Data Identitas Saya || Bagian Manager',
            'data_id_login'     => $data_id_login,
            'data_login'        => $data_login,
            'notif'             => $notif,
            'data_kota'         => $data_kotkab,
            // Data Login      
            'login'             => $data_login_karyawan,
            'role_level'        => $date_role_level,
            'identitas'         => $data_identitas,
            'alamat'            => $data_alamat
        );
        $this->load->view('manager/index', $data);
    }
}

/* End of file ControllerProfile.php and path \application\controllers\manager\ControllerProfile.php */