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

class Popup_waste extends CI_Controller {

	/*Limit Paging*/
	var $limit = 10;
	function __construct()
	{
		parent::__construct();
		$this->load->model('branch/cabang_model', '', TRUE);
	}

	function index()
	{
			//$this->fungsi->fungsi();
			$this->list_waste();
	}

/*List Waste*/
function list_waste()
{
//Default
if($this->session->userdata('txt_cari_waste')=='')
{
$this->session->set_userdata('txt_cari_waste', '');
$this->session->set_userdata('txt_opt_waste', 'idlimbah');
}
//$this->fungsi->menu_auth();	
  $data['title'] ='.::PT WGI Web Application::. | Popup List Waste';
  $data['sub_title'] = 'POPUP WASTE';
  $data['content'] = 'popup/popup_waste';	
  $data['form_action']= site_url('popup/popup_waste/');

//Otorisasi menu

		
		$this->fungsi->trans_auth($this->session->userdata('view'));
		$data['form_action']= site_url('popup/popup_waste/popup_waste');
	
if(isset($_POST['button']))
			{
				$data['txt_cari_waste'] = $this->input->post('txt_cari_waste');
				$data['txt_opt_waste'] = $this->input->post('txt_opt_waste');
				//set session user data untuk pencarian, untuk paging pencarian
				$this->session->set_userdata('txt_cari_waste', $data['txt_cari_waste']);
				$this->session->set_userdata('txt_opt_waste', $data['txt_opt_waste']);
			} 
			else 
			{
				$data['txt_cari_waste'] = $this->session->userdata('txt_cari_waste');
				$data['txt_opt_waste'] = $this->session->userdata('txt_opt_waste');
			}

/* Setting Parameter Untuk Paging */
$uri_segment = 4;
$offset =    $this->uri->segment($uri_segment);
$waste = $this->cabang_model->search_waste($this->limit, $offset,$data['txt_opt_waste'],$data['txt_cari_waste'])->result();
$num_rows = $this->cabang_model->count_all_num_rows_search_waste($data['txt_opt_waste'],$data['txt_cari_waste']);
$config['base_url'] = site_url('popup/popup_supp/list_waste/');
if ($num_rows > 0) // Jika query menghasilkan data
		{
			// Membuat pagination			
			$config['total_rows'] = $num_rows;
			$config['per_page'] = $this->limit;
			$config['uri_segment'] = $uri_segment;
			$this->pagination->initialize($config);
			$data['pagination'] = $this->pagination->create_links();
			$i = 0 + $offset;
			
			$tmpl = array( 'table_open'    => '<table border="0" cellpadding="1" cellspacing="1" id="list">',
						  'row_alt_start'  => '<tr class="zebra">',
						  'row_alt_end'    => '</tr>'
						  );
			$this->table->set_template($tmpl);

			// Set heading untuk tabel
			$this->table->set_empty("&nbsp;");
			$this->table->set_heading('ID', 'Name', 'Option');
		
			foreach ($waste  as $wastes)
			{		
$this->table->add_row($wastes->idlimbah, $wastes->name, anchor('#','Select',array('class' => 'ok','onclick' => 'sendValue('.'\''.$wastes->name.'\''.','.'\''.$wastes->idlimbah.'\''.','.'\''.$wastes->vnumb.'\''.');')));		
					
			}
			$data['table'] = $this->table->generate();
			$data['message']= '';
			}
			else
			{
			$data['message']= 'Data Empty.';
			}		
		$data['link'] = array('link_add' => anchor('branch/cabang_waste/add_waste_proc','Add Waste', array('class' => 'add','target' => '_blank')));
		$this->load->view('templates/theme01/template_popup', $data);


}



}

