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

$_SESSION['usuario'] = $_GET["usuario"];
$_SESSION['clave'] = $_GET["clave"];
	
$sql = "select v.vend_cod, vend_nombre from vendedores v, usuario u where u.vend_cod = v.vend_cod and u.user_cod = '".$_SESSION['usuario']."'";

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 '{"items":'. json_encode($vend) .'}'; 
} catch(PDOException $e) {
	echo '{"items":[{"VEND_COD":"0","VEND_NOMBRE":"NO EXISTE"}]}'; 
}


?>