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.
277 righe
8.3 KiB
277 righe
8.3 KiB
<!-- Permessi ANAC --> |
|
<?php |
|
$configPath = substr(__DIR__, 0, strpos(__DIR__, "/public_html")) . "/config.php"; |
|
include_once $configPath; |
|
include_once($beRoot."/guue/class/TedEsender.class.php"); |
|
|
|
|
|
function ___not_available($text = "Non hai il permesso per visualizzare questo pannello.") |
|
{ |
|
?> |
|
<div class="alert alert-danger"> |
|
<h4><?= __($text) ?></h4> |
|
</div> |
|
<?php |
|
die(); |
|
} |
|
if(isset($_POST["codice"]) && isset($_POST["codice_scheda"])) { |
|
$codice = intval($_POST["codice"]); |
|
$codice_scheda = intval($_POST["codice_scheda"]); |
|
} elseif(isset($_POST["codice"]) && isset($_POST["form"])) { |
|
$codice = intval($_POST["codice"]); |
|
$form = $_POST["form"]; |
|
} elseif(isset($_GET["codice"])) { |
|
$codice = intval($_GET["codice"]); |
|
$codice_scheda = null; |
|
} else { |
|
___not_available(); |
|
} |
|
|
|
|
|
$npa = NuovaPiattaformaAppalti::init(null, $codice); |
|
if(!$npa->verifyUtente()) { |
|
die_forbidden(); |
|
} |
|
|
|
$lock = $npa->checkLock(); |
|
|
|
|
|
// Carichiamo i riferimenti |
|
$npa->checkIfCardNeedsXMLDocument(); |
|
|
|
if(!$npa->check["eform"]["required"]) { |
|
___not_available(); |
|
} |
|
|
|
$noticeTypes = eFormsManager::listAvailableNoticeForms(); |
|
|
|
// Carichiamo le schede compatibili |
|
$compatibleCards = $npa->fetchCompatibleGUUECards(true, false); |
|
$draftCards = $npa->fetchCompatibleGUUECards(true, true); |
|
$compatibleTypes = $npa->metadataSchede[$npa->scheda["id_scheda"]]["guue"]; |
|
|
|
if(!empty($form)) { |
|
if(!in_array($form, $compatibleTypes)) { |
|
swalDie("Scheda non compatibile", "Attenzione", "reload", "error", false); |
|
} |
|
$titolo = "{$form}. Scheda ANAC n° {$npa->scheda['codice']}"; |
|
if(!empty($lot)) { |
|
$titolo .= " - Lotto {$lot["codice"]}"; |
|
} |
|
$codiceScheda = eFormsManager::nuovaSchedaFromAnac($form, $titolo, $npa); |
|
|
|
if(empty($codiceScheda)) { |
|
swalDie("Impossibile creare la scheda GUUE", "Attenzione", "reload", "error", false); |
|
} |
|
|
|
if(!$npa->selezionaSchedaGUUE($codiceScheda)) { |
|
swalDie("Impossibile assegnare la scheda GUUE", "Attenzione", "reload", "errore", false); |
|
} |
|
|
|
$guue_query = [ |
|
"modulo" => $npa->fascicolo["modulo_riferimento"], |
|
"codice_elemento" => $npa->fascicolo["id_riferimento"], |
|
"codice" => $codiceScheda, |
|
"form" => $form |
|
]; |
|
|
|
$guueUrl = "/backend/guue/edit.php?" . http_build_query($guue_query); |
|
|
|
swalDie("Sarai ora reindirizzato alla nuova scheda GUUE", "Scheda creata con successo", $guueUrl, "success", false); |
|
} |
|
if($codice_scheda !== null) { |
|
$compatibleCards = array_column($compatibleCards, "codice"); |
|
$draftCards = array_column($draftCards, "codice"); |
|
if(!in_array($codice_scheda, $compatibleCards) && !in_array($codice_scheda, $draftCards)) { |
|
die("swal({title: js_dict['error-retry'], html:`Scheda non compatibile`})"); |
|
} |
|
// Check che la scheda non sia già usata |
|
//$assignedANAC = NuovaPiattaformaAppalti::fetchSchede(["codice", "id_scheda"], ["codice" => ["!=", $codice, "codice_scheda_guue" => $codice_scheda]], false, false); |
|
$assignedANAC = NuovaPiattaformaAppalti::fetchSchede( |
|
[ |
|
"s.codice", |
|
"id_scheda" |
|
], |
|
[ |
|
"s.codice" => ["!=", $codice], |
|
"codice_scheda_guue" => $codice_scheda, |
|
"id_riferimento" => $npa->fascicolo["id_riferimento"], |
|
"modulo_riferimento" => $npa->fascicolo["modulo_riferimento"] |
|
], |
|
true, |
|
false |
|
); |
|
if(!empty($assignedANAC)) { |
|
die("swal({title: js_dict['error-retry'], html:`Questa scheda GUUE è già usata dalla scheda ANAC {$assignedANAC['id_scheda']} n°{$assignedANAC['codice']}`, type: 'error'})"); |
|
} |
|
|
|
|
|
if($npa->selezionaSchedaGUUE($codice_scheda)) { |
|
swalDie("La scheda GUUE n°{$codice_scheda} è stata selezionata", "Scheda selezionata con successo!", "reload", "success", false); |
|
} |
|
die("swal({title: js_dict['error-retry'], html:`Impossibile aggiornare la scheda`, type: 'error'})"); |
|
} |
|
|
|
if($lock) { |
|
?> |
|
<div class="alert alert-warning"> |
|
<h4>Non puoi cambiare la scheda GUUE per questa scheda.</h4> |
|
</div> |
|
<?php |
|
} |
|
|
|
$activeCard = $npa->scheda["codice_scheda_guue"]; |
|
?> |
|
|
|
|
|
<h3>Scegli la Scheda GUUE da allegare a questa scheda ANAC</h3> |
|
|
|
<?php if(!empty($compatibleCards)): ?> |
|
|
|
|
|
|
|
<hr> |
|
|
|
<h5>Schede GUUE pronte all'invio:</h5> |
|
<?php foreach($compatibleCards as $card) : ?> |
|
|
|
<?php |
|
$_active = $card["codice"] == $activeCard; |
|
$guue_query = ["modulo" => $npa->fascicolo["modulo_riferimento"], "codice_elemento" => $npa->fascicolo["id_riferimento"], "codice" => $card["codice"], "form" => $card["form"]]; |
|
$guue_url = "/backend/guue/edit.php?" . http_build_query($guue_query); |
|
?> |
|
<div class="d-flex my-2"> |
|
<div class="w-100"> |
|
<a <?php if(!$lock) : ?> onclick='changeGUUE(<?= $card["codice"] ?>)' <?php endif; ?> class="btn btn-<?= $_active ? "success" : "secondary" ?> btn-block text-left"> |
|
<?php if($_active): ?> |
|
<i class="fa fa-chevron-right mr-2"></i> |
|
<?php endif; ?> |
|
<span>Scheda GUUE <?= $card["form"] ?> (n°<?=$card["codice"]?>)</span> |
|
</a> |
|
</div> |
|
<div class="flex-shrink-1 pl-2"> |
|
<a class="btn btn-outline-primary btn-block text-nowrap" href="<?= $guue_url ?>" > |
|
<i class="fa fa-link mr-2"></i> |
|
<?= __("Apri") ?> |
|
</a> |
|
</div> |
|
</div> |
|
<?php endforeach; ?> |
|
<?php endif; ?> |
|
|
|
<?php if(!empty($draftCards)): ?> |
|
<hr> |
|
<h5>Schede GUUE in fase di compilazione:</h5> |
|
<?php foreach($draftCards as $card) : ?> |
|
<?php |
|
$_active = $card["codice"] == $activeCard; |
|
|
|
$guueName = $noticeTypes["options"][$card["form"]] ?? "{$card["form"]}"; |
|
$guueQuery = ["modulo" => $npa->fascicolo["modulo_riferimento"], "codice_elemento" => $npa->fascicolo["id_riferimento"], "codice" => $card["codice"], "form" => $card["form"]]; |
|
$guueUrl = "/backend/guue/edit.php?" . http_build_query($guueQuery); |
|
?> |
|
<div class="d-flex my-2"> |
|
<div class="w-100"> |
|
<a onclick='changeGUUE(<?= $card["codice"] ?>)' class="btn btn-<?= $_active ? "success" : "info" ?> btn-block text-left"> |
|
<?php if($_active): ?> |
|
<i class="fa fa-chevron-right mr-2"></i> |
|
<?php endif; ?> |
|
<span>Scheda GUUE <?= $guueName ?> (n°<?= $card["codice"] ?>)</span> |
|
</a> |
|
</div> |
|
<div class="flex-shrink-1 pl-2"> |
|
<a class="btn btn-outline-primary btn-block text-nowrap" href="<?= $guueUrl ?>" > |
|
<i class="fa fa-pencil-alt mr-2"></i> |
|
<?= __("Apri") ?> |
|
</a> |
|
</div> |
|
</div> |
|
<?php endforeach; ?> |
|
<?php endif; ?> |
|
|
|
<hr> |
|
<h5>Crea una nuova scheda GUUE:</h5> |
|
<?php |
|
$codice_lotto_npa = $npa->scheda["codice_lotto"]; |
|
if(!empty($codice_lotto_npa)) { |
|
$lot = $npa->getLots($codice_lotto_npa) ?? null; |
|
if(!empty($lot)) |
|
$lot = reset($lot); |
|
} |
|
?> |
|
<div class="my-1"> |
|
<?php foreach($compatibleTypes as $type) : ?> |
|
<?php |
|
$guueName = $noticeTypes["options"][$type] ?? "$type"; |
|
?> |
|
<a |
|
class="btn my-2 btn-primary btn-block text-left" |
|
onclick="newGUUE(`<?= $type ?>`)" |
|
> |
|
<i class="fa fa-plus mr-2"></i> |
|
<span>Crea nuova scheda GUUE <?= $guueName ?></span> |
|
</a> |
|
<?php endforeach; ?> |
|
</div> |
|
<script> |
|
let newGUUE = function(formType) { |
|
$.ajax({ |
|
|
|
type: "POST", |
|
url: `/backend/npa/ajax/scelta_guue.php`, |
|
data: { |
|
codice: <?= $npa->scheda["codice"] ?>, |
|
form: formType, |
|
}, |
|
dataType: "script", |
|
beforeSend: function() { |
|
|
|
$("#wait_div").show(); |
|
|
|
} |
|
|
|
}).fail(function(response) { |
|
|
|
swal(js_dict["error-retry"]); |
|
|
|
}).done(function(response) { |
|
|
|
eval(response); |
|
|
|
}).always(function() { |
|
|
|
$("#wait_div").slideUp('fast'); |
|
|
|
}); |
|
} |
|
let changeGUUE = function(codice_scheda) { |
|
$.ajax({ |
|
|
|
type: "POST", |
|
url: `/backend/npa/ajax/scelta_guue.php`, |
|
data: { |
|
codice: <?= $npa->scheda["codice"] ?>, |
|
codice_scheda: codice_scheda, |
|
}, |
|
dataType: "script", |
|
beforeSend: function() { |
|
|
|
$("#wait_div").show(); |
|
|
|
} |
|
|
|
}).fail(function(response) { |
|
|
|
swal(js_dict["error-retry"]); |
|
|
|
}).done(function(response) { |
|
|
|
eval(response); |
|
|
|
}).always(function() { |
|
|
|
$("#wait_div").slideUp('fast'); |
|
|
|
}); |
|
} |
|
</script>
|