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.
 
 
 
 
 

327 righe
17 KiB

<?
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php";
include_once($configPath);
if (!empty($_SESSION["utente"])) {
$concorso = publicConcorso::init($_POST["codice"]);
if (!empty($concorso) && !empty($_POST["codice_lotto"])) {
if ($concorso->setLotto($_POST["codice_lotto"])) {
$record = $concorso->info;
$lotto = $concorso->lotto;
$round = $concorso->round;
$breadcrumb = array();
$breadcrumb["/".$radice."/"] = Modulo::getInfo($radice)["titolo"];
$breadcrumb["/".$radice."/dettaglio.php?codice={$record["codice"]}"] = __("Dettaglio");
$breadcrumb["partecipa.php?codice={$record["codice"]}&codice_lotto={$lotto["codice"]}"] = __("Pannello");
$breadcrumb[] = __("Carica documento");
include_once ($root."/layout/top.php");
?>
<div class="container">
<?
if ($concorso->partecipazioneAttiva()) {
$postTipologia = $_POST["tipologia"];
?>
<h3><?= $record["oggetto"] ?></h3>
<?
$richieste = $concorso->getRichieste($postTipologia);
if (!empty($richieste)) {
foreach($richieste AS $tmp) {
if ($tmp["locked"] == "S") { $richiesta = $tmp; }
}
}
if(!empty($richiesta)) {
$error = false;
$partecipante = $concorso->miaPartecipazione();
if (!empty($partecipante)) {
if ($partecipante["conferma"]=="S") {
if ($concorso->revoca() != false) {
$partecipante = $concorso->miaPartecipazione();
}
}
}else {
$partecipante = $concorso->savePartecipante();
}
$tmpCriteri = $concorso->getCriteri();
$criteri = [];
$economica = false;
if (!empty($tmpCriteri)) {
foreach($tmpCriteri AS $tmp) {
if (!empty($tmp["auto"]) || $tmp["tipologia"] == "Q") {
$criteri[] = $tmp;
}
}
}
if (!empty($criteri)) {
$data = [];
if (!empty($_POST["salt"])) {
$salt = "";
$continua = true;
if (!empty($_POST["salt"])) {
$continua = false;
$salt = $_POST["salt"];
$public = openssl_pkey_get_public(trim($record["public_key"]));
if (openssl_public_encrypt($salt,$encryptedSalt,$public)) { $continua = true; }
}
$concorso->deleteBusta($richiesta["codice"]);
$sql = "DELETE FROM b_offerte_concorsi WHERE codice_partecipante = :codice_partecipante AND tipo = :tipologia ";
$ris = $pdo->go($sql,array(":codice_partecipante"=>$partecipante["codice"],":tipologia"=>$postTipologia));
scriviLog("b_offerte_concorsi","DELETE",$pdo->getSQL());
$offerta = array("codice_partecipante"=>$partecipante["codice"],"codice_round"=>$round["codice"],"tipo"=>$postTipologia);
if (!empty($encryptedSalt)) { $offerta["salt"] = $encryptedSalt; }
$offerta["verificata"] = "S";
$salva = new salva();
$salva->debug = false;
$salva->nome_tabella = "b_offerte_concorsi";
$salva->operazione = "INSERT";
$salva->oggetto = $offerta;
$codice_offerta = $salva->save();
ob_start();
$errori = [];
if (!empty($codice_offerta)) {
foreach($criteri AS $index => $criterio) {
if ($criterio["tipologia"] == "Q") {
$inputs = $concorso->getFormCriterio($criterio["codice"]);
if (!empty($inputs)) {
foreach($inputs AS $input) {
$data = $_POST["criterio-form-input"][$input["codice"]];
$value = "";
if (isset($data["value"])) { $value = $data["value"]; }
if (isset($data["value"]) && is_array($data["value"])) { $value = json_encode($data["value"]); }
if (!empty($data["file"])) {
$path = $config["chunk_folder"]."/".$_SESSION["utente"]->codice."/".$data["file"];
if (file_exists($path)) {
adaptMemoryLimitToFile($path);
$content = file_get_contents($path);
$file = array();
$file_info = new finfo(FILEINFO_MIME_TYPE);
$file["mime"] = $file_info->file($path);
$file["size"] = filesize($path);
$file["md5"] = hash("md5",$content);
$file["sha1"] = hash("sha1",$content);
$file["sha256"] = hash("sha256",$content);
$file["filename"] = $data["file"];
$file["content"] = simple_encrypt($content,$config["simple_encrypt"]["offer"]);
unlink($path);
$value = json_encode($file);
}
}
if ($input["obbligatorio"] == "N" || $value !== "") {
$insert = [];
$insert["codice_input"] = $input["codice"];
$insert["codice_offerta"] = $codice_offerta;
$insert["cryptedContent"] = openssl_encrypt($value,"AES128",$salt,OPENSSL_RAW_DATA,$config["simple_encrypt"]["offer"]);
$salva = new salva();
$salva->debug = false;
$salva->nome_tabella = "b_concorsi_form_data";
$salva->operazione = "INSERT";
$salva->oggetto = $insert;
if ($salva->save() == false) {
$errori[] = $input["titolo"] . " - " . __("errore nel salvataggio");
} else {
if (!isset($criteri[$index]["data"])) { $criteri[$index]["data"] = []; }
$criteri[$index]["data"][$input["codice"]] = $value;
}
} else {
$errori[] = $input["titolo"] . " - " . __("obbligatorio");
}
}
}
} else if (!empty($criterio["auto"])) {
$offers = [["codice"=>$criterio["codice"],"titolo"=>$criterio["denominazione"],"valore"=>($_POST["offerta"][$criterio["codice"]]["value"] ?? "")]];
if (empty($errori)) {
foreach($offers AS $offer) {
if ($offer["valore"] !== "") {
$data[$offer["codice"]] = $offer["valore"];
$insert = [];
$insert["codice_offerta"] = $codice_offerta;
$insert["codice_partecipante"] = $partecipante["codice"];
$insert["tipo"] = $criterio["tipologia"];
$insert["codice_dettaglio"] = $offer["codice"];
$insert["cryptedOffer"] = openssl_encrypt($offer["valore"],"AES128",$salt,OPENSSL_RAW_DATA,$config["simple_encrypt"]["offer"]);
$salva = new salva();
$salva->debug = false;
$salva->nome_tabella = "b_dettaglio_offerte_concorsi";
$salva->operazione = "INSERT";
$salva->oggetto = $insert;
if (empty($salva->save())) {
$errori[] = $offer["titolo"] . " - " . __("errore nel salvataggio");
} else {
if (!isset($criteri[$index]["data"])) { $criteri[$index]["data"] = []; }
$criteri[$index]["data"][$offer["codice"]] = $offer["valore"];
}
} else {
$errori[] = $offer["titolo"] . " - " . __("obbligatorio");
}
}
}
}
}
if (empty($errori)) {
ob_start();
foreach($criteri AS $criterio) {
if ($criterio["tipologia"] == "Q" && !empty($criterio["data"])) {
$concorso->printFormCriterio($criterio["codice"],false,false,$criterio["data"]);
} else if (!empty($criterio["auto"])) {
$concorso->printOfferCriterio($criterio["codice"],false,false,$criterio["data"]);
}
}
$html = ob_get_clean();
if (!empty($html)) {
ob_start();
?>
<html>
<head>
<style>
table, th, td {
border: 1px solid grey;
}
.card-header {
border: 1px solid grey;
font-weight:bold;
text-align:center;
padding:10px;
}
.card-body {
border: 1px solid grey;
padding:10px;
margin-bottom:10px;
}
.value-container {
text-align:center;
padding:10px;
}
</style>
</head>
<body>
<h3 style="text-align:center">
<?= $record["oggetto"] ?><br>
<small><?= __("Lotto") . " {$lotto["numero"]}<br>{$lotto["cig"]}<br>{$lotto["oggetto"]}" ?></small>
</h3>
<h4 style="text-align:center"><?= $richiesta["titolo"] ?></h4>
<strong>
<?= __("ID Partecipante") ?>: <?= $partecipante["id"] ?>
</strong><br><br>
<?
$header = ob_get_clean();
$html = $header . $html . "</body></html>";
$tmp_path = $config["chunk_folder"]."/".$codice_offerta."_offer.pdf";
$content = documentConverter::getPDFWithWKHTML($html,"A4","portrait",(isset($unitTestExecution)) ? false : true);
if (!empty($content)) {
file_put_contents($tmp_path, $content);
$offerFile = file_get_contents($tmp_path);
$parser = new \Smalot\PdfParser\Parser();
$contentForHash = $parser->parseFile($tmp_path)->getText();
$contentForHash = preg_replace("/[^a-zA-Z0-9]/", '', $contentForHash);
unlink($tmp_path);
$update = array();
$update["md5"] = hash("md5",$offerFile);
$update["sha1"] = hash("sha1",$offerFile);
$update["sha256"] = hash("sha256",$offerFile);
$update["shaContent"] = hash("sha256",$contentForHash);
$continua = false;
$cryptedContent = openssl_encrypt($offerFile,"AES128",$salt,OPENSSL_RAW_DATA,$config["simple_encrypt"]["offer"]);
if ($cryptedContent !== false) { $continua = true; }
$update["cryptedContent"] = $cryptedContent;
if ($continua) {
$_SESSION["concorsioffers"][$partecipante["codice"]][$postTipologia] = $salt;
$update["codice"] = $codice_offerta;
$salva = new salva();
$salva->debug = false;
$salva->nome_tabella = "b_offerte_concorsi";
$salva->operazione = "UPDATE";
$salva->oggetto = $update;
$codice_offerta = $salva->save();
if ($codice_offerta !== false) {
$stop_delete = true;
alertManager::printSuccessBox(__("Operazione effettuata con successo"));
?>
<a class="btn btn-block btn-lg btn-warning" target="_blank" onclick="$('#downloadOffer').slideDown();" href="download-offer.php?codice_concorso=<?= $concorso->info["codice"] ?>&codice_lotto=<?= $concorso->lotto["codice"] ?>&tipo=<?= $postTipologia ?>&token=<?= tokenGen() ?>">
<span class="fa fa-download"></span> <?= __("Scarica offerta") ?>
</a>
<div class="collapse" id="downloadOffer">
<a class="btn btn-block btn-lg btn-success" href="partecipa.php?codice=<?= $record["codice"] ?>&codice_lotto=<?= $concorso->lotto["codice"] ?>&open=<?= $postTipologia ?>">
<span class="fa fa-upload"></span> <?= __("Carica documento") ?>
</a>
</div>
<?
} else {
alertManager::printAlertBox(__('errore nel salvataggio offerta') . " - #009");
}
} else {
alertManager::printAlertBox(__('errore nella generazione del PDF'));
}
} else {
alertManager::printAlertBox(__('errore nella criptazione dell\'offerta'));
}
} else {
alertManager::printAlertBox(__('errore nella generazione dell\'offerta'));
}
} else {
alertManager::printAlertBox(__('errore nel salvataggio offerta') . " - #008");
?>
<div class="card card-body">
<ul>
<li><?
echo implode("</li><li>",$errori);
?>
</li>
</ul>
</div>
<?
}
} else {
alertManager::printAlertBox(__('errore nel salvataggio offerta') . " - #007");
}
if (!isset($stop_delete)) {
$sql = "DELETE FROM b_offerte_concorsi WHERE codice_partecipante = :codice_partecipante AND tipo = :tipologia ";
$ris = $pdo->go($sql,array(":codice_partecipante"=>$partecipante["codice"],":tipologia"=>$postTipologia));
scriviLog("b_concorsi_buste","DELETE",$pdo->getSQL());
}
} else {
alertManager::printAlertBox(__('Password') . " " . __('Obbligatoria'));
}
} else {
alertManager::printAlertBox(__('Impossibile continuare') . " - #001");
}
} else {
alertManager::printAlertBox(__('Impossibile continuare') . " - #000");
}
} else {
alertManager::printAlertBox(__('Impossibile continuare'));
}
?>
<a class="btn btn-block btn-lg btn-primary" href="partecipa.php?codice=<?= $record["codice"] ?>&codice_lotto=<?= $lotto["codice"] ?>">
<?= __("Torna al pannello per continuare le operazioni") ?>
</a>
</div>
<?
include_once ($root."/layout/bottom.php");
} else {
echo '<meta http-equiv="refresh" content="0;URL=/index.php">';
die();
}
} else {
echo '<meta http-equiv="refresh" content="0;URL=/index.php">';
die();
}
} else {
echo '<meta http-equiv="refresh" content="0;URL=/index.php">';
die();
}
?>