$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_programmi_art21.codice, b_programmi_art21.codice_ente, b_programmi_art21.tipologia, b_programmi_art21.anno, b_programmi_art21.invio_cpn, b_programmi_art21.stato FROM b_programmi_art21 WHERE b_programmi_art21.codice > 0 "; if (!empty($_GET["ente"])) { $bind[":enteFiltro"] = $_GET["ente"]; $sql .= " AND b_programmi_art21.codice_ente = :enteFiltro "; } if (!$_SESSION["utente"]->fromHere()) { $sql .= " AND codice_ente = :codice_ente"; $bind[":codice_ente"] = $_SESSION["utente"]->codice_ente; } $risultati = $pdo->go($sql. " GROUP BY b_programmi_art21.codice",$bind); if ($risultati->rowCount() > 0) { $return["recordsTotal"] = (int)$risultati->rowCount(); if (isset($_GET["tipologia"]) && $_GET["tipologia"]!=="") { $bind[":tipologia"] = $_GET["tipologia"]; $sql .= " AND b_programmi_art21.tipologia = :tipologia "; } switch($_GET["order"][0]["column"]) { case "1": $order = "b_programmi_art21.stato "; break; case "2": $order = "b_programmi_art21.anno "; break; case "3": $order = "b_programmi_art21.tipologia "; break; default: $order = "b_programmi_art21.codice "; } if ($_GET["order"][0]["dir"] == "desc") { $order.= "DESC "; } else { $order.= "ASC "; } $sql .= " GROUP BY b_programmi_art21.codice ORDER BY " . $order . " "; if ($_GET["length"] !== "-1") { $sql.= "LIMIT ". (int)$_GET["start"] .", " . (int)$_GET["length"]; } $risultati = $pdo->go($sql,$bind); if ($risultati->rowCount() > 0) { $return["recordsFiltered"] = $return["recordsTotal"]; $return["data"] = array(); $stati = Programma::getStati(); $tipologie = Programma::tipologie(); while($record = $risultati->fetch(PDO::FETCH_ASSOC)) { $stato = $stati[$record["stato"]]; $row = array(); $row[] = '
'; $row[] = __($stato["titolo"]); $row[] = $record["anno"]; $row[] = __($tipologie[$record["tipologia"]]); if (!empty($enti)) { $row[] = $enti[$record["codice_ente"]]["denominazione"] ?? ""; } ob_start(); ?> $row[] = ob_get_clean(); ob_start(); ?> $row[] = ob_get_clean(); if ($_SESSION["utente"]->permission("cpn")) { ob_start(); ?> $row[] = ob_get_clean(); if (!empty($record["invio_cpn"])) { ob_start(); if (empty($_SESSION["cpn"]["token"])) { ?> } else { ?> " title="= __("Download") ?>" target="_blank"> } $row[] = ob_get_clean(); } else { $row[] = ""; } } $return["data"][] = $row; } } else { $return["data"] = array(); } } else { $return["data"] = array(); } echo json_encode($return); } } ?>