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

class Login extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		
		$this->load->model('login_mdl','mdl');
	}
	
	public function index()
	{			
		$data['title'] = 'LOGIN';
		// echo $this->encrypt->encode('admin');
		// echo "<br>".$this->encrypt->decode('eVbsDQjTcnUtV7+CV/Xc9ZFpjiXFSXP0WzX9LpexhlHedvGS6j9ogM8+9Z5x40FKnHmTLEeod88ae11JQP2O9Q==');
		$this->load->view('login/login_form',$data);		
		//var_dump($this->session->all_userdata());
		
	}

	public function registrasi()
	{			
		$data['title'] = 'Registrasi';
		$this->load->view('login/registrasi_form',$data);		
		//var_dump($this->session->all_userdata());
		
	}

	public function forgotpassword()
	{			
		$data['title'] = 'Forget Password';
		// echo $this->encrypt->encode('admin');
		// echo "<br>".$this->encrypt->decode('eVbsDQjTcnUtV7+CV/Xc9ZFpjiXFSXP0WzX9LpexhlHedvGS6j9ogM8+9Z5x40FKnHmTLEeod88ae11JQP2O9Q==');
		$this->load->view('login/forgotpassword_form',$data);		
		//var_dump($this->session->all_userdata());
		
	}
	
	function loginpass()
	{			
		$form_data = $this->input->post();
		$return = $this->mdl->do_login($form_data);
		if($return){
			echo json_encode(array('success'=>true,'msg'=>'Login Berhasil!'));
		} else {			
			echo json_encode(array('msg'=>"Login Gagal, Password yang anda masukan salah!"));
		}
	}
	
}

