gestione gare pubbliche
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.
 
 
 
 
 

230 righe
8.7 KiB

<!-- Permessi ANAC -->
<?php
$configPath = substr(__DIR__, 0, strpos(__DIR__, "/public_html")) . "/config.php";
include_once $configPath;
function ___not_available()
{
die("<h4>Non hai i permessi per visualizzare questo pannello.</h4>");
}
$codice = $_GET["codice"] ?? null;
$npa = NuovaPiattaformaAppalti::init($codice);
if (empty($npa->fascicolo)) ___not_available();
// Verifica utente
if(!$npa->verifyUtente()) { ___not_available(); }
?>
<?php $currentUserRole = $npa->getCurrentUserRole(RoleSyncBehaviour::NEVER_SYNC); ?>
<?php $stazioniAppaltanti = json_decode($npa->fascicolo["stazioni_appaltanti"], true); ?>
<table class="table table-striped table-bordered table-hover" id="tab-lotti" width="100%" style="margin: 0px !important">
<thead>
<tr>
<th width="270px"><?= __("Ruolo") ?></th>
<th><?= __("Codice fiscale") ?></th>
<th><?= __("Collaborazione") ?></th>
<th width="200px"><?= __("Azione") ?></th>
</tr>
</thead>
<tbody>
<?php foreach (DelegheRoles::ANY as $ruolo) : ?>
<?php
$syncMode = $ruolo == DelegheRoles::RP ? RoleSyncBehaviour::SYNC_ON_NULL : RoleSyncBehaviour::NEVER_SYNC;
if ($_GET["sync_deleghe"] ?? 0 == 1) {
$syncMode = RoleSyncBehaviour::ALWAYS_SYNC;
}
$cf = $npa->getUserFromRole($ruolo, $syncMode);
$canDelegate = $ruolo !== DelegheRoles::RP && $currentUserRole === DelegheRoles::RP && empty($cf);
$canRevoke = $ruolo !== DelegheRoles::RP && $currentUserRole === DelegheRoles::RP && !empty($cf);
$infoSA = empty($cf) ? [] : $npa->getFullDelegaInfo($cf);
$canTakeOver =
$ruolo === DelegheRoles::RP &&
$currentUserRole !== DelegheRoles::RP &&
$npa->canCurrentUserTakeOver();
?>
<tr>
<td><b><?= $ruolo ?></b> - <?= __(DelegheRoles::Nomi[$ruolo]) ?></td>
<td>
<input class="deleghe-input form-control" type="hidden" name="initial-<?= $ruolo ?>" value="<?= $cf ?>">
<input <?= $canDelegate ? '' : 'disabled' ?> class="deleghe-input form-control" type="text" name="<?= $ruolo ?>" value="<?= $cf ?>">
</td>
<td>
<?php if ($canTakeOver || $canDelegate) : ?>
<select name="<?= $ruolo ?>-stazioneAppaltante" class="not-chosen form-control select">
<?php foreach($stazioniAppaltanti as $sa) : ?>
<option
value="<?= htmlspecialchars($sa["codiceFiscale"]) ?>####<?= htmlspecialchars($sa["codiceAusa"]) ?>"
<?php if(!empty($infoSA["sa_cf"]) && $infoSA["sa_cf"] == $sa["codiceFiscale"]): ?> selected <?php endif; ?>
>
CF: <?= htmlspecialchars($sa["codiceFiscale"]) ?>, AUSA: <?= htmlspecialchars($sa["codiceAusa"]) ?>
</option>
<?php endforeach; ?>
</select>
<?php else: ?>
<div class="input-group">
<input class="form-control" disabled value="<?= $infoSA["sa_cf"] ?? "" ?>">
<input class="form-control" disabled value="<?= $infoSA["sa_ausa"] ?? "" ?>">
</div>
<?php endif; ?>
</td>
<td>
<?php if ($canTakeOver) : ?>
<button onclick="requestTakeOver(event, '<?= $ruolo ?>')" class="btn btn-warning">
<span class="fa fa-user-tie mr-2"></span>
<?= __("Prendi carico") ?>
</button>
<?php endif; ?>
<?php if ($canDelegate) : ?>
<button onclick="requestDelegate(event, '<?= $ruolo ?>', false)" class="btn btn-primary">
<span class="fa fa-user-plus mr-2"></span>
<?= __("Delega un") ?> <?= $ruolo ?>
</button>
<?php elseif ($canRevoke) : ?>
<button onclick="requestDelegate(event, '<?= $ruolo ?>', true)" class="btn btn-danger">
<span class="fa fa-user-times mr-2"></span>
<?= __("Revoca") ?> <?= $ruolo ?>
</button>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script>
window.requestTakeOver = function(e, role) {
const self = this;
e.preventDefault();
Swal({
title: js_dict["sei-sicuro"],
text: "Sei sicuro di voler assumere la carica di RP? Il vecchio RP sarà sollevato dall'incarico.",
type: "warning",
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: js_dict.conferma,
cancelButtonText: js_dict.annulla,
closeOnConfirm: true
}).then((result) => {
if (result.value) {
self.doTakeOver(role);
}
});
}
window.doTakeOver = function(role) {
const valoreCollaborazione = document.querySelector(`select[name=${role}-stazioneAppaltante]`).value.split("####");
const sa_cf = valoreCollaborazione[0];
const sa_ausa = valoreCollaborazione[1];
$.ajax({
type: "POST",
url: "/backend/npa/ajax/delegate.php",
data: {
codice: <?= $npa->fascicolo["codice"] ?>,
sa_cf : sa_cf,
sa_ausa : sa_ausa,
ruolo: role,
action: 'take-over',
},
dataType: "script",
beforeSend: function() {
$("#wait_div").show();
}
}).fail(function(response) {
swal(js_dict["error-retry"]);
}).done(function(response) {
refreshModalHelper();
}).always(function() {
$("#wait_div").slideUp('fast');
});
}
window.requestDelegate = function(e, role, revoke) {
let cf = null;
let message = null;
if (revoke) {
cf = document.querySelector(`input.deleghe-input[name=initial-${role}]`).value;
message = `Sei sicuro di voler revocare la delega di '${role}' da ${cf}?`;
} else {
cf = document.querySelector(`input.deleghe-input[name=${role}]`).value;
const initial = document.querySelector(`input.deleghe-input[name=initial-${role}]`).value;
if (cf.length == 0) {
swal(`Inserisci un codice fiscale.`);
return;
}
if (cf === initial) {
swal(`Il Codice Fiscale ${cf} ha già il ruolo ${role}.`);
return;
}
message = `Sei sicuro di voler incaricare ${cf} con il ruolo '${role}'?`;
}
const self = this;
e.preventDefault();
Swal({
title: js_dict["sei-sicuro"],
text: message,
type: "warning",
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: js_dict.conferma,
cancelButtonText: js_dict.annulla,
closeOnConfirm: true
}).then((result) => {
if (result.value) {
self.doDelegate(cf, role, revoke);
}
});
}
window.doDelegate = function(cf, role, revoke) {
let requestData = {
codice: <?= $npa->fascicolo["codice"] ?>,
cf: cf,
ruolo: role,
action: revoke ? 'revoke' : 'delegate',
}
if(!revoke) {
const valoreCollaborazione = document.querySelector(`select[name=${role}-stazioneAppaltante]`).value.split("####");
requestData['sa_cf'] = valoreCollaborazione[0];
requestData['sa_ausa'] = valoreCollaborazione[1];
}
$.ajax({
type: "POST",
url: "/backend/npa/ajax/delegate.php",
data: requestData,
dataType: "script",
beforeSend: function() {
$("#wait_div").show();
}
}).fail(function(response) {
swal(js_dict["error-retry"]);
}).done(function(response) {
refreshModalHelper();
}).always(function() {
$("#wait_div").slideUp('fast');
});
}
</script>