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.
378 righe
20 KiB
378 righe
20 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
if (!empty($_SESSION["utente"])) { |
|
$gara = publicGara::init($_POST["codice"]); |
|
if (!empty($gara) && !empty($_POST["codice_lotto"])) { |
|
if ($gara->setLotto($_POST["codice_lotto"])) { |
|
$record = $gara->info; |
|
$lotto = $gara->lotto; |
|
$round = $gara->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 ($gara->partecipazioneAttiva()) { |
|
$postTipologia = $_POST["tipologia"]; |
|
?> |
|
<h3><?= $record["oggetto"] ?></h3> |
|
<? |
|
$richieste = $gara->getRichieste($postTipologia); |
|
if (!empty($richieste)) { |
|
foreach($richieste AS $tmp) { |
|
if ($tmp["locked"] == "S") { $richiesta = $tmp; } |
|
} |
|
} |
|
if(!empty($richiesta)) { |
|
$error = false; |
|
$partecipante = $gara->miaPartecipazione(); |
|
if (!empty($partecipante)) { |
|
|
|
if ($partecipante["conferma"]=="S") { |
|
if ($gara->revoca() != false) { |
|
$partecipante = $gara->miaPartecipazione(); |
|
} |
|
} |
|
}else { |
|
$partecipante = $gara->savePartecipante(); |
|
} |
|
$tmpCriteri = $gara->getCriteri(); |
|
$criteri = []; |
|
if ($postTipologia == "economica") { |
|
$economica = true; |
|
} else { |
|
$economica = false; |
|
} |
|
if (!empty($tmpCriteri)) { |
|
foreach($tmpCriteri AS $tmp) { |
|
if ($economica) { |
|
if (($tmp["economico"] == "S" || $tmp["busta"] == "economica") && !empty($tmp["auto"])) { |
|
$criteri[] = $tmp; |
|
} |
|
} else { |
|
if ($tmp["economico"] == "N" && $tmp["busta"] != "economica" && (!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; } |
|
} |
|
|
|
$gara->deleteBusta($richiesta["codice"]); |
|
$sql = "DELETE FROM b_offerte_gare WHERE codice_partecipante = :codice_partecipante AND tipo = :tipologia "; |
|
$ris = $pdo->go($sql,array(":codice_partecipante"=>$partecipante["codice"],":tipologia"=>$postTipologia)); |
|
scriviLog("b_offerte_gare","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_gare"; |
|
$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 = $gara->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_gare_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"])) { |
|
if ($criterio["tipologia"] === "E") { |
|
$voci = $gara->getElencoPrezzi($criterio["codice"]); |
|
$offers = []; |
|
if (!empty($voci)) { |
|
foreach ($voci AS $voce) { |
|
$valore = ($_POST["offerta"][$criterio["codice"].".".$voce["codice"]]["value"] ?? ""); |
|
if (!empty($valore)) { |
|
$valore = number_format($valore,$criterio["decimali"],".",""); |
|
} |
|
$offers[] = ["codice"=>$criterio["codice"].".".$voce["codice"],"titolo"=>$voce["descrizione"],"valore"=>$valore]; |
|
} |
|
} |
|
} else { |
|
$offers = [["codice"=>$criterio["codice"],"titolo"=>$criterio["denominazione"],"valore"=>($_POST["offerta"][$criterio["codice"]]["value"] ?? "")]]; |
|
} |
|
if ($economica && !isset($first) && $criterio["economico"] == "S") { |
|
$first = true; |
|
$criterio["denominazione"] = "ONERI SICUREZZA AZIENDALE"; |
|
$tmpCriterio["denominazione"] = "ONERI SICUREZZA AZIENDALE"; |
|
$tmpCriterio["codice"] = $criterio["codice"].".01"; |
|
$valore_sicurezza = ($_POST["offerta"][$tmpCriterio["codice"]]["value"] ?? ""); |
|
$offers[] = ["codice"=>$tmpCriterio["codice"],"titolo"=>$tmpCriterio["denominazione"],"valore"=>$valore_sicurezza]; |
|
$tmpCriterio["denominazione"] = "COSTO DELLA MANODOPERA"; |
|
$tmpCriterio["codice"] = $criterio["codice"].".02"; |
|
$costo_manodopera = ($_POST["offerta"][$tmpCriterio["codice"]]["value"] ?? ""); |
|
$offers[] = ["codice"=>$tmpCriterio["codice"],"titolo"=>$tmpCriterio["denominazione"],"valore"=>$costo_manodopera]; |
|
} |
|
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_gare"; |
|
$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(); |
|
|
|
$list_partecipanti = $gara->listPartecipanti(); |
|
|
|
if ($economica) { |
|
foreach($criteri AS $criterio) { |
|
$data["partecipanti"] = $list_partecipanti; |
|
$gara->printOfferEconomica(false,false,$data); |
|
break; |
|
} |
|
} else { |
|
foreach($criteri AS $criterio) { |
|
if ($criterio["tipologia"] == "Q" && !empty($criterio["data"])) { |
|
$gara->printFormCriterio($criterio["codice"],false,false,$criterio["data"]); |
|
} else if (!empty($criterio["auto"]) && $criterio["busta"] != 'economica') { |
|
$gara->printOfferCriterio($criterio["codice"],false,false,$criterio["data"]); |
|
} |
|
} |
|
} |
|
$html = ob_get_clean(); |
|
// echo "<textarea>$html</textarea>"; |
|
// die(); |
|
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> |
|
<? if (!$economica) { ?><small><?= __("Lotto") . " {$lotto["numero"]}<br>{$lotto["cig"]}<br>{$lotto["oggetto"]}" ?></small><? } ?> |
|
</h3> |
|
<? if (!$economica) { ?> |
|
<h4 style="text-align:center"><?= $richiesta["titolo"] ?></h4> |
|
<strong> |
|
<?= $list_partecipanti ?> |
|
</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["gareoffers"][$partecipante["codice"]][$postTipologia] = $salt; |
|
|
|
$update["codice"] = $codice_offerta; |
|
$salva = new salva(); |
|
$salva->debug = false; |
|
|
|
$salva->nome_tabella = "b_offerte_gare"; |
|
$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" onclick="$('#downloadOffer').slideDown();" target="_blank" href="download-offer.php?codice_gara=<?= $gara->info["codice"] ?>&codice_lotto=<?= $gara->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=<?= $gara->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_gare WHERE codice_partecipante = :codice_partecipante AND tipo = :tipologia "; |
|
$ris = $pdo->go($sql,array(":codice_partecipante"=>$partecipante["codice"],":tipologia"=>$postTipologia)); |
|
scriviLog("b_gare_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(); |
|
} |
|
?>
|
|
|