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

$sql = "select FAWD_ITEM, FAWD_CODBAR, ARTI_DES, FAWD_CANT, FAWD_PRUNIT, FAWD_TOTAL, FAWD_REFERENCIA FROM FACTURA_WEB_DETALLE P, ARTICULO A WHERE P.ARTI_COD = A.ARTI_COD 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();
	$itep = $stmt->fetchAll(PDO::FETCH_OBJ);
	$dbh = null;
	echo '{"items":'. json_encode($itep) .'}'; 
} catch(PDOException $e) {
	echo '{"items":[{"PEWD_CODBAR":""}]}' . $sql; 
}


?>