<?php
session_start();
include 'config.php';

$sql = "SELECT FACT_ID, PREF_PRE, FACT_NUMERO FROM FACTURA_WEB W, FACTURAS F WHERE W.FACW_IDFAC = F.FACT_ID AND FACW_ID = ". $_GET["id"];

try {
	$dbh = new PDO("firebird:dbname=$dbname", $_SESSION['usuario'], $_SESSION['clave']);	
	$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	$stmt = $dbh->prepare($sql);
	$stmt->execute();
	$liqp = $stmt->fetchAll(PDO::FETCH_OBJ);
	$dbh = null;
	echo '{"items":'. json_encode($liqp) .'}'; 
} catch(PDOException $e) {
	echo '{"items":[{"FACT_ID":"0"}]}'; //. $sql; 
}


?>