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

$_SESSION['usuario'] = "REPLICA";
$_SESSION['clave'] = "REPLICA";

$sql = "SELECT FIRST 1 FACT_ID, PREF_PRE, FACT_NUMERO, FACT_ANULADO FROM FACTURAS WHERE VEND_COD = ".$_GET["codvend"]." ORDER BY FACT_ID DESC";

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();
	$vend = $stmt->fetchAll(PDO::FETCH_OBJ);
	$dbh = null;
	echo json_encode($vend); 
} catch(PDOException $e) {
	echo '{"items":[{"VEND":"0","NOMBRE":"NO EXISTE"}]}'; 
}


?>