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

class Dashboard_delegasi extends CI_Controller {
	function index(){
		
		if($this->session->userdata('is_logged_in')==FALSE){
			redirect('login');
		}
		$this->load->model('antrian/antrian_dirput_m','antrian_dirput');
        $page=$this->uri->segment(3);
        $batas=1;
        if(!$page):
        $offset = 0;
        else:
        $offset = $page;
        endif;

        $data['key']="";
        $postkata = $this->input->post('key');
        if(!empty($postkata))
        {
            $data['key'] = $this->input->post('key');
            $this->session->set_userdata('key_word', $data['key']);
        }
        else
        {
            $data['key'] = $this->session->userdata('key_word');
        }
        $data['data_antrian'] = $this->antrian_dirput->get_antrian($batas,$offset,$data['key']);
        $tot_hal = $this->antrian_dirput->get_total_antrian();
        $config['base_url'] = base_url() . 'antrian_dirput/cari/';
        $config['total_rows'] = $tot_hal->num_rows();
        //print_r($config['total_rows']);
        $config['per_page'] = $batas;
        $config['uri_segment'] = 3;
        $config['full_tag_open'] = '<ul class="pagination" pagination-sm no-margin pull-right>';
        $config['full_tag_close'] = '</ul>';
        $config['first_link'] = '&laquo; First';
        $config['first_tag_open'] = '<li class="prev page">';
        $config['first_tag_close'] = '</li>';
        $config['last_link'] = 'Last &raquo;';
        $config['last_tag_open'] = '<li class="next page">';
        $config['last_tag_close'] = '</li>';
        $config['next_link'] = 'Next &rarr;';
        $config['next_tag_open'] = '<li class="next page">';
        $config['next_tag_close'] = '</li>';
        $config['prev_link'] = '&larr; Prev';
        $config['prev_tag_open'] = '<li class="prev page">';
        $config['prev_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li><a href="">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li class="page">';
        $config['num_tag_close'] = '</li>';
        $this->pagination->initialize($config);
        $data["paginator"] =$this->pagination->create_links();
        print_r($data["paginator"]);
        $data['jlhpage']=$page;
        $data['jumlah_row']=$tot_hal->num_rows();
        $this->load->view('header');
        $this->load->view('antrian/antrian_dirput_v',$data);
        $this->load->view('footer');
	}

	public function cari(){
        $page=$this->uri->segment(3);
        $batas=1;
        if(!$page):
        $offset = 0;
        else:
        $offset = $page;
        endif;

        $data['keyword']="";
        $keyword = $this->input->post('keyword');
        echo $keyword;
        if(!empty($keyword))
        {
            $data['keyword'] = $this->input->post('keyword');
            $this->session->set_userdata('keyword', $data['keyword']);
        }
        else
        {
            $data['keyword'] = $this->session->userdata('keyword');
        }

        $this->load->model('antrian/antrian_dirput_m','antrian_dirput');
        $tot_hal = $this->antrian_dirput->get_total_antrian($data['keyword']);
        $data['data_antrian'] = $this->antrian_dirput->get_antrian($batas,$offset,$data['keyword']);
        $config['base_url'] = base_url() . 'antrian_dirput/cari/';
        $config['total_rows'] = $tot_hal->num_rows();
        $config['per_page'] = $batas;
        $config['uri_segment'] = 3;
        $config['full_tag_open'] = '<ul class="pagination" pagination-sm no-margin pull-right>';
        $config['full_tag_close'] = '</ul>';
        $config['first_link'] = '&laquo; First';
        $config['first_tag_open'] = '<li class="prev page">';
        $config['first_tag_close'] = '</li>';
        $config['last_link'] = 'Last &raquo;';
        $config['last_tag_open'] = '<li class="next page">';
        $config['last_tag_close'] = '</li>';
        $config['next_link'] = 'Next &rarr;';
        $config['next_tag_open'] = '<li class="next page">';
        $config['next_tag_close'] = '</li>';
        $config['prev_link'] = '&larr; Prev';
        $config['prev_tag_open'] = '<li class="prev page">';
        $config['prev_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li><a href="">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li class="page">';
        $config['num_tag_close'] = '</li>';
        $this->pagination->initialize($config);
        $data["paginator"] =$this->pagination->create_links();
        $data['jlhpage']=$page;
        $data['$total_rows']=$tot_hal->num_rows();
        $data['jumlah_row']=$tot_hal->num_rows();
        $this->load->view('header');
        $this->load->view('antrian/antrian_dirput_v',$data);
        $this->load->view('footer');
    }

}
