<?php

session_start();
$com="AS";
include("DMMYSQLG.php");
//include("DSA1000.php");
$com="AS";
require_once("DMMYSQLG.php");

$resultado=[];

  
	  $textBus=mysqli_real_escape_string($con,$_REQUEST['term']);
	  if(trim($textBus)!=''){
              $sq_retrieve=mysqli_query($con ,"SELECT DISTINCT(n_reg),pclave,descripcion,cod_var,pmontomax FROM valeryus09 WHERE modulo='".$_SESSION['mod_sis']."' AND descripcion like '$textBus%' AND pmontomax='ABONO' AND ppago='SI'
                      or modulo='".$_SESSION['mod_sis']."' AND   n_reg like '$textBus%'  AND pmontomax='ABONO' AND ppago='SI' order by n_reg");
         
              //echo "SELECT DISTINCT(n_reg),descripcion,cod_var,pmontomax FROM valeryus09 WHERE modulo='".$_SESSION['mod_sis']."' AND descripcion like '$textBus%' AND pmontomax='ABONO' AND ppago='SI'
                //      or modulo='".$_SESSION['mod_sis']."' AND   n_reg like '$textBus%'  AND pmontomax='ABONO' AND ppago='SI' order by n_reg";
              
              
          }
                    //@$sql = mysqli_query($con ,);
		  while(@$reg = mysqli_fetch_array($sq_retrieve)){
			
                      $row["label"]="(".$reg['n_reg'].")".$reg['descripcion'];
                       $row["descripcion"]=$reg['descripcion'];
                       
                        $row["pmontomax"]=$reg['pmontomax'];
                       $row["id"]=$reg['n_reg'];
                       $row["pclave"]=$reg['pclave'];
                      $row["value"]=$reg['descripcion'];
                       
              $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 valeryus09.descripcion,valeryus09.n_reg,valeryus09.cod_var,valeryus09.pmontomax FROM valeryus09 WHERE valeryus09.modulo='".$_SESSION['mod_sis']."' AND descripcion like '$q%' AND pmontomax='ABONO' AND ppago='SI' order by descripcion limit $limit");
//elseif($_GET['tipBus']=='c')
//		$sq_invent=mysqli_query($con ,"SELECT * FROM valeryus09 WHERE valeryus09.modulo='".$_SESSION['mod_sis']."' AND   n_reg like '$q%' OR cod_var='$q' AND pmontomax='ABONO' AND ppago='SI' order by n_reg limit $limit");
//while($dt_invent=mysqli_fetch_array($sq_invent)){
//	echo "$dt_invent['descripcion']|$dt_invent['n_reg']|$dt_invent['pmontomax']\n";

?>