<?php
class MDL_bc30 extends CI_Model
{
	function __construct()
    {
        parent::__construct();
		
	}
	
	function bc30hdr_All($limit,$start,$sidx,$sord, $where){
		$this->db->select("
			[id_bc_out_hdr]
      ,[CAR]
      ,[JnEks]
      ,[KatEks]
      ,[JNPEB]
      ,[JNEKSOld]
      ,[JNLAIN]
      ,[JNDAG]
      ,[JNBYR]
      ,[IDEKS]
      ,[NPWPEKS]
      ,[NamaEks]
      ,[AlmtEks]
      ,[NoSiup]
      ,[TgSiup]
      ,[JnPerus]
      ,[NoTdp]
      ,[TgTdp]
      ,[Niper]
      ,[StatusH]
      ,[IdQq]
      ,[NpwpQq]
      ,[NamaQq]
      ,[AlmtQq]
      ,[NiperQq]
      ,[NAMABELI]
      ,[ALMTBELI]
      ,[NEGBELI]
      ,[IDPPJK]
      ,[NPWPPPJK]
      ,[NamaPpjk]
      ,[AlmtPpjk]
      ,[NoPpjk]
      ,[TgPpjk]
      ,[MODA]
      ,[TGEKS]
      ,[CARRIER]
      ,[VOY]
      ,[NOSHIPORD]
      ,[TGSHIPORD]
      ,[PELMUAT]
      ,[PELBONGKAR]
      ,[PELTRANSIT]
      ,[NOINV]
      ,[TGINV]
      ,[NOLPSE]
      ,[TGLPSE]
      ,[PROPBRG]
      ,[NEGTUJU]
      ,[FLSIE]
      ,[FLKARANT]
      ,[FLSM]
      ,[FLIZLAIN]
      ,[DELIVERY]
      ,[KDVAL]
      ,[KdHrg]
      ,[NilInv]
      ,[FREIGHT]
      ,[ASURANSI]
      ,[KdAss]
      ,[FOB]
      ,[MERK]
      ,[JMCONT]
      ,[BRUTO]
      ,[NETTO]
      ,[JMBRG]
      ,[JMBRGCTH]
      ,[JMBRGGAB]
      ,[JMBRGPJT]
      ,[NODAFT]
      ,convert(varchar,[TGDAFT], 103) as TGDAFT
      ,[KDKTR]
      ,[KTRGATE]
      ,[NILPE]
      ,[KDBANK]
      ,[LOKBANK]
      ,[NOSSP]
      ,[TGSSP]
      ,[JNTPB]
      ,[LOKTPB]
      ,[KDLOKBRG]
      ,[KDKTRMUAT]
      ,[KDKTRPRIKS]
      ,[TGSIAP]
      ,[WKSIAP]
      ,[ASALDATA]
      ,[TPNAME]
      ,[PEBOK]
      ,[LENGKAP]
      ,[JNPARTOF]
      ,[BENDERA]
      ,[TTDPEB]
      ,[STATUS]
      ,[SNRF]
      ,[NOBCF]
      ,[TGBCF]
      ,[SERIBCF]
      ,[NOMOREDI]
      ,[KMDT]
      ,[VOLUME]
      ,[KDHANGGAR]
      ,[KONS]
      ,[JMLKMSPEB]
      ,[PELMUATEKS]
      ,[NILKURS]
      ,[PNBP]
      ,[NOBC11]
      ,[TGBC11]
      ,[POSBC11]
      ,[SUBPOSBC11]
      ,convert(varchar,[create_date], 101) as create_date
      ,[create_by]
      ,convert(varchar,[update_date], 101) as update_date
      ,[update_by]
      ,[typedok]
      ,[statusdok]
      ,[noinv1]
      ,[tginv1]
      ,[inv_hdr_id]
      ,[bc_in_from_in]
      ,[nopol]
      ,convert(varchar, (select tbl_data_out_hdr.doc_out_date from tbl_data_out_hdr where tbl_data_out_hdr.id_terkait = tbl_bc_out_hdr.id_bc_out_hdr), 103)	 as doc_out_date 			
		");
        $this->db->from("[tbl_bc_out_hdr]");
        $this->db->where($where);
        $this->db->limit($limit,$start);
        $this->db->order_by($sidx,$sord);
        $result = $this->db->get()->result(); 
        //die($this->db->last_query());
        return $result;
	
	
	}
	
	function bc30hdr_CountAll($where){
		$this->db->select("*");
        $this->db->from("tbl_bc_out_hdr");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $result;
    }
	
	function bc30datadtl_All($limit,$start,$sidx,$sord, $where){
		$this->db->select("
		 [id_bc_out_dtl]
      ,[id_bc_out_hdr]
      ,[CAR]
      ,[SERIBRG]
      ,[HS]
      ,[URBRG1]
      ,[URBRG2]
      ,[URBRG3]
      ,[URBRG4]
      ,[DMERK]
      ,[SIZE]
      ,[TYPE]
      ,[KDBRG]
      ,[KDIZIN]
      ,[NOIZIN]
      ,[TGIZIN]
      ,[JMKOLI]
      ,[JNKOLI]
      ,[DNilInv]
      ,[FOBPERBRG]
      ,[FOBPERSAT]
      ,[KDPE]
      ,[TARIPPE]
      ,[HPATOK]
      ,[JMSATUAN]
      ,[JNSATUAN]
      ,[NETDET]
      ,[JMSATPE]
      ,[JNSATPE]
      ,[KDVALPE]
      ,[NILVALPE]
      ,[PEPERBRG]
      ,[DTLOK]
      ,[NCV]
      ,[DVolume]
      ,[NegAsal]
		");
        $this->db->from("[tbl_bc_out_dtl]");
        $this->db->where($where);
        $this->db->limit($limit,$start);
        $this->db->order_by($sidx,$sord);
        $result = $this->db->get()->result(); 
        //die($this->db->last_query());
        return $result;
	}
	
	function bc30datadtl_CountAll($where){
		$this->db->select("*");
        $this->db->from("[tbl_bc_out_dtl]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $result;
    }
	
	function bc30datadok_All($limit,$start,$sidx,$sord, $where){
		$this->db->select("
		   [id_bc_out_dok]
		  ,[id_bc_out_hdr]
		  ,[CAR]
		  ,[KdDok]
		  ,(select top 1 [dbo].[tblTabelpeb].[URAIAN] from [dbo].[tblTabelpeb] where [dbo].[tblTabelpeb].[KDTAB]='06' and [dbo].[tblTabelpeb].[KDREC]=[KdDok] ) as uraian
		  ,[NoDok]
		  ,[TgDok]
		");
        $this->db->from("[tbl_bc_out_dok]");
        $this->db->where($where);
        $this->db->limit($limit,$start);
        $this->db->order_by($sidx,$sord);
        $result = $this->db->get()->result(); 
        //die($this->db->last_query());
        return $result;
	}
	
	function bc30datadok_CountAll($where){
		$this->db->select("*");
        $this->db->from("[tbl_bc_out_dok]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $result;
    }

	
	function bc30getdatahdr_All($limit,$start,$sidx,$sord, $where){
		$this->db->select("
			[idpebhdr]
		  ,[CAR]
		  ,[JnEks]
		  ,[KatEks]
		  ,[JNPEB]
		  ,[JNEKSOld]
		  ,[JNLAIN]
		  ,[JNDAG]
		  ,[JNBYR]
		  ,[IDEKS]
		  ,[NPWPEKS]
		  ,[NamaEks]
		  ,[AlmtEks]
		  ,[NoSiup]
		  ,[TgSiup]
		  ,[JnPerus]
		  ,[NoTdp]
		  ,[TgTdp]
		  ,[Niper]
		  ,[StatusH]
		  ,[IdQq]
		  ,[NpwpQq]
		  ,[NamaQq]
		  ,[AlmtQq]
		  ,[NiperQq]
		  ,[NAMABELI]
		  ,[ALMTBELI]
		  ,[NEGBELI]
		  ,[IDPPJK]
		  ,[NPWPPPJK]
		  ,[NamaPpjk]
		  ,[AlmtPpjk]
		  ,[NoPpjk]
		  ,[TgPpjk]
		  ,[MODA]
		  ,[TGEKS]
		  ,[CARRIER]
		  ,[VOY]
		  ,[NOSHIPORD]
		  ,[TGSHIPORD]
		  ,[PELMUAT]
		  ,[PELBONGKAR]
		  ,[PELTRANSIT]
		  ,[NOINV]
		  ,[TGINV]
		  ,[NOLPSE]
		  ,[TGLPSE]
		  ,[PROPBRG]
		  ,[NEGTUJU]
		  ,[FLSIE]
		  ,[FLKARANT]
		  ,[FLSM]
		  ,[FLIZLAIN]
		  ,[DELIVERY]
		  ,[KDVAL]
		  ,[KdHrg]
		  ,[NilInv]
		  ,[FREIGHT]
		  ,[ASURANSI]
		  ,[KdAss]
		  ,[FOB]
		  ,[MERK]
		  ,[JMCONT]
		  ,[BRUTO]
		  ,[NETTO]
		  ,[JMBRG]
		  ,[JMBRGCTH]
		  ,[JMBRGGAB]
		  ,[JMBRGPJT]
		  ,[NODAFT]
		  ,[TGDAFT]
		  ,[KDKTR]
		  ,[KTRGATE]
		  ,[NILPE]
		  ,[KDBANK]
		  ,[LOKBANK]
		  ,[NOSSP]
		  ,[TGSSP]
		  ,[JNTPB]
		  ,[LOKTPB]
		  ,[KDLOKBRG]
		  ,[KDKTRMUAT]
		  ,[KDKTRPRIKS]
		  ,[TGSIAP]
		  ,[WKSIAP]
		  ,[ASALDATA]
		  ,[TPNAME]
		  ,[PEBOK]
		  ,[LENGKAP]
		  ,[JNPARTOF]
		  ,[BENDERA]
		  ,[TTDPEB]
		  ,[STATUS]
		  ,[SNRF]
		  ,[NOBCF]
		  ,[TGBCF]
		  ,[SERIBCF]
		  ,[NOMOREDI]
		  ,[KMDT]
		  ,[VOLUME]
		  ,[KDHANGGAR]
		  ,[KONS]
		  ,[JMLKMSPEB]
		  ,[PELMUATEKS]
		  ,[NILKURS]
		  ,[PNBP]
		  ,[NOBC11]
		  ,[TGBC11]
		  ,[POSBC11]
		  ,[SUBPOSBC11]
		  ,[jnkemas]
		  ,[gabinvoice]
		  ,[filename]
		  ,[laodeddate]
			
		");
        $this->db->from("[tblPebHdr]");
        $this->db->where($where);
        $this->db->limit($limit,$start);
        $this->db->order_by($sidx,$sord);
        $result = $this->db->get()->result(); 
        //die($this->db->last_query());
        return $result;
	
	
	}
	
	function bc30getdatahdr_CountAll($where){
		$this->db->select("*");
        $this->db->from("tblPebHdr");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $result;
    }
	
	function bc30getdatadtl_All($limit,$start,$sidx,$sord, $where){
		$this->db->select("
		   [idpebdtl]
		  ,[idpebhdr]
		  ,[CAR]
		  ,[SERIBRG]
		  ,[HS]
		  ,[URBRG1]
		  ,[URBRG2]
		  ,[URBRG3]
		  ,[URBRG4]
		  ,[DMERK]
		  ,[SIZE]
		  ,[TYPE]
		  ,[KDBRG]
		  ,[KDIZIN]
		  ,[NOIZIN]
		  ,[TGIZIN]
		  ,[JMKOLI]
		  ,[JNKOLI]
		  ,[DNilInv]
		  ,[FOBPERBRG]
		  ,[FOBPERSAT]
		  ,[KDPE]
		  ,[TARIPPE]
		  ,[HPATOK]
		  ,[JMSATUAN]
		  ,[JNSATUAN]
		  ,[NETDET]
		  ,[JMSATPE]
		  ,[JNSATPE]
		  ,[KDVALPE]
		  ,[NILVALPE]
		  ,[PEPERBRG]
		  ,[DTLOK]
		  ,[NCV]
		  ,[DVolume]
		  ,[NegAsal]
		  ,[NOINV]
		  ,[gabinvoice]
			
		");
        $this->db->from("[tblPebDtl]");
        $this->db->where($where);
        $this->db->limit($limit,$start);
        $this->db->order_by($sidx,$sord);
        $result = $this->db->get()->result(); 
        //die($this->db->last_query());
        return $result;
	}
	
	function bc30getdatadtl_CountAll($where){
		$this->db->select("*");
        $this->db->from("[tblPebDtl]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $result;
    }

}