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

class c_limbo extends CI_Controller {
	function __construct(){
		parent::__construct();		
		$this->load->model('m_masters');
        $this->load->helper(array('url','html','form'));
        $this->load->library('session');
		ini_set('max_execution_time', 0); 
		date_default_timezone_set("Asia/Jakarta");
	}
	public function index()
	{
	}

	public function changepassword()
	{
		$errmsg = "";
		$password = $this->input->post('password');
		$confpassword = $this->input->post('confpassword');

		if($password == "")
		{
			$errmsg = $errmsg. "<br>". "Password cannot be empty!";
		}
		if($password <> $confpassword)
		{
			$errmsg = $errmsg . "<br>". "Password and Confirm Password does not match!";
		}

		if ($errmsg == "")
		{
		    	$querystring = "update operators set password = md5('".$password."') where operator = '".$this->session->userdata('tempusername')."'";
				$this->m_masters->querying($querystring);

				$querystring = "update operators set loggedin ='1' where operator = '".$this->session->userdata('tempusername')."'";
				$this->m_masters->querying($querystring);
				$currentusername = $this->session->userdata('tempusername');
				$currentprivileges = $this->session->userdata('tempprivileges');
				$currentprivilege = $this->session->userdata('tempprivilege');

				$this->session->set_userdata('username',$currentusername);
				$this->session->set_userdata('privileges',$currentprivileges);
				$this->session->set_userdata('privilege',$currentprivilege);	
				echo 'Password Successfully updated!';
		}
		else
		{
			echo $errmsg ;
		}
	}

	public function changepasswordawal()
	{
		$this->load->view('v_CPA');
	}
}