<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Psikolog extends CI_Controller {
	function index(){
		if (isset($_POST['submit'])){
			$username = $this->input->post('a');
			$password = hash("sha512", md5($this->input->post('b')));
			$cek = $this->model_app->cek_login($username,$password,'users');
		    $row = $cek->row_array();
		    $total = $cek->num_rows();
			if ($total > 0){
				$this->session->set_userdata('upload_image_file_manager',true);
				$this->session->set_userdata(array('username'=>$row['username'],
								   'level'=>$row['level'],
                                   'id_session'=>$row['id_session']));

				redirect('administrator/home');
			}else{
				$data['title'] = 'Username atau Password salah!';
				$this->load->view('administrator/view_login',$data);
			}
		}else{
			$data['title'] = 'Psikolog &rsaquo; Log In';
			$this->load->view('administrator/view_login_psikolog',$data);
		}
	}

	function lists(){
		$jumlah= $this->model_utama->view_where('users',array('level'=>'user'))->num_rows();
		$config['base_url'] = base_url().'psikolog/list/';
		$config['total_rows'] = $jumlah;
		$config['per_page'] = 30; 	
		if ($this->uri->segment('3')==''){
			$dari = 0;
		}else{
			$dari = $this->uri->segment('3');
		}
		$data['title'] = "Psikolog Kami";
		$data['description'] = description();
		$data['keywords'] = keywords();
		if (is_numeric($dari)) {
			$data['psikolog'] = $this->model_utama->view_where_ordering_limit('users',array('level'=>'user'),'username','DESC',$dari,$config['per_page']);
		}else{
			redirect('main');
		}
		$this->pagination->initialize($config);
		$this->template->load(template().'/template',template().'/psikolog_list',$data);
	}
}
