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.
140 righe
5.8 KiB
140 righe
5.8 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_progetti.codice, |
|
b_progetti.codice_ente, |
|
b_progetti.tipologia, |
|
b_progetti.anno, |
|
b_progetti.cup, |
|
b_progetti.cui, |
|
b_progetti.importo, |
|
b_progetti.stato_programmazione, |
|
b_progetti.oggetto |
|
FROM b_progetti |
|
WHERE b_progetti.codice > 0 "; |
|
if (!empty($_GET["ente"])) { |
|
$bind[":enteFiltro"] = $_GET["ente"]; |
|
$sql .= " AND b_progetti.codice_ente = :enteFiltro "; |
|
} |
|
if ($_SESSION["utente"]->gerarchia > 10) { |
|
$ids = Utente::getPermissionsInModulo($_SESSION["ente"]->codice,$_SESSION["utente"]->codice,"progetti"); |
|
$ids = implode(",",$ids); |
|
$sql .= " AND b_progetti.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_progetti.codice",$bind); |
|
if ($risultati->rowCount() > 0) { |
|
$return["recordsTotal"] = (int)$risultati->rowCount(); |
|
$filterApplied = false; |
|
if (!empty($_GET["search"]["value"])) { |
|
$filterApplied = true; |
|
$sql .= " AND ( "; |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_progetti.codice"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_progetti.oggetto"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_progetti.cui"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_progetti.cup"); |
|
$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_progetti.stato = :status "; |
|
} |
|
if (isset($_GET["tipologia"]) && $_GET["tipologia"]!=="") { |
|
$filterApplied = true; |
|
$bind[":tipologia"] = $_GET["tipologia"]; |
|
$sql .= " AND b_progetti.tipologia = :tipologia "; |
|
} |
|
|
|
switch($_GET["order"][0]["column"]) { |
|
case "1": $order = "b_progetti.anno "; break; |
|
case "2": $order = "b_progetti.cui "; break; |
|
case "3": $order = "b_progetti.cup "; break; |
|
case "4": $order = "b_progetti.tipologia "; break; |
|
case "6": $order = "b_progetti.importo "; break; |
|
default: $order = "b_progetti.codice "; |
|
} |
|
if ($_GET["order"][0]["dir"] == "desc") { |
|
$order.= "DESC "; |
|
} else { |
|
$order.= "ASC "; |
|
} |
|
|
|
$sql .= " GROUP BY b_progetti.codice ORDER BY " . $order . " "; |
|
$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(); |
|
|
|
while($record = $risultati->fetch(PDO::FETCH_ASSOC)) { |
|
$row = array(); |
|
$row[] = $record["codice"]; |
|
$row[] = $record["anno"]; |
|
$row[] = $record["cui"]; |
|
$row[] = $record["cup"]; |
|
$row[] = __(progetto::tipologie()[$record["tipologia"]]); |
|
$panelHref = "/backend/progetti/panel.php?codice={$record["codice"]}"; |
|
$oggetto = "<strong>" . $record["oggetto"] . "</strong>"; |
|
if ($record["stato_programmazione"] == "I") { |
|
$oggetto .= "<br><small class='badge badge-warning'>" . __("Incompiuto") . "</small>"; |
|
$row["DT_RowClass"] = "text-warning"; |
|
} else if ($record["stato_programmazione"] == "A") { |
|
$oggetto .= "<br><small class='badge badge-danger'>" . __("Non riproposto") . "</small>"; |
|
$row["DT_RowClass"] = "text-danger"; |
|
} |
|
$row[] = "<a href='{$panelHref}' title='".__("gestisci")."'>{$oggetto}</a>"; |
|
$row[] = number_format($record["importo"],2,",","."); |
|
if (!empty($enti)) { |
|
$row[] = $enti[$record["codice_ente"]]["denominazione"] ?? ""; |
|
} |
|
$row[] = "<a href='{$panelHref}' title='".__("gestisci")."' class='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); |
|
} |
|
} |
|
?>
|
|
|