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.
106 righe
4.3 KiB
106 righe
4.3 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; |
|
|
|
$bind = array(":codice_gestore"=>$_SESSION["ente"]->codice); |
|
$sql = "SELECT b_cpn.codice, b_cpn.stato, |
|
b_cpn.oggetto, |
|
b_cpn.codice_ente |
|
FROM b_cpn |
|
LEFT JOIN b_cpn_lotti ON b_cpn.codice = b_cpn_lotti.codice_cpn AND b_cpn_lotti.eliminato = 'N' |
|
WHERE b_cpn.codice > 0 "; |
|
if ($_SESSION["utente"]->gerarchia > 10) { |
|
$ids = Utente::getPermissionsInModulo($_SESSION["ente"]->codice,$_SESSION["utente"]->codice,"cpn"); |
|
$ids = implode(",",$ids); |
|
$sql .= " AND b_cpn.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_cpn.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_cpn.oggetto"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_cpn_lotti.cig"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_cpn_lotti.oggetto"); |
|
$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_cpn.stato = :status "; |
|
} |
|
|
|
$order = "b_cpn.codice "; |
|
switch($_GET["order"][0]["column"]) { |
|
case "1": $order = "b_cpn.codice "; break; |
|
case "2": $order = "b_cpn.stato "; break; |
|
case "3": $order = "b_cpn.oggetto "; break; |
|
case "6": $order = "b_cpn.codice_ente "; break; |
|
} |
|
if ($_GET["order"][0]["dir"] == "desc") { |
|
$order.= "DESC "; |
|
} else { |
|
$order.= "ASC "; |
|
} |
|
|
|
$sql .= "GROUP BY b_cpn.codice ORDER BY " . $order . ", b_cpn.codice DESC "; |
|
$risultatiBeforLimit = $pdo->go($sql,$bind); |
|
if ($_GET["length"] !== "-1") { $sql.= "LIMIT ". (int)$_GET["start"] .", " . (int)$_GET["length"]; } |
|
$risultati = $pdo->go($sql,$bind); |
|
$cpn = new attiCPN; |
|
if ($risultati->rowCount() > 0) { |
|
if ($filterApplied) { |
|
$return["recordsFiltered"] = (int)$risultatiBeforLimit->rowCount(); |
|
} else { |
|
$return["recordsFiltered"] = $return["recordsTotal"]; |
|
} |
|
$return["data"] = array(); |
|
|
|
$stati = attiCPN::getStati(); |
|
while($record = $risultati->fetch(PDO::FETCH_ASSOC)) { |
|
|
|
$stato = $stati[$record["stato"]]; |
|
$panelHref = "/backend/cpn/panel.php?codice={$record["codice"]}"; |
|
$row = array(); |
|
$row[] = '<div id="flag_'.$record["codice"].'" class="status_flag" style="background-color:'.$stato["color"].'"></div>'; |
|
$row[] = __($stato["titolo"]); |
|
$row[] = "<strong><a href='{$panelHref}'>{$record["oggetto"]}</strong>"; |
|
$row[] = Ente::getInfoFromID($record["codice_ente"])[0]["denominazione"] ?? "n.a."; |
|
$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); |
|
} |
|
} |
|
?>
|
|
|