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.
195 righe
7.3 KiB
195 righe
7.3 KiB
<? |
|
|
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
$error = true; |
|
$id_modulo = "preliminari"; |
|
|
|
if (!empty($_POST) && !empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice,$_POST["codice"],$id_modulo) && tokenVerify() && $_SESSION["utente"]->unlockSupporto()) { |
|
|
|
$error = false; |
|
$errori = []; |
|
if (!empty($_POST["cpv"])) { |
|
// Verifica tipologia vs cpv |
|
$tipologia = $_POST["tipologia"] ?? null; |
|
if($tipologia) { |
|
$cpvs = $_POST["cpv"]; |
|
// Per ogni CPV |
|
foreach($cpvs as $cpv) { |
|
// Otteniamo le prime due cifre |
|
$cpv_macro = intval(substr(trim($cpv, " -"), 0, 2)); |
|
$fTipologia = substr($tipologia,0,1); |
|
// Se non è valido |
|
if(!( |
|
($fTipologia == "F" && ($cpv_macro < 45 || $cpv_macro == 48)) || |
|
($fTipologia == "L" && $cpv_macro == 45) || |
|
($fTipologia == "S" && $cpv_macro > 45) |
|
)) { |
|
// Mostriamo un errore leggibile |
|
$nomeTipologia = [ |
|
"L" => "Lavori", |
|
"F" => "Forniture", |
|
"S" => "Servizi" |
|
][$fTipologia] ?? "Sconosciuta"; |
|
$errori[] = __("Il CPV") . " " . $cpv . " " . __("non è compatibile con la categoria '{$nomeTipologia}'"); |
|
} else { |
|
$errori = []; |
|
break; |
|
} |
|
} |
|
} |
|
|
|
if (!empty($_POST["extraInfo"]["copyInfo"]["codice"])) { |
|
$copy = gara::init($_POST["extraInfo"]["copyInfo"]["codice"]); |
|
if (!empty($copy)) { |
|
$clonable = CloneGara::clonableInfo($copy); |
|
if (!empty($clonable)) { |
|
foreach($clonable AS $idDomanda => $quesito) { |
|
if (empty($_POST["extraInfo"]["copyInfo"][$idDomanda])) { |
|
$errori[] = __("Elementi da copiare"). " - {$quesito} - " . __("Obbligatorio"); |
|
} |
|
} |
|
} |
|
} else { |
|
$errori[] = __("Impossibile eseguire la copia richiesta"); |
|
} |
|
} |
|
// Se ci sono errori muoriamo malissimo |
|
if(!empty($errori)) { |
|
?> |
|
swal({title:js_dict.error,html:`<?= implode("<br>", $errori) ?>`}); |
|
<?php |
|
|
|
die(); |
|
} |
|
|
|
if (!empty($_POST["extraInfo"]["importi"])) { |
|
if ($_SESSION["ente"]->checkLimite($radice) || $_POST["codice"] > 0) { |
|
if ($_POST["codice"] > 0) { |
|
$existingGara = gara::init($_POST["codice"]); |
|
if (empty($existingGara)) { |
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
} else { |
|
if (!isset($_POST["procedura"])) { |
|
$_POST["procedura"] = $existingGara->info["procedura"]; |
|
$_POST["tipologia"] = $existingGara->info["tipologia"]; |
|
} |
|
} |
|
} |
|
$_POST["prezzoRiferimento"] = gara::getTotaleImportiFromTipologie($_POST["extraInfo"]["importi"]); |
|
$checkImporto = true; |
|
$importiMassimiEnte = $_SESSION["ente"]->getImportiMassimiProcedure(); |
|
if (!empty($importiMassimiEnte)) { |
|
foreach($importiMassimiEnte AS $limite) { |
|
if ((empty($limite["tipologia"]) || $limite["tipologia"] == $_POST["tipologia"]) && $limite["importo_max"] < $_POST["prezzoRiferimento"]) { |
|
$checkImporto = false; |
|
break; |
|
} |
|
} |
|
} |
|
if ($checkImporto) { |
|
$checkImportoUtente = true; |
|
if (!empty($_SESSION["utente"]->collaborazione)) { |
|
$limitiCollaborazione = $_SESSION["utente"]->getCollaborazioneAttiva()["limiti"] ?? ""; |
|
$limitiCollaborazione = json_decode($limitiCollaborazione,true); |
|
if (!empty($limitiCollaborazione)) { |
|
if (!empty($limitiCollaborazione[$_POST["procedura"]])) { |
|
if ($limitiCollaborazione[$_POST["procedura"]] < $_POST["prezzoRiferimento"]) { |
|
$checkImportoUtente = false; |
|
} |
|
} else { |
|
$checkImportoUtente = false; |
|
} |
|
} |
|
} |
|
if ($checkImportoUtente) { |
|
$entiAbilitati = $_SESSION["utente"]->getEntiBeneficiari(); |
|
$checkEnte = false; |
|
foreach($entiAbilitati AS $ente) { |
|
if ($_POST["codice_ente"] == $ente["codice"]) { |
|
$checkEnte = true; |
|
break; |
|
} |
|
} |
|
if ($checkEnte) { |
|
$gara = gara::save($_POST); |
|
if (is_a($gara,"gara")) { |
|
if (!$_SESSION["ente"]->checkLimite($radice) && empty($_POST["codice"])) { |
|
$_SESSION["ente"]->sendAlertLimite($radice); |
|
} |
|
if(!empty($_POST['marketplace']) && $_POST['marketplace'] == true){ |
|
return ['save' => true, 'gara' => $gara]; |
|
}elseif(!empty($gara->error_rda)){ |
|
|
|
$msg = implode('<br>', $gara->error_rda); |
|
$msg .= "<br>". __('Si prega di contattare il Servizio Help Desk'); |
|
?> |
|
swal({title:js_dict["warning-msg"],html: "<?=$msg?>" ,type:"warning"}).then(function(){ |
|
window.location.href="/backend/gare/panel.php?codice=<?= $gara->info["codice"] ?>"; |
|
}); |
|
<? |
|
|
|
}else{ |
|
?> |
|
swal({title:js_dict["success-msg"],type:"success"}).then(function(){ |
|
window.location.href="/backend/gare/panel.php?codice=<?= $gara->info["codice"] ?>"; |
|
}); |
|
<? |
|
} |
|
|
|
} else { |
|
|
|
if ($gara === -1) { |
|
?> |
|
swal({title:js_dict.error,html:"<?= __("Errore nella generazione della chiave") ?>",type:"error"}); |
|
<? |
|
}else { |
|
?> |
|
swal({title:js_dict.error,html:js_dict["error-generic"],type:"error"}); |
|
<? |
|
} |
|
|
|
} |
|
} else { |
|
?> |
|
swal({title:js_dict.error,html:"<?= __("Ente non abilitato") ?>",type:"error"}); |
|
<? |
|
die(); |
|
} |
|
} else { |
|
?> |
|
swal({title:js_dict.error,html:"<?= __("Utente non abilitato alla gestione di questa procedura") ?>",type:"error"}); |
|
<? |
|
die(); |
|
} |
|
} else { |
|
?> |
|
swal({title:js_dict.error,html:"<?= __("Piattaforma non abilitata alla gestione di questa procedura") ?>",type:"error"}); |
|
<? |
|
die(); |
|
} |
|
} else { |
|
?> |
|
swal({title:js_dict.error,html:"<?= __("Limite di procedure raggiunto") ?>",type:"error"}); |
|
<? |
|
die(); |
|
} |
|
} else { |
|
?> |
|
swal({title:js_dict.error,html:"<?= __("Importi di gara obbligatori") ?>",type:"error"}); |
|
<? |
|
die(); |
|
} |
|
} else { |
|
?> |
|
swal({title:js_dict.error,html:"<?= __("categorie merceologiche") . " " . __("obbligatorio") ?>",type:"error"}); |
|
<? |
|
die(); |
|
} |
|
} |
|
if ($error) { |
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
} |
|
?>
|
|
|