<?php 

/*

Fungsi : Controller untuk create BA

*/



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



class Security_pos1 extends CI_Controller {

	

/*-------------Inisialisasi variabel--------------*/ 

	

	//Menu ID utk keperluan otorisasi

	var $menu_list_izin_masuk  = 228;

	var $menu_create_izin_masuk = 227;

	

/*-------------Inisialisasi variabel--------------*/ 	



/*------------Fungsi local------------------------*/	

	function __construct()
	{

		parent::__construct();
		$this->load->model('security/security_model', '', TRUE);
		$this->fungsi->check_login();
	}

	public function index()
	{	
		$this->security_add_izin_masuk();
	}
	


	function security_add_izin_masuk()
	{	
		$this->fungsi->menu_auth($this->menu_create_izin_masuk);
		$data['menu_path'] = 'CIBITUNG > SECURITY > IZIN MASUK > CREATE IZIN MASUK POS I';
		$data['form_action']= site_url('security/security_pos1/add_izin_masuk');
		$this->load->view('security/security_izin_masuk_pos1_form', $data);
	}

	function add_izin_masuk()
	{
		$this->fungsi->trans_auth($this->session->userdata('add'));

		$data = array(
						'pos' => "1",
						'nama_pengunjung' => $this->input->post('nama_pengunjung'),
						'alamat' => $this->input->post('alamat'),
						'nama_perusahaan' => $this->input->post('nama_perusahaan'),
						'nama_yang_dikunjung' => $this->input->post('nama_yang_dikunjung'),
						'tujuan_kunjungan' => $this->input->post('tujuan_kunjungan'),
						'sudah_janji' => $this->input->post('janji'),
						'tanggal_kunjungan' => $this->input->post('tanggal_kunjungan'),
						'jumlah_pengunjung' => $this->input->post('jumlah_pengunjung'),
						'no_polis' => $this->input->post('no_polis'),
						'no_kartu_pengunjung' => date('no_kartu_pengunjung'),
						'jam_masuk' => $this->input->post('jam_keluar'),
						'jam_keluar' => $this->input->post('jam_keluar')
					 );

		$this->security_model->addIzinMasuk($data);
		$this->session->set_flashdata('message_ok', 'Data surat izin masuk pos 1 tersimpan.');
		redirect('security/security_pos1');
	}

	// function list_izin_masuk()
	// {
	// 	//Otorisasi menu
	// 	$this->fungsi->menu_auth($this->menu_list_izin_masuk);
		
	// 	//Check otorisasi
	// 	$this->fungsi->trans_auth($this->session->userdata('view'));
		
	// 	if(isset($_POST['submit']))
 //        {
 //            $data['search'] = $this->input->post('txt_search');
	//         //set session user data untuk pencarian, untuk paging pencarian
	//         $this->session->set_userdata('sess_search', $data['search']);
 //        } else 
 //        {
 //            $data['search']  =  $this->session->userdata('sess_search');
 //        }
			
	// 	/* Setting Parameter Untuk Paging */
	// 	$uri_segment = 4;
	// 	$offset = $this->uri->segment($uri_segment);
	// 	$izin_masuk = $this->security_model->viewIzinMasuk($this->config->item('paging_limit'), $offset, $data['search'], '1')->result();
	// 	$num_rows = $this->security_model->countIzinMasuk($data['search'], '1');
	// 	$data['total'] = $num_rows;
	// 	$config['base_url'] = site_url('security/security_pos1/add_izin_masuk');
	// 	if($num_rows > 0) // Jika query menghasilkan data
	// 	{
	// 		// Membuat pagination			
	// 		$config['total_rows'] = $num_rows;
	// 		$config['per_page'] = $this->config->item('paging_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('Tanggal Kunjungan', 'Nama Pengunjung', 'Alamat', 'Nama Perusahaan', 'Nama Yang Dikunjungi', 'Tujuan Kunjungan', 'Janji', 'Jumlah Pengunjung', 'Nomor Polisi', 'Nomor Kartu Pengunjung', 'Jam Masuk', 'Jam Keluar');
				
	// 		foreach($izin_masuk as $row)
	// 		{	
	// 			$this->table->add_row($row->tanggal_kunjungan, $row->nama_pengunjung, $row->alamat, $row->nama_perusahaan, $row->nama_yang_dikunjung, $row->tujuan_kunjungan, $row->sudah_janji, $row->jumlah_pengunjung, $row->no_polis, $row->no_kartu_pengunjung, date('H:i', strtotime($row->jam_masuk)), date('H:i', strtotime($row->jam_keluar)), anchor('security/security_ba/edit_form_ba/'.$row->id,'Edit',array('class' => 'update')));
	// 		}
	// 		$data['table'] = $this->table->generate();
	// 	} else
	// 	{
	// 		$data['message'] = 'No data to display';
	// 	}		
	// 	$data['menu_path'] = 'CIBITUNG > SECURITY > IZIN MASUK > LIST IZIN MASUK POS I';
	// 	//$data['link'] = array('link_back' => anchor('admin/admin_role','Back', array('class' => 'back')));	
	// 	$data['form_action']= site_url('security/security_pos1/list_izin_masuk');
	// 	$this->load->view('security/security_list_izin_masuk_pos1', $data);
	// }	


}