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.
183 righe
8.1 KiB
183 righe
8.1 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice)) { |
|
if (isset($_GET["draw"])) { |
|
|
|
$return = array(); |
|
$return["draw"] = (int)$_GET["draw"]; |
|
$return["recordsTotal"] = (int)0; |
|
$return["recordsFiltered"] = (int)0; |
|
$colonnaEnte = false; |
|
$enti = $_SESSION["utente"]->getEntiBeneficiari(); |
|
if (!empty($enti)) { |
|
$enti[$_SESSION["ente"]->codice] = $_SESSION["ente"]->getInfo(); |
|
} |
|
$bind = array(":codice_gestore"=>$_SESSION["ente"]->codice); |
|
$sql = "SELECT b_gare.codice, |
|
b_gare.badge, |
|
b_gare.codice_ente, |
|
b_gare.id, |
|
b_gare.tipologia, |
|
b_gare.procedura, |
|
b_gare.modalita, |
|
b_gare.stato, |
|
b_gare.prezzoRiferimento, |
|
b_gare.oggetto, |
|
b_gare.fase_attiva, |
|
b_gare.utente_creazione, |
|
GROUP_CONCAT(b_gare_lotti.cig) AS cig |
|
FROM b_gare |
|
LEFT JOIN b_gare_lotti ON b_gare.codice = b_gare_lotti.codice_gara |
|
WHERE b_gare.codice > 0 "; |
|
if (!empty($_GET["ente"])) { |
|
$bind[":enteFiltro"] = $_GET["ente"]; |
|
$sql .= " AND b_gare.codice_ente = :enteFiltro "; |
|
} |
|
if ($_SESSION["utente"]->gerarchia > 10) { |
|
$ids = Utente::getPermissionsInModulo($_SESSION["ente"]->codice,$_SESSION["utente"]->codice,"gare"); |
|
$ids = implode(",",$ids); |
|
$sql .= " AND b_gare.codice IN ({$ids}) "; |
|
} |
|
if (!$_SESSION["utente"]->fromHere()) { |
|
$sql .= " AND codice_ente = :codice_ente"; |
|
$bind[":codice_ente"] = $_SESSION["utente"]->codice_ente; |
|
} |
|
$risultati = $pdo->go($sql. " GROUP BY b_gare.codice",$bind); |
|
if ($risultati->rowCount() > 0) { |
|
$checkPubblicata = $pdo->prepare("SELECT codice FROM b_gare_round WHERE codice_gara = :codice AND pubblicazione < now()"); |
|
$return["recordsTotal"] = (int)$risultati->rowCount(); |
|
$filterApplied = false; |
|
if (!empty($_GET["search"]["value"])) { |
|
$filterApplied = true; |
|
$sql .= " AND ( "; |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_gare.id"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_gare.oggetto"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_gare_lotti.oggetto"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_gare_lotti.cig"); |
|
$sql .= "(" . $suddivisione["sql"] . ") "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$sql .= ") "; |
|
} |
|
|
|
if (isset($_GET["stato"]) && $_GET["stato"]!=="") { |
|
$filterApplied = true; |
|
$bind[":status"] = $_GET["stato"]; |
|
$sql .= " AND b_gare.stato = :status "; |
|
} |
|
if (isset($_GET["tipologia"]) && $_GET["tipologia"]!=="") { |
|
$filterApplied = true; |
|
$bind[":tipologia"] = $_GET["tipologia"]; |
|
$sql .= " AND b_gare.tipologia = :tipologia "; |
|
} |
|
if (isset($_GET["modalita"]) && $_GET["modalita"]!=="") { |
|
$filterApplied = true; |
|
$bind[":modalita"] = $_GET["modalita"]; |
|
$sql .= " AND b_gare.modalita = :modalita "; |
|
} |
|
if (isset($_GET["creatore"]) && $_GET["creatore"]!=="") { |
|
$filterApplied = true; |
|
$bind[":creatore"] = $_GET["creatore"]; |
|
$sql .= " AND b_gare.utente_creazione = :creatore "; |
|
} |
|
if (isset($_GET["procedura"]) && $_GET["procedura"]!=="") { |
|
$filterApplied = true; |
|
$bind[":procedura"] = $_GET["procedura"]; |
|
$sql .= " AND b_gare.procedura = :procedura "; |
|
} |
|
|
|
switch($_GET["order"][0]["column"]) { |
|
case "2": $order = "b_gare.codice "; break; |
|
case "4": $order = "b_gare.badge "; break; |
|
case "6": $order = "b_gare.oggetto "; break; |
|
case "7": $order = "b_gare.prezzoRiferimento "; break; |
|
// case "7": $order = "b_gare_round.pubblicazione "; break; |
|
// case "8": $order = "b_gare_round.chiarimenti "; break; |
|
// case "9": $order = "b_gare_round.scadenza "; break; |
|
default: $order = "b_gare.codice "; |
|
} |
|
if ($_GET["order"][0]["dir"] == "desc") { |
|
$order.= "DESC "; |
|
} else { |
|
$order.= "ASC "; |
|
} |
|
|
|
$sql .= " GROUP BY b_gare.codice ORDER BY " . $order . ", b_gare.id DESC "; |
|
$risultatiBeforLimit = $pdo->go($sql,$bind); |
|
if ($_GET["length"] !== "-1") { $sql.= "LIMIT ". (int)$_GET["start"] .", " . (int)$_GET["length"]; } |
|
$risultati = $pdo->go($sql,$bind); |
|
if ($risultati->rowCount() > 0) { |
|
if ($filterApplied) { |
|
$return["recordsFiltered"] = (int)$risultatiBeforLimit->rowCount(); |
|
} else { |
|
$return["recordsFiltered"] = $return["recordsTotal"]; |
|
} |
|
$return["data"] = array(); |
|
|
|
$stati = gara::getStati(); |
|
$tipologie = getTipologieAffidamento(); |
|
$procedure = getProcedure(); |
|
while($record = $risultati->fetch(PDO::FETCH_ASSOC)) { |
|
$panelHref = "/backend/gare/panel.php?codice={$record["codice"]}"; |
|
$stato = $stati[$record["stato"]]; |
|
if ($record["stato"] == 20 ) { |
|
$checkPubblicata->execute([":codice"=>$record["codice"]]); |
|
if ($checkPubblicata->rowCount() === 0) { |
|
$stato["titolo"] = "Programmata pubblicazione"; |
|
} |
|
} |
|
$tipologia = $tipologie[$record["tipologia"]] ?? []; |
|
$tipologia = $tipologia["titolo"] ?? "n.a."; |
|
$procedura = $procedure[$record["procedura"]] ?? []; |
|
$procedura = $procedura["titolo"] ?? "n.a."; |
|
$row = array(); |
|
$row[] = '<div id="flag_'.$record["codice"].'" class="status_flag" style="background-color:'.$stato["color"].'"></div>'; |
|
$row[] = __($stato["titolo"]); |
|
$row[] = $record["id"]; |
|
$row[] = str_replace(",","<br>",$record["cig"]); |
|
$row[] = ($record["badge"] > 0) ? "<span class='badge badge-danger' style='font-size:1em'>" . $record["badge"] . "</span> " : ""; |
|
$row[] = __($tipologia); |
|
$row[] = __($procedura); |
|
ob_start(); |
|
?> |
|
<? if ($record["modalita"] == "extra") { ?> |
|
<small class="float-right badge badge-info"><span class="fa fa-scroll"></span> <?= __("Extra-piattaforma") ?></small> |
|
<? } else { ?> |
|
<small class="float-right badge badge-warning"><span class="fa fa-paper-plane"></span> <?= __("Telematica") ?></small> |
|
<? } ?> |
|
<strong><a href="<?= $panelHref ?>"><?= $record["oggetto"] ?></a></strong> |
|
<? |
|
$row[] = ob_get_clean(); |
|
$row[] = number_format($record["prezzoRiferimento"],2,",","."); |
|
if (!empty($enti)) { |
|
$row[] = $enti[$record["codice_ente"]]["denominazione"] ?? $_SESSION["ente"]->getInfo()["denominazione"]; |
|
} |
|
$creatore = Utente::getInfoFromID($record["utente_creazione"]); |
|
if (empty($creatore)) |
|
$creatore = ["cognome" => "n.a." , "nome" => ""]; |
|
$row[] = "{$creatore["cognome"]} {$creatore["nome"]}"; |
|
$row[] = "<a href='{$panelHref}' title='".__("gestisci")."' class='btn btn-info btn-sm'><span class='fa fa-th'></span></a>"; |
|
$return["data"][] = $row; |
|
} |
|
} else { |
|
$return["data"] = array(); |
|
} |
|
} else { |
|
$return["data"] = array(); |
|
} |
|
|
|
echo json_encode($return); |
|
} |
|
} |
|
?>
|
|
|