<?php



class Report_model extends CI_Model{	

	public function __construct(){
		//database loading
		$this->load->database();
	}
	
	
	
	public function get_icd_report_search($date_in='',$date_out='',$con_no='',$bill_la_no='',$ref_no='',$tok_no='',$ge_no=''){
		$this->db->select('idl_date,igedl_igeo_gate_out_pass_date,icdl_c_no,idl_bill_of_loading,agl_name,iml_name') 
				->from('icd_container_details_list')
				->join('icd_details_list','icd_details_list.idl_id=icd_container_details_list.icdl_idl_id')
				->join('icd_gate_entry_details_list','icd_gate_entry_details_list.igedl_idl_id=icd_details_list.idl_id')
				->join('agent_list','agent_list.agl_id=icd_gate_entry_details_list.igedl_agl_id','Left')
				->join('login','login.l_id=icd_gate_entry_details_list.igedl_agl_id','Left')
				->join('importer_list','importer_list.iml_id=icd_gate_entry_details_list.igedl_importer_name','Left')
				
				// ->join('container_status_list','container_status_list.csl_id=icd_details_list.idl_csl_id') 
				;
				
		if($date_in!=''){
			$this->db->where('idl_date>=',$date_in); 
			$this->db->where('igedl_igeo_gate_out_pass_date<=',$date_out);
		}
		if($con_no!=''){
			$this->db->where('icdl_c_no',$con_no);
		}
		if($bill_la_no!=''){
			$this->db->where('idl_bill_of_loading',$bill_la_no);
		}
		if($ref_no!=''){
			$this->db->where('idl_ref_no',$ref_no);
		}
		if($tok_no!=''){
			$this->db->join('icd_gate_entry_token_list','icd_gate_entry_token_list.igetl_igedl_id=icd_gate_entry_details_list.igedl_id')					
				->where('igetl_token_no',$tok_no);
		}
		if($ge_no!=''){
			$this->db->where('igedl_gate_entry_no',$ge_no);
		}
		$this->db->group_by('icdl_id');
		
		$query=$this->db->get();
		return $query->result_array(); 
				
	}

	




}	

?>