<?php
class CT_produksi_data 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');
		} 
	}  
	
	function index(){
		
		$this->load->view('pasi_ceisa_gudang/view_gudang');
	} 
	//--------------------------------mulai 
	function loaddata_produksi_rdd(){; 
		$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
		$spt='dbo.SPX_PRODUKSI_RDD'; 
		$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
		$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
		$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
		$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r100']=array("db" => "r100" ,"sc" => "r100","ctype"=>"text", "bypassvalue"=>"");
	
 			
 		$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']:10; // get how many rows we want to have into the grid 
		$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
		$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
  	  
		if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
 		 
		if (array_key_exists($sidx, $def_col)) {  
				$fsidx=$def_col[$sidx];
				$sidx=$fsidx['db'];
		}else{
				$sidx='rID'; //DEFAULT SORT KALU GA ADA
		}
        $sidx=$sidx.'='. $sord;
		  
		$xmldoc =  XMLbasic($spt); 
		paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
  		$adaSearchStatus=0;
		
        if ($search == 'true'){ 
            if (!empty($filters)){ 
				$array = json_decode($filters); 
                foreach($array->rules as $arr=>$k){ 
						$fcr=$def_col[$k->field]; 
	 					if ($fcr != null) 
						{ 
							if ($fcr['ctype']=='int'){ 
								$searchString = $k->data; 
								if ($searchString!=$fcr['bypassvalue']) { 
									addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
									  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
										$adaSearchStatus=1;
									  }
								} 
							 
							} 
							elseif ($fcr['ctype']=='text'){ 
					        	$searchString = $k->data; 
								if ($searchString!=$fcr['bypassvalue']) 
							     addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
							}  
							elseif ($fcr['ctype']=='date'){ 
								$searchString = $k->data; 
								if (trim($searchString) != '' ){ 
									$dateArray=explode('/',$searchString);  
									$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
								} 
								 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
							}  
						} 
                 } 
             } 
	   }  
  
		if ($adaSearchStatus==0){
			addSearchNum($xmldoc,'r1','-1','3','-1'); 
		}
		$str = $xmldoc->saveXML(); 
	//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
	//	 print_r($str);die(); SP_T_HEADER_BC_23
	 	 exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_RDD',$sts,$des,$rows,$detail);  
	 	echo $rows; 
		}

		function loaddata_produksi_dbc(){; 
			$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
			$spt='dbo.SPX_PRODUKSI_DBC'; 
			$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
			$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
			$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r100']=array("db" => "r100" ,"sc" => "r100","ctype"=>"text", "bypassvalue"=>"");
		
				 
			 $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']:10; // get how many rows we want to have into the grid 
			$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
			$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
			$posisi = isset($_POST['posisi'])?$_POST['posisi']:''; 
			if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
			  
			if (array_key_exists($sidx, $def_col)) {  
					$fsidx=$def_col[$sidx];
					$sidx=$fsidx['db'];
			}else{
					$sidx='rID'; //DEFAULT SORT KALU GA ADA
			}
			$sidx=$sidx.'='. $sord;
			  
			$xmldoc =  XMLbasic($spt); 
			paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
			  $adaSearchStatus=0;
			
			if ($search == 'true'){ 
				if (!empty($filters)){ 
					$array = json_decode($filters); 
					foreach($array->rules as $arr=>$k){ 
							$fcr=$def_col[$k->field]; 
							 if ($fcr != null) 
							{ 
								if ($fcr['ctype']=='int'){ 
									$searchString = $k->data; 
									if ($searchString!=$fcr['bypassvalue']) { 
										addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
										  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
											$adaSearchStatus=1;
										  }
									} 
								 
								} 
								elseif ($fcr['ctype']=='text'){ 
									$searchString = $k->data; 
									if ($searchString!=$fcr['bypassvalue']) 
									 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
								}  
								elseif ($fcr['ctype']=='date'){ 
									$searchString = $k->data; 
									if (trim($searchString) != '' ){ 
										$dateArray=explode('/',$searchString);  
										$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
									} 
									 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
								}  
							} 
					 } 
				 } 
		   }  
	  
			if ($adaSearchStatus==0){
				addSearchNum($xmldoc,'r1','-1','3','-1'); 
			}
			$str = $xmldoc->saveXML(); 
		//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
		//	 print_r($str);die(); SP_T_HEADER_BC_23
			  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_DBC',$sts,$des,$rows,$detail);  
			 echo $rows; 
			}

		function loaddata_produksi_mld(){; 
			$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
			$spt='dbo.SPX_PRODUKSI_MLD'; 
			$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
			$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
			$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r100']=array("db" => "r100" ,"sc" => "r100","ctype"=>"text", "bypassvalue"=>"");
		
				 
			 $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']:10; // get how many rows we want to have into the grid 
			$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
			$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
			
			if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
			  
			if (array_key_exists($sidx, $def_col)) {  
					$fsidx=$def_col[$sidx];
					$sidx=$fsidx['db'];
			}else{
					$sidx='rID'; //DEFAULT SORT KALU GA ADA
			}
			$sidx=$sidx.'='. $sord;
			  
			$xmldoc =  XMLbasic($spt); 
			paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
			  $adaSearchStatus=0;
			
			if ($search == 'true'){ 
				if (!empty($filters)){ 
					$array = json_decode($filters); 
					foreach($array->rules as $arr=>$k){ 
							$fcr=$def_col[$k->field]; 
							 if ($fcr != null) 
							{ 
								if ($fcr['ctype']=='int'){ 
									$searchString = $k->data; 
									if ($searchString!=$fcr['bypassvalue']) { 
										addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
										  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
											$adaSearchStatus=1;
										  }
									} 
								 
								} 
								elseif ($fcr['ctype']=='text'){ 
									$searchString = $k->data; 
									if ($searchString!=$fcr['bypassvalue']) 
									 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
								}  
								elseif ($fcr['ctype']=='date'){ 
									$searchString = $k->data; 
									if (trim($searchString) != '' ){ 
										$dateArray=explode('/',$searchString);  
										$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
									} 
									 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
								}  
							} 
					 } 
				 } 
		   }  
	  
			if ($adaSearchStatus==0){
				addSearchNum($xmldoc,'r1','-1','3','-1'); 
			}
			$str = $xmldoc->saveXML(); 
		//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
		//	 print_r($str);die(); SP_T_HEADER_BC_23
			  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_MLD',$sts,$des,$rows,$detail);  
			 echo $rows; 
			}
	
			function loaddata_produksi_mdd(){; 
				$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
				$spt='dbo.SPX_PRODUKSI_MDD'; 
				$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
				$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
				$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r100']=array("db" => "r100" ,"sc" => "r100","ctype"=>"text", "bypassvalue"=>"");
			
					 
				 $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']:10; // get how many rows we want to have into the grid 
				$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
				$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
				
				if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
				  
				if (array_key_exists($sidx, $def_col)) {  
						$fsidx=$def_col[$sidx];
						$sidx=$fsidx['db'];
				}else{
						$sidx='rID'; //DEFAULT SORT KALU GA ADA
				}
				$sidx=$sidx.'='. $sord;
				  
				$xmldoc =  XMLbasic($spt); 
				paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
				  $adaSearchStatus=0;
				
				if ($search == 'true'){ 
					if (!empty($filters)){ 
						$array = json_decode($filters); 
						foreach($array->rules as $arr=>$k){ 
								$fcr=$def_col[$k->field]; 
								 if ($fcr != null) 
								{ 
									if ($fcr['ctype']=='int'){ 
										$searchString = $k->data; 
										if ($searchString!=$fcr['bypassvalue']) { 
											addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
											  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
												$adaSearchStatus=1;
											  }
										} 
									 
									} 
									elseif ($fcr['ctype']=='text'){ 
										$searchString = $k->data; 
										if ($searchString!=$fcr['bypassvalue']) 
										 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
									}  
									elseif ($fcr['ctype']=='date'){ 
										$searchString = $k->data; 
										if (trim($searchString) != '' ){ 
											$dateArray=explode('/',$searchString);  
											$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
										} 
										 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
									}  
								} 
						 } 
					 } 
			   }  
		  
				if ($adaSearchStatus==0){
					addSearchNum($xmldoc,'r1','-1','3','-1'); 
				}
				$str = $xmldoc->saveXML(); 
			//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
			//	 print_r($str);die(); SP_T_HEADER_BC_23
				  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_MDD',$sts,$des,$rows,$detail);  
				 echo $rows; 
				}
		
				function loaddata_produksi_sbc(){; 
					$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
					$spt='dbo.SPX_PRODUKSI_SBC'; 
					$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
					$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
					$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r100']=array("db" => "r100" ,"sc" => "r100","ctype"=>"text", "bypassvalue"=>"");
				
						 
					 $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']:10; // get how many rows we want to have into the grid 
					$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
					$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
					
					if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
					  
					if (array_key_exists($sidx, $def_col)) {  
							$fsidx=$def_col[$sidx];
							$sidx=$fsidx['db'];
					}else{
							$sidx='rID'; //DEFAULT SORT KALU GA ADA
					}
					$sidx=$sidx.'='. $sord;
					  
					$xmldoc =  XMLbasic($spt); 
					paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
					  $adaSearchStatus=0;
					
					if ($search == 'true'){ 
						if (!empty($filters)){ 
							$array = json_decode($filters); 
							foreach($array->rules as $arr=>$k){ 
									$fcr=$def_col[$k->field]; 
									 if ($fcr != null) 
									{ 
										if ($fcr['ctype']=='int'){ 
											$searchString = $k->data; 
											if ($searchString!=$fcr['bypassvalue']) { 
												addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
												  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
													$adaSearchStatus=1;
												  }
											} 
										 
										} 
										elseif ($fcr['ctype']=='text'){ 
											$searchString = $k->data; 
											if ($searchString!=$fcr['bypassvalue']) 
											 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
										}  
										elseif ($fcr['ctype']=='date'){ 
											$searchString = $k->data; 
											if (trim($searchString) != '' ){ 
												$dateArray=explode('/',$searchString);  
												$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
											} 
											 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
										}  
									} 
							 } 
						 } 
				   }  
			  
					if ($adaSearchStatus==0){
						addSearchNum($xmldoc,'r1','-1','3','-1'); 
					}
					$str = $xmldoc->saveXML(); 
				//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
				//	 print_r($str);die(); SP_T_HEADER_BC_23
					  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_SBC',$sts,$des,$rows,$detail);  
					 echo $rows; 
					}

					function loaddata_produksi_ext(){; 
						$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
						$spt='dbo.SPX_PRODUKSI_EXT'; 
						$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
						$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
						$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r100']=array("db" => "r100" ,"sc" => "r100","ctype"=>"text", "bypassvalue"=>"");
					
							 
						 $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']:10; // get how many rows we want to have into the grid 
						$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
						$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
						
						if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
						  
						if (array_key_exists($sidx, $def_col)) {  
								$fsidx=$def_col[$sidx];
								$sidx=$fsidx['db'];
						}else{
								$sidx='rID'; //DEFAULT SORT KALU GA ADA
						}
						$sidx=$sidx.'='. $sord;
						  
						$xmldoc =  XMLbasic($spt); 
						paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
						  $adaSearchStatus=0;
						
						if ($search == 'true'){ 
							if (!empty($filters)){ 
								$array = json_decode($filters); 
								foreach($array->rules as $arr=>$k){ 
										$fcr=$def_col[$k->field]; 
										 if ($fcr != null) 
										{ 
											if ($fcr['ctype']=='int'){ 
												$searchString = $k->data; 
												if ($searchString!=$fcr['bypassvalue']) { 
													addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
													  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
														$adaSearchStatus=1;
													  }
												} 
											 
											} 
											elseif ($fcr['ctype']=='text'){ 
												$searchString = $k->data; 
												if ($searchString!=$fcr['bypassvalue']) 
												 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
											}  
											elseif ($fcr['ctype']=='date'){ 
												$searchString = $k->data; 
												if (trim($searchString) != '' ){ 
													$dateArray=explode('/',$searchString);  
													$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
												} 
												 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
											}  
										} 
								 } 
							 } 
					   }  
				  
						if ($adaSearchStatus==0){
							addSearchNum($xmldoc,'r1','-1','3','-1'); 
						}
						$str = $xmldoc->saveXML(); 
					//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
					//	 print_r($str);die(); SP_T_HEADER_BC_23
						  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_EXT',$sts,$des,$rows,$detail);  
						 echo $rows; 
						}					

function loaddata_produksi_tube(){; 
							$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
							$spt='dbo.SPX_PRODUKSI_TUBE'; 
							$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
							$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
							$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
							$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r100']=array("db" => "r100" ,"sc" => "r100","ctype"=>"text", "bypassvalue"=>"");
						
								 
							 $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']:10; // get how many rows we want to have into the grid 
							$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
							$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
							
							if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
							  
							if (array_key_exists($sidx, $def_col)) {  
									$fsidx=$def_col[$sidx];
									$sidx=$fsidx['db'];
							}else{
									$sidx='rID'; //DEFAULT SORT KALU GA ADA
							}
							$sidx=$sidx.'='. $sord;
							  
							$xmldoc =  XMLbasic($spt); 
							paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
							  $adaSearchStatus=0;
							
							if ($search == 'true'){ 
								if (!empty($filters)){ 
									$array = json_decode($filters); 
									foreach($array->rules as $arr=>$k){ 
											$fcr=$def_col[$k->field]; 
											 if ($fcr != null) 
											{ 
												if ($fcr['ctype']=='int'){ 
													$searchString = $k->data; 
													if ($searchString!=$fcr['bypassvalue']) { 
														addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
														  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
															$adaSearchStatus=1;
														  }
													} 
												 
												} 
												elseif ($fcr['ctype']=='text'){ 
													$searchString = $k->data; 
													if ($searchString!=$fcr['bypassvalue']) 
													 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
												}  
												elseif ($fcr['ctype']=='date'){ 
													$searchString = $k->data; 
													if (trim($searchString) != '' ){ 
														$dateArray=explode('/',$searchString);  
														$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
													} 
													 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
												}  
											} 
									 } 
								 } 
						   }  
					  
							if ($adaSearchStatus==0){
								addSearchNum($xmldoc,'r1','-1','3','-1'); 
							}
							$str = $xmldoc->saveXML(); 
						//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
						//	 print_r($str);die(); SP_T_HEADER_BC_23
							  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_TUBE',$sts,$des,$rows,$detail);  
							 echo $rows; 
							}					
	


							function loaddata_produksi_wire(){; 
								$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
								$spt='dbo.SPX_PRODUKSI_WIRE'; 
								$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
								$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
								$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
								$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r100']=array("db" => "r100" ,"sc" => "r100","ctype"=>"text", "bypassvalue"=>"");
							
									 
								 $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']:10; // get how many rows we want to have into the grid 
								$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
								$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
								
								if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
								  
								if (array_key_exists($sidx, $def_col)) {  
										$fsidx=$def_col[$sidx];
										$sidx=$fsidx['db'];
								}else{
										$sidx='rID'; //DEFAULT SORT KALU GA ADA
								}
								$sidx=$sidx.'='. $sord;
								  
								$xmldoc =  XMLbasic($spt); 
								paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
								  $adaSearchStatus=0;
								
								if ($search == 'true'){ 
									if (!empty($filters)){ 
										$array = json_decode($filters); 
										foreach($array->rules as $arr=>$k){ 
												$fcr=$def_col[$k->field]; 
												 if ($fcr != null) 
												{ 
													if ($fcr['ctype']=='int'){ 
														$searchString = $k->data; 
														if ($searchString!=$fcr['bypassvalue']) { 
															addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
															  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
																$adaSearchStatus=1;
															  }
														} 
													 
													} 
													elseif ($fcr['ctype']=='text'){ 
														$searchString = $k->data; 
														if ($searchString!=$fcr['bypassvalue']) 
														 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
													}  
													elseif ($fcr['ctype']=='date'){ 
														$searchString = $k->data; 
														if (trim($searchString) != '' ){ 
															$dateArray=explode('/',$searchString);  
															$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
														} 
														 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
													}  
												} 
										 } 
									 } 
							   }  
						  
								if ($adaSearchStatus==0){
									addSearchNum($xmldoc,'r1','-1','3','-1'); 
								}
								$str = $xmldoc->saveXML(); 
							//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
							//	 print_r($str);die(); SP_T_HEADER_BC_23
								  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_WIRE',$sts,$des,$rows,$detail);  
								 echo $rows; 
								}					
		
	




				function loaddata_produksi_all(){; 
					$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
					$spt='dbo.SPX_PRODUKSI_ALL'; 
					$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
					$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
					$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
				
						 
					 $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']:10; // get how many rows we want to have into the grid 
					$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
					$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
					$posisi = isset($_POST['posisi'])?$_POST['posisi']:'';
					if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
					  
					if (array_key_exists($sidx, $def_col)) {  
							$fsidx=$def_col[$sidx];
							$sidx=$fsidx['db'];
					}else{
							$sidx='rID'; //DEFAULT SORT KALU GA ADA
					}
					$sidx=$sidx.'='. $sord;
					  
					$xmldoc =  XMLbasic($spt); 
					paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
					  $adaSearchStatus=0;
					
					if ($search == 'true'){ 
						if (!empty($filters)){ 
							$array = json_decode($filters); 
							foreach($array->rules as $arr=>$k){ 
									$fcr=$def_col[$k->field]; 
									 if ($fcr != null) 
									{ 
										if ($fcr['ctype']=='int'){ 
											$searchString = $k->data; 
											if ($searchString!=$fcr['bypassvalue']) { 
												addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
												  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
													$adaSearchStatus=1;
												  }
											} 
										 
										} 
										elseif ($fcr['ctype']=='text'){ 
											$searchString = $k->data; 
											if ($searchString!=$fcr['bypassvalue']) 
											 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
										}  
										elseif ($fcr['ctype']=='date'){ 
											$searchString = $k->data; 
											if (trim($searchString) != '' ){ 
												$dateArray=explode('/',$searchString);  
												$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
											} 
											 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
										}  
									} 
							 } 
						 } 
				   }  
			  
					if ($adaSearchStatus==0){
						addSearchNum($xmldoc,'r1','-1','3','-1'); 
					}
				//	AddField($xmldoc ,'posisi', $posisi); 
					$str = $xmldoc->saveXML(); 
				//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
				//	 print_r($str);die(); SP_T_HEADER_BC_23
					  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_ALL',$sts,$des,$rows,$detail);  
					 echo $rows; 
					}			
  //-----------------------pilih bom

		function loaddata_bom_rdd(){; 
			$def_col= array(); 
			$spt='dbo.SPX_PRODUKSI_RDD_BOM'; 
			$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r1']=array("db" => "r1" ,"sc" => "ri","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"date", "bypassvalue"=>"");
			$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"date", "bypassvalue"=>"");
			$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"text", "bypassvalue"=>"");
			 $def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
			$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
			$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
			$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
			$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
			$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
			$def_col['i5']=array("db" => "i5" ,"sc" => "i5","ctype"=>"text", "bypassvalue"=>"");
			
			 $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']:10; // get how many rows we want to have into the grid 
			$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
			$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
			$posisi = isset($_POST['posisi'])?$_POST['posisi']:'';

			if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
			  
			 if (array_key_exists($sidx, $def_col)) {  
					$fsidx=$def_col[$sidx];
					$sidx=$fsidx['db'];
			}else{
					$sidx='rID'; //DEFAULT SORT KALU GA ADA
			}
			$sidx=$sidx.'='. $sord;
			  
			$xmldoc =  XMLbasic($spt); 
			paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
	 
				 
			if ($search == 'true'){ 
				if (!empty($filters)){ 
					$array = json_decode($filters); 
					foreach($array->rules as $arr=>$k){ 
							$fcr=$def_col[$k->field]; 
							 if ($fcr != null) 
							{ 
								if ($fcr['ctype']=='int'){ 
									$searchString = $k->data; 
									if ($searchString!=$fcr['bypassvalue'])  
										addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
									   
								} 
								elseif ($fcr['ctype']=='text'){ 
									$searchString = $k->data; 
									if ($searchString!=$fcr['bypassvalue']) 
									 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
								}  
								elseif ($fcr['ctype']=='date'){ 
									$searchString = $k->data; 
									if (trim($searchString) != '' ){ 
										$dateArray=explode('/',$searchString);  
										$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
									} 
									 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
								}  
							} 
					 } 
				 } 
		   }  
		   $xmldoc =  XMLbasic('json'); 
		   AddField($xmldoc ,'posisi', $posisi); 
			$str = $xmldoc->saveXML();   
			 exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_RDD_BOM',$sts,$des,$rows,$detail);   
			  echo $rows; 
			}
			

			function loaddata_bom_item(){; 
				$def_col= array(); 
				$spt='dbo.SPX_PRODUKSI_RDD_BOM'; 
				$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r1']=array("db" => "r1" ,"sc" => "ri","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"text", "bypassvalue"=>"");
				 $def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
				$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
				$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
				$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
				$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
				$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
				$def_col['i5']=array("db" => "i5" ,"sc" => "i5","ctype"=>"text", "bypassvalue"=>"");
				
				 $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']:10; // get how many rows we want to have into the grid 
				$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
				$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
				$posisi = isset($_POST['posisi'])?$_POST['posisi']:'';
	
				if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
				  
				 if (array_key_exists($sidx, $def_col)) {  
						$fsidx=$def_col[$sidx];
						$sidx=$fsidx['db'];
				}else{
						$sidx='rID'; //DEFAULT SORT KALU GA ADA
				}
				$sidx=$sidx.'='. $sord;
				  
				$xmldoc =  XMLbasic($spt); 
				paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
		 
					 
				if ($search == 'true'){ 
					if (!empty($filters)){ 
						$array = json_decode($filters); 
						foreach($array->rules as $arr=>$k){ 
								$fcr=$def_col[$k->field]; 
								 if ($fcr != null) 
								{ 
									if ($fcr['ctype']=='int'){ 
										$searchString = $k->data; 
										if ($searchString!=$fcr['bypassvalue'])  
											addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
										   
									} 
									elseif ($fcr['ctype']=='text'){ 
										$searchString = $k->data; 
										if ($searchString!=$fcr['bypassvalue']) 
										 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
									}  
									elseif ($fcr['ctype']=='date'){ 
										$searchString = $k->data; 
										if (trim($searchString) != '' ){ 
											$dateArray=explode('/',$searchString);  
											$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
										} 
										 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
									}  
								} 
						 } 
					 } 
			   }  
		  
			   AddField($xmldoc ,'posisi', $posisi); 
				$str = $xmldoc->saveXML();   
				 exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_RDD_BOM',$sts,$des,$rows,$detail);   
				  echo $rows; 
				}
				
				function loaddata_all_bom_item(){; 
					$def_col= array(); 
					$spt='dbo.SPX_PRODUKSI_ALL_BOM'; 
					$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r1']=array("db" => "r1" ,"sc" => "ri","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"text", "bypassvalue"=>"");
					 $def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
					$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
					$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
					$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
					$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
					$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
					$def_col['i5']=array("db" => "i5" ,"sc" => "i5","ctype"=>"text", "bypassvalue"=>"");
					
					 $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']:10; // get how many rows we want to have into the grid 
					$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
					$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
					$posisi = isset($_POST['posisi'])?$_POST['posisi']:'';
		
					if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
					  
					 if (array_key_exists($sidx, $def_col)) {  
							$fsidx=$def_col[$sidx];
							$sidx=$fsidx['db'];
					}else{
							$sidx='rID'; //DEFAULT SORT KALU GA ADA
					}
					$sidx=$sidx.'='. $sord;
					  
					$xmldoc =  XMLbasic($spt); 
					paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
			 
						 
					if ($search == 'true'){ 
						if (!empty($filters)){ 
							$array = json_decode($filters); 
							foreach($array->rules as $arr=>$k){ 
									$fcr=$def_col[$k->field]; 
									 if ($fcr != null) 
									{ 
										if ($fcr['ctype']=='int'){ 
											$searchString = $k->data; 
											if ($searchString!=$fcr['bypassvalue'])  
												addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
											   
										} 
										elseif ($fcr['ctype']=='text'){ 
											$searchString = $k->data; 
											if ($searchString!=$fcr['bypassvalue']) 
											 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
										}  
										elseif ($fcr['ctype']=='date'){ 
											$searchString = $k->data; 
											if (trim($searchString) != '' ){ 
												$dateArray=explode('/',$searchString);  
												$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
											} 
											 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
										}  
									} 
							 } 
						 } 
				   }  
			  
				   AddField($xmldoc ,'posisi', $posisi); 
					$str = $xmldoc->saveXML();   
					 exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_ALL_BOM',$sts,$des,$rows,$detail);   
					  echo $rows; 
					}
					
	
	
	
	
	
	


























			function loaddata_produksi_rdd_material(){; 
				$def_col= array(); 
				$spt='dbo.SPX_PRODUKSI_RDD_MATERIAL'; 
				$def_col['id']=array("db" => "id" ,"sc" => "id","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r27']=array("db" => "r27" ,"sc" => "r27","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r28']=array("db" => "r28" ,"sc" => "r28","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r29']=array("db" => "r29" ,"sc" => "r29","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r30']=array("db" => "r30" ,"sc" => "r30","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r31']=array("db" => "r31" ,"sc" => "r31","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r32']=array("db" => "r32" ,"sc" => "r32","ctype"=>"text", "bypassvalue"=>"");
				 $def_col['ru']=array("db" => "ru" ,"sc" => "ru","ctype"=>"int", "bypassvalue"=>"");
				$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
				$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
				$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
				$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
				$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
				
				 $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']:10; // get how many rows we want to have into the grid 
				$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
				$sord = isset($_POST['sord'])?$_POST['sord']:'asc'; // get the direction 
				
				  $kurs = isset($_POST['kurs'])?$_POST['kurs']:''; // get the direction 
				  $id_header = isset($_POST['id_header'])?$_POST['id_header']:''; // get the direction 
				   $supp_code_len = isset($_POST['len_supp_code'])?$_POST['len_supp_code']:'3'; // get the direction 
				
				if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
				  
				 if (array_key_exists($sidx, $def_col)) {  
						$fsidx=$def_col[$sidx];
						$sidx=$fsidx['db'];
				}else{
						$sidx='rID'; //DEFAULT SORT KALU GA ADA
				}
				$sidx=$sidx.'='. $sord;
				  
				$xmldoc =  XMLbasic($spt); 
				 paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
				AddField($xmldoc ,'id_header', $id_header); 
				AddField($xmldoc ,'kurs',$kurs); 
				 
				if ($search == 'true'){ 
					if (!empty($filters)){ 
						$array = json_decode($filters); 
						foreach($array->rules as $arr=>$k){ 
								$fcr=$def_col[$k->field]; 
								 if ($fcr != null) 
								{ 
									if ($fcr['ctype']=='int'){ 
										$searchString = $k->data; 
										if ($searchString!=$fcr['bypassvalue'])  
											addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
										   
									} 
									elseif ($fcr['ctype']=='text'){ 
										$searchString = $k->data; 
										if ($searchString!=$fcr['bypassvalue']) 
										 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
									}  
									elseif ($fcr['ctype']=='date'){ 
										$searchString = $k->data; 
										if (trim($searchString) != '' ){ 
											$dateArray=explode('/',$searchString);  
											$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
										} 
										 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
									}  
								} 
						 } 
					 } 
			   }  
		  
		  
				$str = $xmldoc->saveXML() ;
				//print_r($str);die();
				exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_RDD_MATERIAL',$sts,$des,$rows,$detail);  
				  echo $rows; 
				}
	
				function loaddata_produksi_all_material(){; 
					$def_col= array(); 
					$spt='dbo.SPX_PRODUKSI_ALL_MATERIAL'; 
					$def_col['id']=array("db" => "id" ,"sc" => "id","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r27']=array("db" => "r27" ,"sc" => "r27","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r28']=array("db" => "r28" ,"sc" => "r28","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r29']=array("db" => "r29" ,"sc" => "r29","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r30']=array("db" => "r30" ,"sc" => "r30","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r31']=array("db" => "r31" ,"sc" => "r31","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r32']=array("db" => "r32" ,"sc" => "r32","ctype"=>"text", "bypassvalue"=>"");
					 $def_col['ru']=array("db" => "ru" ,"sc" => "ru","ctype"=>"int", "bypassvalue"=>"");
					$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
					$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
					$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
					$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
					$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
					
					 $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']:10; // get how many rows we want to have into the grid 
					$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
					$sord = isset($_POST['sord'])?$_POST['sord']:'asc'; // get the direction 
					
					  $kurs = isset($_POST['kurs'])?$_POST['kurs']:''; // get the direction 
					  $id_header = isset($_POST['id_header'])?$_POST['id_header']:''; // get the direction 
					   $supp_code_len = isset($_POST['len_supp_code'])?$_POST['len_supp_code']:'3'; // get the direction 
					
					if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
					  
					 if (array_key_exists($sidx, $def_col)) {  
							$fsidx=$def_col[$sidx];
							$sidx=$fsidx['db'];
					}else{
							$sidx='rID'; //DEFAULT SORT KALU GA ADA
					}
					$sidx=$sidx.'='. $sord;
					  
					$xmldoc =  XMLbasic($spt); 
					 paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
					AddField($xmldoc ,'id_header', $id_header); 
					AddField($xmldoc ,'kurs',$kurs); 
					 
					if ($search == 'true'){ 
						if (!empty($filters)){ 
							$array = json_decode($filters); 
							foreach($array->rules as $arr=>$k){ 
									$fcr=$def_col[$k->field]; 
									 if ($fcr != null) 
									{ 
										if ($fcr['ctype']=='int'){ 
											$searchString = $k->data; 
											if ($searchString!=$fcr['bypassvalue'])  
												addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
											   
										} 
										elseif ($fcr['ctype']=='text'){ 
											$searchString = $k->data; 
											if ($searchString!=$fcr['bypassvalue']) 
											 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
										}  
										elseif ($fcr['ctype']=='date'){ 
											$searchString = $k->data; 
											if (trim($searchString) != '' ){ 
												$dateArray=explode('/',$searchString);  
												$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
											} 
											 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
										}  
									} 
							 } 
						 } 
				   }  
			  
			  
					$str = $xmldoc->saveXML() ;
					//print_r($str);die();
					exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_ALL_MATERIAL',$sts,$des,$rows,$detail);  
					  echo $rows; 
					}
		
	

				function loaddata_produksi_rdd_output(){; 
					$def_col= array(); 
					$spt='dbo.SPX_PRODUKSI_RDD_OUTPUT'; 
					$def_col['id']=array("db" => "id" ,"sc" => "id","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r27']=array("db" => "r27" ,"sc" => "r27","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r28']=array("db" => "r28" ,"sc" => "r28","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r29']=array("db" => "r29" ,"sc" => "r29","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r30']=array("db" => "r30" ,"sc" => "r30","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r31']=array("db" => "r31" ,"sc" => "r31","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r32']=array("db" => "r32" ,"sc" => "r32","ctype"=>"text", "bypassvalue"=>"");
					 $def_col['ru']=array("db" => "ru" ,"sc" => "ru","ctype"=>"int", "bypassvalue"=>"");
					$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
					$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
					$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
					$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
					$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
					
					 $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']:10; // get how many rows we want to have into the grid 
					$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
					$sord = isset($_POST['sord'])?$_POST['sord']:'asc'; // get the direction 
					
					  $kurs = isset($_POST['kurs'])?$_POST['kurs']:''; // get the direction 
					  $id_header = isset($_POST['id_header'])?$_POST['id_header']:''; // get the direction 
					   $supp_code_len = isset($_POST['len_supp_code'])?$_POST['len_supp_code']:'3'; // get the direction 
					
					if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
					  
					 if (array_key_exists($sidx, $def_col)) {  
							$fsidx=$def_col[$sidx];
							$sidx=$fsidx['db'];
					}else{
							$sidx='rID'; //DEFAULT SORT KALU GA ADA
					}
					$sidx=$sidx.'='. $sord;
					  
					$xmldoc =  XMLbasic($spt); 
					 paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
					AddField($xmldoc ,'id_header', $id_header); 
					AddField($xmldoc ,'kurs',$kurs); 
					 
					if ($search == 'true'){ 
						if (!empty($filters)){ 
							$array = json_decode($filters); 
							foreach($array->rules as $arr=>$k){ 
									$fcr=$def_col[$k->field]; 
									 if ($fcr != null) 
									{ 
										if ($fcr['ctype']=='int'){ 
											$searchString = $k->data; 
											if ($searchString!=$fcr['bypassvalue'])  
												addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
											   
										} 
										elseif ($fcr['ctype']=='text'){ 
											$searchString = $k->data; 
											if ($searchString!=$fcr['bypassvalue']) 
											 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
										}  
										elseif ($fcr['ctype']=='date'){ 
											$searchString = $k->data; 
											if (trim($searchString) != '' ){ 
												$dateArray=explode('/',$searchString);  
												$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
											} 
											 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
										}  
									} 
							 } 
						 } 
				   }  
			  
			  
					$str = $xmldoc->saveXML() ;
					//print_r($str);die();
					exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_RDD_OUTPUT',$sts,$des,$rows,$detail);  
					  echo $rows; 
					}
		
					function loaddata_produksi_all_output(){; 
						$def_col= array(); 
						$spt='dbo.SPX_PRODUKSI_ALL_OUTPUT'; 
						$def_col['id']=array("db" => "id" ,"sc" => "id","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"date", "bypassvalue"=>"");
						$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"date", "bypassvalue"=>"");
						$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"date", "bypassvalue"=>"");
						$def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r27']=array("db" => "r27" ,"sc" => "r27","ctype"=>"date", "bypassvalue"=>"");
						$def_col['r28']=array("db" => "r28" ,"sc" => "r28","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r29']=array("db" => "r29" ,"sc" => "r29","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r30']=array("db" => "r30" ,"sc" => "r30","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r31']=array("db" => "r31" ,"sc" => "r31","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r32']=array("db" => "r32" ,"sc" => "r32","ctype"=>"text", "bypassvalue"=>"");
						 $def_col['ru']=array("db" => "ru" ,"sc" => "ru","ctype"=>"int", "bypassvalue"=>"");
						$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
						$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
						$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
						$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
						$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
						
						 $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']:10; // get how many rows we want to have into the grid 
						$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
						$sord = isset($_POST['sord'])?$_POST['sord']:'asc'; // get the direction 
						
						  $kurs = isset($_POST['kurs'])?$_POST['kurs']:''; // get the direction 
						  $id_header = isset($_POST['id_header'])?$_POST['id_header']:''; // get the direction 
						   $supp_code_len = isset($_POST['len_supp_code'])?$_POST['len_supp_code']:'3'; // get the direction 
						
						if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
						  
						 if (array_key_exists($sidx, $def_col)) {  
								$fsidx=$def_col[$sidx];
								$sidx=$fsidx['db'];
						}else{
								$sidx='rID'; //DEFAULT SORT KALU GA ADA
						}
						$sidx=$sidx.'='. $sord;
						  
						$xmldoc =  XMLbasic($spt); 
						 paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
						AddField($xmldoc ,'id_header', $id_header); 
						AddField($xmldoc ,'kurs',$kurs); 
						 
						if ($search == 'true'){ 
							if (!empty($filters)){ 
								$array = json_decode($filters); 
								foreach($array->rules as $arr=>$k){ 
										$fcr=$def_col[$k->field]; 
										 if ($fcr != null) 
										{ 
											if ($fcr['ctype']=='int'){ 
												$searchString = $k->data; 
												if ($searchString!=$fcr['bypassvalue'])  
													addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
												   
											} 
											elseif ($fcr['ctype']=='text'){ 
												$searchString = $k->data; 
												if ($searchString!=$fcr['bypassvalue']) 
												 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
											}  
											elseif ($fcr['ctype']=='date'){ 
												$searchString = $k->data; 
												if (trim($searchString) != '' ){ 
													$dateArray=explode('/',$searchString);  
													$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
												} 
												 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
											}  
										} 
								 } 
							 } 
					   }  
				  
				  
						$str = $xmldoc->saveXML() ;
						//print_r($str);die();
						exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_ALL_OUTPUT',$sts,$des,$rows,$detail);  
						  echo $rows; 
						}	

					function loaddata_produksi_rdd_mesin(){; 
						$def_col= array(); 
						$spt='dbo.SPX_PRODUKSI_RDD_MACHINE'; 
						$def_col['id']=array("db" => "id" ,"sc" => "id","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"date", "bypassvalue"=>"");
						$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"date", "bypassvalue"=>"");
						
						 $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']:10; // get how many rows we want to have into the grid 
						$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
						$sord = isset($_POST['sord'])?$_POST['sord']:'asc'; // get the direction 
						
						  $kurs = isset($_POST['kurs'])?$_POST['kurs']:''; // get the direction 
						  $posisi = isset($_POST['posisi'])?$_POST['posisi']:''; // get the direction 
						
						if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
						  
						 if (array_key_exists($sidx, $def_col)) {  
								$fsidx=$def_col[$sidx];
								$sidx=$fsidx['db'];
						}else{
								$sidx='rID'; //DEFAULT SORT KALU GA ADA
						}
						$sidx=$sidx.'='. $sord;
						  
						$xmldoc =  XMLbasic($spt); 
						 paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
						AddField($xmldoc ,'posisi', $posisi); 
						 
						if ($search == 'true'){ 
							if (!empty($filters)){ 
								$array = json_decode($filters); 
								foreach($array->rules as $arr=>$k){ 
										$fcr=$def_col[$k->field]; 
										 if ($fcr != null) 
										{ 
											if ($fcr['ctype']=='int'){ 
												$searchString = $k->data; 
												if ($searchString!=$fcr['bypassvalue'])  
													addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
												   
											} 
											elseif ($fcr['ctype']=='text'){ 
												$searchString = $k->data; 
												if ($searchString!=$fcr['bypassvalue']) 
												 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
											}  
											elseif ($fcr['ctype']=='date'){ 
												$searchString = $k->data; 
												if (trim($searchString) != '' ){ 
													$dateArray=explode('/',$searchString);  
													$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
												} 
												 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
											}  
										} 
								 } 
							 } 
					   }  
				  
				  
						$str = $xmldoc->saveXML() ;
					//	print_r($str);die();
						exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_RDD_MACHINE',$sts,$des,$rows,$detail);  
						  echo $rows; 
						}
	
						

						function loaddata_produksi_out_lot(){; 
							$def_col= array(); 
							$spt='dbo.SPX_PRODUKSI_OUT_LOT'; 
							$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
							$def_col['r1']=array("db" => "r1" ,"sc" => "ri","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"int", "bypassvalue"=>"");
							$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"int", "bypassvalue"=>"");
							$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"int", "bypassvalue"=>"");
							$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"int", "bypassvalue"=>"");
							$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"int", "bypassvalue"=>"");
							$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"int", "bypassvalue"=>"");
							$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"int", "bypassvalue"=>"");
							$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"date", "bypassvalue"=>"");
							$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"text", "bypassvalue"=>"");
							$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"date", "bypassvalue"=>"");
							$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"text", "bypassvalue"=>"");
							 $def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
							$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
							$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
							$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
							$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
							$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
							$def_col['i5']=array("db" => "i5" ,"sc" => "i5","ctype"=>"text", "bypassvalue"=>"");
							
							 $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']:10; // get how many rows we want to have into the grid 
							$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
							$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
							$id_header = isset($_POST['id_header'])?$_POST['id_header']:die('Pilih Dokumen');; // get the requested page 
							$noproduksi = isset($_POST['noproduksi'])?$_POST['noproduksi']:die('Pilih Dokumen');; // get the requested page 
					 	 
							if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
							  
							 if (array_key_exists($sidx, $def_col)) {   
									$fsidx=$def_col[$sidx];
									$sidx=$fsidx['db'];
							}else{
									$sidx='rID'; //DEFAULT SORT KALU GA ADA
							}
							$sidx=$sidx.'='. $sord;
							  
							$xmldoc =  XMLbasic($spt); 
							paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
							AddField($xmldoc ,'id_header',$id_header);
							AddField($xmldoc ,'noproduksi',$noproduksi);
						 
								 
							if ($search == 'true'){ 
								if (!empty($filters)){ 
									$array = json_decode($filters); 
									foreach($array->rules as $arr=>$k){ 
											$fcr=$def_col[$k->field]; 
											 if ($fcr != null) 
											{ 
												if ($fcr['ctype']=='int'){ 
													$searchString = $k->data; 
													if ($searchString!=$fcr['bypassvalue'])  
														addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
													   
												} 
												elseif ($fcr['ctype']=='text'){ 
													$searchString = $k->data; 
													if ($searchString!=$fcr['bypassvalue']) 
													 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
												}  
												elseif ($fcr['ctype']=='date'){ 
													$searchString = $k->data; 
													if (trim($searchString) != '' ){ 
														$dateArray=explode('/',$searchString);  
														$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
													} 
													 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
												}  
											} 
									 } 
								 } 
						   }  
					  
					  
							$str = $xmldoc->saveXML();   
							 exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_OUT_LOT',$sts,$des,$rows,$detail);  
							  echo $rows; 
							}						

							function loaddata_produksi_out_lot_meter(){; 
								$def_col= array(); 
								$spt='dbo.SPX_PRODUKSI_OUT_LOT_METER'; 
								$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
								$def_col['r1']=array("db" => "r1" ,"sc" => "ri","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"int", "bypassvalue"=>"");
								$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"int", "bypassvalue"=>"");
								$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"int", "bypassvalue"=>"");
								$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"int", "bypassvalue"=>"");
								$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"int", "bypassvalue"=>"");
								$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"int", "bypassvalue"=>"");
								$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"int", "bypassvalue"=>"");
								$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"date", "bypassvalue"=>"");
								$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"date", "bypassvalue"=>"");
								$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"text", "bypassvalue"=>"");
								 $def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
								$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
								$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
								$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
								$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
								$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
								$def_col['i5']=array("db" => "i5" ,"sc" => "i5","ctype"=>"text", "bypassvalue"=>"");
								
								 $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']:10; // get how many rows we want to have into the grid 
								$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
								$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
								$id_header = isset($_POST['id_header'])?$_POST['id_header']:die('Pilih Dokumen');; // get the requested page 
								$noproduksi = isset($_POST['noproduksi'])?$_POST['noproduksi']:die('Pilih Dokumen');; // get the requested page 
							  
								if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
								  
								 if (array_key_exists($sidx, $def_col)) {   
										$fsidx=$def_col[$sidx];
										$sidx=$fsidx['db'];
								}else{
										$sidx='rID'; //DEFAULT SORT KALU GA ADA
								}
								$sidx=$sidx.'='. $sord;
								  
								$xmldoc =  XMLbasic($spt); 
								paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
								AddField($xmldoc ,'id_header',$id_header);
								AddField($xmldoc ,'noproduksi',$noproduksi);
							 
									 
								if ($search == 'true'){ 
									if (!empty($filters)){ 
										$array = json_decode($filters); 
										foreach($array->rules as $arr=>$k){ 
												$fcr=$def_col[$k->field]; 
												 if ($fcr != null) 
												{ 
													if ($fcr['ctype']=='int'){ 
														$searchString = $k->data; 
														if ($searchString!=$fcr['bypassvalue'])  
															addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
														   
													} 
													elseif ($fcr['ctype']=='text'){ 
														$searchString = $k->data; 
														if ($searchString!=$fcr['bypassvalue']) 
														 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
													}  
													elseif ($fcr['ctype']=='date'){ 
														$searchString = $k->data; 
														if (trim($searchString) != '' ){ 
															$dateArray=explode('/',$searchString);  
															$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
														} 
														 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
													}  
												} 
										 } 
									 } 
							   }  
						  
						  
								$str = $xmldoc->saveXML();   
								 exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_OUT_LOT_METER',$sts,$des,$rows,$detail);  
								  echo $rows; 
								}					


							function loaddata_produksi_in_lot(){; 
								$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
								$spt='dbo.SPX_PRODUKSI_IN_LOT'; 
								$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
								$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
								$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
								$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
								$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
							
									 
								 $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']:10; // get how many rows we want to have into the grid 
								$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
								$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
								$id_detail = isset($_POST['id_detail'])?$_POST['id_detail']:die('Pilih Dokumen');; // get the requested page 
								$kodebarang = isset($_POST['kodebarang'])?$_POST['kodebarang']:die('Pilih Dokumen');; // get the requested page 
								$namabarang = isset($_POST['namabarang'])?$_POST['namabarang']:die('Pilih Dokumen');; // get the requested page 
								$itemno = isset($_POST['itemno'])?$_POST['itemno']:die('Pilih Dokumen');; // get the requested page 
									
								if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
								  
								if (array_key_exists($sidx, $def_col)) {  
										$fsidx=$def_col[$sidx];
										$sidx=$fsidx['db'];
								}else{
										$sidx='rID'; //DEFAULT SORT KALU GA ADA
								}
								$sidx=$sidx.'='. $sord;
								  
								$xmldoc =  XMLbasic($spt); 
								paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
								  $adaSearchStatus=0;
								  AddField($xmldoc ,'id_detail',$id_detail);
								  AddField($xmldoc ,'kodebarang',$kodebarang);
								  AddField($xmldoc ,'namabarang',$namabarang);
								  AddField($xmldoc ,'itemno',$itemno);
									  
								if ($search == 'true'){ 
									if (!empty($filters)){ 
										$array = json_decode($filters); 
										foreach($array->rules as $arr=>$k){ 
												$fcr=$def_col[$k->field]; 
												 if ($fcr != null) 
												{ 
													if ($fcr['ctype']=='int'){ 
														$searchString = $k->data; 
														if ($searchString!=$fcr['bypassvalue']) { 
															addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
															  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
																$adaSearchStatus=1;
															  }
														} 
													 
													} 
													elseif ($fcr['ctype']=='text'){ 
														$searchString = $k->data; 
														if ($searchString!=$fcr['bypassvalue']) 
														 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
													}  
													elseif ($fcr['ctype']=='date'){ 
														$searchString = $k->data; 
														if (trim($searchString) != '' ){ 
															$dateArray=explode('/',$searchString);  
															$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
														} 
														 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
													}  
												} 
										 } 
									 } 
							   }  
						  
								if ($adaSearchStatus==0){
									addSearchNum($xmldoc,'r1','-1','3','-1'); 
								}
								$str = $xmldoc->saveXML(); 
							//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
							//	 print_r($str);die(); //SP_T_HEADER_BC_23
								  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_IN_LOT',$sts,$des,$rows,$detail);  
								 echo $rows; 
								}		
		
								
								function loaddata_material_all(){; 
									$def_col= array(); 
									$spt='dbo.SPX_MATERIAL_ALL'; 
									$def_col['id']=array("db" => "id" ,"sc" => "id","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"date", "bypassvalue"=>"");
									$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"date", "bypassvalue"=>"");
									$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"date", "bypassvalue"=>"");
									$def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r27']=array("db" => "r27" ,"sc" => "r27","ctype"=>"date", "bypassvalue"=>"");
									$def_col['r28']=array("db" => "r28" ,"sc" => "r28","ctype"=>"text", "bypassvalue"=>"");
									$def_col['r29']=array("db" => "r29" ,"sc" => "r29","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r30']=array("db" => "r30" ,"sc" => "r30","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r31']=array("db" => "r31" ,"sc" => "r31","ctype"=>"int", "bypassvalue"=>"");
									$def_col['r32']=array("db" => "r32" ,"sc" => "r32","ctype"=>"text", "bypassvalue"=>"");
									 $def_col['ru']=array("db" => "ru" ,"sc" => "ru","ctype"=>"int", "bypassvalue"=>"");
									$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
									$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
									$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
									$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
									$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
									
									 $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']:10; // get how many rows we want to have into the grid 
									$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
									$sord = isset($_POST['sord'])?$_POST['sord']:'asc'; // get the direction 
									
									$id_header = isset($_POST['id_header'])?$_POST['id_header']:''; // get the direction 
									if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
									  
									 if (array_key_exists($sidx, $def_col)) {  
											$fsidx=$def_col[$sidx];
											$sidx=$fsidx['db'];
									}else{
											$sidx='rID'; //DEFAULT SORT KALU GA ADA
									}
									$sidx=$sidx.'='. $sord;
									  
									$xmldoc =  XMLbasic($spt); 
									 paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
									AddField($xmldoc ,'id_header', $id_header); 
									 
									if ($search == 'true'){ 
										if (!empty($filters)){ 
											$array = json_decode($filters); 
											foreach($array->rules as $arr=>$k){ 
													$fcr=$def_col[$k->field]; 
													 if ($fcr != null) 
													{ 
														if ($fcr['ctype']=='int'){ 
															$searchString = $k->data; 
															if ($searchString!=$fcr['bypassvalue']) { 
																addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
																  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
																	$adaSearchStatus=1;
																  }
															}
														 
														} 
														elseif ($fcr['ctype']=='text'){ 
															$searchString = $k->data; 
															if ($searchString!=$fcr['bypassvalue']) 
															 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
														}  
														elseif ($fcr['ctype']=='date'){ 
															$searchString = $k->data; 
															if (trim($searchString) != '' ){ 
																$dateArray=explode('/',$searchString);  
																$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
															} 
															 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
														}  
													} 
											 } 
										 } 
								   }  
							  
									$str = $xmldoc->saveXML() ;
									//print_r($str);die();
									exec_sp_json($xmldoc, 'dbo.SPX_MATERIAL_ALL',$sts,$des,$rows,$detail);  
									  echo $rows; 
									}
			
									
									function loaddata_produksi_item_lot_diganti(){; 
										$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
										$spt='dbo.SPX_PRODUKSI_LOT_DIGANTI'; 
										$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
										$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
										$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
										$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
										$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
										$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
										$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
										$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
										$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
										$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
										$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
										$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
										$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
										$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
										$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
									
											 
										 $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']:10; // get how many rows we want to have into the grid 
										$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
										$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
										$id_header = isset($_POST['id_header'])?$_POST['id_header']:die('Pilih Dokumen');; // get the requested page 
 											
										if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
										  
										if (array_key_exists($sidx, $def_col)) {  
												$fsidx=$def_col[$sidx];
												$sidx=$fsidx['db'];
										}else{
												$sidx='rID'; //DEFAULT SORT KALU GA ADA
										}
										$sidx=$sidx.'='. $sord;
										  
										$xmldoc =  XMLbasic($spt); 
										paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
										  $adaSearchStatus=0;
										  AddField($xmldoc ,'id_header',$id_header);
 											  
										if ($search == 'true'){ 
											if (!empty($filters)){ 
												$array = json_decode($filters); 
												foreach($array->rules as $arr=>$k){ 
														$fcr=$def_col[$k->field]; 
														 if ($fcr != null) 
														{ 
															if ($fcr['ctype']=='int'){ 
																$searchString = $k->data; 
																if ($searchString!=$fcr['bypassvalue']) { 
																	addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
																	  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
																		$adaSearchStatus=1;
																	  }
																} 
															 
															} 
															elseif ($fcr['ctype']=='text'){ 
																$searchString = $k->data; 
																if ($searchString!=$fcr['bypassvalue']) 
																 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
															}  
															elseif ($fcr['ctype']=='date'){ 
																$searchString = $k->data; 
																if (trim($searchString) != '' ){ 
																	$dateArray=explode('/',$searchString);  
																	$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
																} 
																 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
															}  
														} 
												 } 
											 } 
									   }  
								  
										if ($adaSearchStatus==0){
											addSearchNum($xmldoc,'r1','-1','3','-1'); 
										}
										$str = $xmldoc->saveXML(); 
									//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
									//	 print_r($str);die(); //SP_T_HEADER_BC_23
										  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_LOT_DIGANTI',$sts,$des,$rows,$detail);  
										 echo $rows; 
										}		
													

										
										function loaddata_produksi_item_lot_pengganti_rdd(){;  
											$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
											$spt='dbo.SPX_PRODUKSI_LOT_PENGGANTI_RDD'; 
											$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
											$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
											$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
											$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
											$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
											$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
											$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
											$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
											$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
											$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
											$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
											$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
											$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
											$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
											$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
										
												 
											 $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']:10; // get how many rows we want to have into the grid 
											$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
											$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
											$itemno = isset($_POST['itemno'])?$_POST['itemno']:die('Pilih Dokumen');; // get the requested page 
											$nomorlot = isset($_POST['nomorlot'])?$_POST['nomorlot']:die('Pilih Dokumen');; // get the requested page 
												 
											if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
											  
											if (array_key_exists($sidx, $def_col)) {  
													$fsidx=$def_col[$sidx];
													$sidx=$fsidx['db'];
											}else{
													$sidx='rID'; //DEFAULT SORT KALU GA ADA
											}
											$sidx=$sidx.'='. $sord;
											  
											$xmldoc =  XMLbasic($spt); 
											paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
											  $adaSearchStatus=0;
											  AddField($xmldoc ,'itemno',$itemno);
											  AddField($xmldoc ,'nomorlot',$nomorlot);
												   
											if ($search == 'true'){ 
												if (!empty($filters)){ 
													$array = json_decode($filters); 
													foreach($array->rules as $arr=>$k){ 
															$fcr=$def_col[$k->field]; 
															 if ($fcr != null) 
															{ 
																if ($fcr['ctype']=='int'){ 
																	$searchString = $k->data; 
																	if ($searchString!=$fcr['bypassvalue']) { 
																		addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
																		  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
																			$adaSearchStatus=1;
																		  }
																	} 
																 
																} 
																elseif ($fcr['ctype']=='text'){ 
																	$searchString = $k->data; 
																	if ($searchString!=$fcr['bypassvalue']) 
																	 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
																}  
																elseif ($fcr['ctype']=='date'){ 
																	$searchString = $k->data; 
																	if (trim($searchString) != '' ){ 
																		$dateArray=explode('/',$searchString);  
																		$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
																	} 
																	 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
																}  
															} 
													 } 
												 } 
										   }  
									  
											if ($adaSearchStatus==0){
												addSearchNum($xmldoc,'r1','-1','3','-1'); 
											}
											$str = $xmldoc->saveXML(); 
										//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
										//	 print_r($str);die(); //SP_T_HEADER_BC_23
											  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_LOT_PENGGANTI_RDD',$sts,$des,$rows,$detail);  
											 echo $rows; 
											}		
	


function loaddata_produksi_item_lot_pengganti_non_rdd(){; 
												$def_col= array();  //SP_T_HEADER_BC_23 //SP_T_HEADER_BELI
												$spt='dbo.SPX_PRODUKSI_LOT_PENGGANTI_NON_RDD'; 
												$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
												$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
												$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"-100");
												$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
												$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
												$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
												$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
												$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
												$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
												$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"text", "bypassvalue"=>"");
												$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
												$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
												$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
												$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
												$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
											
													 
												 $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']:10; // get how many rows we want to have into the grid 
												$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
												$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
												$itemno = isset($_POST['itemno'])?$_POST['itemno']:die('Pilih Dokumen');; // get the requested page 
												$nomorlot = isset($_POST['nomorlot'])?$_POST['nomorlot']:die('Pilih Dokumen');; // get the requested page 
													 
												if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
												  
												if (array_key_exists($sidx, $def_col)) {  
														$fsidx=$def_col[$sidx];
														$sidx=$fsidx['db'];
												}else{
														$sidx='rID'; //DEFAULT SORT KALU GA ADA
												}
												$sidx=$sidx.'='. $sord;
												  
												$xmldoc =  XMLbasic($spt); 
												paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
												  $adaSearchStatus=0;
												  AddField($xmldoc ,'itemno',$itemno);
												  AddField($xmldoc ,'nomorlot',$nomorlot);
													   
												if ($search == 'true'){ 
													if (!empty($filters)){ 
														$array = json_decode($filters); 
														foreach($array->rules as $arr=>$k){ 
																$fcr=$def_col[$k->field]; 
																 if ($fcr != null) 
																{ 
																	if ($fcr['ctype']=='int'){ 
																		$searchString = $k->data; 
																		if ($searchString!=$fcr['bypassvalue']) { 
																			addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
																			  if (($fcr['sc'])=='r2' || ($fcr['sc'])=='r1'){
																				$adaSearchStatus=1;
																			  }
																		} 
																	 
																	} 
																	elseif ($fcr['ctype']=='text'){ 
																		$searchString = $k->data; 
																		if ($searchString!=$fcr['bypassvalue']) 
																		 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
																	}  
																	elseif ($fcr['ctype']=='date'){ 
																		$searchString = $k->data; 
																		if (trim($searchString) != '' ){ 
																			$dateArray=explode('/',$searchString);  
																			$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
																		} 
																		 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
																	}  
																} 
														 } 
													 } 
											   }  
										  
												if ($adaSearchStatus==0){
													addSearchNum($xmldoc,'r1','-1','3','-1'); 
												}
												$str = $xmldoc->saveXML(); 
											//	 print_r($adaSearchStatus);		SP_T_HEADER_BELI
											//	 print_r($str);die(); //SP_T_HEADER_BC_23
												  exec_sp_json($xmldoc, 'dbo.SPX_PRODUKSI_LOT_PENGGANTI_NON_RDD',$sts,$des,$rows,$detail);  
												 echo $rows; 
												}		
														

		//----------------------------------- selesai-------------------------------

























			












	    function loaddata_material_rdd2(){; 
			$def_col= array(); 
			$spt='dbo.SPX_LIST_MATERIAL'; 
			$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
			$def_col['ri']=array("db" => "ri" ,"sc" => "ri","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"date", "bypassvalue"=>"");
			$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"date", "bypassvalue"=>"");
			$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"text", "bypassvalue"=>"");
			 $def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
			$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
			$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
			$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
			$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
			$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
			$def_col['i5']=array("db" => "i5" ,"sc" => "i5","ctype"=>"text", "bypassvalue"=>"");
			
			 $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']:10; // get how many rows we want to have into the grid 
			$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
			$sord = isset($_POST['sord'])?$_POST['sord']:'0'; // get the direction 
		 
			if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
			  
			 if (array_key_exists($sidx, $def_col)) {  
					$fsidx=$def_col[$sidx];
					$sidx=$fsidx['db'];
			}else{
					$sidx='rID'; //DEFAULT SORT KALU GA ADA
			}
			$sidx=$sidx.'='. $sord;
			  
			$xmldoc =  XMLbasic($spt); 
			paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
	 
				 
			if ($search == 'true'){ 
				if (!empty($filters)){ 
					$array = json_decode($filters); 
					foreach($array->rules as $arr=>$k){ 
							$fcr=$def_col[$k->field]; 
							 if ($fcr != null) 
							{ 
								if ($fcr['ctype']=='int'){ 
									$searchString = $k->data; 
									if ($searchString!=$fcr['bypassvalue'])  
										addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
									   
								} 
								elseif ($fcr['ctype']=='text'){ 
									$searchString = $k->data; 
									if ($searchString!=$fcr['bypassvalue']) 
									 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
								}  
								elseif ($fcr['ctype']=='date'){ 
									$searchString = $k->data; 
									if (trim($searchString) != '' ){ 
										$dateArray=explode('/',$searchString);  
										$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
									} 
									 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
								}  
							} 
					 } 
				 } 
		   }  
	  
	  
			$str = $xmldoc->saveXML();   
			 exec_sp_json($xmldoc, 'dbo.SPX_LIST_MATERIAL',$sts,$des,$rows,$detail);  
			  echo $rows; 
			}
			

			function loaddata_bom_mdd(){; 
				$def_col= array(); 
				$spt='dbo.SPX_MATERIAL_RDD'; 
				$def_col['id']=array("db" => "id" ,"sc" => "id","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r2']=array("db" => "r2" ,"sc" => "r2","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r11']=array("db" => "r11" ,"sc" => "r11","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r12']=array("db" => "r12" ,"sc" => "r12","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r13']=array("db" => "r13" ,"sc" => "r13","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r14']=array("db" => "r14" ,"sc" => "r14","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r23']=array("db" => "r23" ,"sc" => "r23","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r24']=array("db" => "r24" ,"sc" => "r24","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r25']=array("db" => "r25" ,"sc" => "r25","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r26']=array("db" => "r26" ,"sc" => "r26","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r27']=array("db" => "r27" ,"sc" => "r27","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r28']=array("db" => "r28" ,"sc" => "r28","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r29']=array("db" => "r29" ,"sc" => "r29","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r30']=array("db" => "r30" ,"sc" => "r30","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r31']=array("db" => "r31" ,"sc" => "r31","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r32']=array("db" => "r32" ,"sc" => "r32","ctype"=>"text", "bypassvalue"=>"");
				 $def_col['ru']=array("db" => "ru" ,"sc" => "ru","ctype"=>"int", "bypassvalue"=>"");
				$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
				$def_col['i1']=array("db" => "i1" ,"sc" => "i1","ctype"=>"text", "bypassvalue"=>"");
				$def_col['i2']=array("db" => "i2" ,"sc" => "i2","ctype"=>"text", "bypassvalue"=>"");
				$def_col['i3']=array("db" => "i3" ,"sc" => "i3","ctype"=>"text", "bypassvalue"=>"");
				$def_col['i4']=array("db" => "i4" ,"sc" => "i4","ctype"=>"text", "bypassvalue"=>"");
				
				 $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']:10; // get how many rows we want to have into the grid 
				$sidx = isset($_POST['sidx'])?$_POST['sidx']:'rID'; // get index row - i.e. user click to sort 
				$sord = isset($_POST['sord'])?$_POST['sord']:'asc'; // get the direction 
				
				  $kurs = isset($_POST['kurs'])?$_POST['kurs']:''; // get the direction 
				  $supp_code = isset($_POST['supp_code'])?$_POST['supp_code']:''; // get the direction 
				   $supp_code_len = isset($_POST['len_supp_code'])?$_POST['len_supp_code']:'3'; // get the direction 
				
				if ($sord == 'asc') { $sord = '0'; } else if ($sord == 'desc') { $sord = '1'; } 
				  
				 if (array_key_exists($sidx, $def_col)) {  
						$fsidx=$def_col[$sidx];
						$sidx=$fsidx['db'];
				}else{
						$sidx='rID'; //DEFAULT SORT KALU GA ADA
				}
				$sidx=$sidx.'='. $sord;
				  
				$xmldoc =  XMLbasic($spt); 
				 paramViewJSON($xmldoc, $limit, $page,  $sidx, $sord); 
				AddField($xmldoc ,'supp_code', substr($supp_code,0,$supp_code_len)); 
				AddField($xmldoc ,'kurs',$kurs); 
				 
				if ($search == 'true'){ 
					if (!empty($filters)){ 
						$array = json_decode($filters); 
						foreach($array->rules as $arr=>$k){ 
								$fcr=$def_col[$k->field]; 
								 if ($fcr != null) 
								{ 
									if ($fcr['ctype']=='int'){ 
										$searchString = $k->data; 
										if ($searchString!=$fcr['bypassvalue'])  
											addSearchNum($xmldoc,$fcr['sc'],$searchString,'2','1');  
										   
									} 
									elseif ($fcr['ctype']=='text'){ 
										$searchString = $k->data; 
										if ($searchString!=$fcr['bypassvalue']) 
										 addSearchText($xmldoc,$fcr['sc'],'1','1',$searchString); 
									}  
									elseif ($fcr['ctype']=='date'){ 
										$searchString = $k->data; 
										if (trim($searchString) != '' ){ 
											$dateArray=explode('/',$searchString);  
											$searchString = $dateArray[2].$dateArray[1].$dateArray[0]; 
										} 
										 addSearchDate($xmldoc,$fcr['sc'],$searchString,'1','1'); 
									}  
								} 
						 } 
					 } 
			   }  
		  
		  
				$str = $xmldoc->saveXML() ;
				//print_r($str);die();
				exec_sp_json($xmldoc, 'dbo.SPX_MATERIAL_RDD',$sts,$des,$rows,$detail);  
				  echo $rows; 
				}
	
				
	
	
	
	
	
	
	
	
	
	
	
	

	

	
		
		


	

function __purpose($bc_prefix){; 
	$spt='dbo.MG_MS_CMB_PURPOSE'; 
	$xmldoc =  XMLbasic($spt); 
		AddField($xmldoc ,'bc_prefix',$bc_prefix); 
		
	$str = $xmldoc->saveXML(); 
	// print_r($adaSearchStatus);		
	// print_r($str);die();
		wh_exec_sp_json($xmldoc, $spt,$sts,$des,$rows,$detail);  
		return $rows; 
	}
	

function __type_item($bc_prefix){; 
	$spt='dbo.MG_MS_CMB_PURPOSE'; 
	$xmldoc =  XMLbasic($spt); 
		AddField($xmldoc ,'bc_prefix',$bc_prefix); 
		
	$str = $xmldoc->saveXML(); 
	// print_r($adaSearchStatus);		
	// print_r($str);die();
		wh_exec_sp_json($xmldoc, $spt,$sts,$des,$rows,$detail);  
		return $rows; 
	}
	
function __type_price($bc_prefix){; 
	$spt='dbo.MG_MS_CMB_TYPE_PRICE'; 
	$xmldoc =  XMLbasic($spt); 
		AddField($xmldoc ,'bc_prefix',$bc_prefix); 
		
	$str = $xmldoc->saveXML(); 
	// print_r($adaSearchStatus);		
	// print_r($str);die();
		wh_exec_sp_json($xmldoc, $spt,$sts,$des,$rows,$detail);  
		return $rows; 
	}
		
				

	function save_header(){  
		

		$ID_HEADER 					= isset($_POST['ID_HEADER'])?$_POST['ID_HEADER']:'-1'; // get the requested page 
		$NOMOR_PO 					= isset($_POST['NOMOR_PO'])?$_POST['NOMOR_PO']:''; // get the requested page 
		$NOMOR_DO 					= isset($_POST['NOMOR_DO'])?$_POST['NOMOR_DO']:''; // get the requested page 
		$TANGGAL_DO		 			= isset($_POST['TANGGAL_DO'])?$_POST['TANGGAL_DO']:''; // get the requested page 
		$NOMOR_INVOICE 					= isset($_POST['NOMOR_INVOICE'])?$_POST['NOMOR_INVOICE']:''; // get the requested page 
		$NOMOR_EFAKTUR 					= isset($_POST['NOMOR_EFAKTUR'])?$_POST['NOMOR_EFAKTUR']:''; // get the requested page 
		$SUPPLIER_CODE				= isset($_POST['SUPPLIER_CODE'])?$_POST['SUPPLIER_CODE']:''; // get the requested page 
		$SUPPLIER_NAME				= isset($_POST['SUPPLIER_NAME'])?$_POST['SUPPLIER_NAME']:''; // get the requested page 
  		



			
				$SPT='SP_T_BELI_ADD'; //'SP_T_BC_FROM_PO_CREATEX';  //($ID_HEADER=='-1')?'SP_T_BC_FROM_PO_CREATEX':'SP_T_BC_FROM_PO_CREATEX';
				
				$xmldoc =  XMLbasic('json');  
				AddField($xmldoc ,'ID_HEADER',$ID_HEADER);// get the requested page 
				AddField($xmldoc ,'NOMOR_PO',$NOMOR_PO); // get the requested page 
				AddField($xmldoc ,'NOMOR_DO',$NOMOR_DO); // get the requested page 
				AddField($xmldoc ,'TANGGAL_DO',$TANGGAL_DO); // get the requested page 
				AddField($xmldoc ,'NOMOR_INVOICE',$NOMOR_INVOICE); // get the requested page 
				AddField($xmldoc ,'NOMOR_EFAKTUR',$NOMOR_EFAKTUR); // get the requested page 
				AddField($xmldoc ,'SUPPLIER_CODE',$SUPPLIER_CODE); // get the requested page 
				AddField($xmldoc ,'SUPPLIER_NAME',$SUPPLIER_NAME); // get the requested page 
  				AddField($xmldoc,'data_by',$this->session->userdata('DX_user_id'));


				
				$str = $xmldoc->saveXML();
					// print_r($str);die();
				exec_sp_array($xmldoc, $SPT ,$sts,$des,$rows,$detail); 
				echo json_encode(array('valid'=>($sts=='00'?true:false)
				,'stsno' => $sts
				, 'stsmsg' => $des
				, 'detail' => $detail)
				); 
		}
		
	 function finish_header(){  
	
	
			$ID_HEADER 				= isset($_POST['ID_HEADER'])?$_POST['ID_HEADER']:'-1'; // get the requested page 
			$receive_no 					= isset($_POST['receive_no'])?$_POST['receive_no']:''; // get the requested page 
			$receive_date 			= isset($_POST['receive_date'])?$_POST['receive_date']:''; // get the requested page 
	
			$ndpbm_usd 			= isset($_POST['ndpbm_usd'])?$_POST['ndpbm_usd']:'0'; // get the requested page 
			$ndpbm_hdr 			= isset($_POST['ndpbm_hdr'])?$_POST['ndpbm_hdr']:'0'; // get the requested page 
		
			$finish_date 			= isset($_POST['finish_date'])?$_POST['finish_date']:''; // get the requested page 
			$finish_time 			= isset($_POST['finish_time'])?$_POST['finish_time']:''; // get the requested page 
						
			$SPT='MG_MS_BC_IN_FINISH';
			
			$xmldoc =  XMLbasic('json');  
			AddField($xmldoc ,'ID_HEADER',$ID_HEADER );
			AddField($xmldoc ,'receive_no',$receive_no );
			AddField($xmldoc ,'receive_date',$receive_date );
			AddField($xmldoc ,'ndpbm_usd',$ndpbm_usd );
			AddField($xmldoc ,'ndpbm_hdr',$ndpbm_hdr );
			AddField($xmldoc ,'finish_date',$finish_date );
			AddField($xmldoc ,'finish_time',$finish_time );
				
			$str = $xmldoc->saveXML();
				// print_r($str);die();
				wh_exec_sp_array($xmldoc, $SPT ,$sts,$des,$rows,$detail); 
			echo json_encode(array('valid'=>($sts=='00'?true:false)
			,'stsno' => $sts
			, 'stsmsg' => $des
			, 'detail' => $detail)
			); 
	}
					
	 function cancel_header(){  
					
	
			$ID_HEADER 				= isset($_POST['ID_HEADER'])?$_POST['ID_HEADER']:'-1'; // get the requested page 
			$info 					= isset($_POST['info'])?$_POST['info']:''; // get the requested page 
						
			$SPT='MG_MS_BC_IN_CANCEL';
			
			$xmldoc =  XMLbasic('json');  
			AddField($xmldoc ,'ID_HEADER',$ID_HEADER );
			AddField($xmldoc ,'info',$info ); 
				
			$str = $xmldoc->saveXML();
				// print_r($str);die();
				wh_exec_sp_array($xmldoc, $SPT ,$sts,$des,$rows,$detail); 
			echo json_encode(array('valid'=>($sts=='00'?true:false)
			,'stsno' => $sts
			, 'stsmsg' => $des
			, 'detail' => $detail)
			); 
	}
	
	function save_detail(){  
					
		
		$ID_HEADER 				= isset($_POST['ID_HEADER'])?$_POST['ID_HEADER']:'-1'; // get the requested page 
		$ID_BARANG 				= isset($_POST['ID_BARANG'])?$_POST['ID_BARANG']:'-1'; // get the requested page 

		$HARGA_PENYERAHAN 		= isset($_POST['HARGA_PENYERAHAN'])?$_POST['HARGA_PENYERAHAN']:''; // get the requested page 
		$JUMLAH_KEMASAN 		= isset($_POST['JUMLAH_KEMASAN'])?$_POST['JUMLAH_KEMASAN']:''; // get the requested page 
		$JUMLAH_SATUAN 			= isset($_POST['JUMLAH_SATUAN'])?$_POST['JUMLAH_SATUAN']:''; // get the requested page 
		$KODE_KEMASAN 			= isset($_POST['KODE_KEMASAN'])?$_POST['KODE_KEMASAN']:'0'; // get the requested page 
		$NETTO 					= isset($_POST['NETTO'])?$_POST['NETTO']:'0'; // get the requested page 
		$POS_TARIF 				= isset($_POST['POS_TARIF'])?$_POST['POS_TARIF']:'0'; // get the requested page 
		$SERI_BARANG 			= isset($_POST['SERI_BARANG'])?$_POST['SERI_BARANG']:'0'; // get the requested page 
		$VOLUME 				= isset($_POST['VOLUME'])?$_POST['VOLUME']:''; // get the requested page 
		$ms_item_id 			= isset($_POST['ms_item_id'])?$_POST['ms_item_id']:'-1'; // get the requested page 
		$KODE_NEGARA_ASAL 		= isset($_POST['KODE_NEGARA_ASAL'])?$_POST['KODE_NEGARA_ASAL']:''; // get the requested page 
			
		$BM 			 		= isset($_POST['BM'])?$_POST['BM']:''; // get the requested page 
		$PPNBM 					= isset($_POST['PPNBM'])?$_POST['PPNBM']:''; // get the requested page 
		$PPH 					= isset($_POST['PPH'])?$_POST['PPH']:''; // get the requested page 
		$PPN 					= isset($_POST['PPN'])?$_POST['PPN']:''; // get the requested page 
		$series 				= isset($_POST['series'])?$_POST['series']:''; // get the requested page 
		$TAHUN_PEMBUATAN 		= isset($_POST['TAHUN_PEMBUATAN'])?$_POST['TAHUN_PEMBUATAN']:''; // get the requested page 
		$po_no 					= isset($_POST['po_no'])?$_POST['po_no']:''; // get the requested page 
		$po_date 				= isset($_POST['po_date'])?$_POST['po_date']:''; // get the requested page 
		
		$SPT=($ID_BARANG=='-1')?'MG_MS_BC_IN_ITEM_ADD':'MG_MS_BC_IN_ITEM_EDIT';
		
		$xmldoc =  XMLbasic('json');  
		AddField($xmldoc ,'ID_HEADER',$ID_HEADER );
		AddField($xmldoc ,'ID_BARANG',$ID_BARANG );
		AddField($xmldoc ,'HARGA_PENYERAHAN',$HARGA_PENYERAHAN );
		AddField($xmldoc ,'JUMLAH_KEMASAN',$JUMLAH_KEMASAN );
		AddField($xmldoc ,'JUMLAH_SATUAN',$JUMLAH_SATUAN ); 
		AddField($xmldoc ,'KODE_KEMASAN',$KODE_KEMASAN ); 
		AddField($xmldoc ,'NETTO',$NETTO ); 
		AddField($xmldoc ,'POS_TARIF',$POS_TARIF ); 
		AddField($xmldoc ,'SERI_BARANG',$SERI_BARANG ); 
		AddField($xmldoc ,'VOLUME',$VOLUME ); 
		AddField($xmldoc ,'ms_item_id',$ms_item_id ); 
		AddField($xmldoc ,'KODE_NEGARA_ASAL',$KODE_NEGARA_ASAL ); 
		AddField($xmldoc ,'BM',$BM ); 
		AddField($xmldoc ,'PPNBM',$PPNBM ); 
		AddField($xmldoc ,'PPH',$PPH ); 
		AddField($xmldoc ,'PPN',$PPN );  ; 
		AddField($xmldoc ,'series',$series ); 
		AddField($xmldoc ,'TAHUN_PEMBUATAN',$TAHUN_PEMBUATAN );  
		AddField($xmldoc ,'po_no',$po_no ); 
		AddField($xmldoc ,'po_date',$po_date );  
		
		$str = $xmldoc->saveXML();
		// print_r($str);die();
			wh_exec_sp_array($xmldoc, $SPT ,$sts,$des,$rows,$detail); 
		echo json_encode(array('valid'=>($sts=='00'?true:false)
		,'stsno' => $sts
		, 'stsmsg' => $des
		, 'detail' => $detail)
		); 
		}
		
		
	function delete_detail(){  
		
		
		$ID_HEADER 				= isset($_POST['ID_HEADER'])?$_POST['ID_HEADER']:'-1'; // get the requested page 
		$ID_BARANG 				= isset($_POST['ID_BARANG'])?$_POST['ID_BARANG']:'-1'; // get the requested page 
	
		$SPT='MG_MS_BC_IN_ITEM_DELETE';
		
		$xmldoc =  XMLbasic('json');  
		AddField($xmldoc ,'ID_HEADER',$ID_HEADER );
		AddField($xmldoc ,'ID_BARANG',$ID_BARANG );
		
		$str = $xmldoc->saveXML();
		// print_r($str);die();
			wh_exec_sp_array($xmldoc, $SPT ,$sts,$des,$rows,$detail); 
		echo json_encode(array('valid'=>($sts=='00'?true:false)
		,'stsno' => $sts
		, 'stsmsg' => $des
		, 'detail' => $detail)
		); 
		}
		
		
			function mapping_all_item(){   
				$ID_HEADER 				= isset($_POST['ID_HEADER'])?$_POST['ID_HEADER']:'-1'; // get the requested page 
					$SPT='MG_MS_BC_IN_ITEM_MAPPING_AUTO';
				
				$xmldoc =  XMLbasic('json');  
				AddField($xmldoc ,'ID_HEADER',$ID_HEADER ); 
					
				$str = $xmldoc->saveXML();
					// print_r($str);die();
					wh_exec_sp_array($xmldoc, $SPT ,$sts,$des,$rows,$detail); 
				echo json_encode(array('valid'=>($sts=='00'?true:false)
				,'stsno' => $sts
				, 'stsmsg' => $des
				, 'detail' => $detail)
				); 
		}
		
					
	function create_bc_molts(){
			$supplier_id = isset($_POST['supplier_id'])?$_POST['supplier_id']:die('Pilih Customer');; // get the requested page 
				$bc_prefix = isset($_POST['bc_prefix'])?$_POST['bc_prefix']:die('Type BC tidak di ketahui');; // get the requested page 
			$lst_id = isset($_POST['lst_id'])?$_POST['lst_id']:die('pilih SA penyusun Dokument');; // get the requested page 
		
			$xmldoc =  XMLbasic('json'); 
			AddField($xmldoc ,'ms_supplier_customer_id',$supplier_id);
			AddField($xmldoc ,'bc_prefix',$bc_prefix); 
			
			for ($i = 0; $i <  count($lst_id); $i++) {
				$this->_insert_id_to_field($xmldoc,$lst_id[$i]);
			} 
			$str = $xmldoc->saveXML();  
		//print_r($str);die();
			wh_exec_sp_array($xmldoc, 'dbo.MG_MS_BC_IN_IMPORT_FROM_MOLTS',$sts,$des,$rows,$detail); 
			echo json_encode(array('valid'=>($sts=='00'?true:false),'stsno' => $sts, 'stsmsg' => $des)); 
	}
		
		
	function create_bc_invoce(){
			$supplier_id = isset($_POST['supplier_id'])?$_POST['supplier_id']:die('Pilih Customer');; // get the requested page 
				$bc_prefix = isset($_POST['bc_prefix'])?$_POST['bc_prefix']:die('Type BC tidak di ketahui');; // get the requested page 
			$lst_id = isset($_POST['lst_id'])?$_POST['lst_id']:die('pilih SA penyusun Dokument');; // get the requested page 
			$ms_manual_invoice_type_id = isset($_POST['invoice_prefix_id'])?$_POST['invoice_prefix_id']:'-1'; // get the direction 
				$KODE_VALUTA = isset($_POST['KODE_VALUTA'])?$_POST['KODE_VALUTA']:'-1'; // get the direction 
		
			$xmldoc =  XMLbasic('json'); 
			AddField($xmldoc ,'ms_supplier_customer_id',$supplier_id);
			AddField($xmldoc ,'bc_prefix',$bc_prefix); 
			AddField($xmldoc ,'ms_manual_invoice_type_id',$ms_manual_invoice_type_id); 
			AddField($xmldoc ,'KODE_VALUTA',$KODE_VALUTA); 
			
			for ($i = 0; $i <  count($lst_id); $i++) {
				$this->_insert_id_to_field($xmldoc,$lst_id[$i]);
			} 
			$str = $xmldoc->saveXML();  
			wh_exec_sp_array($xmldoc, 'dbo.MG_MS_BC_IN_IMPORT_FROM_INVOICE',$sts,$des,$rows,$detail); 
			echo json_encode(array('valid'=>($sts=='00'?true:false),'stsno' => $sts, 'stsmsg' => $des)); 
	}
 }