<?php
class MDL_bc25 extends CI_Model
{
	function __construct()
    {
        parent::__construct();
		
	}
	
	function getbc25dataAll($limit,$start,$sidx,$sord, $where){
		$this->db->select("
			[id_sa_hdr]
			  ,[SA_NO]
			  ,[status]
			  ,[NPWP_PEMBELI]
			  ,[NAMA_PEMBELI]
			  ,[BC25No]
			  ,convert(varchar, [BC25Tg], 103) as BC25Tg
			  ,[BC25NAJU]
			  ,[BC25TGAJU]
			  ,[KdKpbc]
			  ,[KdKpbcTujuan]
			  ,[JnBC25]
			  ,[JnBarang]
			  ,[Kondisi]
			  ,[Dari]
			  ,[Tujuan]
			  ,[TujuanKirim]
			  ,[UsahaID]
			  ,[UsahaNpwp]
			  ,[UsahaNama]
			  ,[UsahaAlmt]
			  ,[UsahaStatus]
			  ,[PenerimaID]
			  ,[PenerimaNpwp]
			  ,[PenerimaNama]
			  ,[PenerimaAlmt]
			  ,[PenerimaNiper]
			  ,[PenerimaStatus]
			  ,[TempatPenimbunan]
			  ,[TgKeluar]
			  ,[TglMusnah]
			  ,[BAMusnah]
			  ,[KdVal]
			  ,[Ndpbm]
			  ,[HargaRp]
			  ,[HargaBBRp]
			  ,[Bruto]
			  ,[Netto]
			  ,[JmBrg]
			  ,[JmBB]
			  ,[JmCont]
			  ,[KotaTtd]
			  ,[TglTtd]
			  ,[NamaTtd]
			  ,[KotattdPenerima]
			  ,[TglTtdPenerima]
			  ,[NamaTtdPenerima]
			  ,[TmpPeriksaFisik]
			  ,[AlmtPeriksaFisik]
			  ,[TgPeriksaFisik]
			  ,[WkPeriksaFisik]
			  ,[ContakPerson]
			  ,[NoPhone]
			  ,[jml_inv]
			  ,[typedok]
			  ,nip_bc
			  ,nama_bc 
			  ,convert(varchar, [create_date], 101) as create_date
			  ,[create_by]
			  ,convert(varchar, [update_date], 101) as update_date
			  ,[update_by]
			  ");
        $this->db->from("[tbl_sa_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 getbc25dataCountAll($where){
		$this->db->select("*");
        $this->db->from("[tbl_sa_hdr]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $result;
    }
	
	function getassybc25viewdataAll($limit,$start,$sidx,$sord, $where){
		$this->db->select("
				[id_sa]
			  ,[id_sa_hdr]
			  ,[SA_NO]
			  ,[NPWP_PEMBELI]
			  ,[NAMA_PEMBELI]
			  ,[ALAMAT]
			  ,[INV_NO]
			  ,[ASSY_CODE]
			  ,[ASSY_NO]
			  ,[TOTAL_SET]
			  ,[SATUAN]
			  ,[JUMLAH_COLI]
			  ,[GROSSWEIGHT]
			  ,[SATUANGROSS]
			  ,[NETWEIGHT]
			  ,[SATUANNET]
			   ,[PRICE]
			   ,[AMOUNT]
			  ,[create_date]
			  ,[create_by]
			  ,[update_date]
			  ,[update_by]
			  ");
        $this->db->from("[tbl_sa]");
        $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 getassybc25viewCountAll($where){
		$this->db->select("*");
        $this->db->from("[tbl_sa]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $result;
    }
	
	
	function getbbbc25viewdataAll($limit,$start,$sidx,$sord, $where){
		$this->db->select("
				[id_sa_bb]
			  ,[id_sa_hdr]
			  ,[SA_NO]
			  ,[NO_URUT]
			  ,[PART_NAME]
			  ,[QTY]
			  ,[UNIT]
			  ,[STATUS]
			  ,[CURR]
			  ,[PRICE]
			  ,[CIF]
			  ,[NDPMB]
			  ,[NDPDM_NOW]
			  ,[HARGA_PABEAN]
			  ,[HS]
			  ,[BM]
			  ,[PPN]
			  ,[PPH]
			  ,[BM_RP]
			  ,[PPN_RP]
			  ,[PPH_RP]
			  ,[create_date]
			  ,[create_by]
			  ,[update_date]
			  ,[update_by]
			  ");
        $this->db->from("[tbl_sa_bb]");
        $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 getbb25viewCountAll($where){
		$this->db->select("*");
        $this->db->from("[tbl_sa_bb]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $result;
    }
	
	function viewbc25_dokAll($limit,$start,$sidx,$sord, $where){
		$this->db->select("
				[SA_NO]
				,[INV_NO]
			  ");
        $this->db->from("[tbl_sa]");
		$this->db->where($where);
        $this->db->group_by(array("INV_NO", "SA_NO"));
        $this->db->limit($limit,$start);
        $this->db->order_by($sidx,$sord);
        $result = $this->db->get()->result(); 
        //die($this->db->last_query());
        return $result;
	
	
	}
	
	function viewbc25_dokCountAll($where){
		$this->db->select("
			count(*) as cnt
			
		");
		
		//$this->db->select("*");
        $this->db->from("[tbl_sa]");
        $this->db->where($where);
		$this->db->group_by(array("INV_NO", "SA_NO"));
        $query = $this->db->get();
		$rowcount = $query->num_rows();
		//$result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $rowcount;
    }
	
	
	
	
	
	

}