<?php

session_start();
$com="AS";
include("DMMYSQLG.php");
$resultado=[];
	  $textBus=mysqli_real_escape_string($con,$_REQUEST['term']);
	  if(trim($textBus)!=''){
                @$sq_retrieve =mysqli_query($con ,"SELECT DISTINCT(nparte1), np_desc1 FROM fdepartamento WHERE modulo='".$_SESSION['mod_sis']."' AND   np_desc1 like '$textBus%' and sub='SI' or
                    modulo='".$_SESSION['mod_sis']."' AND   nparte1 like '$textBus%' and sub='SI' order by nparte1");
          }
     
		  while(@$reg = mysqli_fetch_array($sq_retrieve)){	
                      $row["label"]="(".$reg['nparte1'].")".$reg['np_desc1'];
                       $row["gdescrip"]=$reg['np_desc1'];
                      $row["id"]=$reg['nparte1'];
                      $row["value"]=$reg['np_desc1'];
              $resultado[]=$row;  
		  }          
  echo json_encode($resultado);
//$q = mysqli_real_escape_string($con,$_GET["q"]);
//$limit= mysqli_real_escape_string($con,$_GET["limit"]);
//if($_GET['tipBus']=='d')
//	$sq_invent=mysqli_query($con ,"SELECT fdepartamento.np_desc1,fdepartamento.nparte1,fdepartamento.cod_var FROM fdepartamento WHERE fdepartamento.modulo='".$_SESSION['mod_sis']."' AND   np_desc1 like '$q%' and sub='SI' order by np_desc1 limit $limit");
//elseif($_GET['tipBus']=='c')
//		$sq_invent=mysqli_query($con ,"SELECT * FROM fdepartamento WHERE fdepartamento.modulo='".$_SESSION['mod_sis']."' AND   nparte1 like '$q%' OR cod_var='$q' and sub='SI' order by nparte1 limit $limit");
//while($dt_invent=mysqli_fetch_array($sq_invent)){
//	echo "$dt_invent['np_desc1']|$dt_invent['nparte1']\n";
//}
?>