<?php
  include("conn.php");
  $xAtajo = (isset($_POST['xAtajo']))?$_POST['xAtajo']:-1;

  $vListaItems      = array();
  $vItem = array();    
  $sql = "select D.ID_ATAJO, D.ID_ITEM, D.VALOR1, I.MODO, I.COMPONENTE, I.LISTA
          from ATJ_ATAJOS_DETALLE D
               inner join CFG_INFO_ATAJO I
               on D.ID_INFO_ATAJO = I.ID_INFO_ATAJO
          where D.ID_ATAJO = " . $xAtajo;
  $RsItems = $DBSegu->Execute($sql);
  if (!$RsItems) {
    print $DBSegu->ErrorMsg();
  }

  while (!$RsItems->EOF) {
    $contador = 0;		
    if ($vListaItems <> '') {
      foreach ($vListaItems as $name1 => $value1) { 
	      $contador++;
  	    $$name1 = $value1;
      }
  	}
       
    $vItem['codigo'] = $RsItems->fields['ID_ITEM'];
    $vItem['valor'] = utf8_encode($RsItems->fields['VALOR1']);
    $vItem['modo'] = $RsItems->fields['MODO'];
    $vItem['componente'] = $RsItems->fields['COMPONENTE'];
    $vItem['lista'] = $RsItems->fields['LISTA'];
		
  	$vListaItems[$contador] = $vItem;

  	$RsItems->Movenext();			
  }
  ob_end_clean();

  header('Content-type: application/json; charset=utf-8');
  echo json_encode($vListaItems);
?>