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.
 
 
 
 
 

118 righe
5.2 KiB

<?
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php";
include_once($configPath);
$error = true;
$id_modulo = "pubblica";
$cmd_info = gara::getInfoModulo("pubblica");
if (!empty($_POST) && !empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($cmd_info["modulo_riferimento"]) && $_SESSION["utente"]->permission($radice,$_POST["codice"],$id_modulo) && tokenVerify()) {
$gara = gara::init($_POST["codice"],$_POST["codice_round"]);
if (!empty($gara)) {
$lock = $gara->checkLock($cmd_info["id"]);
$record = $gara->info;
$round = $gara->round;
if ($record["fase_attiva"] == $round["numero"]) {
$record_update = $record;
$round_update = $_POST;
$round_update["codice"] = $_POST["codice_round"];
if ($record["stato"] <= 21) {
if ($_POST["pubblica"] > 0) {
$record_update["stato"] = "20";
} else {
$record_update["stato"] = "10";
}
}
$salva = new salva();
$salva->debug = false;
$salva->nome_tabella = "b_gare";
$salva->operazione = "UPDATE";
$salva->oggetto = $record_update;
$salva->expect = array("codice","stato");
$codice = $salva->save();
if (!empty($codice)) {
$salva = new salva();
$salva->debug = false;
$salva->nome_tabella = "b_gare_round";
$salva->operazione = "UPDATE";
$salva->oggetto = $round_update;
if (!$lock) {
$salva->expect = array("codice","pubblica","pubblicazione","chiarimenti","scadenza","apertura","sopralluogo");
} else {
$salva->expect = array("codice","pubblica");
}
$codice_round = $salva->save();
if (!empty($codice_round)) {
$error = false;
if (!$lock) {
if ($round["pubblica"] > 0) {
$newRound = $gara->getRounds($round["codice"])[0] ?? false;
$keysChecks = ["chiarimenti","scadenza","apertura","sopralluogo"];
$edits = [];
foreach($keysChecks AS $key) {
if ($round[$key] != $newRound[$key]) {
$edits[$key] = ["old"=>$round[$key],"new"=>$newRound[$key]];
}
}
if (!empty($edits) && !$gara->quickPanel) {
$manager = $gara->getManagerAvvisi();
$avviso = [];
$avviso["codice"] = "";
$avviso["titolo"] = __("Modifica termini di gara") . " - " . $gara->info["oggetto"];
$avviso["testo"] = __("Si comunica l'avvenuta modifica dei termini come di seguito riportato") . ":<br>";
foreach($edits AS $key => $termini) {
switch($key) {
case "chiarimenti": $label = "Richiesta chiarimenti"; break;
case "apertura": $label = "Apertura offerte"; break;
case "sopralluogo": $label = "Richiesta sopralluogo"; break;
default: $label = "Presentazione offerte"; break;
}
$avviso["testo"] .= "<br><strong>" . __($label) . "</strong><br>" . __("Vecchio termine") . ": " . mysql2datetime($termini["old"]) . "<br><strong>" . __("Nuovo termine") . "</strong>: " . mysql2datetime($termini["new"]) . "<br><br>";
}
$avviso["modulo"] = "gare";
$avviso["codice_elemento"] = $gara->info["codice"];
$avviso["sub"] = $gara->round["codice"];
$avviso["attivo"] = "I";
$avviso["data"] = date("d/m/Y H:i:s");
$codiceAvviso = $manager->saveAvviso($avviso);
if (!empty($codiceAvviso) && !empty($gara->getDestinatari(true))) {
$manager->sendAvviso($codiceAvviso);
}
}
} else {
if (!$round["infoFase"]["aperta"] && $_POST["pubblica"] > 0 && $gara->getModalita()["online"]) {
$error = true;
$destinatari = $gara->getDestinatari();
if (!empty($destinatari)) {
$error = false;
$gara->inviaInvito($destinatari);
} else {
?>
swal({title:js_dict.error,type:"error",html:"<?= __("Nessun operatore economico invitato") ?>"});
<?
}
}
}
}
}
if (!$error) {
$gara->addToLog("UPDATE",__("Pubblicazione") . " " . __("Fase") . " " . $gara->round["numero"]);
$gara->info["stato"] = $record_update["stato"];
$_SESSION["ente"]->manageUpdates("gare",$gara->info["codice"],$gara);
?>
swal({title:js_dict["success-msg"],type:"success"}).then(function(){ window.location.href="/backend/gare/panel.php?codice=<?= $record["codice"] ?>"; });
<?
}
}
} else {
?>
swal({title:js_dict.error,html:"<?= __('La fase non è attiva') ?>",type:"warning"});
<?
die();
}
}
}
if ($error) {
header('HTTP/1.0 403 Forbidden');
die();
}
?>