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.
900 righe
32 KiB
900 righe
32 KiB
<? |
|
$_cdir = __DIR__; |
|
$configPath = substr(__DIR__, 0, strpos(__DIR__, "/public_html")) . "/config.php"; |
|
include_once($configPath); |
|
|
|
if (empty($_SESSION["utente"]) || !$_SESSION["utente"]->permission($radice) || empty($_GET["form"])) { |
|
|
|
die("<meta http-equiv='refresh' content='0;URL=/backend/{$radice}'>"); |
|
} |
|
|
|
include_once "{$_cdir}/class/TedEsender.class.php"; |
|
|
|
$settings = TedEsender::getSettings(); |
|
|
|
|
|
// Se l'utente sta indicando modulo e codice elemento esplicitamente |
|
// - In realtà vengono linkati da altri moduli, per poi essere settati |
|
$modulo = purify($_GET["modulo"] ?? ""); // Modulo collegato (gara/pcp/appalto) |
|
$codice_elemento = intval(purify($_GET["codice_elemento"] ?? "")); // elemento del modulo collegato |
|
|
|
if (!empty($modulo) && !empty($codice_elemento)) { |
|
|
|
// Verifichiamo che il modulo esista e sia compatibile |
|
$modulo_collegato = TedEsender::moduliCollegati()[$_GET["modulo"]] ?? null; |
|
// Verifichiamo il permesso |
|
if ($modulo_collegato && $_SESSION["utente"]->permission($modulo, $codice_elemento)) { |
|
// Pass |
|
} else { |
|
die("<meta http-equiv='refresh' content='0;URL=/backend/{$radice}'>"); |
|
} |
|
} |
|
// Codice del form |
|
$codice = 0; |
|
// Sottosezione attuale |
|
$subsection_index = 0; |
|
|
|
|
|
|
|
if (!empty($_GET["codice"]) && is_numeric($_GET["codice"])) { |
|
$codice = $_GET["codice"]; |
|
} |
|
if (!empty($_GET["subsection_index"]) && is_numeric($_GET["subsection_index"])) { |
|
$subsection_index = $_GET["subsection_index"]; |
|
} |
|
// ID del form |
|
$notice = purify($_GET["form"]); |
|
|
|
// Verifica versione (codice legacy) |
|
if (TedEsender::getVersion($codice) == "eSender") { |
|
if (strpos($notice, ".xsd") === false) { |
|
$notice .= ".xsd"; |
|
} |
|
} |
|
|
|
// Verifica che il form esista |
|
if (!in_array($notice, array_keys($settings["forms"]))) { |
|
die("<meta http-equiv='refresh' content='0;URL=/backend/{$radice}'>"); |
|
} |
|
|
|
// istanziamo TED |
|
$ted = new TedEsender($notice, $codice, $settings, "{$_cdir}/config/xml"); |
|
$ted->setMode("edit"); |
|
|
|
// Codice lotto |
|
$lotto_riferimento = $ted->info["lotto_riferimento"]; |
|
|
|
if (empty($lotto_riferimento) && !empty($_GET["codice_lotto"]) && is_numeric($_GET["codice_lotto"])) { |
|
$lotto_riferimento = $_GET["codice_lotto"]; |
|
$ted->info["lotto_riferimento"] = $lotto_riferimento; |
|
} |
|
// Aggiorniamo se necessario il collegamento |
|
if (!empty($modulo) && !empty($codice_elemento)) { |
|
$ted->info["modulo"] = $modulo; |
|
$ted->info["codice_elemento"] = $codice_elemento; |
|
} else { |
|
$modulo = $ted->info["modulo"] ?? null; |
|
$codice_elemento = $ted->info["codice_elemento"] ?? null; |
|
|
|
if ( |
|
empty($ted->info["codice"]) && |
|
!empty($_GET["codice_ente"]) && |
|
in_array($_GET["codice_ente"], array_column($_SESSION["utente"]->getEntiBeneficiari(false), "codice")) |
|
) { |
|
$ted->info["codice_ente"] = (int) $_GET["codice_ente"]; |
|
} |
|
} |
|
|
|
|
|
$ted->debug = DEVELOP_ENV; |
|
|
|
// Verifichiamo che il form non sia cancellato |
|
if (($ted->info["soft_delete"] ?? "N") == "S") { |
|
die("<meta http-equiv='refresh' content='0;URL=/backend/{$radice}'>"); |
|
} |
|
|
|
|
|
// Se abbiamo un modulo associato |
|
if (!empty($modulo) && !empty($codice_elemento)) { |
|
$breadcrumb = []; |
|
$breadcrumb["/{$modulo}"] = Modulo::getInfo($modulo)["titolo"]; |
|
$breadcrumb["/{$modulo}/panel.php?codice={$codice_elemento}"] = __("Pannello"); |
|
$breadcrumb["/{$modulo}/guue/index.php?codice={$codice_elemento}"] = __("GUUE"); |
|
$breadcrumb[""] = "Form " . $ted->info["form"]; |
|
} else { |
|
$breadcrumb = []; |
|
$breadcrumb["/{$radice}/"] = Modulo::getInfo($radice)["titolo"]; |
|
//$breadcrumb = $ted->getBreadcrumb($breadcrumb); |
|
$breadcrumb[""] = "Form " . $ted->info["form"]; |
|
} |
|
|
|
|
|
$required_css[] = "/src/css/extra/files.css"; |
|
$required_js[] = "/src/js/extra/files.js"; |
|
|
|
include_once "{$beRoot}/layout/top.php"; |
|
|
|
if ($ted->version == "eSender") { |
|
?> |
|
<div class="alert alert-danger" role="alert"> |
|
<h1><?= __('Attenzione') ?></h1> |
|
<hr> |
|
<p><?= __('L\'avviso richiesto è stato scritto utilizzando una versione attualmente in disuso del modulo GUUE, si è pregati di tornare alla pagina precedente e creare un nuovo avviso.') ?></p> |
|
<a class="btn btn-primary" href="<?= url('/backend/guue/') ?>">Torna alla pagina precedente</a> |
|
</div> |
|
<? |
|
include_once "{$beRoot}/layout/bottom.php"; |
|
die(); |
|
} |
|
|
|
|
|
//include_once "../npa/inc/components/suggestions.php"; |
|
|
|
|
|
$ted->manageChangeSection(); |
|
|
|
|
|
// Ottieniamo la sezione desiderata |
|
$current_section = $_GET["section"] ?? null; |
|
|
|
$sections = $ted->getReorderedSections(); |
|
$first_section = $sections[0]["name"]; |
|
// Verifichiamo con una regex che sia valida |
|
if ($current_section && preg_match("/GR-([A-Za-z0-9-_])+/i", $_GET["section"]) !== 1) { |
|
$current_section = null; |
|
$_GET["section"] = null; |
|
} |
|
// Se non è valida, peschiamo la prima sezione |
|
if ($current_section == null) { |
|
$current_section = $first_section; |
|
$current_query = []; |
|
parse_str($_SERVER['QUERY_STRING'], $current_query); |
|
$current_query["section"] = $first_section; |
|
$url = "/backend/guue/edit.php?" . http_build_query($current_query); |
|
die("<meta http-equiv='refresh' content='0;URL={$url}'>"); |
|
} |
|
// Otteniamo un array inverso |
|
// "GR-Lot" => 0 |
|
$section_indicies_by_name = array_flip(array_column($sections, "name")); |
|
// Otteniamo l'indice numerico della sezione attuale |
|
$section_index = $section_indicies_by_name[$current_section] ?? null; |
|
|
|
// Abbiamo una sottosezione valida? |
|
$valid_section = true; |
|
// Utile per gestire la sezione non trovata |
|
$first_section_name = $ted->translate($sections[0]["_label"] ?? ""); |
|
// Sezione non trovata |
|
if ($section_index === null) { |
|
$valid_section = false; |
|
$section_name = $_GET["section"]; |
|
} else { |
|
// Otteniamo i nomi |
|
$section_name = $ted->translate($sections[$section_index]["_label"] ?? ""); |
|
|
|
|
|
// Otteniamo le sezioni ripetibili e le ripetizioni attuali |
|
$section_repetitions_by_name = $ted->getRepeatableSections(); |
|
// Ripetizioni via indice numerico |
|
$sections_repetitions_by_index = []; |
|
foreach ($section_repetitions_by_name as $key => $value) { |
|
$index = $section_indicies_by_name[$key] ?? null; |
|
if ($index !== null) { |
|
$sections_repetitions_by_index[$index] = $value["value"]; |
|
} |
|
} |
|
// Otteniamo l'indice di sottosezione richiesto dall'utente |
|
$subsection_index = $_GET["subsection_index"] ?? null; |
|
if (!is_numeric($subsection_index)) { |
|
$subsection_index = 0; |
|
} |
|
|
|
// Logica: |
|
// Se è ripetibile, ottiene le ripetizioni attuali della sezione da 0 a X |
|
// Se non è ripetibile, ottiene null |
|
$current_section_repetitions = empty($section_repetitions_by_name[$current_section]) ? null : $section_repetitions_by_name[$current_section]["value"]; |
|
|
|
|
|
|
|
// Se non è ripetibile, solo 0 è accettabile |
|
if ($current_section_repetitions == null) { |
|
if ($subsection_index != 0) { |
|
$valid_section = false; |
|
} |
|
// Se è ripetibile, è accettabile solo un indice presente (0 non è accettabile se abbiamo 0 ripetizioni) |
|
} else { |
|
if ($subsection_index >= $current_section_repetitions) { |
|
if ($current_section_repetitions > 0) { |
|
// Facciamo fallback sull'ultima disponibile |
|
$subsection_index = $current_section_repetitions - 1; |
|
} else { |
|
$valid_section = false; |
|
} |
|
} |
|
} |
|
} |
|
|
|
// Sanitizziamo i parametri per uso successivo |
|
$_GET["subsection_index"] = $subsection_index; |
|
$_GET["section"] = $current_section; |
|
|
|
|
|
// Calcoliamoci Previous e Next |
|
$previous = []; |
|
// Se non siamo nella prima sezione |
|
if ($section_index > 0) { |
|
// Verifichiamo di essere in una ripetizione |
|
if ($subsection_index > 0) { |
|
// Passiamo semplicemente all'index di sottosezione precedente |
|
$previous["name"] = $sections[$section_index]["name"]; |
|
$previous["index"] = $subsection_index - 1; |
|
} |
|
// Non siamo in una ripetizione o siamo all'indice 0 di una ripetizione, ergo cambiamo sezione |
|
else { |
|
// Prendiamo la sezione precedente |
|
$previous_index = $section_index - 1; |
|
$previous_subsection_index = 0; |
|
do { |
|
// Verifichiamo che la sezione precedente non sia ripetibile |
|
if (!isset($sections_repetitions_by_index[$previous_index])) { |
|
// In quel caso possiamo navigarci senza problema all'indice 0 |
|
$previous_subsection_index = 0; |
|
break; |
|
} |
|
// Verifichiamo che ci sia almeno una ripetizione |
|
if ($sections_repetitions_by_index[$previous_index] == 0) { |
|
// Se non ci sono ripetizioni, la sezione non è transitabile |
|
if (--$previous_index < 0) { |
|
// Se abbiamo esaurito le opzioni, muoriamo male |
|
break; |
|
} |
|
// Continuiamo con quella precedente |
|
continue; |
|
} |
|
// Transitiamo sull'ultima ripetizione disponibile |
|
$previous_subsection_index = $sections_repetitions_by_index[$previous_index] - 1; |
|
break; |
|
} while (true); |
|
|
|
// Abbiamo trovato qualcosa, popoliamo previous |
|
if ($previous_index >= 0) { |
|
$previous["name"] = $sections[$previous_index]["name"]; |
|
$previous["index"] = $previous_subsection_index; |
|
} |
|
} |
|
} |
|
|
|
$next = []; |
|
// Verifichiamo di essere in una non ripetizione o nell'ultima ripetizione |
|
if (empty($sections_repetitions_by_index[$section_index]) || $subsection_index >= $sections_repetitions_by_index[$section_index] - 1) { |
|
// In questo caso dobbiamo solo rimandare alla prossima sezione, se esiste |
|
$next_index = $section_index; |
|
$next_subsection_index = 0; |
|
do { |
|
// Se abbiamo esaurito le opzioni, muoriamo male |
|
if (empty($sections[++$next_index])) { |
|
$next_index = null; |
|
break; |
|
} |
|
// Verifichiamo che la sezione successiva non sia ripetibile |
|
if (!isset($sections_repetitions_by_index[$next_index])) { |
|
// In quel caso possiamo navigarci senza problema all'indice 0 |
|
$next_subsection_index = 0; |
|
break; |
|
} |
|
// Verifichiamo che ci sia almeno una ripetizione |
|
if ($sections_repetitions_by_index[$next_index] == 0) { |
|
// Se non ci sono ripetizioni, la sezione non è transitabile |
|
// Continuiamo con quella successiva |
|
continue; |
|
} |
|
// Transitiamo sulla prima ripetizione disponibile |
|
$next_subsection_index = 0; |
|
break; |
|
} while (true); |
|
if ($next_index !== null) { |
|
$next["name"] = $sections[$next_index]["name"]; |
|
$next["index"] = $next_subsection_index; |
|
} |
|
} |
|
// Altrimenti, navighiamo semplicemente nella prossima sottosezione |
|
else { |
|
$next["name"] = $sections[$section_index]["name"]; |
|
$next["index"] = $subsection_index + 1; |
|
} |
|
|
|
// Fix di errori singoli |
|
$ted_errors = $ted->errors ?? null; |
|
if (!empty($ted_errors) && !array_is_list($ted_errors)) { |
|
$ted_errors = [$ted_errors]; |
|
} |
|
|
|
// Verifica stato di successo successo |
|
$validation_success = false; |
|
if (isset($_SESSION["guue_verified_" . $ted->info["codice"]])) { |
|
unset($_SESSION["guue_verified_" . $ted->info["codice"]]); |
|
$validation_success = true; |
|
} |
|
|
|
// Mettiamo da parte i tasti di navigazione |
|
ob_start(); |
|
|
|
?> |
|
<?php if (!empty($previous)) : ?> |
|
<button title="<?= __guue("Vai alla sezione precedente") ?>" disabled onclick="switchSection('<?= $previous['name'] ?? null ?>', '<?= $previous['index'] ?? null ?>')" class="guue-nav-button btn btn-outline-primary"> |
|
<span class="fa fa-backward"></span> |
|
<span class="nav-text ml-2"><?= __guue("Indietro") ?></span> |
|
</button> |
|
<?php endif; ?> |
|
<?php if (!empty($next)) : ?> |
|
<button title="<?= __guue("Vai alla sezione successiva") ?>" disabled onclick="switchSection('<?= $next['name'] ?? null ?>', '<?= $next['index'] ?? null ?>')" class="guue-nav-button btn btn-outline-primary ml-3"> |
|
<span class="fa fa-forward"></span> |
|
<span class="nav-text ml-2"><?= __guue("Avanti") ?></span> |
|
</button> |
|
<?php endif; ?> |
|
|
|
<?php |
|
$fully_completed = $ted->completed(); |
|
?> |
|
<?php if (!$ted->isReadyForAnacTransmission()) : ?> |
|
<button title="<?= __guue("Verifica formalmente i dati inseriti e salva la sezione corrente.") ?>" disabled onclick="saveSection('<?= $form['name'] ?? null ?>', '<?= $form['index'] ?? null ?>', 'save-and-remain')" class="guue-nav-button btn btn-success ml-3"> |
|
<span class="fa fa-save"></span> |
|
<span class="nav-text ml-2"><?= __guue("Salva sezione") ?></span> |
|
</button> |
|
<?php endif; ?> |
|
<?php if ($ted->canBeReadyForAnac()) : //($ted->info["stato"] ?? "") === "DA TRASMETTERE") : ?> |
|
<?php $link = "/backend/guue/ready.php?codice={$ted->info["codice"]}&form={$ted->info["form"]}&ready=true" ?> |
|
<a class="btn btn-info ml-3" onclick="form_ready(`<?= $link ?>`, true)" title="<?= __guue("Blocca le modifiche e rende il Form pronto per ANAC") ?>"> |
|
<span class="fa fa-lock"></span> |
|
<span class="nav-text ml-2"><?= __guue("Pronto per ANAC") ?></span> |
|
</a> |
|
<?php elseif($ted->canBeUnlockedForANAC()) : ?> |
|
<?php $link = "/backend/guue/ready.php?codice={$ted->info["codice"]}&form={$ted->info["form"]}&ready=false" ?> |
|
<a class="btn btn-warning ml-3" onclick="form_ready(`<?= $link ?>`, false)" title="<?= __guue("Sblocca le modifiche per correggere il form") ?>"> |
|
<span class="fa fa-unlock"></span> |
|
<span class="nav-text ml-2"><?= __guue("Sblocca modifiche") ?></span> |
|
</a> |
|
<?php elseif ($fully_completed && !$ted->isReadyForAnacTransmission()) : ?> |
|
<button onclick="verify()" class="btn btn-info ml-3 " title="<?= __guue("Verifica il form per la trasmissione") ?>"> |
|
<span class="fa fa-check"></span> |
|
<span class="nav-text ml-2"><?= __guue("Verifica per la trasmissione") ?></span> |
|
</button> |
|
<?php endif; ?> |
|
|
|
|
|
<?php |
|
$navigation_buttons = ob_get_clean(); |
|
|
|
$readonly = false; |
|
if ($ted->isReadyForAnacTransmission()) { |
|
//$navigation_buttons = ""; |
|
$readonly = true; |
|
} |
|
$small_navigation_buttons = str_replace('class="nav-text ml-2"', 'style="display:none;"', $navigation_buttons); |
|
|
|
?> |
|
|
|
|
|
|
|
<?php if (!$valid_section) : ?> |
|
<!-- Invalid section handler --> |
|
<div class="pb-1"> |
|
<div class="alert alert-danger"> |
|
<h4><?= __guue("Sezione \"{$section_name}\" non trovata.") ?></h4> |
|
<hr> |
|
<button onclick="switchSection('<?= $first_section ?>', 0, true)" class="btn btn-outline-primary"> |
|
<span class="fa fa-backward"></span> |
|
<?= __guue("Torna a ") . $first_section_name ?> |
|
</button> |
|
</div> |
|
</div> |
|
<?php else : ?> |
|
<div class="row"> |
|
<div class="col flex-grow-1"> |
|
<?php include_once($beRoot . "/layout/top.php"); ?> |
|
<div class="pt-5 pb-3"> |
|
<div class="row"> |
|
<div class="col-12"> |
|
<h2> |
|
<?= Modulo::header($radice) ?> |
|
</h2> |
|
<hr> |
|
<h3><?= $ted->title ?? "Notice" ?></h3> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
<div class="col flex-grow-0 align-self-center"> |
|
<div class="row"> |
|
<div id="guue-big-nav" class="col-12 px-4 d-flex justify-content-end text-nowrap"> |
|
<?= $navigation_buttons; ?> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<div class=" pt-3"> |
|
<?php if ($validation_success) : ?> |
|
|
|
<div class="pb-1"> |
|
<div class="alert alert-success"> |
|
<h4><?= __guue('Validazione superata') ?></h4> |
|
<hr> |
|
<p> |
|
Congratulazioni! Il form ha superato la validazione ed è pronto per essere trasmesso! |
|
</p> |
|
<?php |
|
if ($ted->advanced_debug) : |
|
?> |
|
<a class="btn btn-primary d-block" href='#' onclick="downloadElementContents(document.getElementById('debug_physical_model'), 'modello_fisico.xml')"> |
|
Download XML (validazione) |
|
</a> |
|
<pre id='debug_physical_model' style='width:100%; max-height: 300px; overflow-y: scroll'><?= print_r(htmlspecialchars($ted->toXML()), true) ?></pre> |
|
<?php |
|
endif; |
|
?> |
|
</div> |
|
</div> |
|
<?php endif; ?> |
|
<? if (!empty($ted_errors)) { ?> |
|
<div class="pb-1"> |
|
<div class="alert alert-danger"> |
|
<h4><?= __guue('Errori di validazione GUUE') ?></h4> |
|
<hr> |
|
<div style="max-height: 300px; overflow-y: scroll;"> |
|
<ul> |
|
<?php foreach ($ted_errors as $error) : ?> |
|
<li><?= $ted->processErrorForDisplay($error); ?></li> |
|
<?php endforeach; ?> |
|
<?php |
|
if ($ted->advanced_debug) : |
|
?> |
|
<a class="btn btn-primary d-block" href='#' onclick="downloadElementContents(document.getElementById('debug_physical_model'), 'modello_fisico.xml')"> |
|
Download XML (validazione) |
|
</a> |
|
<pre id='debug_physical_model' style='width:100%; max-height: 300px; overflow-y: scroll'><?= print_r(htmlspecialchars($ted->toXML()), true) ?></pre> |
|
<?php |
|
endif; |
|
?> |
|
</ul> |
|
</div> |
|
</div> |
|
</div> |
|
<? } ?> |
|
<?php if(empty($ted->__get("npa"))): ?> |
|
<?php if(!$fully_completed && $ted->info["codice"] > 0) { |
|
alertManager::printAlertBox("Scheda GUUE non collegata", "Torna alla scheda ANAC di competenza e ri-seleziona questa scheda GUUE per associarle e proseguire con la modifica"); |
|
$readonly = true; |
|
} |
|
?> |
|
<?php else: ?> |
|
|
|
<?php |
|
$cardLink = $ted->npa->getCardLink(); |
|
$ted->setSuggestions(); |
|
|
|
?> |
|
<?php if($cardLink): ?> |
|
<a class="btn btn-info text-left btn-block mb-2" href="<?= $cardLink ?>"> |
|
<i class="fas fa-link mr-2"></i> |
|
Collegata alla scheda ANAC n°<?= $ted->npa->scheda["codice"] ?> |
|
</a> |
|
<? $pubblicazione = unserialize($ted->npa->scheda["pubblicazione"] ?? ""); ?> |
|
<?php NuovaPiattaformaAppalti::printPubblicazioneEU($pubblicazione, true); ?> |
|
<?php endif; ?> |
|
<?php endif; ?> |
|
<form id="guue-form" rel="validate" method="post" class="mt-2" action="/backend/guue/save.php"> |
|
<input type="hidden" name="modulo" value="<?= $ted->info["modulo"] ?? null ?>"> |
|
<input type="hidden" name="codice_elemento" value="<?= $ted->info["codice_elemento"] ?? null ?>"> |
|
<input type="hidden" name="lotto_riferimento" value="<?= $ted->info["lotto_riferimento"] ?? null ?>"> |
|
|
|
<?php if (!empty($ted->info["titolo"])) : ?> |
|
<input type="hidden" name="titolo" value="<?= $ted->info["titolo"] ?>"> |
|
<input type="hidden" name="codice_ente" value="<?= $ted->info["codice_ente"] ?>"> |
|
<?php endif; ?> |
|
<?php if ($current_section == $sections[0]["name"] || $current_section == "GR-Organisations-Section") : ?> |
|
<div class="row" id="form-metadata"> |
|
<div class="col-sm-12 mb-3"> |
|
<div class="card"> |
|
<div class="card-header"> |
|
<p class="h5 text-muted mb-0"><?= __guue("Informazioni sul form") ?></p> |
|
</div> |
|
<div class="card-body"> |
|
<?php if($readonly): ?> |
|
<fieldset disabled> |
|
<?php endif; ?> |
|
<div class="row"> |
|
<div class="form-group col-12"> |
|
<label for="titolo"><?= __guue('Titolo del form') ?>: <?= TedEsender::MANDATORY_ASTERISK ?></label> |
|
<input type="text" rel="S;2;0;A" class="form-control" name="titolo" aria-describedby="help-text-titolo" value="<?= $ted->info["titolo"] ?>" title="<?= __guue('titolo') ?>"> |
|
<small id="help-text-titolo" class="form-text text-muted"><?= __guue("Inserire una breve descrizione utile per individuare il form nelle fasi successive") ?>.</small> |
|
</div> |
|
|
|
|
|
<?php if(false) : // Scelta enti disattiva ?> |
|
<?php $enti = $_SESSION["utente"]->getEntiBeneficiari(false); |
|
if ($enti !== false) : ?> |
|
|
|
<div class="form-group col-sm"> |
|
<label for="codice_ente"><?= __guue("Beneficiario") ?>: <?= TedEsender::MANDATORY_ASTERISK ?> </label> |
|
<select name="codice_ente" onChange="window.location.href='/backend/guue/edit.php?form=<?= $notice ?>&codice_ente='+$(this).val()" class="form-control" title="<?= __guue("beneficiario") ?>" rel="S;0;0;N" id="codice_ente"> |
|
<option value="">Seleziona...</option> |
|
<? |
|
foreach ($enti as $ente) { |
|
?> |
|
<option <?= $ted->info["codice_ente"] == $ente["codice"] ? 'selected="selected"' : null ?> value="<?= $ente["codice"] ?>"><?= $ente["denominazione"] ?></option> |
|
<? |
|
} |
|
?> |
|
</select> |
|
</div> |
|
<?php else: ?> |
|
<input id="codice_ente" type="hidden" name="codice_ente" value="<?= $_SESSION["ente"]->codice ?> |
|
<?php endif; ?> |
|
<?php endif; ?> |
|
<?php if ($ted->version == "eForms") : ?> |
|
<?php if (!empty($section_repetitions_by_name)) : ?> |
|
<?php foreach ($section_repetitions_by_name as $rep) : ?> |
|
<div class="col-sm-2 form-group d-none"> |
|
<?php if(!$rep["reps_locked"]) : ?> |
|
<label for="reps-<?= $ted->slugify($rep["id"]) ?>"><?= $rep["label"] ?>: <?= TedEsender::MANDATORY_ASTERISK ?></label> |
|
<?php endif; ?> |
|
<input type="<?= $rep["reps_locked"] ? "hidden" : "text" ?>" title="<?= $rep["label"]; ?>" class="form-control section-repetition-count" data-identifier="<?= $rep["id"] ?>" data-value="<?= $rep["value"] ?>" rel="<?= $rep["rel"] ?>" name="reps[<?= $rep["id"] ?>]" id="reps-<?= $ted->slugify($rep["id"]) ?>" value="<?= $rep["value"] ?>"> |
|
</div> |
|
<?php endforeach; ?> |
|
<script type="text/javascript"> |
|
$('.section-repetition-count').on('change', function(event) { |
|
//console.log($(this).data('value') > 0, $(this).val() < $(this).data('value'), $(this).val(), $(this).data('value')); |
|
if ($(this).data('value') > 0 && $(this).val() < $(this).data('value')) { |
|
swal({ |
|
title: js_dict.attenzione, |
|
html: "<div class='text-danger rounded-0'><?= __guue("Questa operazione comporterà una perdita di dati per la sezione: ") ?>" + $(this).data("identifier") + "</div>", |
|
type: "warning", |
|
confirmButtonText: "OK", |
|
confirmButtonColor: "#f0ad4e" |
|
}); |
|
} |
|
}) |
|
</script> |
|
<?php endif; ?> |
|
<?php endif; ?> |
|
</div> |
|
|
|
<?php if($readonly): ?> |
|
</fieldset> |
|
<?php endif; ?> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
<?php else : ?> |
|
<!-- Placeholder --> |
|
<div id="form-metadata"></div> |
|
<?php endif; ?> |
|
|
|
<div class="row"> |
|
<div class="col-12 col-md-3 order-2" id="guue-commands"> |
|
<div class="row"> |
|
<div class="col-sm-12"> |
|
<div class="ml-1 mb-3 justify-content-center" id="guue-small-nav" style="transition: height 0.25s ease-out, opacity 0.15s ease-out; display: none;"> |
|
<?= $small_navigation_buttons; ?> |
|
</div> |
|
<?php if(!$readonly): ?> |
|
<?php if (!empty($ted->info["codice"])) : ?> |
|
<div class="alert alert-info" role="alert"> |
|
<i class="fas fa-sm fa-info mr-2"></i> |
|
<span><?= __guue("Il salvataggio delle modifiche è automatico.") ?></span> |
|
</div> |
|
|
|
<?php else : ?> |
|
<div class="alert alert-warning" role="alert"> |
|
<b><i class="fas fa-exclamation-triangle"></i> <?= __guue("Attenzione") ?>!</b> |
|
<?= __guue("Assicurati di inserire un titolo e salvare prima di effettuare modifiche") ?> |
|
</div> |
|
<?php endif; ?> |
|
<?php endif; ?> |
|
|
|
</div> |
|
<div id="guue-sections" class="col-sm-12"> |
|
<div class="list-group"> |
|
<?php |
|
foreach ($sections as $index => $section) { |
|
|
|
|
|
$repetitions = 1; |
|
$repeatable = false; |
|
$section["active"] = $current_section == $section["name"]; |
|
if (!empty($section_repetitions_by_name[$section["id"]])) { |
|
$repetitions = $section_repetitions_by_name[$section["id"]]["value"]; |
|
$repeatable = true; |
|
} |
|
|
|
for ($i = 0; $i < $repetitions; $i++) { |
|
$section["index"] = 0; |
|
$active = $section["active"]; |
|
if ($repetitions > 1) { |
|
$section["index"] = $i; |
|
$section["display_index"] = $i + 1; |
|
if ($active) { |
|
$active = $subsection_index == $i; |
|
} |
|
} |
|
$completed = $ted->isSectionComplete($section["name"], $repeatable ? $i : null); |
|
?> |
|
<?php |
|
$color = "-warning"; |
|
if ($active) { |
|
$color = $completed ? "-success" : "-primary"; |
|
} else { |
|
$color = $completed ? "-success" : "-warning"; |
|
} |
|
?> |
|
<button disabled class="guue-section list-group-item list-group-item<?= $color ?> list-group-item-action <?= $active ? ' active' : null ?>" onclick="switchSection('<?= $section['name'] ?>','<?= $section['index'] ?? null ?>')"> |
|
<span class="<?= !empty($section["subsection"]) ? 'pl-4 ' : null ?><?= !$active ? '' : null ?>"><i class="fas <?= $completed ? 'fa-check-circle' . (!$active ? ' text-success' : null) : 'fa-times-circle ' . (!$active ? ' text-warning' : null) ?> mr-2"></i></span> |
|
<?= $ted->translate($section["_label"] ?? ($section["subsection"] ?? $section["name"])) ?> |
|
<?= $repetitions > 1 ? "<small>({$section["display_index"]})</small>" : null ?> |
|
</button> |
|
<? |
|
} |
|
} |
|
?> |
|
</div> |
|
</div> |
|
<div class="col-sm-12 mt-2"> |
|
<?php if (!$fully_completed) : ?> |
|
<div class="alert alert-secondary px-3 py-2" role="alert"> |
|
<small> |
|
<i class="text-success fas fa-sm fa-check-circle mr-1"></i> |
|
<span><?= __guue("Le sezioni contrassegnate da questa spunta sono state verificate formalmente. Una volta che lo saranno tutte, sarà possibile avviare la validazione GUUE."); ?></span> |
|
</small> |
|
</div> |
|
|
|
<?php else : ?> |
|
<div class="alert alert-success" role="alert"> |
|
<small> |
|
<b><i class="fas fa-check-circle text-success fa-sm mr-1"></i> <?= __guue("Form formalmente validato.") ?></b> |
|
<?= __guue("Il form ha superato la validazione formale in tutte le sue sezioni.") ?> |
|
</small> |
|
</div> |
|
<?php endif; ?> |
|
</div> |
|
</div> |
|
</div> |
|
<div class="col-12 col-md-9 order-1"> |
|
<? |
|
$errori = json_decode(base64_decode($ted->info["errori"]), 1); |
|
if (!empty($errori)) { |
|
?> |
|
<div class="alert alert-danger alert-dismissible fade show" role="alert"> |
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> |
|
<span aria-hidden="true">×</span> |
|
<span class="sr-only">Close</span> |
|
</button> |
|
<strong><i class="fas fa-exclamation-triangle mr-3"></i><?= __guue("Attenzione! Si sono verificati i seguenti errori:") ?></strong> |
|
<ul class="text-break"> |
|
<? |
|
foreach ($ted->validationRuleToHuman($errori) as $errore) { |
|
?><li><?= ($errore) ?></li><? |
|
} |
|
?> |
|
</ul> |
|
</div> |
|
<? |
|
} |
|
if (!empty($ted->info["form"])) { |
|
?> |
|
<input type="hidden" name="token" value="<?= tokenGen() ?>"> |
|
<input type="hidden" name="form" value="<?= $ted->info["form"] ?>"> |
|
<input type="hidden" name="codice" value="<?= $ted->info["codice"] ?>"> |
|
<input type="hidden" name="anno" value="<?= $ted->info["anno"] ?>"> |
|
<input type="hidden" name="current_section" value="<?= $current_section ?>"> |
|
<input type="hidden" name="current_subsection_index" value="<?= $subsection_index ?>"> |
|
<input type="hidden" name="next_section" id="next-section-input" value=""> |
|
<input type="hidden" name="next_subsection_index" id="next-subsection-index" value=""> |
|
<input type="hidden" name="action" id="action" value="empty"> |
|
<input type="hidden" name="draft" value="N" id="draft"> |
|
<?php if($readonly): ?> |
|
<fieldset disabled> |
|
<?php endif; ?> |
|
<? |
|
|
|
$ted->printForm($sections[$section_index], $subsection_index ?? 0); |
|
} |
|
?> |
|
<?php if($readonly): ?> |
|
</fieldset> |
|
<?php endif; ?> |
|
</div> |
|
</div> |
|
</form> |
|
</div> |
|
<?php endif; ?> |
|
|
|
|
|
<script type="text/javascript"> |
|
let form_ready = function(url, ready) { |
|
swal({ |
|
title: "<?= __guue("Attenzione") ?>", |
|
text: ready ? `<?= __guue("Stai per confermare questo Form per ANAC, una volta fatto non potrai modificarlo.") ?>` : `<?= __guue("Sbloccando questo Form potrai modificarlo nuovamente, ma dovrai ri-bloccarlo prima di poterlo inviare con una scheda ANAC.") ?>`, |
|
type: "warning", |
|
showCancelButton: true, |
|
confirmButtonText: "<?= __guue('Prosegui') ?>", |
|
cancelButtonText: "<?= __guue('Annulla') ?>", |
|
}).then((result) => { |
|
if (result.value && result.value == true) { |
|
window.location = url; |
|
} |
|
}); |
|
} |
|
let verify = function() { |
|
event.preventDefault(); |
|
$('#action').val('verify'); |
|
$("#draft").val("N"); |
|
$("#guue-form").submit(); |
|
} |
|
|
|
let saveSection = function(section, subsection, action) { |
|
event.preventDefault(); |
|
$("#action").val(action); |
|
$("#next-section-input").val(section) |
|
if (!isNaN(parseInt(subsection))) { |
|
$("#next-subsection-index").val(subsection); |
|
} |
|
swal({ |
|
title: "<?= __guue("Come vuoi proseguire?") ?>", |
|
type: "question", |
|
html: ` |
|
<div> |
|
<div class="row mb-2"> |
|
<div class="col-6 pr-1"> |
|
<button type="button" class="btn btn-block btn-lg swal-btn-draft btn-warning"><?= __guue("Salva in bozza") ?></button> |
|
</div> |
|
<div class="col-6 pl-1"> |
|
<button type="button" class="btn btn-block btn-lg swal-btn-verify btn-success"><?= __guue("Salva e verifica") ?></button> |
|
</div> |
|
</div> |
|
</div> |
|
`, |
|
showConfirmButton: false, |
|
showCancelButton: false, |
|
onBeforeOpen: () => { |
|
$('.swal-btn-draft').on('click', function() { |
|
$("#draft").val("S"); |
|
$("#guue-form").removeAttr("rel"); |
|
$("#guue-form").submit(); |
|
}); |
|
$('.swal-btn-verify').on('click', function() { |
|
$("#draft").val("N"); |
|
$("#guue-form").submit(); |
|
}); |
|
} |
|
}); |
|
} |
|
let scrollToField = function(fieldId) { |
|
document.querySelectorAll("code").forEach(function(el) { |
|
if (el.innerText.includes(fieldId)) { |
|
el.scrollIntoView({ |
|
block: "center", |
|
behavior: "smooth" |
|
}); |
|
//console.log(el); |
|
return false; |
|
} |
|
}); |
|
} |
|
window.guue_readonly = <?= $readonly ? "true" : "false"?>; |
|
|
|
let switchSection = function(section, subsection, skip_verify) { |
|
|
|
event.preventDefault(); |
|
$("#next-section-input").val(section) |
|
if (!isNaN(parseInt(subsection))) { |
|
$("#next-subsection-index").val(subsection); |
|
} |
|
|
|
let html = $('<div>').append( |
|
$('<div>').addClass('row mb-2').append( |
|
$('<div>').addClass('col-6').append( |
|
$('<button>').attr('type', 'button').addClass('btn btn-block btn-lg swal-btn-draft btn-warning').text('<?= __guue("Salva in bozza") ?>') |
|
) |
|
).append( |
|
$('<div>').addClass('col-6').append( |
|
$('<button>').attr('type', 'button').addClass('btn btn-block btn-lg swal-btn-verify btn-success').text('<?= __guue("Salva e verifica") ?>') |
|
) |
|
).append( |
|
$('<div>').addClass('col-12 mt-2').append( |
|
$('<button>').attr('type', 'button').addClass('btn btn-block btn-lg swal-btn-no-save btn-secondary').text('<?= __guue("Prosegui senza salvare") ?>') |
|
) |
|
) |
|
); |
|
if (skip_verify == true) { |
|
var searchParams = new URLSearchParams(window.location.search); |
|
searchParams.set("section", section); |
|
if (!isNaN(parseInt(subsection))) { |
|
searchParams.set("subsection_index", parseInt(subsection)); |
|
} |
|
window.location.search = searchParams.toString(); |
|
return; |
|
} |
|
if(guue_readonly) { |
|
var searchParams = new URLSearchParams(window.location.search); |
|
searchParams.set("section", section); |
|
if (!isNaN(parseInt(subsection))) { |
|
searchParams.set("subsection_index", parseInt(subsection)); |
|
} |
|
window.location.search = searchParams.toString(); |
|
return; |
|
} |
|
swal({ |
|
title: "<?= __guue("Stai per cambiare sezione") ?>", |
|
type: "warning", |
|
html: html, |
|
showConfirmButton: false, |
|
showCancelButton: false, |
|
onBeforeOpen: () => { |
|
$('.swal-btn-no-save').on('click', function() { |
|
var searchParams = new URLSearchParams(window.location.search); |
|
searchParams.set("section", section); |
|
if (!isNaN(parseInt(subsection))) { |
|
searchParams.set("subsection_index", parseInt(subsection)); |
|
} |
|
window.location.search = searchParams.toString(); |
|
}); |
|
$('.swal-btn-draft').on('click', function() { |
|
$("#draft").val("S"); |
|
$("#guue-form").removeAttr("rel"); |
|
$("#guue-form").submit(); |
|
}); |
|
$('.swal-btn-verify').on('click', function() { |
|
$("#draft").val("N"); |
|
$("#guue-form").submit(); |
|
}); |
|
} |
|
}); |
|
} |
|
|
|
let redirect_swal_options = { |
|
title: "<?= __guue("Attenzione") ?>", |
|
text: "<?= __guue("Stai per cambiare sezione, i dati non salvati andranno persi") ?>", |
|
type: "warning", |
|
showCancelButton: true, |
|
confirmButtonText: "<?= __guue('Prosegui') ?>", |
|
cancelButtonText: "<?= __guue('Annulla') ?>", |
|
} |
|
|
|
$(".guue-nav").on('click', function(event) { |
|
event.preventDefault(); |
|
swal(redirect_swal_options).then((result) => { |
|
if (result.value && result.value == true) { |
|
window.location = $(this).attr("href"); |
|
} |
|
}); |
|
}); |
|
|
|
let breadcrumb = $("a", ".breadcrumb-item"); |
|
breadcrumb.on('click', function(event) { |
|
event.preventDefault(); |
|
swal(redirect_swal_options).then((result) => { |
|
if (result.value && result.value == true) { |
|
window.location = $(event.target).attr("href"); |
|
} |
|
}); |
|
}); |
|
|
|
$(document).ready(function() { |
|
|
|
let commands = $("#guue-commands") |
|
|
|
$(".guue-section").each(function() { |
|
this.disabled = false; |
|
}) |
|
|
|
$(".guue-nav-button").each(function() { |
|
this.disabled = false; |
|
}) |
|
|
|
}) |
|
</script> |
|
<? |
|
|
|
|
|
include_once "{$beRoot}/layout/bottom.php";
|
|
|