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

class User extends CI_Controller {
    private $isLoggedIn;
    function __construct(){
        parent::__construct();
        $this->load->model('user_model', 'user_m');
    }

    function profile(){
        chekLoggedInAndAjaxReq();
        $this->load->view('user/profile');
    }

    function updateDataProfileJson(){
        chekLoggedInAndAjaxReq();
        $params   = $this->input->post();
        $response = $this->user_m->updateDataProfile($params);
        echo json_encode($response);
    }

    function changePass(){
        chekLoggedInAndAjaxReq();
        $this->load->view('user/change_pass');
    }

    function updatePasswordJson(){
        chekLoggedInAndAjaxReq();
        $params   = $this->input->post();
        $response = $this->user_m->updateDataPassword($params);
        echo json_encode($response);
    }

    function listData(){
        $this->load->view('user/manage_user');
    }

    function getJsonDataUser(){
        $params   = $this->input->post();
        $response = $this->user_m->getDataUserDtTable($params);
        echo json_encode($response);
    }

    function getdetailDataUserJson(){
        $params   = $this->input->post();
        $response = $this->user_m->getdetailDataUser($params);
        echo json_encode($response);
    }

    function resetPasswordUserJson(){
        $params   = $this->input->post();
        $response = $this->user_m->resetPasswordUser($params);
        echo json_encode($response);
    }

    function addUserJson(){
        $params   = $this->input->post();
        $response = $this->user_m->addUser($params);
        echo json_encode($response);
    }

    function editUserJson(){
        $params   = $this->input->post();
        $response = $this->user_m->editUser($params);
        echo json_encode($response);
    }

    function deleteDataUserJson(){
        $params   = $this->input->post();
        $response = $this->user_m->deleteDataUser($params);
        echo json_encode($response);
    }

    function logout(){
        $this->session->sess_destroy();
        redirect('login');
    }

}
