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.
161 righe
7.4 KiB
161 righe
7.4 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_simog.codice, b_simog.stato, b_simog.smart_cig, |
|
b_simog.oggetto, b_simog.anno_riferimento, b_simog.cf_utente_simog, |
|
b_simog.codice_ente |
|
FROM b_simog |
|
LEFT JOIN b_simog_lotti ON b_simog.codice = b_simog_lotti.codice_simog AND b_simog_lotti.eliminato = 'N' |
|
WHERE b_simog.codice_gestore = :codice_gestore "; |
|
if ($_SESSION["utente"]->gerarchia > 10) { |
|
$ids = Utente::getPermissionsInModulo($_SESSION["ente"]->codice,$_SESSION["utente"]->codice,"anac"); |
|
$ids = implode(",",$ids); |
|
$sql .= " AND b_simog.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_simog.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_simog.oggetto"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_simog.cf_utente_simog"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_simog_lotti.cig"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_simog.cf_utente_simog"); |
|
$sql .= "(" . $suddivisione["sql"] . ") OR "; |
|
$bind = array_merge($bind,$suddivisione["bind"]); |
|
|
|
$suddivisione = suddivisione_pdo($_GET["search"]["value"],"b_simog_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_simog.stato = :status "; |
|
} |
|
|
|
$order = "b_simog.codice "; |
|
switch($_GET["order"][0]["column"]) { |
|
case "1": $order = "b_simog.codice "; break; |
|
case "2": $order = "b_simog.stato "; break; |
|
case "3": $order = "b_simog.oggetto "; break; |
|
case "4": $order = "b_simog.anno_riferimento "; break; |
|
case "6": $order = "b_simog.codice_ente "; break; |
|
} |
|
if ($_GET["order"][0]["dir"] == "desc") { |
|
$order.= "DESC "; |
|
} else { |
|
$order.= "ASC "; |
|
} |
|
|
|
$sql .= "GROUP BY b_simog.codice ORDER BY " . $order . ", b_simog.codice DESC "; |
|
$risultatiBeforLimit = $pdo->go($sql,$bind); |
|
if ($_GET["length"] !== "-1") { $sql.= "LIMIT ". (int)$_GET["start"] .", " . (int)$_GET["length"]; } |
|
$risultati = $pdo->go($sql,$bind); |
|
$anac = new anac; |
|
if ($risultati->rowCount() > 0) { |
|
if ($filterApplied) { |
|
$return["recordsFiltered"] = (int)$risultatiBeforLimit->rowCount(); |
|
} else { |
|
$return["recordsFiltered"] = $return["recordsTotal"]; |
|
} |
|
$return["data"] = array(); |
|
|
|
$stati = anac::getStati(); |
|
$ris_lotti = $pdo->prepare("SELECT codice, cig, 190data_inizio, 190data_fine, 190importoAggiudicato, 190liquidazioni FROM b_simog_lotti WHERE codice_simog = :simog AND eliminato = 'N' ORDER BY ordinamento"); |
|
while($record = $risultati->fetch(PDO::FETCH_ASSOC)) { |
|
|
|
$stato = $stati[$record["stato"]]; |
|
|
|
$row = array(); |
|
$row[] = '<div id="flag_'.$record["codice"].'" class="status_flag" style="background-color:'.$stato["color"].'"></div>'; |
|
$row[] = __($stato["titolo"]); |
|
ob_start(); |
|
if ($record["smart_cig"] == "S") { echo "<span class='badge badge-info'>" . __("SMART CIG") . "</span>"; } |
|
?> |
|
<strong><?= $record["oggetto"] ?></strong> |
|
<br><small><?= $record["cf_utente_simog"] ?></small> |
|
<? |
|
$row[] = ob_get_clean(); |
|
ob_start(); |
|
$ris_lotti->bindValue(":simog",$record["codice"]); |
|
$ris_lotti->execute(); |
|
if ($ris_lotti->rowCount() > 0) { |
|
?> |
|
<? if ($ris_lotti->rowCount() > 10) { ?> |
|
<button class="btn btn-primary btn-sm btn-block" onClick="$('#lotti-<?= $record["codice"] ?>').slideToggle()"> |
|
<?= __("Lotti") ?> |
|
<span class="badge badge-info"><?= $ris_lotti->rowCount() ?></span> |
|
</button> |
|
<? } ?> |
|
<div id="lotti-<?= $record["codice"] ?>" class="text-center <?= ($ris_lotti->rowCount() > 10) ? "collapse" : "" ?>"> |
|
<? |
|
while($lotto = $ris_lotti->fetch(PDO::FETCH_ASSOC)) { |
|
$btnStatus = "btn-info"; |
|
$icon = "fa fa-check"; |
|
$missing = $anac->check190Lotto($lotto); |
|
$tooltip = ""; |
|
if (!empty($missing)) { |
|
$icon = "fa fa-exclamation-triangle"; |
|
$btnStatus = "btn-danger"; |
|
foreach($missing AS $id) { |
|
$tooltip .= "<br>" . anac::labels190()[$id]; |
|
} |
|
} |
|
if (!empty($tooltip)) { $tooltip = "data-toggle='tooltip' data-placement='top' data-html='true' title='<strong>L.190/2012</strong>{$tooltip}'"; } |
|
$url = ($record["smart_cig"] == "N") ? "lotti/panel.php?codice_simog={$record["codice"]}&codice_lotto={$lotto["codice"]}" : "/backend/anac/panel.php?codice=".$record["codice"]; |
|
?> |
|
<a <?= $tooltip ?> class="btn <?= $btnStatus ?> btn-block btn-sm m-0 mb-1 p-0" href="<?= $url ?>"> |
|
<span class="<?= $icon ?>"></span> <?= (!empty($lotto["cig"])) ? $lotto["cig"] : ("#".$lotto["codice"]); ?> |
|
</a> |
|
<? |
|
} |
|
?> |
|
</div> |
|
<? |
|
} |
|
$row[] = ob_get_clean(); |
|
$row[] = $record["anno_riferimento"]; |
|
$row[] = Ente::getInfoFromID($record["codice_ente"])[0]["denominazione"] ?? ""; |
|
$row[] = "<a href='/backend/anac/panel.php?codice=".$record["codice"]."' 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); |
|
} |
|
} |
|
?>
|
|
|