$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[] = '
'; $row[] = __($stato["titolo"]); ob_start(); if ($record["smart_cig"] == "S") { echo "" . __("SMART CIG") . ""; } ?> = $record["oggetto"] ?>