<?php
class CT_bc27 extends CI_Controller{
  function __construct()
    {
      parent::__construct();
		if (!$this->dx_auth->is_logged_in()) {
            header('HTTP/1.1 401 Unauthorize');die('expire'); 
        }
        
        $uid = $this->session->userdata('DX_user_id');
        
        if(!permissionAuth(2) && $uid != RID){ 
            header('HTTP/1.1 401 Unauthorize');die('noaccess');
        }
		
			$this->load->model("exim/mdl_bc27", 'mdl_bc27');
  }
  
	function index(){

		$this->load->view('exim/view_bc27');
	}
	
	function loaddata(){
		$search = isset($_POST['_search'])?$_POST['_search']:false;
		$searchField = isset($_POST['searchField'])?$_POST['searchField']:'';
		$searchString = isset($_POST['searchString'])?$_POST['searchString']:'';
		$filters =  isset($_POST['filters'])?$_POST['filters']:'';
		
		$page = isset($_POST['page'])?$_POST['page']:1; // get the requested page
		$limit = isset($_POST['rows'])?$_POST['rows']:20; // get how many rows we want to have into the grid
		$sidx = isset($_POST['sidx'])?$_POST['sidx']:'id_bc_out_hdr'; // get index row - i.e. user click to sort
		$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction	
		
		$q =(isset($_POST['q']) && !empty($_POST['q']))?$_POST['q']:'0';
		$id_bc_out_hdr =(isset($_POST['id_bc_out_hdr']) && !empty($_POST['id_bc_out_hdr']))?$_POST['id_bc_out_hdr']:'';
			
		$where = " 1=1 and typedok='BC27' ";
		
		if ($q=='66'){
			$where =" id_bc_out_hdr=$id_bc_out_hdr ";
		}
		

		if ($search == 'true'){
			if (!empty($filters)){
				$array = json_decode($filters);
				foreach($array->rules as $arr=>$k){
					
					if ( $k->field == "CAR" ) {
						$searchString = $k->data;
						$where .= " and CAR like  '%".$searchString."%'"; 
					} else if ( $k->field == "NAMABELI" ) {
						$searchString = $k->data;
						$where .= " and NAMABELI like  '%".$searchString."%'"; 
					} else if ( $k->field == "NEGBELI" ) {
						$searchString = $k->data;
						$where .= " and NEGBELI like  '%".$searchString."%'"; 
					} else if ( $k->field == "NOINV" ) {
						$searchString = $k->data;
						$where .= " and NOINV like  '%".$searchString."%'"; 
					} else if ( $k->field == "NilInv" ) {
						$searchString = $k->data;
						$where .= " and NilInv =  $searchString"; 
					} else if ( $k->field == "TGINV" ) {
						$searchString = $k->data;
						$where .= " and TGINV =  '$searchString'"; 
					} else if ( $k->field == "KDVAL" ) {
						$searchString = $k->data;
						$where .= " and KDVAL like  '%".$searchString."%'"; 
					}  else if ( $k->field == "statusdok" ) {
						$searchString = $k->data;
						$where .= " and statusdok like  '%".$searchString."%'"; 
					} else if ( $k->field == "NODAFT" ) {
						$searchString = $k->data;
						$where .= " and NODAFT like  '%".$searchString."%'"; 
					} 
			
				}
			}
		}	
			
		$start = $limit*$page - $limit;
		if ($start<0) $start=0;
		
		$records = $this->mdl_bc27->bc27hdr_All($limit,$start,$sidx,$sord, $where);
		$count = $this->mdl_bc27->bc27hdr_CountAll($where);
		
		
		if( $count > 0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } 
		if ($page > $total_pages) $page=$total_pages;
		
		$responce->page = $page;
		$responce->total = $total_pages;
		$responce->records =  $count;
		$i=0;
		foreach($records as $r){

			$responce->rows[$i]['id_bc_out_hdr']=$r->id_bc_out_hdr; 
			$responce->rows[$i]['CAR']=$r->CAR; 
			$responce->rows[$i]['JnEks']=$r->JnEks; 
			$responce->rows[$i]['KatEks']=$r->KatEks; 
			$responce->rows[$i]['JNPEB']=$r->JNPEB; 
			$responce->rows[$i]['JNEKSOld']=$r->JNEKSOld; 
			$responce->rows[$i]['JNLAIN']=$r->JNLAIN; 
			$responce->rows[$i]['JNDAG']=$r->JNDAG; 
			$responce->rows[$i]['JNBYR']=$r->JNBYR; 
			$responce->rows[$i]['IDEKS']=$r->IDEKS; 
			$responce->rows[$i]['NPWPEKS']=$r->NPWPEKS; 
			$responce->rows[$i]['NamaEks']=$r->NamaEks; 
			$responce->rows[$i]['AlmtEks']=$r->AlmtEks; 
			$responce->rows[$i]['NoSiup']=$r->NoSiup; 
			$responce->rows[$i]['TgSiup']=$r->TgSiup; 
			$responce->rows[$i]['JnPerus']=$r->JnPerus; 
			$responce->rows[$i]['NoTdp']=$r->NoTdp; 
			$responce->rows[$i]['TgTdp']=$r->TgTdp; 
			$responce->rows[$i]['Niper']=$r->Niper; 
			$responce->rows[$i]['StatusH']=$r->StatusH; 
			$responce->rows[$i]['IdQq']=$r->IdQq; 
			$responce->rows[$i]['NpwpQq']=$r->NpwpQq; 
			$responce->rows[$i]['NamaQq']=$r->NamaQq; 
			$responce->rows[$i]['AlmtQq']=$r->AlmtQq; 
			$responce->rows[$i]['NiperQq']=$r->NiperQq; 
			$responce->rows[$i]['NAMABELI']=$r->NAMABELI; 
			$responce->rows[$i]['ALMTBELI']=$r->ALMTBELI; 
			$responce->rows[$i]['NEGBELI']=$r->NEGBELI; 
			$responce->rows[$i]['IDPPJK']=$r->IDPPJK; 
			$responce->rows[$i]['NPWPPPJK']=$r->NPWPPPJK; 
			$responce->rows[$i]['NamaPpjk']=$r->NamaPpjk; 
			$responce->rows[$i]['AlmtPpjk']=$r->AlmtPpjk; 
			$responce->rows[$i]['NoPpjk']=$r->NoPpjk; 
			$responce->rows[$i]['TgPpjk']=$r->TgPpjk; 
			$responce->rows[$i]['MODA']=$r->MODA; 
			$responce->rows[$i]['TGEKS']=$r->TGEKS; 
			$responce->rows[$i]['CARRIER']=$r->CARRIER; 
			$responce->rows[$i]['VOY']=$r->VOY; 
			$responce->rows[$i]['NOSHIPORD']=$r->NOSHIPORD; 
			$responce->rows[$i]['TGSHIPORD']=$r->TGSHIPORD; 
			$responce->rows[$i]['PELMUAT']=$r->PELMUAT; 
			$responce->rows[$i]['PELBONGKAR']=$r->PELBONGKAR; 
			$responce->rows[$i]['PELTRANSIT']=$r->PELTRANSIT; 
			$responce->rows[$i]['NOINV']=$r->NOINV; 
			$responce->rows[$i]['TGINV']=$r->TGINV; 
			$responce->rows[$i]['NOLPSE']=$r->NOLPSE; 
			$responce->rows[$i]['TGLPSE']=$r->TGLPSE; 
			$responce->rows[$i]['PROPBRG']=$r->PROPBRG; 
			$responce->rows[$i]['NEGTUJU']=$r->NEGTUJU; 
			$responce->rows[$i]['FLSIE']=$r->FLSIE; 
			$responce->rows[$i]['FLKARANT']=$r->FLKARANT; 
			$responce->rows[$i]['FLSM']=$r->FLSM; 
			$responce->rows[$i]['FLIZLAIN']=$r->FLIZLAIN; 
			$responce->rows[$i]['DELIVERY']=$r->DELIVERY; 
			$responce->rows[$i]['KDVAL']=$r->KDVAL; 
			$responce->rows[$i]['KdHrg']=$r->KdHrg; 
			$responce->rows[$i]['NilInv']=$r->NilInv; 
			$responce->rows[$i]['FREIGHT']=$r->FREIGHT; 
			$responce->rows[$i]['ASURANSI']=$r->ASURANSI; 
			$responce->rows[$i]['KdAss']=$r->KdAss; 
			$responce->rows[$i]['FOB']=$r->FOB; 
			$responce->rows[$i]['MERK']=$r->MERK; 
			$responce->rows[$i]['JMCONT']=$r->JMCONT; 
			$responce->rows[$i]['BRUTO']=$r->BRUTO; 
			$responce->rows[$i]['NETTO']=$r->NETTO; 
			$responce->rows[$i]['JMBRG']=$r->JMBRG; 
			$responce->rows[$i]['JMBRGCTH']=$r->JMBRGCTH; 
			$responce->rows[$i]['JMBRGGAB']=$r->JMBRGGAB; 
			$responce->rows[$i]['JMBRGPJT']=$r->JMBRGPJT; 
			$responce->rows[$i]['NODAFT']=$r->NODAFT; 
			$responce->rows[$i]['TGDAFT']=$r->TGDAFT; 
			$responce->rows[$i]['KDKTR']=$r->KDKTR; 
			$responce->rows[$i]['KTRGATE']=$r->KTRGATE; 
			$responce->rows[$i]['NILPE']=$r->NILPE; 
			$responce->rows[$i]['KDBANK']=$r->KDBANK; 
			$responce->rows[$i]['LOKBANK']=$r->LOKBANK; 
			$responce->rows[$i]['NOSSP']=$r->NOSSP; 
			$responce->rows[$i]['TGSSP']=$r->TGSSP; 
			$responce->rows[$i]['JNTPB']=$r->JNTPB; 
			$responce->rows[$i]['LOKTPB']=$r->LOKTPB; 
			$responce->rows[$i]['KDLOKBRG']=$r->KDLOKBRG; 
			$responce->rows[$i]['KDKTRMUAT']=$r->KDKTRMUAT; 
			$responce->rows[$i]['KDKTRPRIKS']=$r->KDKTRPRIKS; 
			$responce->rows[$i]['TGSIAP']=$r->TGSIAP; 
			$responce->rows[$i]['WKSIAP']=$r->WKSIAP; 
			$responce->rows[$i]['ASALDATA']=$r->ASALDATA; 
			$responce->rows[$i]['TPNAME']=$r->TPNAME; 
			$responce->rows[$i]['PEBOK']=$r->PEBOK; 
			$responce->rows[$i]['LENGKAP']=$r->LENGKAP; 
			$responce->rows[$i]['JNPARTOF']=$r->JNPARTOF; 
			$responce->rows[$i]['BENDERA']=$r->BENDERA;
			$responce->rows[$i]['TTDPEB']=$r->TTDPEB;
			$responce->rows[$i]['STATUS']=$r->STATUS;
			$responce->rows[$i]['SNRF']=$r->SNRF;
			$responce->rows[$i] ['NOBCF'] =$r->NOBCF; 
			$responce->rows[$i] ['TGBCF'] =$r->TGBCF; 
			$responce->rows[$i] ['SERIBCF'] =$r->SERIBCF; 
			$responce->rows[$i] ['NOMOREDI'] =$r->NOMOREDI; 
			$responce->rows[$i] ['KMDT'] =$r->KMDT; 
			$responce->rows[$i] ['VOLUME'] =$r->VOLUME; 
			$responce->rows[$i] ['KDHANGGAR'] =$r->KDHANGGAR; 
			$responce->rows[$i] ['KONS']=$r->KONS; 
			$responce->rows[$i] ['JMLKMSPEB']=$r->JMLKMSPEB; 
			$responce->rows[$i] ['PELMUATEKS'] =$r->PELMUATEKS; 
			$responce->rows[$i] ['NILKURS']=$r->NILKURS; 
			$responce->rows[$i] ['PNBP'] =$r->PNBP; 
			$responce->rows[$i] ['NOBC11'] =$r->NOBC11; 
			$responce->rows[$i] ['TGBC11'] =$r->TGBC11; 
			$responce->rows[$i] ['POSBC11'] =$r->POSBC11; 
			$responce->rows[$i] ['SUBPOSBC11'] =$r->SUBPOSBC11; 
			$responce->rows[$i] ['create_date'] =$r->create_date; 
			$responce->rows[$i] ['create_by'] =$r->create_by; 
			$responce->rows[$i] ['update_date']=$r->update_date; 
			$responce->rows[$i] ['update_by']=$r->update_by; 
			$responce->rows[$i] ['typedok'] =$r->typedok; 
			$responce->rows[$i] ['statusdok']=$r->statusdok; 
			$responce->rows[$i] ['noinv1'] =$r->noinv1; 
			$responce->rows[$i] ['tginv1'] =$r->tginv1; 
			$responce->rows[$i] ['inv_hdr_id'] =$r->inv_hdr_id; 
			$responce->rows[$i] ['bc_in_from_in'] =$r->bc_in_from_in; 
			$responce->rows[$i] ['nopol'] =$r->nopol; 
			
		
			$i++;
		}
		echo json_encode($responce);
			
        
		
		
    }
	
	 function view_bc27_getdata(){

		$this->load->view('exim/view_bc27_getdata');

	}
	
	function load_bc27_getadata(){
		$search = isset($_POST['_search'])?$_POST['_search']:false;
		$searchField = isset($_POST['searchField'])?$_POST['searchField']:'';
		$searchString = isset($_POST['searchString'])?$_POST['searchString']:'';
		$filters =  isset($_POST['filters'])?$_POST['filters']:'';
		
		$page = isset($_POST['page'])?$_POST['page']:1; // get the requested page
		$limit = isset($_POST['rows'])?$_POST['rows']:20; // get how many rows we want to have into the grid
		$sidx = isset($_POST['sidx'])?$_POST['sidx']:'idpebhdr'; // get index row - i.e. user click to sort
		$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction	
		
		$status =(isset($_POST['statusbc27loaddatahdr']) && !empty($_POST['statusbc27loaddatahdr']))?$_POST['statusbc27loaddatahdr']:'XX';
			
		$where = " 1=1 ";
		
		if($status == '00'){
			
			$where = " 1=1 and status='00' ";
		};
		

		if ($search == 'true'){
			if (!empty($filters)){
				$array = json_decode($filters);
				foreach($array->rules as $arr=>$k){
					
					if ( $k->field == "gabinvoice" ) {
						$searchString = $k->data;
						$where .= " and gabinvoice like  '%".$searchString."%'"; 
					} else if ( $k->field == "laodeddate" ) {
						$searchString = $k->data;
						$where .= " and laodeddate =  '$searchString'"; 
					} else if ( $k->field == "NAMABELI" ) {
						$searchString = $k->data;
						$where .= " and NAMABELI like  '%".$searchString."%'"; 
					} else if ( $k->field == "NEGBELI" ) {
						$searchString = $k->data;
						$where .= " and NEGBELI like  '%".$searchString."%'"; 
					} else if ( $k->field == "NOINV" ) {
						$searchString = $k->data;
						$where .= " and NOINV like  '%".$searchString."%'"; 
					} else if ( $k->field == "NilInv" ) {
						$searchString = $k->data;
						$where .= " and NilInv =  $searchString"; 
					} else if ( $k->field == "TGINV" ) {
						$searchString = $k->data;
						$where .= " and TGINV =  '$searchString'"; 
					} else if ( $k->field == "KDVAL" ) {
						$searchString = $k->data;
						$where .= " and KDVAL like  '%".$searchString."%'"; 
					} 
			
				}
			}
		}	
			
		$start = $limit*$page - $limit;
		if ($start<0) $start=0;
		
		$records = $this->mdl_bc27->bc27getdatahdr_All($limit,$start,$sidx,$sord, $where);
		$count = $this->mdl_bc27->bc27getdatahdr_CountAll($where);
		
		
		if( $count > 0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } 
		if ($page > $total_pages) $page=$total_pages;
		
		$responce->page = $page;
		$responce->total = $total_pages;
		$responce->records =  $count;
		$i=0;
		foreach($records as $r){
						
		  $responce->rows[$i]['idbc27hdr']=$r->idbc27hdr; 
		  $responce->rows[$i]['CAR']=$r->CAR; 
		  $responce->rows[$i]['JnEks']=$r->JnEks; 
		  $responce->rows[$i]['KatEks']=$r->KatEks; 
		  $responce->rows[$i]['JNPEB']=$r->JNPEB; 
		  $responce->rows[$i]['JNEKSOld']=$r->JNEKSOld; 
		  $responce->rows[$i]['JNLAIN']=$r->JNLAIN; 
		  $responce->rows[$i]['JNDAG']=$r->JNDAG; 
		  $responce->rows[$i]['JNBYR']=$r->JNBYR; 
		  $responce->rows[$i]['IDEKS']=$r->IDEKS; 
		  $responce->rows[$i]['NPWPEKS']=$r->NPWPEKS; 
		  $responce->rows[$i]['NamaEks']=$r->NamaEks; 
		  $responce->rows[$i]['AlmtEks']=$r->AlmtEks; 
		  $responce->rows[$i]['NoSiup']=$r->NoSiup; 
		  $responce->rows[$i]['TgSiup']=$r->TgSiup; 
		  $responce->rows[$i]['JnPerus']=$r->JnPerus; 
		  $responce->rows[$i]['NoTdp']=$r->NoTdp; 
		  $responce->rows[$i]['TgTdp']=$r->TgTdp; 
		  $responce->rows[$i]['Niper']=$r->Niper; 
		  $responce->rows[$i]['StatusH']=$r->StatusH; 
		  $responce->rows[$i]['IdQq']=$r->IdQq; 
		  $responce->rows[$i]['NpwpQq']=$r->NpwpQq; 
		  $responce->rows[$i]['NamaQq']=$r->NamaQq; 
		  $responce->rows[$i]['AlmtQq']=$r->AlmtQq; 
		  $responce->rows[$i]['NiperQq']=$r->NiperQq; 
		  $responce->rows[$i]['NAMABELI']=$r->NAMABELI; 
		  $responce->rows[$i]['ALMTBELI']=$r->ALMTBELI; 
		  $responce->rows[$i]['NEGBELI']=$r->NEGBELI; 
		  $responce->rows[$i]['IDPPJK']=$r->IDPPJK; 
		  $responce->rows[$i]['NPWPPPJK']=$r->NPWPPPJK; 
		  $responce->rows[$i]['NamaPpjk']=$r->NamaPpjk; 
		  $responce->rows[$i]['AlmtPpjk']=$r->AlmtPpjk; 
		  $responce->rows[$i]['NoPpjk']=$r->NoPpjk; 
		  $responce->rows[$i]['TgPpjk']=$r->TgPpjk; 
		  $responce->rows[$i]['MODA']=$r->MODA; 
		  $responce->rows[$i]['TGEKS']=$r->TGEKS; 
		  $responce->rows[$i]['CARRIER']=$r->CARRIER; 
		  $responce->rows[$i]['VOY']=$r->VOY; 
		  $responce->rows[$i]['NOSHIPORD']=$r->NOSHIPORD; 
		  $responce->rows[$i]['TGSHIPORD']=$r->TGSHIPORD; 
		  $responce->rows[$i]['PELMUAT']=$r->PELMUAT; 
		  $responce->rows[$i]['PELBONGKAR']=$r->PELBONGKAR; 
		  $responce->rows[$i]['PELTRANSIT']=$r->PELTRANSIT; 
		  $responce->rows[$i]['NOINV']=$r->NOINV; 
		  $responce->rows[$i]['TGINV']=$r->TGINV; 
		  $responce->rows[$i]['NOLPSE']=$r->NOLPSE; 
		  $responce->rows[$i]['TGLPSE']=$r->TGLPSE; 
		  $responce->rows[$i]['PROPBRG']=$r->PROPBRG; 
		  $responce->rows[$i]['NEGTUJU']=$r->NEGTUJU; 
		  $responce->rows[$i]['FLSIE']=$r->FLSIE; 
		  $responce->rows[$i]['FLKARANT']=$r->FLKARANT; 
		  $responce->rows[$i]['FLSM']=$r->FLSM; 
		  $responce->rows[$i]['FLIZLAIN']=$r->FLIZLAIN; 
		  $responce->rows[$i]['DELIVERY']=$r->DELIVERY; 
		  $responce->rows[$i]['KDVAL']=$r->KDVAL; 
		  $responce->rows[$i]['KdHrg']=$r->KdHrg; 
		  $responce->rows[$i]['NilInv']=$r->NilInv; 
		  $responce->rows[$i]['FREIGHT']=$r->FREIGHT; 
		  $responce->rows[$i]['ASURANSI']=$r->ASURANSI; 
		  $responce->rows[$i]['KdAss']=$r->KdAss; 
		  $responce->rows[$i]['FOB']=$r->FOB; 
		  $responce->rows[$i]['MERK']=$r->MERK; 
		  $responce->rows[$i]['JMCONT']=$r->JMCONT; 
		  $responce->rows[$i]['BRUTO']=$r->BRUTO; 
		  $responce->rows[$i]['NETTO']=$r->NETTO; 
		  $responce->rows[$i]['JMBRG']=$r->JMBRG; 
		  $responce->rows[$i]['JMBRGCTH']=$r->JMBRGCTH; 
		  $responce->rows[$i]['JMBRGGAB']=$r->JMBRGGAB; 
		  $responce->rows[$i]['JMBRGPJT']=$r->JMBRGPJT; 
		  $responce->rows[$i]['NODAFT']=$r->NODAFT; 
		  $responce->rows[$i]['TGDAFT']=$r->TGDAFT; 
		  $responce->rows[$i]['KDKTR']=$r->KDKTR; 
		  $responce->rows[$i]['KTRGATE']=$r->KTRGATE; 
		  $responce->rows[$i]['NILPE']=$r->NILPE; 
		  $responce->rows[$i]['KDBANK']=$r->KDBANK; 
		  $responce->rows[$i]['LOKBANK']=$r->LOKBANK; 
		  $responce->rows[$i]['NOSSP']=$r->NOSSP; 
		  $responce->rows[$i]['TGSSP']=$r->TGSSP; 
		  $responce->rows[$i]['JNTPB']=$r->JNTPB; 
		  $responce->rows[$i]['LOKTPB']=$r->LOKTPB; 
		  $responce->rows[$i]['KDLOKBRG']=$r->KDLOKBRG; 
		  $responce->rows[$i]['KDKTRMUAT']=$r->KDKTRMUAT; 
		  $responce->rows[$i]['KDKTRPRIKS']=$r->KDKTRPRIKS; 
		  $responce->rows[$i]['TGSIAP']=$r->TGSIAP; 
		  $responce->rows[$i]['WKSIAP']=$r->WKSIAP; 
		  $responce->rows[$i]['ASALDATA']=$r->ASALDATA; 
		  $responce->rows[$i]['TPNAME']=$r->TPNAME; 
		  $responce->rows[$i]['PEBOK']=$r->PEBOK; 
		  $responce->rows[$i]['LENGKAP']=$r->LENGKAP; 
		  $responce->rows[$i]['JNPARTOF']=$r->JNPARTOF; 
		  $responce->rows[$i]['BENDERA']=$r->BENDERA;
		  $responce->rows[$i]['TTDPEB']=$r->TTDPEB;
		  $responce->rows[$i]['STATUS']=$r->STATUS;
		  $responce->rows[$i]['SNRF']=$r->SNRF;
		  $responce->rows[$i] ['NOBCF'] =$r->NOBCF; 
		  $responce->rows[$i] ['TGBCF'] =$r->TGBCF; 
		  $responce->rows[$i] ['SERIBCF'] =$r->SERIBCF; 
		  $responce->rows[$i] ['NOMOREDI'] =$r->NOMOREDI; 
		  $responce->rows[$i] ['KMDT'] =$r->KMDT; 
		  $responce->rows[$i] ['VOLUME'] =$r->VOLUME; 
		  $responce->rows[$i] ['KDHANGGAR'] =$r->KDHANGGAR; 
		  $responce->rows[$i] ['KONS']=$r->KONS; 
		  $responce->rows[$i] ['JMLKMSPEB']=$r->JMLKMSPEB; 
		  $responce->rows[$i] ['PELMUATEKS'] =$r->PELMUATEKS; 
		  $responce->rows[$i] ['NILKURS']=$r->NILKURS; 
		  $responce->rows[$i] ['PNBP'] =$r->PNBP; 
		  $responce->rows[$i] ['NOBC11'] =$r->NOBC11; 
		  $responce->rows[$i] ['TGBC11'] =$r->TGBC11; 
		  $responce->rows[$i] ['POSBC11'] =$r->POSBC11; 
		  $responce->rows[$i] ['SUBPOSBC11'] =$r->SUBPOSBC11; 
		  $responce->rows[$i] ['jnkemas']=$r->jnkemas; 
		  $responce->rows[$i] ['gabinvoice'] =$r->gabinvoice; 
		  $responce->rows[$i] ['filename'] =$r->filename; 
		  $responce->rows[$i] ['laodeddate'] =$r->laodeddate; 

			
			$i++;
		}
		echo json_encode($responce);
		
    }
  
	function getdatabc27(){

		$filename = (isset($_POST['filename']) && !empty($_POST['filename']))?$_POST['filename']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		$id_bc27_upload = (isset($_POST['id_bc27_upload']) && !empty($_POST['id_bc27_upload']))?$_POST['id_bc27_upload']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		$username = $this->session->userdata('DX_username');
		
	/* 	echo " exec('[spi_getdata_bc27] @filename=''$filename'', @idfile=$id_bc27_upload, @username=''$username'' ')";
	    die();  */
		$qry = $this->db->query("
			BEGIN TRY
			
			 exec('[spi_getdata_bc27] @filename=''$filename'', @idfile=$id_bc27_upload, @username=''$username'' ')
			
			END TRY
			BEGIN CATCH 
				SELECT 
				'06' AS status
				,ERROR_MESSAGE() AS description;
				
			END CATCH;
			
			");
		 $rs = $qry->result_array();
		 // $r = $qry->result();		
		 // var_dump($r);die();
		 foreach ($rs as $row){
			 $status = $row['status'];
			 $msg = $row['description'];
		 }  
		 
		 echo json_encode(array('status' => $status, 'desc' => $msg));



	}
	
	function view_bc27_datauploaded(){
	
		$this->load->view('exim/view_bc27_datauploaded');
	
	}
	
	function prosesdatasa(){
	    $username = $this->session->userdata('DX_username');
		$idbc27hdr = (isset($_POST['idbc27hdr']) && !empty($_POST['idbc27hdr']))?$_POST['idbc27hdr']:die('{"sts":"ERROR","desc":"SA Param Tidak Ditemukan"}');
		$qry = $this->db->query("
			BEGIN TRY
			
			 exec('[spi_getdata_bc27] @idbc27hdr=$idbc27hdr, @userid=''$username'' ')
			
			END TRY
			BEGIN CATCH 
				SELECT 
				'06' AS status
				,ERROR_MESSAGE() AS description;
				
			END CATCH;
			
			");
		 $rs = $qry->result_array();
		 // $r = $qry->result();		
		 // var_dump($r);die();
		 foreach ($rs as $row){
			 $status = $row['status'];
			 $msg = $row['description'];
		 }  
		 
		 echo json_encode(array('status' => $status, 'desc' => $msg));
	
	}
	function view_bc27_getassy(){
		$idbc27hdr = (isset($_POST['idbc27hdr']) && !empty($_POST['idbc27hdr']))?$_POST['idbc27hdr']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		$gabinvoice = (isset($_POST['gabinvoice']) && !empty($_POST['gabinvoice']))?$_POST['gabinvoice']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		$data['idbc27hdr']=$idbc27hdr;
		$data['gabinvoice']=$gabinvoice;
		$this->load->view('exim/view_bc27_getassy', $data);
	
	}
	
	function data_bc27_getdatadetil(){
	
	$search = isset($_POST['_search'])?$_POST['_search']:false;
	$searchField = isset($_POST['searchField'])?$_POST['searchField']:'';
	$searchString = isset($_POST['searchString'])?$_POST['searchString']:'';
	$filters =  isset($_POST['filters'])?$_POST['filters']:'';
	
	$page = isset($_POST['page'])?$_POST['page']:1; // get the requested page
	$limit = isset($_POST['rows'])?$_POST['rows']:20; // get how many rows we want to have into the grid
	$sidx = isset($_POST['sidx'])?$_POST['sidx']:'[idbc23dtl]'; // get index row - i.e. user click to sort
	$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction	
	
	// $gabinvoice = (isset($_POST['gabinvoice']) && !empty($_POST['gabinvoice']))?$_POST['gabinvoice']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
	$idbc27hdr = (isset($_POST['idbc27hdr']) && !empty($_POST['idbc27hdr']))?$_POST['idbc27hdr']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
	
	$where = " 1=1 and idbc27hdr='$idbc27hdr' ";
	

	if ($search == 'true'){
		if (!empty($filters)){
			$array = json_decode($filters);
			foreach($array->rules as $arr=>$k){
				
				if ( $k->field == "[idbc23dtl]" ) {
					$searchString = $k->data;
					$where .= " and [idbc23dtl] like  '%".$searchString."%'"; 
				}
		
			}
		}
	}	
		
	$start = $limit*$page - $limit;
	if ($start<0) $start=0;
	
	$records = $this->mdl_bc27->bc27getdatadtl_All($limit,$start,$sidx,$sord, $where);
	$count = $this->mdl_bc27->bc27getdatadtl_CountAll($where);
	
	
	if( $count > 0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } 
	if ($page > $total_pages) $page=$total_pages;
	
	$responce->page = $page;
	$responce->total = $total_pages;
	$responce->records =  $count;
	$i=0;
	foreach($records as $r){
		  $responce->rows[$i]['idbc27dtl']=$r->idbc27dtl;
		  $responce->rows[$i]['idbc27hdr']=$r->idbc27hdr;
		  $responce->rows[$i]['CAR']=$r->CAR;
		  $responce->rows[$i]['SERIBRG']=$r->SERIBRG;
		  $responce->rows[$i]['HS']=$r->HS;
		  $responce->rows[$i]['URBRG1']=$r->URBRG1;
		  $responce->rows[$i]['URBRG2']=$r->URBRG2;
		  $responce->rows[$i]['URBRG3']=$r->URBRG3;
		  $responce->rows[$i]['URBRG4']=$r->URBRG4;
		  $responce->rows[$i]['DMERK']=$r->DMERK;
		  $responce->rows[$i]['SIZE']=$r->SIZE;
		  $responce->rows[$i]['TYPE']=$r->TYPE;
		  $responce->rows[$i]['KDBRG']=$r->KDBRG;
		  $responce->rows[$i]['KDIZIN']=$r->KDIZIN;
		  $responce->rows[$i]['NOIZIN']=$r->NOIZIN;
		  $responce->rows[$i]['TGIZIN']=$r->TGIZIN;
		  $responce->rows[$i]['JMKOLI']=$r->JMKOLI;
		  $responce->rows[$i]['JNKOLI']=$r->JNKOLI;
		  $responce->rows[$i]['DNilInv']=$r->DNilInv;
		  $responce->rows[$i]['FOBPERBRG']=$r->FOBPERBRG;
		  $responce->rows[$i]['FOBPERSAT']=$r->FOBPERSAT;
		  $responce->rows[$i]['KDPE']=$r->KDPE;
		  $responce->rows[$i]['TARIPPE']=$r->TARIPPE;
		  $responce->rows[$i]['HPATOK']=$r->HPATOK;
		  $responce->rows[$i]['JMSATUAN']=$r->JMSATUAN;
		  $responce->rows[$i]['JNSATUAN']=$r->JNSATUAN;
		  $responce->rows[$i]['NETDET']=$r->NETDET;
		  $responce->rows[$i]['JMSATPE']=$r->JMSATPE;
		  $responce->rows[$i]['JNSATPE']=$r->JNSATPE;
		  $responce->rows[$i]['KDVALPE']=$r->KDVALPE;
		  $responce->rows[$i]['NILVALPE']=$r->NILVALPE;
		  $responce->rows[$i]['PEPERBRG']=$r->PEPERBRG;
		  $responce->rows[$i]['DTLOK']=$r->DTLOK;
		  $responce->rows[$i]['NCV']=$r->NCV;
		  $responce->rows[$i]['DVolume']=$r->DVolume;
		  $responce->rows[$i]['NegAsal']=$r->NegAsal;
		  $responce->rows[$i]['NOINV']=$r->NOINV;
		  $responce->rows[$i]['gabinvoice']=$r->gabinvoice;
	
		$i++;
	}
		echo json_encode($responce);
	
  
	}
	
	function prosesdatabc27(){
	    $username = $this->session->userdata('DX_username');
		$idbc27hdr = (isset($_POST['idbc27hdr']) && !empty($_POST['idbc27hdr']))?$_POST['idbc27hdr']:die('{"sts":"ERROR","desc":"SA Param Tidak Ditemukan"}');
		//echo " exec('[spi_proses_bc27] @idbc27hdr=$idbc27hdr, @userid=''$username'' ')"; die();
		$qry = $this->db->query("
			BEGIN TRY
			
			 exec('[spi_proses_bc27] @idbc27hdr=$idbc27hdr, @userid=''$username'' ')
			
			END TRY
			BEGIN CATCH 
				SELECT 
				'06' AS status
				,ERROR_MESSAGE() AS description;
				
			END CATCH;
			
			");
		 $rs = $qry->result_array();
		 // $r = $qry->result();		
		 // var_dump($r);die();
		 foreach ($rs as $row){
			 $status = $row['status'];
			 $msg = $row['description'];
		 }  
		 
		 echo json_encode(array('sts' => $status, 'desc' => $msg));
	
	}
	
	function update_bc27_sa_hdr(){
		$username = $this->session->userdata('DX_username');
		$idbc27hdr = (isset($_POST['id_bc_out_hdr']) && !empty($_POST['id_bc_out_hdr']))?$_POST['id_bc_out_hdr']:die('{"sts":"ERROR","desc":"SA Param Tidak Ditemukan"}');
		$nobc27 = (isset($_POST['nobc27']) && !empty($_POST['nobc27']))?$_POST['nobc27']:die('{"sts":"ERROR","desc":"NO BC Param Tidak Ditemukan"}');
		$tglbc27 = (isset($_POST['tglbc27']) && !empty($_POST['tglbc27']))?$_POST['tglbc27']:die('{"sts":"ERROR","desc":"TGL Param Tidak Ditemukan"}');
		
		
		//echo " exec('[spi_proses_bc27] @idbc27hdr=$idbc27hdr, @userid=''$username'' ')"; die();
		$qry = $this->db->query("
			BEGIN TRY
			
			 exec(' sp_insertmodulbc27 @idbc27hdr=$idbc27hdr, @userid=''$username'', @nobc27=''$nobc27'', @tglbc27=''$tglbc27'' ')
			
			END TRY
			BEGIN CATCH 
				SELECT 
				'06' AS status
				,ERROR_MESSAGE() AS description;
				
			END CATCH;
			
			");
		 $rs = $qry->result_array();
		 // $r = $qry->result();		
		 // var_dump($r);die();
		 foreach ($rs as $row){
			 $status = $row['status'];
			 $msg = $row['description'];
		 }  
		 
		 echo json_encode(array('sts' => $status, 'desc' => $msg));
	
		
	
	
	}
	function view_bc27_dtl(){
		$id_bc_out_hdr = (isset($_POST['id_bc_out_hdr']) && !empty($_POST['id_bc_out_hdr']))?$_POST['id_bc_out_hdr']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		$CAR = (isset($_POST['CAR']) && !empty($_POST['CAR']))?$_POST['CAR']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		
		$q = $this->db->query("
			SELECT  filename, noprosesdata  from [tblbc27hdr] where noprosesdata=$CAR
		");
		
		$rs = $q->result_array();
		//var_dump($rs); die();
		$filename='';
		foreach ($rs as $row){
			$filename=$row['filename'];		
		}
		
		
		$q = $this->db->query("
			SELECT  id_terkait, doc_out_no, id_data_out_hdr  from [tbl_data_out_hdr] where id_terkait=$id_bc_out_hdr and doc_out_to_id=5
		");
		
		$rs = $q->result_array();
		//var_dump($rs); die();
		$id_data_out_hdr='';
		foreach ($rs as $row){
			$id_data_out_hdr=$row['id_data_out_hdr'];		
		}
		
		$q1 = $this->db->query("
			select [id_data_out_hdr]
			  ,[doc_out_no]
			  ,convert(varchar, [doc_out_date], 103) as doc_out_date
			  ,[doc_out_to_id]
			  ,[id_data_out_hdr_h_status]
			  ,[id_terkait]
			  ,convert(varchar, [approve_date], 103) as approve_date
			  FROM[tbl_data_out_hdr]
			  where id_terkait = $id_bc_out_hdr
		");
		
		$rs1 = $q1->result_array();
		//var_dump($rs); die();
		$doc_out_date='';
		$approve_date='';
		foreach ($rs1 as $row1){
			$doc_out_date=$row1['doc_out_date'];		
			$approve_date=$row1['approve_date'];		
		}
		
		$data["doc_out_date"]= $doc_out_date;
		$data["approve_date"]= $approve_date;
		$data["idhdrbc27"]	= $id_data_out_hdr;
		$data['filename']=$filename;
				
		$data['filename']=$filename;
		
		$data['id_bc_out_hdr']=$id_bc_out_hdr;
	    $data['CAR']=$CAR;
	    $data['loading_indicator'] =  "<div class='loading_indicator'>loading...<br/><img src='./assets/images/loading.gif' alt='loading' /></div>";
		
		$this->load->view('exim/view_bc27_dtl', $data);
	
	}
	
	function loaddatadetil(){
		$search = isset($_POST['_search'])?$_POST['_search']:false;
		$searchField = isset($_POST['searchField'])?$_POST['searchField']:'';
		$searchString = isset($_POST['searchString'])?$_POST['searchString']:'';
		$filters =  isset($_POST['filters'])?$_POST['filters']:'';
		
		$page = isset($_POST['page'])?$_POST['page']:1; // get the requested page
		$limit = isset($_POST['rows'])?$_POST['rows']:20; // get how many rows we want to have into the grid
		$sidx = isset($_POST['sidx'])?$_POST['sidx']:'[idpebdtl]'; // get index row - i.e. user click to sort
		$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction	
		
		// $gabinvoice = (isset($_POST['gabinvoice']) && !empty($_POST['gabinvoice']))?$_POST['gabinvoice']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		 $idhdrbc27 = (isset($_POST['idhdrbc27']) && !empty($_POST['idhdrbc27']))?$_POST['idhdrbc27']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		
		 $where = " id_bc_out_hdr=$idhdrbc27 ";
		

		if ($search == 'true'){
			if (!empty($filters)){
				$array = json_decode($filters);
				foreach($array->rules as $arr=>$k){
					
					if ( $k->field == "[SERIBRG]" ) {
						$searchString = $k->data;
						$where .= " and [SERIBRG] = $searchString "; 
					} else if ( $k->field == "HS" ) {
						$searchString = $k->data;
						$where .= " and HS like  '%".$searchString."%'"; 
					} else if ( $k->field == "URBRG1" ) {
						$searchString = $k->data;
						$where .= " and URBRG1 like  '%".$searchString."%'"; 
					} else if ( $k->field == "URBRG2" ) {
						$searchString = $k->data;
						$where .= " and URBRG2 like  '%".$searchString."%'"; 
					} else if ( $k->field == "URBRG3" ) {
						$searchString = $k->data;
						$where .= " and URBRG3 like  '%".$searchString."%'"; 
					} else if ( $k->field == "URBRG4" ) {
						$searchString = $k->data;
						$where .= " and URBRG4 like  '%".$searchString."%'"; 
					} else if ( $k->field == "DMERK" ) {
						$searchString = $k->data;
						$where .= " and DMERK like  '%".$searchString."%'"; 
					}  else if ( $k->field == "SIZE" ) {
						$searchString = $k->data;
						$where .= " and SIZE like  '%".$searchString."%'"; 
					}  else if ( $k->field == "TYPE" ) {
						$searchString = $k->data;
						$where .= " and TYPE like  '%".$searchString."%'"; 
					}   else if ( $k->field == "KDBRG" ) {
						$searchString = $k->data;
						$where .= " and KDBRG like  '%".$searchString."%'"; 
					}  else if ( $k->field == "JNSATUAN" ) {
						$searchString = $k->data;
						$where .= " and JNSATUAN like  '%".$searchString."%'"; 
					} 
			
				}
			}
		}	
			
		$start = $limit*$page - $limit;
		if ($start<0) $start=0;
		
		$records = $this->mdl_bc27->bc27datadtl_All($limit,$start,$sidx,$sord, $where);
		$count = $this->mdl_bc27->bc27datadtl_CountAll($where);
		
		
		if( $count > 0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } 
		if ($page > $total_pages) $page=$total_pages;
		
		$responce->page = $page;
		$responce->total = $total_pages;
		$responce->records =  $count;
		$i=0;
		foreach($records as $r){
			  $responce->rows[$i]['id_bc_out_dtl']=$r->id_bc_out_dtl;
			  $responce->rows[$i]['id_bc_out_hdr']=$r->id_bc_out_hdr;
			  $responce->rows[$i]['CAR']=$r->CAR;
			  $responce->rows[$i]['SERIBRG']=$r->SERIBRG;
			  $responce->rows[$i]['HS']=$r->HS;
			  $responce->rows[$i]['URBRG1']=$r->URBRG1;
			  $responce->rows[$i]['URBRG2']=$r->URBRG2;
			  $responce->rows[$i]['URBRG3']=$r->URBRG3;
			  $responce->rows[$i]['URBRG4']=$r->URBRG4;
			  $responce->rows[$i]['DMERK']=$r->DMERK;
			  $responce->rows[$i]['SIZE']=$r->SIZE;
			  $responce->rows[$i]['TYPE']=$r->TYPE;
			  $responce->rows[$i]['KDBRG']=$r->KDBRG;
			  $responce->rows[$i]['KDIZIN']=$r->KDIZIN;
			  $responce->rows[$i]['NOIZIN']=$r->NOIZIN;
			  $responce->rows[$i]['TGIZIN']=$r->TGIZIN;
			  $responce->rows[$i]['JMKOLI']=$r->JMKOLI;
			  $responce->rows[$i]['JNKOLI']=$r->JNKOLI;
			  $responce->rows[$i]['DNilInv']=$r->DNilInv;
			  $responce->rows[$i]['FOBPERBRG']=$r->FOBPERBRG;
			  $responce->rows[$i]['FOBPERSAT']=$r->FOBPERSAT;
			  $responce->rows[$i]['KDPE']=$r->KDPE;
			  $responce->rows[$i]['TARIPPE']=$r->TARIPPE;
			  $responce->rows[$i]['HPATOK']=$r->HPATOK;
			  $responce->rows[$i]['JMSATUAN']=$r->JMSATUAN;
			  $responce->rows[$i]['JNSATUAN']=$r->JNSATUAN;
			  $responce->rows[$i]['NETDET']=$r->NETDET;
			  $responce->rows[$i]['JMSATPE']=$r->JMSATPE;
			  $responce->rows[$i]['JNSATPE']=$r->JNSATPE;
			  $responce->rows[$i]['KDVALPE']=$r->KDVALPE;
			  $responce->rows[$i]['NILVALPE']=$r->NILVALPE;
			  $responce->rows[$i]['PEPERBRG']=$r->PEPERBRG;
			  $responce->rows[$i]['DTLOK']=$r->DTLOK;
			  $responce->rows[$i]['NCV']=$r->NCV;
			  $responce->rows[$i]['DVolume']=$r->DVolume;
			  $responce->rows[$i]['NegAsal']=$r->NegAsal;
			 
		
		$i++;
		}
		echo json_encode($responce);
	
		
	
	}
	
	function loaddatadok(){
		$search = isset($_POST['_search'])?$_POST['_search']:false;
		$searchField = isset($_POST['searchField'])?$_POST['searchField']:'';
		$searchString = isset($_POST['searchString'])?$_POST['searchString']:'';
		$filters =  isset($_POST['filters'])?$_POST['filters']:'';
		
		$page = isset($_POST['page'])?$_POST['page']:1; // get the requested page
		$limit = isset($_POST['rows'])?$_POST['rows']:20; // get how many rows we want to have into the grid
		$sidx = isset($_POST['sidx'])?$_POST['sidx']:'[idpebdtl]'; // get index row - i.e. user click to sort
		$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction	
		
		// $gabinvoice = (isset($_POST['gabinvoice']) && !empty($_POST['gabinvoice']))?$_POST['gabinvoice']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		 $idhdrbc27 = (isset($_POST['idhdrbc27']) && !empty($_POST['idhdrbc27']))?$_POST['idhdrbc27']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		
		 $where = " id_bc_out_hdr=$idhdrbc27 ";
		

		if ($search == 'true'){
			if (!empty($filters)){
				$array = json_decode($filters);
				foreach($array->rules as $arr=>$k){
					
					if ( $k->field == "[SERIBRG]" ) {
						$searchString = $k->data;
						$where .= " and [SERIBRG] = $searchString "; 
					} else if ( $k->field == "HS" ) {
						$searchString = $k->data;
						$where .= " and HS like  '%".$searchString."%'"; 
					} 
			
				}
			}
		}	
			
		$start = $limit*$page - $limit;
		if ($start<0) $start=0;
		
		$records = $this->mdl_bc27->bc27datadok_All($limit,$start,$sidx,$sord, $where);
		$count = $this->mdl_bc27->bc27datadok_CountAll($where);
		
		
		if( $count > 0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } 
		if ($page > $total_pages) $page=$total_pages;
		
		$responce->page = $page;
		$responce->total = $total_pages;
		$responce->records =  $count;
		$i=0;
		foreach($records as $r){
			$responce->rows[$i]['id_bc_out_dok']=$r->id_bc_out_dok;
			$responce->rows[$i]['id_bc_out_hdr']=$r->id_bc_out_hdr;
			$responce->rows[$i]['CAR']=$r->CAR;
			$responce->rows[$i]['KdDok']=$r->KdDok;
			$responce->rows[$i]['uraian']=$r->uraian;
			$responce->rows[$i]['NoDok']=$r->NoDok;
			$responce->rows[$i]['TgDok']=$r->TgDok;
			$i++;
		}
		echo json_encode($responce);
	
	}
	
	function print_bc27_hdr(){
	
		$id_bc_out_hdr = (isset($_REQUEST['id_bc_out_hdr']) && !empty($_REQUEST['id_bc_out_hdr']))?$_REQUEST['id_bc_out_hdr']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		
	
	}
	
	function print_bc27_dtl(){
	
		$id_bc_out_hdr = (isset($_REQUEST['id_bc_out_hdr']) && !empty($_REQUEST['id_bc_out_hdr']))?$_REQUEST['id_bc_out_hdr']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		
	
	}
	
	function prosesdatatofg(){
		$id_bc_out = (isset($_POST['id_bc_out']) && !empty($_POST['id_bc_out']))?$_POST['id_bc_out']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		$typedok = (isset($_POST['typedok']) && !empty($_POST['typedok']))?$_POST['typedok']:die('{"sts":"ERROR","desc":" Param Tidak Ditemukan"}');
		
		$username = $this->session->userdata('DX_username');
      
		$qry = $this->db->query("
			BEGIN TRY
			
			 exec('[spi_prosesdatatofg] @id_bc_out=$id_bc_out, @typedok=''$typedok'', @username=''$username'' ')
			
			END TRY
			BEGIN CATCH 
				SELECT 
				'06' AS status
				,ERROR_MESSAGE() AS description;
				
			END CATCH;
			
			");
		 $rs = $qry->result_array();
		 // $r = $qry->result();		
		 // var_dump($r);die();
		 foreach ($rs as $row){
			 $status = $row['status'];
			 $msg = $row['description'];
		 }  
		//  echo json_encode($responce);
		 // $stmt = " exec('[spi_prosesdatatofg]') ";
		 // $qry = mssql_query($stmt); 
		 // $row = mssql_fetch_array($qry); 
		 // var_dump($row);die();
		
		
		$q = $this->db->query("
			SELECT  id_terkait, doc_out_no, id_data_out_hdr  from [tbl_data_out_hdr] where id_terkait=$id_bc_out and doc_out_to_id=5
		");
		
		$rs = $q->result_array();
		//var_dump($rs); die();
		$id_data_out_hdr='';
		foreach ($rs as $row){
			$id_data_out_hdr=$row['id_data_out_hdr'];		
		}
		
		
		$status = $status;
		$msg = $msg;
		
		echo json_encode(array('sts' => $status, 'desc' => $msg, 'id_data_out_hdr' =>$id_data_out_hdr ));
	
	}
	
	
	
	
	
	
  
 }