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.
265 righe
13 KiB
265 righe
13 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice)) { |
|
|
|
if (isset($_POST["draw"])) { |
|
|
|
$return = []; |
|
$return["draw"] = (int) $_POST["draw"]; |
|
$return["recordsTotal"] = (int) 0; |
|
$return["recordsFiltered"] = (int) 0; |
|
$return["data"] = []; |
|
|
|
$select = trim("SELECT b_conservazione.*"); |
|
$from = "FROM b_conservazione"; |
|
$where = ""; |
|
|
|
$clause = []; |
|
$bind = []; |
|
|
|
$_POST["filters"] = html_entity_decode($_POST["filters"]); |
|
parse_str($_POST["filters"], $filters); |
|
$filters = array_filter($filters); |
|
|
|
$join = ""; |
|
|
|
if(! empty($filters["modulo"]) && ! empty($filters["riferimento"])) { |
|
|
|
switch ($filters["modulo"]) { |
|
|
|
case 'gare': |
|
|
|
$join = "LEFT JOIN b_gare ON b_gare.codice = b_conservazione.codice_elemento"; |
|
|
|
$clause[] = "(b_conservazione.modulo = :modulo AND b_conservazione.codice_elemento = :riferimento)"; |
|
$bind[":modulo"] = "gare"; |
|
$bind[":riferimento"] = (int) $filters["riferimento"]; |
|
|
|
if(! empty($filters["elemento"])) { |
|
|
|
$join = "{$join} LEFT JOIN b_gare_lotti ON b_gare_lotti.codice_gara = b_gare.codice"; |
|
|
|
$suddivisione = suddivisione_pdo($filters["elemento"], "b_gare.oggetto"); |
|
$bind = array_merge($bind, $suddivisione["bind"]); |
|
$terms[] = trim($suddivisione["sql"]); |
|
|
|
$suddivisione = suddivisione_pdo($filters["elemento"], "b_gare_lotti.oggetto"); |
|
$bind = array_merge($bind, $suddivisione["bind"]); |
|
$terms[] = trim($suddivisione["sql"]); |
|
|
|
$suddivisione = suddivisione_pdo($filters["elemento"], "b_gare_lotti.cig"); |
|
$bind = array_merge($bind, $suddivisione["bind"]); |
|
$terms[] = trim($suddivisione["sql"]); |
|
|
|
$suddivisione = suddivisione_pdo($filters["elemento"], "b_gare_lotti.cup"); |
|
$bind = array_merge($bind, $suddivisione["bind"]); |
|
$terms[] = trim($suddivisione["sql"]); |
|
|
|
$clause[] = "( " . implode(" OR ", $terms) . " )"; |
|
|
|
} |
|
|
|
break; |
|
|
|
case 'contratti': |
|
|
|
$join = "LEFT JOIN b_contratti ON b_contratti.codice = b_conservazione.codice_elemento"; |
|
|
|
$clause[] = "(b_conservazione.modulo = :modulo AND b_conservazione.codice_elemento = :riferimento)"; |
|
$bind[":modulo"] = "gare"; |
|
$bind[":riferimento"] = (int) $filters["riferimento"]; |
|
|
|
if(! empty($filters["elemento"])) { |
|
|
|
$suddivisione = suddivisione_pdo($filters["elemento"], "b_contratti.oggetto"); |
|
$bind = array_merge($bind, $suddivisione["bind"]); |
|
$terms[] = trim($suddivisione["sql"]); |
|
|
|
} |
|
break; |
|
|
|
default: |
|
|
|
$join = ""; |
|
|
|
break; |
|
} |
|
|
|
$filters["modulo"]; |
|
|
|
} |
|
|
|
|
|
|
|
if(! empty($filters)) { |
|
|
|
if(! empty($filters["modulo"])) { |
|
|
|
$clause[] = "b_conservazione.modulo = :modulo"; |
|
$bind[":modulo"] = $filters["modulo"]; |
|
|
|
} |
|
|
|
if(! empty($filters["stato"])) { |
|
|
|
$clause[] = "b_conservazione.stato = :stato"; |
|
$bind[":stato"] = $filters["stato"]; |
|
|
|
} |
|
|
|
} |
|
|
|
if(! empty($clause) && count($clause) > 0) { |
|
|
|
$where = implode(" AND ", $clause); |
|
$where = "WHERE {$where}"; |
|
|
|
} |
|
|
|
$order = "ORDER BY b_conservazione.codice ASC"; |
|
$columns = [0 => "codice", 1 => "modulo", 3 => "timestamp_esecuzione"]; |
|
if(! empty($_POST["order"][0]["column"]) && ! empty($_POST["order"][0]["dir"])) { |
|
$column = $columns[$_POST["order"][0]["column"]] ?? null; |
|
if(! empty($column)) { |
|
$dir = "ASC"; |
|
if($_POST["order"][0]["dir"] != "asc") { $dir = "DESC"; } |
|
$order = "ORDER BY b_conservazione.{$column} {$dir}"; |
|
} |
|
} |
|
|
|
$limit = "LIMIT 0, 100"; |
|
if (is_numeric($_POST["start"]) && is_numeric($_POST["length"])) { |
|
$start = (int) $_POST["start"]; |
|
$length = (int) $_POST["length"]; |
|
$limit = "LIMIT {$start}, {$length}"; |
|
} |
|
|
|
$total = $pdo->go("SELECT COUNT(codice) {$from}")->fetch(PDO::FETCH_COLUMN, 0); |
|
if($total > 0) { |
|
|
|
$return["recordsTotal"] = (int) $total; |
|
$return["recordsFiltered"] = (int) $pdo->go("SELECT COUNT(b_conservazione.codice) {$from} {$join} {$where}", $bind)->fetch(PDO::FETCH_COLUMN, 0); |
|
|
|
$pacchetti = $pdo->go("{$select} {$from} {$join} {$where} {$order} {$limit}", $bind); |
|
|
|
$stati = file_get_contents('stati.json'); |
|
$stati = json_decode($stati, TRUE); |
|
|
|
$check = $pdo->prepare("SELECT stato FROM b_conservazione_files WHERE codice_conservazione = :codice_conservazione"); |
|
|
|
$ente = $_SESSION["ente"]->getInfo(); |
|
|
|
$settings = $pdo->prepare("SELECT conservazione FROM b_enti WHERE codice = :codice"); |
|
|
|
while($pacchetto = $pacchetti->fetch(PDO::FETCH_ASSOC)) { |
|
|
|
$connettore = json_decode($ente["conservazione"], true)["connettore"] ?? ""; |
|
if(empty($connettore) && $_SESSION["ente"]->codice !== $pacchetto["codice"]) { |
|
$settings->bindValue(":codice", $pacchetto["codice_ente"]); |
|
$settings->execute(); |
|
if($settings->rowCount() == 1) { |
|
$connettore = $settings->fetch(PDO::FETCH_COLUMN, 0); |
|
$connettore = json_decode($connettore, true)["connettore"] ?? ""; |
|
} |
|
} |
|
|
|
$check->bindValue(":codice_conservazione", $pacchetto["codice"]); |
|
$check->execute(); |
|
|
|
$documents = $check->fetchAll(PDO::FETCH_COLUMN, 0); |
|
|
|
$package_files = count($documents); |
|
|
|
$documents = array_count_values($documents); |
|
|
|
$row = []; |
|
|
|
ob_start(); |
|
?><div data-toggle="tooltip" title="<?= $stati[$pacchetto["stato"]]["titolo"] ?>" id="flag_<?= $pacchetto["codice"] ?>" class="status_flag" style="background-color:<?= $stati[$pacchetto["stato"]]["color"] ?>; display: inline-block"></div><? |
|
$row[] = ob_get_clean(); |
|
|
|
$row[] = $pacchetto["codice"]; |
|
$row[] = strtoupper($pacchetto["modulo"]); |
|
ob_start(); |
|
if($pacchetto["tipologia"] == "download") { |
|
?><i class="text-primary fas fa-download mr-3"></i><? |
|
} else { |
|
?><i class="text-info fas fa-cloud mr-3"></i><? |
|
} |
|
|
|
$titolo = "PDV AUTOMATICO {$pacchetto["codice"]}/" . date('Y', strtotime($pacchetto["timestamp_creazione"])); |
|
if(! empty($pacchetto["titolo"])) { $titolo = $pacchetto["titolo"]; } |
|
|
|
echo $titolo; |
|
$row[] = ob_get_clean(); |
|
$row[] = ! empty($connettore) ? mysql2date($pacchetto["timestamp_esecuzione"]) : "N/P"; |
|
ob_start(); |
|
?> |
|
<div class="btn-group"> |
|
<button type="button" class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown" data-boundary="window" aria-expanded="false"> |
|
<?= __("Gestisci") ?> |
|
</button> |
|
<div class="dropdown-menu"> |
|
<a class="dropdown-item" href="javascript:void(0)" <?= $pacchetto["stato"] >= 5 ? "onclick=\"showModalWithURL('/backend/conservazione/dettaglio/view.php?codice={$pacchetto["codice"]}')\"" : null ?>"><i class="fas fa-<?= $pacchetto["stato"] > 0 ? 'search' : 'cog fa-spin '?> mr-2"></i>Visualizza Contenuto</a> |
|
<? if(empty($package_files) && strtotime($pacchetto["timestamp"]) <= strtotime('-3 hours')) {?><a class="dropdown-item text-dark" href="javascript:void(0)" onclick="confirmBeforeSubmit('<?= $pacchetto['codice'] ?>', '/backend/conservazione/files.php')"><i class="fas fa-search mr-2"></i>Recupera tutti i documenti</a><?} ?> |
|
<div class="dropdown-divider"></div> |
|
<? |
|
if(! empty($connettore) && $pacchetto["tipologia"] == "conservazione") { |
|
if($pacchetto["stato"] > 0 && $pacchetto["stato"] < 6) { |
|
?><a class="dropdown-item text-primary" href="javascript:void(0)" onclick="confirmBeforeSubmit('<?= $pacchetto['codice'] ?>', '/backend/conservazione/invia.php')"><i class="fas fa-angle-double-up mr-2"></i><?= __("Invia Adesso") ?></a><? |
|
} |
|
if(strtotime($pacchetto["timestamp_esecuzione"]) > strtotime('now') && $pacchetto["stato"] < 10) { |
|
?><a class="dropdown-item text-danger" href="javascript:void(0)" onclick="confirmBeforeSubmit('<?= $pacchetto['codice'] ?>', '/backend/conservazione/annulla.php')"><i class="fas fa-stop mr-2"></i><?= __("Annulla") ?></a><? |
|
} |
|
if($pacchetto["stato"] >= 10 && $pacchetto["stato"] < 20) { |
|
if(! empty($documents[90])) { |
|
?> |
|
<div class="dropdown-divider"></div> |
|
<span class="dropdown-item text-danger text-muted text-wrap" style="max-width: 300px;"><?= __("Attenzione, alcuni documenti non sono stati versati correttamente. Si prega ri riprovare.") ?></span> |
|
<a class="dropdown-item text-primary font-weight-bold" href="javascript:void(0)" onclick="confirmBeforeSubmit('<?= $pacchetto['codice'] ?>', '/backend/conservazione/invia.php')"><i class="fas fa-angle-double-up mr-2"></i><?= __("Rinvia i documenti in errore") ?></a> |
|
<div class="dropdown-divider"></div> |
|
<? |
|
} |
|
?> |
|
<a class="dropdown-item text-primary" href="javascript:void(0)"><i class="fas fa-spinner fa-spin mr-2"></i><?= __("Invio in corso") ?></a> |
|
<a class="dropdown-item text-primary" href="javascript:void(0)" onclick="confirmBeforeSubmit('<?= $pacchetto['codice'] ?>', '/backend/conservazione/check.php')"><i class="fas fa-question mr-2"></i><?= __("Verifica lo stato") ?></a> |
|
<? |
|
} |
|
if($pacchetto["stato"] >= 20 && $pacchetto["stato"] < 90) { |
|
?><a class="dropdown-item text-primary" href="javascript:void(0)" onclick="confirmBeforeSubmit('<?= $pacchetto['codice'] ?>', '/backend/conservazione/check.php')"><i class="fas fa-question mr-2"></i><?= __("Ricevi l'aggiornamento di stato") ?></a><? |
|
} |
|
if($pacchetto["stato"] == 110 || $pacchetto["stato"] == 90) { |
|
if(empty($package_files)) { |
|
?><a class="dropdown-item text-primary" href="javascript:void(0)" onclick="confirmBeforeSubmit('<?= $pacchetto['codice'] ?>', '/backend/conservazione/riavvia.php?recupera-file=1')"><i class="fas fa-redo mr-2"></i><?= __("Verifica la presenza di documenti") ?></a><? |
|
} else { |
|
?><a class="dropdown-item text-primary" href="javascript:void(0)" onclick="confirmBeforeSubmit('<?= $pacchetto['codice'] ?>', '/backend/conservazione/riavvia.php')"><i class="fas fa-redo mr-2"></i><?= __("Riavvia il processo") ?></a><? |
|
} |
|
} |
|
} else { |
|
if(! empty($package_files)) { |
|
if($pacchetto["archivio"] == "W") { |
|
?><a class="dropdown-item" href="javascript:void(0)"><i class="fas fa-cog fa-spin mr-2"></i><?= __("Archivio in preparazione") ?></a><? |
|
} else { |
|
?><a class="dropdown-item <?= $pacchetto["archivio"] == "S" ? "text-primary" : "text-info" ?>" href="/backend/conservazione/download.php?codice=<?= $pacchetto["codice"] ?>"><i class="fas fa-download mr-2"></i><?= __("Download") ?></a><? |
|
} |
|
} |
|
} |
|
?> |
|
</div> |
|
</div> |
|
<? |
|
$row[] = ob_get_clean(); |
|
|
|
$return["data"][] = $row; |
|
|
|
} |
|
|
|
} |
|
|
|
echo json_encode($return); |
|
|
|
} |
|
|
|
} |
|
?>
|
|
|