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.
90 righe
4.1 KiB
90 righe
4.1 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
if (isset($_SESSION["utente"]) && isset($_GET["draw"]) && isset($_GET["modulo"]) && isset($_GET["codice_elemento"]) && !empty($_SESSION["utente"]->oe)) { |
|
|
|
$return = array(); |
|
$return["draw"] = (int)$_GET["draw"]; |
|
$return["recordsTotal"] = (int)0; |
|
$return["recordsFiltered"] = (int)0; |
|
$manager = new publicRichiesteOE($_GET["modulo"],$_GET["codice_elemento"],$_GET["sub"] ?? 0); |
|
$filters = []; |
|
$non_scadute = false; |
|
$scadute = false; |
|
if (!empty($_GET["stato"]) && $_GET["stato"] == "attivi") { $non_scadute = true; } |
|
if (!empty($_GET["stato"]) && $_GET["stato"] == "archivio") { $scadute = true; } |
|
if ($non_scadute) { $filters["non_scadute"] = true; } |
|
if ($scadute) { $filters["scadute"] = true; } |
|
$total = $manager->getRichieste("S",$filters); |
|
if (!empty($total)) { |
|
$return["recordsTotal"] = (int)count($total); |
|
$filters = []; |
|
if (!empty($_GET["search"]["value"])) { |
|
$filters["*"] = $_GET["search"]["value"]; |
|
} |
|
if ($non_scadute) { $filters["non_scadute"] = true; } |
|
if ($scadute) { $filters["scadute"] = true; } |
|
$order = []; |
|
$orderKey = "data"; |
|
switch($_GET["order"][0]["column"]) { |
|
case "3": $orderKey = "titolo"; break; |
|
case "4": $orderKey = "data"; break; |
|
case "5": $orderKey = "scadenza"; break; |
|
case "6": $orderKey = "apertura"; break; |
|
} |
|
if ($_GET["order"][0]["dir"] == "desc") { |
|
$order[$orderKey] = "DESC"; |
|
} else { |
|
$order[$orderKey] = "ASC"; |
|
} |
|
$risultati = $manager->getRichieste("S",$filters,$order,$_GET["start"],$_GET["length"]); |
|
if (count($risultati) > 0) { |
|
if (!empty($_GET["search"]["value"])) { |
|
$return["recordsFiltered"] = (int)count($risultati); |
|
} else { |
|
$return["recordsFiltered"] = $return["recordsTotal"]; |
|
} |
|
$return["data"] = array(); |
|
$checkStato = $pdo->prepare("SELECT timestamp_trasmissione FROM r_richieste_oe WHERE codice_richiesta = :richiesta AND codice_operatore = :operatore"); |
|
$checkStato->bindValue(":operatore",$_SESSION["utente"]->oe["codice"]); |
|
foreach($risultati AS $record) { |
|
$color = "bg-danger"; |
|
$stato = __("Scaduto"); |
|
if (strtotime($record["scadenza"]) > time()) { |
|
$color = "bg-warning"; |
|
$stato = __("Attivo"); |
|
} |
|
$checkStato->bindValue(":richiesta",$record["codice"]); |
|
$checkStato->execute(); |
|
if ($checkStato->rowCount() === 1) { |
|
$timestamp = $checkStato->fetch(PDO::FETCH_ASSOC); |
|
if (!empty($timestamp["timestamp_trasmissione"])) { |
|
$color = "bg-success"; |
|
$stato = __("Trasmesso") . "<br>" . mysql2datetime($timestamp["timestamp_trasmissione"]); |
|
} |
|
} |
|
$row = array(); |
|
$row[] = '<div id="flag_'.$record["codice"].'" class="status_flag '.$color.'"></div>'; |
|
$row[] = $stato; |
|
$dettagliTipologiaRichiesta = publicRichiesteOE::ModuliAbilitati()[$record["modulo"]]; |
|
ob_start(); |
|
echo "<span class=\"badge badge-info\">" . Modulo::getInfo($dettagliTipologiaRichiesta["modulo_riferimento"])["titolo"] . "</span><br>"; |
|
echo $dettagliTipologiaRichiesta["tipologie"][$record["tipologia"]] ?? ""; |
|
$actionRichiesta = "showModalWithURL(\"/richieste/view.php?codice={$record["codice"]}&modulo={$record["modulo"]}&codice_elemento={$record["codice_elemento"]}&sub={$record["sub"]}\")"; |
|
$row[] = ob_get_clean(); |
|
$row[] = "<a href=\"#\" onclick='{$actionRichiesta}'>{$record["titolo"]}</a>"; |
|
$row[] = mysql2datetime($record["data"]); |
|
$row[] = mysql2datetime($record["scadenza"]); |
|
$row[] = "<button title='".__("visualizza")."' class='btn btn-block btn-sm btn-info' onclick='".$actionRichiesta."'><span class='fa fa-search'></span></button>"; |
|
$return["data"][] = $row; |
|
} |
|
} else { |
|
$return["data"] = array(); |
|
} |
|
} else { |
|
$return["data"] = array(); |
|
} |
|
|
|
echo json_encode($return); |
|
} |
|
?>
|
|
|