<?php
class Smart extends CI_Controller {

    function __construct() {
        parent::__construct();
		//error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
    $this->load->library('session');
    }
    function index() {
			$this->load->view('smart/login');
    }
    function i_login() {
			$this->load->view('smart/i_login');
    }
    function i_akun_history() {
			$this->load->view('smart/i_akun_history');
    }
    function i_akun_profil() {
			$this->load->view('smart/i_akun_profil');
    }
    function i_upload_profil() {
			$this->load->view('smart/i_upload_profil');
    }
    function i_upload() {
			$this->load->view('smart/i_upload');
    }
    function i_akun_pass() {
			$this->load->view('smart/i_akun_pass');
    }
    function i_set_lokasi() {
			$this->load->view('smart/i_set_lokasi');
    }
    function main() {
			$this->load->view('smart/main');
    }
    function i_utama() {
			$this->load->view('smart/i_utama');
    }
    function i_absensi() {
			$this->load->view('smart/i_absensi');
    }
	function i_absensi2() {
			$this->load->view('smart/i_absensi2');
    }
    function i_menu1() {
			$this->load->view('smart/i_menu1');
    }
    function i_ijin() {
			$this->load->view('smart/i_ijin');
    }
    function i_menu2() {
			$this->load->view('smart/i_menu2');
    }
    function i_manual_masuk() {
			$this->load->view('smart/i_manual_msk');
    }
    function i_manual() {
			$this->load->view('smart/i_manual');
    }
    function i_manual_pulang() {
			$this->load->view('smart/i_manual_plg');
    }
    function i_deteksi() {
			$this->load->view('smart/i_deteksi');
    }
    function i_jamku() {
			$this->load->view('smart/i_jamku');
    }
	function i_jurnal() {
			$this->load->view('smart/i_jurnal');
    }
	function i_pendidikan() {
			$this->load->view('smart/i_pendidikan');
    }
	function i_pelatihan() {
			$this->load->view('smart/i_pelatihan');
    }
	function i_tiket() {
			$this->load->view('smart/i_tiket');
    }
	function proses() {
        $this->form_validation->set_rules('username', 'username', 'required|trim|xss_clean');
        $this->form_validation->set_rules('password', 'password', 'required|trim|xss_clean');

        if ($this->form_validation->run() == FALSE) {
            $this->load->view('login5');
        } else {
			$menuju='';
            $usr = $this->input->post('username');
            $psw = $this->input->post('password');
            $u = $this->db->escape_str($usr);
            $p = $this->db->escape_str($psw);
					$cek = $this->m_user->cek($u, $p);
					if ($cek->num_rows() > 0) {
						//login berhasil, buat session
						foreach ($cek->result() as $qad) {
							$menuju="smart/depan";
							$sess_data['id'] = $qad->id;
							$sess_data['nama'] = $this->balikin($qad->nama);
							$sess_data['username'] = $qad->user;
							$this->session->set_userdata($sess_data);
							$pesane=date("d M Y")." ".date("h:i:s")." Nama : ".$this->balikin($qad->nama)." username : ".$qad->user." Telah melakukan login";
								kirimtelegram($pesane);
						}
						
						redirect($menuju);
					} else {
						$this->session->set_flashdata('result_login', '<br>Username atau Password yang anda masukkan salah.'.$adauser);
						redirect('smart');
					}

        }
    }
}
