gestione gare pubbliche
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

78 righe
2.4 KiB

<?
$error = true;
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php";
include_once($configPath);
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice)) {
$return = array();
$bind = array();
$sql = "SELECT * FROM b_enti WHERE codice > 0 ";
if (isset($_SESSION["ente"])) {
$bind[":codice"] = $_SESSION["ente"]->codice;
$sql .= " AND (codice = :codice OR sua = :codice) ";
}
$risultato = $pdo->go($sql,$bind);
if ($risultato->rowCount() > 0) {
$error = false;
$sua = $pdo->prepare("SELECT * FROM b_enti WHERE codice = :sua ");
$return = [[
"codice",
"attivo",
"timestamp",
"denominazione",
"dominio",
"dominio_sua",
"cf",
"indirizzo",
"citta",
"provincia",
"cap",
"pec",
"codice_sua",
"cf_sua",
"denominazione_sua",
]];
while($ente = $risultato->fetch(PDO::FETCH_ASSOC)) {
if (!empty($ente["sua"])) {
$sua->bindValue(":sua",$ente["sua"]);
$sua->execute();
if ($sua->rowCount() > 0) {
$enteSua = $sua->fetch(PDO::FETCH_ASSOC);
$ente["dominio_sua"] = $enteSua["dominio"];
$ente["codice_sua"] = $enteSua["codice"];
$ente["cf_sua"] = $enteSua["cf"];
$ente["denominazione_sua"] = $enteSua["denominazione"];
}
}
$row = [];
$row[] = $ente["codice"];
$row[] = $ente["attivo"];
$row[] = $ente["timestamp"];
$row[] = $ente["denominazione"];
$row[] = $ente["dominio"];
$row[] = $ente["dominio_sua"] ?? "";
$row[] = $ente["cf"];
$row[] = $ente["indirizzo"];
$row[] = $ente["citta"];
$row[] = $ente["provincia"];
$row[] = $ente["cap"];
$row[] = $ente["pec"];
$row[] = $ente["codice_sua"] ?? "";
$row[] = $ente["cf_sua"] ?? "";
$row[] = $ente["denominazione_sua"] ?? "";
$return[] = $row;
}
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=export.csv");
header("Pragma: no-cache");
header("Expires: 0");
foreach($return AS $row) {
echo "\"" . implode("\";\"",$row) . "\"".PHP_EOL;
}
}
}
if ($error) {
header('HTTP/1.0 403 Forbidden');
die();
}
?>