<?php
class CT_pasi_ceisa_bc_out_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(){
	 	$data['bc_prefix'] ='27';
	 	$data['bc_prefix_name'] ='27_out';
		$this->load->view('pasi_ceisa_bc_out_new/view_pasi_ceisa_bc_27_out', $data);
	} 

	function loaddata_bc25_out(){; 
		$def_col= array();  
		$spt='dbo.SP_T_HEADER_BC_25'; 
		$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
		$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"int", "bypassvalue"=>"-100");
		$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"int", "bypassvalue"=>"-100");
		$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"date", "bypassvalue"=>"");
		$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"int", "bypassvalue"=>"");
		$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "bypassvalue"=>"");
		$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"int", "bypassvalue"=>"");
		$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"int", "bypassvalue"=>"");
		$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"int", "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['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"date", "bypassvalue"=>"");
		$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"date", "bypassvalue"=>"");
		$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"date", "bypassvalue"=>"");
		$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
 		$def_col['rc']=array("db" => "rc" ,"sc" => "rc","ctype"=>"text", "bypassvalue"=>"");
		$def_col['rsk']=array("db" => "rsk" ,"sc" => "rsk","ctype"=>"text", "bypassvalue"=>"");
 		$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
		$def_col['rt']=array("db" => "rt" ,"sc" => "rt","ctype"=>"text", "bypassvalue"=>"");
 		$def_col['rt2']=array("db" => "rt2" ,"sc" => "rt2","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;
									  }
								}
								// else{
									// if ($fcr['sc'])=='r1'){
									
									// }
								// }
			 					  
							} 
							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();   
		 exec_sp_json($xmldoc, 'dbo.SP_T_HEADER_BC_25',$sts,$des,$rows,$detail);  
  		echo $rows; 
		}


	
    function loaddata_bc27_out(){; 
		$def_col= array();  
		$spt='dbo.SP_T_HEADER_BC_27_OUT'; 
		$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
		$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"int", "bypassvalue"=>"-100");
		$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"int", "bypassvalue"=>"-100");
		$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"date", "bypassvalue"=>"");
		$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"int", "bypassvalue"=>"");
		$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "bypassvalue"=>"");
		$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"int", "bypassvalue"=>"");
		$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"int", "bypassvalue"=>"");
		$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"int", "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['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"date", "bypassvalue"=>"");
		$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"date", "bypassvalue"=>"");
		$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
		$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"date", "bypassvalue"=>"");
		$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
 		$def_col['rc']=array("db" => "rc" ,"sc" => "rc","ctype"=>"text", "bypassvalue"=>"");
		$def_col['rsk']=array("db" => "rsk" ,"sc" => "rsk","ctype"=>"text", "bypassvalue"=>"");
 		$def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
		$def_col['rt']=array("db" => "rt" ,"sc" => "rt","ctype"=>"text", "bypassvalue"=>"");
 		$def_col['rt2']=array("db" => "rt2" ,"sc" => "rt2","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);		
		// print_r($str);die();
	 	 exec_sp_json($xmldoc, 'dbo.SP_T_HEADER_BC_27_OUT',$sts,$des,$rows,$detail);  
	 	echo $rows; 
		}

		
		function loaddata_bc41_out(){; 
			$def_col= array();  
			$spt='dbo.SP_T_HEADER_BC_41'; 
			$def_col['rID']=array("db" => "rID" ,"sc" => "rID","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r1']=array("db" => "r1" ,"sc" => "r1","ctype"=>"int", "bypassvalue"=>"-100");
			$def_col['r2']=array("db" => "r2" ,"sc" => "r1","ctype"=>"int", "bypassvalue"=>"-100");
			$def_col['r3']=array("db" => "r3" ,"sc" => "r3","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"date", "bypassvalue"=>"");
			$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r8']=array("db" => "r8" ,"sc" => "r8","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r9']=array("db" => "r9" ,"sc" => "r9","ctype"=>"int", "bypassvalue"=>"");
			$def_col['r10']=array("db" => "r10" ,"sc" => "r10","ctype"=>"int", "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['r15']=array("db" => "r15" ,"sc" => "r15","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"date", "bypassvalue"=>"");
			$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"date", "bypassvalue"=>"");
			$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"date", "bypassvalue"=>"");
			$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
			$def_col['rc']=array("db" => "rc" ,"sc" => "rc","ctype"=>"text", "bypassvalue"=>"");
			$def_col['rsk']=array("db" => "rsk" ,"sc" => "rsk","ctype"=>"text", "bypassvalue"=>"");
			 $def_col['rg']=array("db" => "rg" ,"sc" => "rg","ctype"=>"int", "bypassvalue"=>"-100");
			$def_col['rt']=array("db" => "rt" ,"sc" => "rt","ctype"=>"text", "bypassvalue"=>"");
			 $def_col['rt2']=array("db" => "rt2" ,"sc" => "rt2","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;
										  }
									}
									// else{
										// if ($fcr['sc'])=='r1'){
										
										// }
									// }
									   
								} 
								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();   
			 exec_sp_json($xmldoc, 'dbo.SP_T_HEADER_BC_41',$sts,$des,$rows,$detail);  
			  echo $rows; 
			}



		function loaddata_cust_bc25(){; 
			$def_col= array(); 
			$spt='dbo.SP_T_CUST_SA'; 
			$def_col['rID']=array("db" => "rID" ,"sc" => "rID","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"=>"text", "bypassvalue"=>"");
			$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
			$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "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.SP_T_CUST_SA',$sts,$des,$rows,$detail);  
			  echo $rows; 
			}

			function loaddata_cust_bc27(){; 
				$def_col= array(); 
				$spt='dbo.SP_T_CUST_SA'; 
				$def_col['rID']=array("db" => "rID" ,"sc" => "rID","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"=>"text", "bypassvalue"=>"");
				$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "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.SP_T_CUST_SA',$sts,$des,$rows,$detail);  
				  echo $rows; 
				}

				

				function loaddata_cust_bc41(){; 
					$def_col= array(); 
					$spt='dbo.SP_T_CUST_SA'; 
					$def_col['rID']=array("db" => "rID" ,"sc" => "rID","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"=>"text", "bypassvalue"=>"");
					$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"int", "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.SP_T_CUST_SA',$sts,$des,$rows,$detail);  
					  echo $rows; 
					}
		

			

			function loaddata_file_sa_bc25(){; 
				$def_col= array(); 
				$spt='dbo.SPX_SA';   
				$def_col['rID']=array("db" => "rID" ,"sc" => "rID","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"=>"int", "bypassvalue"=>"");
				$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"int", "bypassvalue"=>"");
				$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"-100");
				$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"=>"date", "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"=>"text", "bypassvalue"=>"");
				$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
				$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"date", "bypassvalue"=>"");
				$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
				 $def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"text", "bypassvalue"=>"");
				 $def_col['rs']=array("db" => "rs" ,"sc" => "rs","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 
				  $cust_code = isset($_POST['cust_code'])?$_POST['cust_code']:''; // get the direction 
				  $id_header = isset($_POST['id_header'])?$_POST['id_header']:'-1'; // get the direction 
				  $mode_source = isset($_POST['mode_source'])?$_POST['mode_source']:'1'; // get the direction 
				   $mode = isset($_POST['mode'])?$_POST['mode']:'1'; // 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 ,'cust_code',$cust_code);
				AddField($xmldoc ,'id_header',$id_header);
				AddField($xmldoc ,'mode_source',$mode_source);
				AddField($xmldoc ,'mode',$mode);
				 
				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_SA',$sts,$des,$rows,$detail);  
				  echo $rows; 
				}
		  

				function loaddata_file_sa_bc27(){; 
					$def_col= array(); 
					$spt='dbo.SPX_SA';   
					$def_col['rID']=array("db" => "rID" ,"sc" => "rID","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"=>"int", "bypassvalue"=>"");
					$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"int", "bypassvalue"=>"");
					$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"-100");
					$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"=>"date", "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"=>"text", "bypassvalue"=>"");
					$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
					$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"date", "bypassvalue"=>"");
					$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
					 $def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"text", "bypassvalue"=>"");
					 $def_col['rs']=array("db" => "rs" ,"sc" => "rs","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 
					  $cust_code = isset($_POST['cust_code'])?$_POST['cust_code']:''; // get the direction 
					  $id_header = isset($_POST['id_header'])?$_POST['id_header']:'-1'; // get the direction 
					  $mode_source = isset($_POST['mode_source'])?$_POST['mode_source']:'1'; // get the direction 
					   $mode = isset($_POST['mode'])?$_POST['mode']:'1'; // 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 ,'cust_code',$cust_code);
					AddField($xmldoc ,'id_header',$id_header);
					AddField($xmldoc ,'mode_source',$mode_source);
					AddField($xmldoc ,'mode',$mode);
					 
					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_SA',$sts,$des,$rows,$detail);  
					  echo $rows; 
					}
			 
					

					function loaddata_file_sa_bc41(){; 
						$def_col= array(); 
						$spt='dbo.SPX_SA';   
						$def_col['rID']=array("db" => "rID" ,"sc" => "rID","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"=>"int", "bypassvalue"=>"");
						$def_col['r4']=array("db" => "r4" ,"sc" => "r4","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r5']=array("db" => "r5" ,"sc" => "r5","ctype"=>"int", "bypassvalue"=>"");
						$def_col['r6']=array("db" => "r6" ,"sc" => "r6","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r7']=array("db" => "r7" ,"sc" => "r7","ctype"=>"text", "bypassvalue"=>"-100");
						$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"=>"date", "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"=>"text", "bypassvalue"=>"");
						$def_col['r16']=array("db" => "r16" ,"sc" => "r16","ctype"=>"date", "bypassvalue"=>"");
						$def_col['r17']=array("db" => "r17" ,"sc" => "r17","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r18']=array("db" => "r18" ,"sc" => "r18","ctype"=>"date", "bypassvalue"=>"");
						$def_col['r19']=array("db" => "r19" ,"sc" => "r19","ctype"=>"text", "bypassvalue"=>"");
						$def_col['r20']=array("db" => "r20" ,"sc" => "r20","ctype"=>"date", "bypassvalue"=>"");
						$def_col['r21']=array("db" => "r21" ,"sc" => "r21","ctype"=>"text", "bypassvalue"=>"");
						 $def_col['r22']=array("db" => "r22" ,"sc" => "r22","ctype"=>"text", "bypassvalue"=>"");
						 $def_col['rs']=array("db" => "rs" ,"sc" => "rs","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 
						  $cust_code = isset($_POST['cust_code'])?$_POST['cust_code']:''; // get the direction 
						  $id_header = isset($_POST['id_header'])?$_POST['id_header']:'-1'; // get the direction 
						  $mode_source = isset($_POST['mode_source'])?$_POST['mode_source']:'1'; // get the direction 
						   $mode = isset($_POST['mode'])?$_POST['mode']:'1'; // 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 ,'cust_code',$cust_code);
						AddField($xmldoc ,'id_header',$id_header);
						AddField($xmldoc ,'mode_source',$mode_source);
						AddField($xmldoc ,'mode',$mode);
						 
						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_SA',$sts,$des,$rows,$detail);  
						  echo $rows; 
						}
								  

				
 }