<?php
class MDL_inventory extends CI_Model
{
	function __construct()
    {
        parent::__construct();
		
	}
	
	function stok_opname_All($limit,$start,$sidx,$sord, $where){
		$this->db->select("
			[id_stock_opname]
			,[date_stock_opname]
			,[part_no]
			,[part_name_customs]
			,[part_name]
			,[qty]
			,[unit]
			,[unit_konversi]
			,[pengali]
			,[netto]
			,[brutto]
			,[typebahan]
			,[create_date]
			,[create_by]
			,[update_date]
			,[update_by]
		");
		$this->db->from("[tbl_stock_opname]");
        $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 stok_opname_CountAll($where){
	
		$this->db->select("*");
        $this->db->from("[tbl_stock_opname]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        return $result;
	
	
	}
	
	function upload_stobahanbakuAll($limit,$start,$sidx,$sord, $where){
		$this->db->select("
		   
			id_stockopname_upload
		  ,[date_upload]
		  ,[filename]
		  ,[filepath]
		  ,[tipe]
		  ,[status_upload]
		  ,[create_date]
		  ,[create_by]
		  ,[update_date]
		  ,[update_by]
			
		");
		$this->db->from("[tbl_uploadstockopname]");
		$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 upload_stobahanbakucountAll($where){
		$this->db->select("*");
        $this->db->from("[tbl_uploadstockopname]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $result;
	}
	//adjusment
	function adjusment_All($limit,$start,$sidx,$sord, $where){
		$this->db->select("
			[id_adjusment]
			,[date_adjusment]
			,[part_no]
			,[part_name_customs]
			,[part_name]
			,[qty]
			,[unit]
			,[unit_konversi]
			,[pengali]
			,[netto]
			,[brutto]
			,[typebahan]
			,[create_date]
			,[create_by]
			,[update_date]
			,[update_by]
		");
		$this->db->from("[tbl_adjusment]");
        $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 adjusment_CountAll($where){
	
		$this->db->select("*");
        $this->db->from("[tbl_adjusment]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        return $result;
	
	
	}
	
	function upload_adjbahanbakuAll($limit,$start,$sidx,$sord, $where){
		$this->db->select("
		   
			id_adjusment_upload
		  ,[date_upload]
		  ,[filename]
		  ,[filepath]
		  ,[tipe]
		  ,[status_upload]
		  ,[create_date]
		  ,[create_by]
		  ,[update_date]
		  ,[update_by]
			
		");
		$this->db->from("[tbl_upload_adjusment]");
		$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 upload_adjbahanbakucountAll($where){
		$this->db->select("*");
        $this->db->from("[tbl_upload_adjusment]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $result;
	}
	
	//----scrap
	function upload_scrapAll($limit,$start,$sidx,$sord, $where){
		$this->db->select("
		   
			[id_scrap_upload]
		  ,[date_upload]
		  ,[filename]
		  ,[tipe]
		  ,[filepath]
		  ,[status_upload]
		  ,[create_date]
		  ,[create_by]
		  ,[update_date]
		  ,[update_by]
			
		");
		$this->db->from("[tbl_upload_scrap]");
		$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 upload_scrapcountAll($where){
		$this->db->select("*");
        $this->db->from("[tbl_upload_scrap]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        //die($this->db->last_query());
        return $result;
	}

	function scrap_All($limit,$start,$sidx,$sord, $where){
		$this->db->select("
			[id_scrap]
		  ,convert(varchar,[date_scrap],101) as date_scrap
		  ,[part_no]
		  ,[part_name_customs]
		  ,[part_name]
		  ,[qty]
		  ,[unit]
		  ,[unit_konversi]
		  ,[pengali]
		  ,[netto]
		  ,[brutto]
		  ,[typebahan]
		  ,[id_scrap_out]
		  ,convert(varchar,[create_date],103) as create_date
		  ,[create_by]
		  ,convert(varchar,[update_date],103) as update_date
		  ,[update_by]
		  ,[status]
		");
		$this->db->from("[tbl_scrap]");
        $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 scrap_CountAll($where){
	
		$this->db->select("*");
        $this->db->from("[tbl_scrap]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        return $result;
	
	
	}
	
	function scrap_out_All($limit,$start,$sidx,$sord, $where){
		$this->db->select("
			[id_scrap_out]
		  ,[date_scrap]
		  ,[part_no]
		  ,[part_name_customs]
		  ,[part_name]
		  ,[qty]
		  ,[unit]
		  ,[unit_konversi]
		  ,[pengali]
		  ,[netto]
		  ,[brutto]
		  ,[typebahan]
		  ,[no_dok_out]
		  ,[id_scrap]
		  ,[create_date]
		  ,[create_by]
		  ,[update_date]
		  ,[update_by]
		  ,[tg_dok_out]
		  ,[no_scrap]
		");
		$this->db->from("[tbl_scrap_out]");
        $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 scrap_out_CountAll($where){
	
		$this->db->select("*");
        $this->db->from("[tbl_scrap_out]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        return $result;
	
	
	}
	
	function scrap_bc25_All($limit,$start,$sidx,$sord, $where){
		$this->db->select("
			[id_sa_hdr]
		  ,[SA_NO]
		  ,[status]
		  ,[NPWP_PEMBELI]
		  ,[NAMA_PEMBELI]
		  ,[BC25No]
		  ,[BC25Tg]
		  ,[BC25NAJU]
		  ,[BC25TGAJU]
		  ,[BC25TGAJU1]
		  ,[KdKpbc]
		  ,[PenerimaID]
		  ,[PenerimaNpwp]
		  ,[PenerimaNama]
		  ,[PenerimaAlmt]
		  ,[PenerimaNiper]
		  ,[PenerimaStatus]
		  ,[TempatPenimbunan]
		  ,[TgKeluar]
		  ,[TglMusnah]
		  ,[BAMusnah]
		  ,[KdVal]
		  ,[Ndpbm]
		  ,[HargaRp]
		  ,[HargaBBRp]
		  ,[Bruto]
		  ,[Netto]
		  ,[JmBrg]
		  ,[JmBB]
		  ,[JmCont]
		  ,[KotaTtd]
		  ,[TglTtd]
		  ,[NamaTtd]
		  ,[jml_inv]
		  ,[typedok]
		  ,[HargaUSD]
		  ,[id_sa]
		  ,[INV_NO]
		  ,[ASSY_CODE]
		  ,[ASSY_NO]
		  ,[TOTAL_SET]
		  ,[SATUAN]
		  ,[JUMLAH_COLI]
		  ,[GROSSWEIGHT]
		  ,[SATUANGROSS]
		  ,[NETWEIGHT]
		  ,[SATUANNET]
		  ,[PRICE]
		  ,[AMOUNT]
		  ,[KD_VAL]
		  ,[TGL_INV]
		  ,[HS_KODE]
		  ,[SERI_BRG]
		  ,[SATUAN_COLI]
		  ,[create_date]
		  ,[create_by]
		  ,[update_date]
		  ,[update_by]
		");
		$this->db->from("[v_sa_hdr_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 scrap_bc25_CountAll($where){
	
		$this->db->select("*");
        $this->db->from("[v_sa_hdr_dtl]");
        $this->db->where($where);
        $result = $this->db->count_all_results(); 
        return $result;
	
	
	}
	
	
	
	
}