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

class Iomo_ctrl extends user_icd_index {
 
	
	public function __construct(){
		parent::__construct();  
		$data = array();
		$this->load->model('admin_model');
		$this->load->model('icd_model');		
	}
	
	/*----------------- load icd_out_gate_pass_authorization_list page -----------------*/
	public function icd_out_gate_pass_authorization_list(){		
		$data['sdata'] 						= array();
		$data['subview'] 					= 'icd/iomo/icd_out_gate_pass_authorization_list';		
		$data['active_cls'] 				= 'conedl_cls';	
		$data['url_list'] 					= $this->admin_model->get_result_array_with_one_where('user_role_list','url_status','1');			
		$data['sdata']['igedl_list'] 		= $this->icd_model->get_icd_igedl_details_list('','','','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_gate_pass_authorization_form page -----------------*/
	public function icd_out_gate_pass_authorization_form($igedl_id){		
		$data['sdata'] 			= array();
		$data['subview'] 		= 'icd/iomo/icd_out_gate_pass_authorization_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']['igedl_data'] 				= $this->icd_model->get_icd_igedl_details_list('',$igedl_id,'','1','1','1','1','1','1','1','0');
		$data['sdata']['iidl_list'] 				= $this->icd_model->get_icdl_iidl_details_list('',$igedl_id,'','1');
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}

	/*----------------- authorize_icd_gate_entry_details -----------------*/
	public function update_icd_out_gate_pass_authorization_details($igedl_id){
		$data['igedl_details'] = array();

		foreach($_POST as $post_key=>$post_rows){
			$data['igedl_details'][$post_key] 		= $this->input->post($post_key);			
		}		
		$data['igedl_details']['igedl_iomo_gop_autho_id'] 			= $this->user['i_user_id'];
		$data['igedl_details']['igedl_iomo_gop_autho_status'] 		= '1';
		$data['igedl_details']['igedl_iomo_gop_autho_date'] 		= date("Y-m-d");
		
		$edit_igedl 			= $this->admin_model->update_data('icd_gate_entry_details_list','igedl_id',$igedl_id,$data['igedl_details']);	
				
		if($edit_igedl!='0'){
			$this->session->set_flashdata('tos_success', 'Details updated');
			redirect('icd/iomo_ctrl/icd_out_gate_pass_authorization_list');		
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/iomo_ctrl/icd_out_gate_pass_authorization_list');
		}		
	}
	
	/*----------------- load icd_gate_pass_out_authorization_at_local_list page -----------------*/
	public function icd_gate_pass_out_authorization_at_local_list(){		
		$data['sdata'] 			= array();
		$data['subview'] 		= 'icd/iomo/icd_gate_pass_out_authorization_at_local_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,'1','Local-Container&Material','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('','','','','1','Local-Container&Material','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_authorization_at_local_form page -----------------*/
	public function icd_gate_pass_out_authorization_at_local_form($igedl_id,$igetl_id){		
		$data['sdata'] 					= array();
		$data['subview'] 				= 'icd/iomo/icd_gate_pass_out_authorization_at_local_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']['agl_list'] 		= $this->admin_model->get_result_array('agent_list');	
		$data['sdata']['igetl_data'] 		= $this->icd_model->get_icdl_igetl_details_list('',$igedl_id,$igetl_id,'','1','Local-Container&Material','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_icd_gate_pass_out_authorize_at_local_details -----------------*/
	public function update_icd_gate_pass_out_authorize_at_local_details($igetl_id){		
		$data['igetl_details'] = array(); 

		foreach($_POST as $post_key=>$post_rows){
			$data['igetl_details'][$post_key] 		= $this->input->post($post_key);			
		}
		$data['igetl_details']['igetl_igpoal_iomo_id'] 		= $this->user['i_user_id'];
		$data['igetl_details']['igetl_igpoal_iomo_status'] 	= '1';
		$data['igetl_details']['igetl_igpoal_iomo_date'] 	= date("Y-m-d");
		
		$edit_igetl 			= $this->admin_model->update_data('icd_gate_entry_token_list','igetl_id',$igetl_id,$data['igetl_details']);
				
		if($edit_igetl!='0'){
			$this->session->set_flashdata('tos_success', 'Details updated');	
			redirect('icd/iomo_ctrl/icd_gate_pass_out_authorization_at_local_list');				
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/iomo_ctrl/icd_gate_pass_out_authorization_at_local_list');
		}			
				
	}

	/*-------load icd_gpofvo_loacl_extra_lcl_list (gpofvo - gate pass of vehicle out) page  -------*/
	public function icd_gpofvo_loacl_extra_lcl_list(){		
		$data['sdata'] 			= array();
		$data['subview'] 		= 'icd/iomo/icd_gpofvo_loacl_extra_lcl_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,'1','Local-LCL/Extra Material','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('','','','','1','Local-LCL/Extra Material','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_gpofvo_loacl_extra_lcl_form (gpofvo - gate pass of vehicle out) page  -------*/
	public function icd_gpofvo_loacl_extra_lcl_form($igedl_id,$igetl_id){		
		$data['sdata'] 					= array();
		$data['subview'] 				= 'icd/iomo/icd_gpofvo_loacl_extra_lcl_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('',$igedl_id,$igetl_id,'','1','Local-LCL/Extra Material','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_icd_gpofvo_loacl_extra_lcl_details (gpofvo - gate pass of vehicle out) -------*/
	public function update_icd_gpofvo_loacl_extra_lcl_details($igetl_id){		
		$data['igetl_details'] = array(); 

		foreach($_POST as $post_key=>$post_rows){
			$data['igetl_details'][$post_key] 		= $this->input->post($post_key);			
		}
		$data['igetl_details']['igetl_igpvolel_iomo_id'] 		= $this->user['i_user_id'];
		$data['igetl_details']['igetl_igpvolel_iomo_status'] 	= '1';
		$data['igetl_details']['igetl_igpvolel_iomo_date'] 		= date("Y-m-d");
		
		$edit_igedl 			= $this->admin_model->update_data('icd_gate_entry_token_list','igetl_id',$igetl_id,$data['igetl_details']);
				
		if($edit_igedl!='0'){
			$this->session->set_flashdata('tos_success', 'Details updated');	
			redirect('icd/iomo_ctrl/icd_gpofvo_loacl_extra_lcl_list');				
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/iomo_ctrl/icd_gpofvo_loacl_extra_lcl_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/iomo/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,'1','Local-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('','','','','1','Local-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/iomo/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,'','1','Local-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/iomo_ctrl/icd_gate_pass_out_transit_empty_approve_list');
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/iomo_ctrl/icd_gate_pass_out_transit_empty_approve_list');
		}			
				
	}

	/*---------- update icd_vehicle_entrytransit_material_list details ----------*/
	public function icd_vehicle_entrytransit_material_list(){		
		$data['sdata'] 			= array();
		$data['subview'] 		= 'icd/iomo/icd_vehicle_entrytransit_material_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-Material','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-Material','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_vehicle_entrytransit_material_form  page  ----------*/
	public function icd_vehicle_entrytransit_material_form($igetl_id){		
		$data['sdata'] 					= array();
		$data['subview'] 				= 'icd/iomo/icd_vehicle_entrytransit_material_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-Material','1','1','1','1','','','','','','','','','','','','','','','','','','','','','','1','1','1','1','1','0');
		$data['sdata']['itml_list'] 	= $this->icd_model->get_icdl_itml_details_list('',$igetl_id,'','1');
		
		$this->load->view('icd/common/icd_sidepanel',$data); 
	}
	
	/*---------- update update_icd_vehicle_entrytransit_material_approve_details details ----------*/
	public function update_icd_vehicle_entrytransit_material_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_tm_iomo_id'] 		= $this->user['i_user_id'];
		$data['igetl']['igetl_tm_iomo_status'] 	= '1';
		$data['igetl']['igetl_tm_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/iomo_ctrl/icd_vehicle_entrytransit_material_list');
		}else {
			$this->session->set_flashdata('tos_warning', 'There is no changes!...');
			redirect('icd/iomo_ctrl/icd_vehicle_entrytransit_material_list');
		}			
				
	}

}
