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.
260 righe
12 KiB
260 righe
12 KiB
<?php |
|
|
|
$configPath = substr(__DIR__, 0, strpos(__DIR__, "/public_html")) . "/config.php"; |
|
include_once($configPath); |
|
|
|
// Implementazione vista schede multiple |
|
$subfolder = $_GET["subfolder"] ?? null; |
|
if($subfolder !== null) { |
|
$subfolder = trim(preg_replace("/[^A-Z0-9_.-]+/", "", $subfolder)); |
|
if(empty($subfolder)) $subfolder = null; |
|
} |
|
|
|
if (!empty($_GET["codice_lotto"]) && !empty($_GET["codice_fascicolo"]) && $_SESSION["utente"]->permission($radice, $_GET["codice_fascicolo"])) { |
|
|
|
$npa = NuovaPiattaformaAppalti::init($_GET["codice_fascicolo"]); |
|
if (!empty($npa)) { |
|
|
|
$basePath = str_replace("backend/", "", explode('?', $_SERVER["REQUEST_URI"], 2)[0]); |
|
$npa->setLotto($_GET["codice_lotto"]); |
|
if (!empty($npa->lot)) { |
|
|
|
$breadcrumb = array(); |
|
$breadcrumb["/{$npa->fascicolo["modulo_riferimento"]}/"] = Modulo::getInfo($npa->fascicolo["modulo_riferimento"])["titolo"]; |
|
$breadcrumb["/{$npa->fascicolo["modulo_riferimento"]}/panel.php?codice={$npa->oggetto->info["codice"]}&codice_round={$npa->oggetto->round["codice"]}"] = __("Pannello"); |
|
$breadcrumb["/{$npa->fascicolo["modulo_riferimento"]}/npa/index.php?codice={$npa->oggetto->info["codice"]}&codice_round={$npa->oggetto->round["codice"]}"] = "ANAC"; |
|
if($subfolder === null) { |
|
$breadcrumb[""] = "Lotto #{$npa->lot["codice_lotto_npa"]}"; |
|
} else { |
|
parse_str($_SERVER['QUERY_STRING'], $current_query); |
|
unset($current_query["subfolder"]); |
|
|
|
$topfolder_url = $basePath . "?" . http_build_query($current_query); |
|
$breadcrumb[ $topfolder_url] = "Lotto #{$npa->lot["codice_lotto_npa"]}"; |
|
$breadcrumb[""] = $subfolder; |
|
} |
|
|
|
|
|
include_once($beRoot . "/layout/top.php"); |
|
require_once "{$beRoot}/npa/inc/components/service_status.php"; |
|
?> |
|
<div class="mt-5"> |
|
<h1 style="border-bottom: 5px solid gray" class="clearfix"> |
|
<?php if($subfolder !== null) : ?> |
|
<?= __("Schede") ?> <?= $subfolder ?> |
|
<?php else: ?> |
|
<?= __("Lotto") ?> #<?= $npa->lot["codice_lotto_npa"] ?> |
|
<?php endif; ?> |
|
</h1> |
|
<h3> |
|
<?php if($subfolder === null) : ?> |
|
<?= $npa->lot["oggetto"] ?> |
|
<?php else: ?> |
|
<?= __("Lotto") ?> #<?= $npa->lot["codice_lotto_npa"] ?> (<?= $npa->lot["oggetto"] ?>) |
|
<?php endif; ?> |
|
</h3> |
|
</div> |
|
<? |
|
|
|
$stati = $npa->listAvailableStatusList(); |
|
$cards = $npa->oggetto->getDescendantCards(); |
|
$nextCards = $npa->getNextCards(); |
|
$schede_disponibili = $npa->getCardsByType(); |
|
|
|
// Assicuriamoci che vengano mostrate tutte le schede create |
|
if(!empty($schede_disponibili)) { |
|
foreach($schede_disponibili as $id => $schede) { |
|
if(!empty($schede)) { |
|
$scheda = $schede[0]; |
|
$cards[$scheda["categoria"]][$id] = $scheda; |
|
} |
|
} |
|
} |
|
|
|
$all_empty = true; |
|
|
|
foreach ($cards as $type => &$list) { |
|
$list = $npa->sortCardsByHierarchy($npa->filterCardsByType($list, true)); |
|
if (!empty($list)) { |
|
$all_empty = false; |
|
?> |
|
<div class="row my-3"> |
|
<div class="col-12"> |
|
<div class="card"> |
|
<div class="card-header"> |
|
<h3 class="card-title mb-0"><?= ucfirst($type) ?></h3> |
|
</div> |
|
<div class="card-body mr-3"> |
|
<? |
|
foreach ($list as $id => $card) { |
|
if($subfolder !== null && $subfolder !== $id) { continue; } |
|
$print_add_scheda = true; |
|
$has_multiple = count($schede_disponibili[$id] ?? []) > 1; |
|
|
|
if ($has_multiple) : |
|
$multiple_id = uniqid("multiple"); |
|
parse_str($_SERVER['QUERY_STRING'], $current_query); |
|
$current_query["subfolder"] = $id; |
|
$subfolder_url = "/backend" . $basePath . "?" . http_build_query($current_query) |
|
?> |
|
<?php if($subfolder === null) : ?> |
|
<a href="<?= $subfolder_url ?>" style="background: linear-gradient(var(--info), var(--primary)); !important" class="pl-3 btn my-1 btn-block btn-primary text-left" data-target="#<?= $multiple_id ?>"> |
|
<div class="d-flex"> |
|
<div class="mr-3 align-self-center"> |
|
<i class="fa fa-folder fa-lg"></i> |
|
</div> |
|
<div> |
|
<span class="title"><?= str_replace('_', '.', $id) ?>) <strong><?= $schede_disponibili[$id][0]["titolo"] ?></strong></span><br> |
|
<span class="status"></span> |
|
</div> |
|
</div> |
|
</a> |
|
<?php else: ?> |
|
<a href="/backend<?= $topfolder_url ?>" class="pl-3 btn my-1 btn-block btn-warning text-left" > |
|
<div class="d-flex"> |
|
<div class="mr-3 align-self-center"> |
|
<i class="fa fa-folder-open fa-lg"></i> |
|
</div> |
|
<div> |
|
<span class="title"><?= __("Cartella superiore") ?></strong></span><br> |
|
<span class="status"></span> |
|
</div> |
|
</div> |
|
</a> |
|
<?php endif; ?> |
|
<div class="multiple-container <?= $subfolder === null ? "collapse" : "" ?>" id="<?= $multiple_id ?>"> |
|
<?php endif; |
|
$is_multiple = false; |
|
$info = $npa->metadataSchede[$id]; |
|
foreach ($schede_disponibili[$id] ?? [] as $scheda) : |
|
$stato = $stati[$scheda["stato"]] ?? $stati[-999]; |
|
if ($scheda["errore"] !== "NO") { |
|
$stato["title"] = __("Errore nello stato:") . " \"{$stato["title"]}\""; |
|
$stato["class"] = "danger"; |
|
$stato["icon"] = "fa fa-times-circle"; |
|
} |
|
$print_add_scheda = $info["multipla"] && in_array($id, $nextCards); |
|
$is_multiple = true; |
|
|
|
$query = [ |
|
"codice" => $scheda["codice"] ?? 0, |
|
"scheda" => $id, |
|
"codice_lotto" => $npa->lot["codice_lotto_npa"], |
|
"modulo_riferimento" => $npa->fascicolo["modulo_riferimento"] ?? null, |
|
"id_riferimento" => $npa->fascicolo["id_riferimento"] ?? null |
|
]; |
|
$query = http_build_query($query); |
|
?> |
|
<a href="/backend/npa/edit.php?<?= $query ?>" class="btn my-1 status-border-<?= $stato["class"] ?> btn-block btn-info text-left"> |
|
<div class="d-flex"> |
|
<div class="mr-3 align-self-center"> |
|
<i class="fa fa-file fa-lg"></i> |
|
</div> |
|
<div> |
|
<span class="title"><?= str_replace('_', '.', $id) ?>) <strong><?= $card["titolo"] ?></strong> - <i><?= mysql2datetime($scheda["timestamp_creazione"]) ?></i></span><br> |
|
<span class="status" data-class="<?= $stato["class"] ?>"><i class="<?= $stato["icon"] ?> mr-2"></i><?= $stato["title"] ?></span> |
|
</div> |
|
</div> |
|
|
|
</a> |
|
<?php endforeach ?> |
|
|
|
<?php if ($print_add_scheda) : |
|
$query = [ |
|
"codice" => 0, |
|
"scheda" => $id, |
|
"codice_lotto" => $npa->lot["codice_lotto_npa"], |
|
"modulo_riferimento" => $npa->fascicolo["modulo_riferimento"] ?? null, |
|
"id_riferimento" => $npa->fascicolo["id_riferimento"] ?? null |
|
]; |
|
$query = http_build_query($query); ?> |
|
<a href="/backend/npa/edit.php?<?= $query ?>" class="btn my-1 btn-block btn-secondary status-border-<?= $is_multiple ? "success" : "secondary" ?> text-left"> |
|
<div class="row align-items-center"> |
|
<div class="col-8"> |
|
<span><?= str_replace('_', '.', $id) ?>) <strong><?= $card["titolo"] ?></strong></span><br> |
|
<p class="badge badge-primary mb-1"> |
|
<?= ucfirst($card['evento']) ?> |
|
</p><hr class="my-1"> |
|
<i class="fa fa-plus-circle mr-2"></i><span> <?= $is_multiple ? __("Crea nuova") : __("Da creare") ?></span> |
|
</div> |
|
<?php if(!$is_multiple): ?> |
|
<div class="col-4"> |
|
<div class="d-flex pl-3 flex-column justify-content-center"> |
|
<?php if(!empty($card["guue"])) : ?> |
|
<p class="mb-1 badge badge-info"> |
|
GUUE richiesta: <?= implode(",", $card["guue"]); ?> |
|
</p> |
|
<?php endif; ?> |
|
<?php if($card["partecipanti"] == true) : ?> |
|
<p class="mb-1 badge badge-warning"> |
|
Richiede partecipanti |
|
</p> |
|
<?php endif; ?> |
|
<?php if($card["aggiudicatari"] == true) : ?> |
|
<p class="mb-1 badge badge-warning"> |
|
Richiede aggiudicazione |
|
</p> |
|
<?php endif; ?> |
|
</div> |
|
</div> |
|
<?php endif; ?> |
|
</div> |
|
</a> |
|
<?php endif; |
|
if ($has_multiple) : ?> |
|
</div> |
|
<?php endif; |
|
} |
|
?> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
<script> |
|
document.addEventListener('DOMContentLoaded', function() { |
|
document.querySelectorAll(".multiple-container").forEach(function(container) { |
|
let statuses = {}; |
|
|
|
container.querySelectorAll(".status").forEach(function(status) { |
|
if(!statuses[status.innerHTML]) { |
|
statuses[status.innerHTML] = {'count' : 0, 'class' : status.dataset.class}; |
|
} |
|
statuses[status.innerHTML]["count"]++; |
|
}); |
|
let status_string = ""; |
|
for([status, data] of Object.entries(statuses)) { |
|
let count = data["count"] > 1 ? ` (${data['count']})` : ''; |
|
status_string += `<span class="badge badge-${data['class']} mr-1">${status}${count}</span>`; |
|
} |
|
document.querySelector(`[data-target='#${container.id}'] .status`).innerHTML = status_string; |
|
}) |
|
}) |
|
</script> |
|
<? |
|
} |
|
} |
|
if ($all_empty) { |
|
?> |
|
<div class="card"> |
|
<div class="card-body"> |
|
<? alertManager::printWarningBox(__("Non sono ancora disponibili schede per questo lotto."), __("Verificare che tutte le schede generali siano state pubblicate.")); ?> |
|
</div> |
|
</div> |
|
<? |
|
} |
|
echo NuovaPiattaformaAppalti::printJavascriptBoilerplate(); |
|
include_once($beRoot . "/layout/bottom.php"); |
|
exit(); |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
header('HTTP/1.0 403 Forbidden'); |
|
$referer = $_SERVER["HTTP_REFERER"]; |
|
?> |
|
<h1>Forbidden</h1> |
|
<a href="<?= $referer ?>"><?= __("Ritorna") ?></a> |
|
<? |
|
exit;
|
|
|