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

$sql = "select CLSU_NOMBRE, CLCU_COD from TRAE_SUCURSALES('" . $_GET["nitcli"] . "')";

try {
	$dbh = new PDO("firebird:dbname=$dbname", $_SESSION['usuario'], $_SESSION['clave']);	
//	$dbh = new PDO("firebird:dbname=$dbname", 'SYSDBA', 'MASTER123');	
	$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	$stmt = $dbh->prepare($sql);
	$stmt->execute();
	$sucur = $stmt->fetchAll(PDO::FETCH_OBJ);
	$dbh = null;
	echo '{"items":'. json_encode($sucur) .'}'; 
} catch(PDOException $e) {
	echo '{"items":[{"CLCU_COD":"01","CLSU_NOMBRE":"NO EXISTE"}]}'; 
}


?>