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

class Transit_empty_ctrl extends user_icd_index {
 
	
	public function __construct(){
		parent::__construct();  
		$data = array();
		$this->load->model('admin_model');
		$this->load->model('icd_model');		
	}
	
	/*---------- update icd_out_vehicle_gate_entry_transit_empty_list details ----------*/
	public function icd_out_vehicle_gate_entry_transit_empty_list(){		
		$data['sdata'] 			= array();
		$data['subview'] 		= 'icd/transit_empty/icd_out_vehicle_gate_entry_transit_empty_list';		
		$data['active_cls'] 	= 'conedl_cls';	
		$data['url_list'] 		= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');		
		if(isset($_POST['token_no_val'])){ 
			$token_no = $this->input->post('token_no_val');
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','',$token_no,'2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','0');
		}else if(!isset($_POST['token_no_val'])){		
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','','','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','0');
		}
		// echo $this->db->last_query();return;
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- update icd_out_vehicle_gate_entry_transit_empty_form details ----------*/
	public function icd_out_vehicle_gate_entry_transit_empty_form($igetl_id){		
		$data['sdata'] 					= array();
		$data['subview'] 				= 'icd/transit_empty/icd_out_vehicle_gate_entry_transit_empty_form';		
		$data['active_cls'] 			= 'dash';			
		$data['url_list'] 				= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');	

		$data['sdata']['aginl_no'] 		= $this->admin_model->get_result_array('auto_generate_id_no_list','aginl_id','3');
		$data['sdata']['igetl_data'] 		= $this->icd_model->get_icdl_igetl_details_list('','',$igetl_id,'','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','0');			
		$data['sdata']['itncl_list'] 	= $this->icd_model->get_icdl_itncl_details_list('',$igetl_id,'','1','','1');
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- update update_icd_out_vehicle_gate_entry_transit_empty_details details ----------*/
	public function update_icd_out_vehicle_gate_entry_transit_empty_details($igetl_id){		
		$data['igetl']['igetl_icd_out_no'] 			= $this->input->post('igetl_icd_out_no');
		
		$data['igetl']['igetl_iovgete_geo_id'] 		= $this->user['i_user_id'];
		$data['igetl']['igetl_iovgete_geo_status'] 	= '1';
		$data['igetl']['igetl_iovgete_geo_date'] 	= date("Y-m-d");
		
		$edit_igetl 			= $this->admin_model->update_data('icd_gate_entry_token_list','igetl_id',$igetl_id,$data['igetl']);
		
		$aginl_val 							=  $this->input->post('igetl_icd_out_no')+1;
		$data['aginl_details']['aginl_val'] = $aginl_val;
		$edit_aginl 						= $this->admin_model->update_data('auto_generate_id_no_list','aginl_id','3',$data['aginl_details']);

		if($edit_igetl!='0'){
			$this->session->set_flashdata('tos_success', 'Details updated');	
			redirect('icd/transit_empty_ctrl/icd_out_vehicle_gate_entry_transit_empty_list');					
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/transit_empty_ctrl/icd_out_vehicle_gate_entry_transit_empty_list');
		}			
				
	}

	/*---------- update icd_out_vehicle_transit_empty_proceed_list details ----------*/
	public function icd_out_vehicle_transit_empty_proceed_list(){		
		$data['sdata'] 			= array();
		$data['subview'] 		= 'icd/transit_empty/icd_out_vehicle_transit_empty_proceed_list';		
		$data['active_cls'] 	= 'conedl_cls';	
		$data['url_list'] 		= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');			
		if(isset($_POST['token_no_val'])){ 
			$token_no = $this->input->post('token_no_val');
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','',$token_no,'2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','0');
		}else if(!isset($_POST['token_no_val'])){		
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','','','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','0');
		}
		// echo $this->db->last_query();return;
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- update update_icd_out_vehicle_transit_empty_proceed_details details ----------*/
	public function update_icd_out_vehicle_transit_empty_proceed_details($igetl_id){		
		
		$data['igetl']['igetl_iovgete_proceed_geo_id'] 		= $this->user['i_user_id'];
		$data['igetl']['igetl_iovgete_proceed_geo_status'] 	= '1';
		$data['igetl']['igetl_iovgete_proceed_geo_date'] 		= date("Y-m-d");
		
		$edit_igetl 			= $this->admin_model->update_data('icd_gate_entry_token_list','igetl_id',$igetl_id,$data['igetl']);
				
		if($edit_igetl!='0'){
			$this->session->set_flashdata('tos_success', 'Details updated');	
			redirect('icd/icd_print_out_ctrl/icd_out_vehicle_transit_empty_proceed_print_out/'.$igetl_id);
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/transit_empty_ctrl/icd_out_vehicle_transit_empty_proceed_list');
		}			
				
	}

	/*---------- update icd_out_vehicle_transit_empty_aproove_list details ----------*/
	public function icd_out_vehicle_transit_empty_aproove_list(){		
		$data['sdata'] 			= array();
		$data['subview'] 		= 'icd/transit_empty/icd_out_vehicle_transit_empty_aproove_list';		
		$data['active_cls'] 	= 'conedl_cls';	
		$data['url_list'] 		= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');			
		if(isset($_POST['token_no_val'])){ 
			$token_no = $this->input->post('token_no_val');
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','',$token_no,'2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','0');
		}else if(!isset($_POST['token_no_val'])){		
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','','','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','0');
		}
		// echo $this->db->last_query();return;
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- load icd_out_vehicle_transit_empty_aproove_form  page  ----------*/
	public function icd_out_vehicle_transit_empty_aproove_form($igetl_id){		
		$data['sdata'] 					= array();
		$data['subview'] 				= 'icd/transit_empty/icd_out_vehicle_transit_empty_aproove_form';		
		$data['active_cls'] 			= 'dash';			
		$data['url_list'] 				= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');		
			
		$data['sdata']['igetl_data'] 		= $this->icd_model->get_icdl_igetl_details_list('','',$igetl_id,'','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','0');			
		$data['sdata']['itncl_list'] 	= $this->icd_model->get_icdl_itncl_details_list('',$igetl_id,'','1','','1');
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- update update_icd_out_vehicle_transit_empty_aproove_details details ----------*/
	public function update_icd_out_vehicle_transit_empty_aproove_details($igetl_id){		
		$data['igetl'] = array();

		foreach($_POST as $post_key=>$post_rows){
			$data['igetl'][$post_key] 		= $this->input->post($post_key);			
		}

		$data['igetl']['igetl_iovgete_aproove_iao_id'] 		= $this->user['i_user_id'];
		$data['igetl']['igetl_iovgete_aproove_iao_status'] 	= '1';
		$data['igetl']['igetl_iovgete_aproove_iao_date'] 		= date("Y-m-d");
		
		$edit_igetl 			= $this->admin_model->update_data('icd_gate_entry_token_list','igetl_id',$igetl_id,$data['igetl']);
				
		if($edit_igetl!='0'){
			$this->session->set_flashdata('tos_success', 'Details updated');	
			redirect('icd/icd_print_out_ctrl/icd_out_vehicle_transit_empty_aproove_print_out/'.$igetl_id);
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/transit_empty_ctrl/icd_out_vehicle_transit_empty_aproove_list');
		}			
				
	}

	/*---------- update icd_out_authorize_transit_empty_list details ----------*/
	public function icd_out_authorize_transit_empty_list(){		
		$data['sdata'] 			= array();
		$data['subview'] 		= 'icd/transit_empty/icd_out_authorize_transit_empty_list';		
		$data['active_cls'] 	= 'conedl_cls';	
		$data['url_list'] 		= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');	
		if(isset($_POST['token_no_val'])){ 
			$token_no = $this->input->post('token_no_val');
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','',$token_no,'2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','0');
		}else if(!isset($_POST['token_no_val'])){		
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','','','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','0');	
		}
		// echo $this->db->last_query();return;
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- update icd_out_authorize_transit_empty_form details ----------*/
	public function icd_out_authorize_transit_empty_form($igetl_id){		
		$data['sdata'] 					= array();
		$data['subview'] 				= 'icd/transit_empty/icd_out_authorize_transit_empty_form';		
		$data['active_cls'] 			= 'dash';			
		$data['url_list'] 				= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');		
			
		$data['sdata']['igetl_data'] 		= $this->icd_model->get_icdl_igetl_details_list('','',$igetl_id,'','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','0');			
		$data['sdata']['itncl_list'] 	= $this->icd_model->get_icdl_itncl_details_list('',$igetl_id,'','1','','1');
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- update update_icd_out_authorize_transit_empty_details details ----------*/
	public function update_icd_out_authorize_transit_empty_details($igetl_id){		
		
		$data['igetl']['igetl_iovgete_igeo_id'] 		= $this->user['i_user_id'];
		$data['igetl']['igetl_iovgete_igeo_status'] 	= '1';
		$data['igetl']['igetl_iovgete_igeo_date'] 		= date("Y-m-d");
		
		$edit_igetl 			= $this->admin_model->update_data('icd_gate_entry_token_list','igetl_id',$igetl_id,$data['igetl']);
				
		if($edit_igetl!='0'){
			$this->session->set_flashdata('tos_success', 'Details updated');	
			redirect('icd/transit_empty_ctrl/icd_out_authorize_transit_empty_list');					
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/transit_empty_ctrl/icd_out_authorize_transit_empty_list');
		}			
				
	}

	/*---------- update icd_gate_pass_out_icd_gate_transit_empty_list details ----------*/
	public function icd_gate_pass_out_icd_gate_transit_empty_list(){		
		$data['sdata'] 			= array();
		$data['subview'] 		= 'icd/transit_empty/icd_gate_pass_out_icd_gate_transit_empty_list';		
		$data['active_cls'] 	= 'conedl_cls';	
		$data['url_list'] 		= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');			
		if(isset($_POST['token_no_val'])){ 
			$token_no = $this->input->post('token_no_val');
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','',$token_no,'2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','1','0');
		}else if(!isset($_POST['token_no_val'])){		
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','','','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','1','0');
		}
		// echo $this->db->last_query();return;
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- load icd_gate_pass_out_icd_gate_transit_empty_form  page  ----------*/
	public function icd_gate_pass_out_icd_gate_transit_empty_form($igetl_id){		
		$data['sdata'] 					= array();
		$data['subview'] 				= 'icd/transit_empty/icd_gate_pass_out_icd_gate_transit_empty_form';		
		$data['active_cls'] 			= 'dash';			
		$data['url_list'] 				= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');		
		
		$data['sdata']['aginl_no'] 		= $this->admin_model->get_result_array('auto_generate_id_no_list','aginl_id','4');
		
		$data['sdata']['igetl_data'] 		= $this->icd_model->get_icdl_igetl_details_list('','',$igetl_id,'','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','1','0');			
		$data['sdata']['itncl_list'] 	= $this->icd_model->get_icdl_itncl_details_list('',$igetl_id,'','1','','1');
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- update update_icd_gate_pass_out_icd_gate_transit_empty_details details ----------*/
	public function update_icd_gate_pass_out_icd_gate_transit_empty_details($igetl_id){		
		$aginl_no 			= $this->admin_model->get_result_array('auto_generate_id_no_list','aginl_id','4');	
		$data['igetl'] = array();

		foreach($_POST as $post_key=>$post_rows){
			$data['igetl'][$post_key] 		= $this->input->post($post_key);			
		}

		$data['igetl']['igetl_transit_gate_pass_out_no'] 		= 'ICD-GPO-'.$aginl_no['aginl_val'];
		$data['igetl']['igetl_gpote_igeo_id'] 					= $this->user['i_user_id'];
		$data['igetl']['igetl_gpote_igeo_status'] 				= '1';
		$data['igetl']['igetl_gpote_igeo_date'] 				= date("Y-m-d");
		
		$edit_igetl 			= $this->admin_model->update_data('icd_gate_entry_token_list','igetl_id',$igetl_id,$data['igetl']);


		$aginl_val 							=  $aginl_no['aginl_val']+1;
		$data['aginl_details']['aginl_val'] = '00'.$aginl_val;
		$edit_aginl 						= $this->admin_model->update_data('auto_generate_id_no_list','aginl_id','4',$data['aginl_details']);
		// echo $this->db->last_query();
		// var_dump($aginl_val);return;
		
				
		if($edit_igetl!='0'){
			$this->session->set_flashdata('tos_success', 'Details updated');	
			redirect('icd/transit_empty_ctrl/icd_gate_pass_out_icd_gate_transit_empty_list');
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/transit_empty_ctrl/icd_gate_pass_out_icd_gate_transit_empty_list');
		}			
				
	}


	/*---------- update icd_gate_vehicle_pass_out_transit_empty_list details ----------*/
	public function icd_gate_vehicle_pass_out_transit_empty_list(){		
		$data['sdata'] 			= array();
		$data['subview'] 		= 'icd/transit_empty/icd_gate_vehicle_pass_out_transit_empty_list';		
		$data['active_cls'] 	= 'conedl_cls';	
		$data['url_list'] 		= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');			
		if(isset($_POST['token_no_val'])){ 
			$token_no = $this->input->post('token_no_val');
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','',$token_no,'2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','1','1','1','0');
		}else if(!isset($_POST['token_no_val'])){		
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','','','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','1','1','1','0');
		}
		// echo $this->db->last_query();return;
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- load icd_gate_vehicle_pass_out_transit_empty_form  page  ----------*/
	public function icd_gate_vehicle_pass_out_transit_empty_form($igetl_id){		
		$data['sdata'] 					= array();
		$data['subview'] 				= 'icd/transit_empty/icd_gate_vehicle_pass_out_transit_empty_form';		
		$data['active_cls'] 			= 'dash';			
		$data['url_list'] 				= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');		
		
		
		$data['sdata']['igetl_data'] 		= $this->icd_model->get_icdl_igetl_details_list('','',$igetl_id,'','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','1','1','1','0');			
		$data['sdata']['itncl_list'] 	= $this->icd_model->get_icdl_itncl_details_list('',$igetl_id,'','1','','1');
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}


	/*---------- update update_icd_gate_vehicle_pass_out_transit_empty_details details ----------*/
	public function update_icd_gate_vehicle_pass_out_transit_empty_details($igetl_id){		
		// $data['igetl'] = array();

		// foreach($_POST as $post_key=>$post_rows){
		// 	$data['igetl'][$post_key] 		= $this->input->post($post_key);			
		// }

		$data['igetl']['igetl_igvpote_igeo_id'] 		= $this->user['i_user_id'];
		$data['igetl']['igetl_igvpote_igeo_status'] 	= '1';
		$data['igetl']['igetl_igvpote_igeo_date'] 	= date("Y-m-d");
		
		$edit_igetl 			= $this->admin_model->update_data('icd_gate_entry_token_list','igetl_id',$igetl_id,$data['igetl']);
		
		if($edit_igetl!='0'){
			$this->session->set_flashdata('tos_success', 'Details updated');	
			redirect('icd/icd_print_out_ctrl/icd_gate_vehicle_pass_out_transit_empty_print_out/'.$igetl_id);
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/transit_empty_ctrl/icd_gate_vehicle_pass_out_transit_empty_list');
		}			 
				
	}

	/*---------- update icd_gate_pass_out_transit_empty_approve_list details ----------*/
	public function icd_gate_pass_out_transit_empty_approve_list(){		
		$data['sdata'] 			= array();
		$data['subview'] 		= 'icd/transit_empty/icd_gate_pass_out_transit_empty_approve_list';		
		$data['active_cls'] 	= 'conedl_cls';	
		$data['url_list'] 		= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');			
		if(isset($_POST['token_no_val'])){ 
			$token_no = $this->input->post('token_no_val');
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','',$token_no,'2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','1','1','0');
		}else if(!isset($_POST['token_no_val'])){		
			$data['sdata']['igetl_list'] 		= $this->icd_model->get_icdl_igetl_details_list('','','','','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','1','1','0');
		}
		// echo $this->db->last_query();return;
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- load icd_gate_pass_out_transit_empty_approve_form  page  ----------*/
	public function icd_gate_pass_out_transit_empty_approve_form($igetl_id){		
		$data['sdata'] 					= array();
		$data['subview'] 				= 'icd/transit_empty/icd_gate_pass_out_transit_empty_approve_form';		
		$data['active_cls'] 			= 'dash';			
		$data['url_list'] 				= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');		
				
		$data['sdata']['igetl_data'] 		= $this->icd_model->get_icdl_igetl_details_list('','',$igetl_id,'','2','Transit-Empty-Container','1','1','1','1','','','','','','','','','','','','','','','1','1','1','1','1','0');			
		$data['sdata']['itncl_list'] 	= $this->icd_model->get_icdl_itncl_details_list('',$igetl_id,'','1','','1');
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*---------- update update_icd_gate_pass_out_transit_empty_approve_details details ----------*/
	public function update_icd_gate_pass_out_transit_empty_approve_details($igetl_id){		
		// $data['igetl'] = array();

		// foreach($_POST as $post_key=>$post_rows){
		// 	$data['igetl'][$post_key] 		= $this->input->post($post_key);			
		// }

		$data['igetl']['igetl_gpote_aproove_iomo_id'] 		= $this->user['i_user_id'];
		$data['igetl']['igetl_gpote_aproove_iomo_status'] 	= '1';
		$data['igetl']['igetl_gpote_aproove_iomo_date'] 	= date("Y-m-d");
		
		$edit_igetl 			= $this->admin_model->update_data('icd_gate_entry_token_list','igetl_id',$igetl_id,$data['igetl']);


		
				
		if($edit_igetl!='0'){
			$this->session->set_flashdata('tos_success', 'Details updated');	
			redirect('icd/transit_empty_ctrl/icd_gate_pass_out_transit_empty_approve_list');
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/transit_empty_ctrl/icd_gate_pass_out_transit_empty_approve_list');
		}			
				
	}




}
