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.
213 righe
8.4 KiB
213 righe
8.4 KiB
<? |
|
$error = true; |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"public_html/"))."config.php"; |
|
include_once($configPath); |
|
if (isset($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice) && tokenVerify()) { |
|
if ($_SESSION["importAnac"][$_POST["operationID"]]["partecipanti"] && !empty($_SESSION["importAnac"][$_POST["operationID"]]["lotti"])) { |
|
$error = false; |
|
$anni = $_SESSION["importAnac"][$_POST["operationID"]]["lotti"]; |
|
$tmpPartecipanti = $_SESSION["importAnac"][$_POST["operationID"]]["partecipanti"]; |
|
$partecipanti = []; |
|
$cf = []; |
|
$raggruppamenti = []; |
|
$errors = []; |
|
foreach ($tmpPartecipanti AS $partecipante) { |
|
if (empty($partecipante["codice_fiscale_capogruppo"])) { |
|
if (!isset($partecipanti[$partecipante["cig"]])) $partecipanti[$partecipante["cig"]] = []; |
|
if (!isset($cf[$partecipante["cig"]])) $cf[$partecipante["cig"]] = []; |
|
$cf[$partecipante["cig"]][] = $partecipante["codice_fiscale"]; |
|
$partecipanti[$partecipante["cig"]][$partecipante["codice_fiscale"]] = $partecipante; |
|
} |
|
} |
|
foreach ($tmpPartecipanti AS $key => $partecipante) { |
|
if (!empty($partecipante["codice_fiscale_capogruppo"])) { |
|
if (isset($cf[$partecipante["cig"]])) { |
|
if (in_array($partecipante["codice_fiscale_capogruppo"],$cf[$partecipante["cig"]]) === false) { |
|
$errors[] = $partecipante["codice_fiscale_capogruppo"] . " - " . __("Codice fiscale non presente tra i capogruppo"); |
|
} else { |
|
if (!empty($partecipante["ruolo"])) { |
|
if (isset($partecipanti[$partecipante["cig"]][$partecipante["codice_fiscale_capogruppo"]])) { |
|
if (!isset($raggruppamenti[$partecipante["cig"]])) { |
|
$raggruppamenti[$partecipante["cig"]] = []; |
|
$raggruppamenti[$partecipante["cig"]] = [$partecipante["codice_fiscale_capogruppo"] => [$partecipanti[$partecipante["cig"]][$partecipante["codice_fiscale_capogruppo"]]]]; |
|
} |
|
$raggruppamenti[$partecipante["cig"]][$partecipante["codice_fiscale_capogruppo"]][] = $partecipante; |
|
} else { |
|
$errors[] = $partecipante["codice_fiscale_capogruppo"] . " - " . __("Codice fiscale non presente tra i capogruppo"); |
|
} |
|
} else { |
|
$errors[] = $partecipante["ragione_sociale"] . " - " . __("Ruolo nel raggruppamento non specificato"); |
|
} |
|
} |
|
} else { |
|
$errors[] = $partecipante["codice_fiscale_capogruppo"] . " - " . __("Codice fiscale non presente tra i capogruppo"); |
|
} |
|
} |
|
} |
|
if (count($errors) === 0) { |
|
foreach($anni AS $anno => $tmpLotti) { |
|
$lotti = []; |
|
foreach($tmpLotti AS $i => $data) { |
|
$tmp = []; |
|
$tmp["cig"] = $data["cig"]; |
|
$tmp["oggetto"] = $data["oggetto"]; |
|
$tmp["sceltaContraente"] = $data["sceltaContraente"]; |
|
$point = substr_count($data["importoAggiudicazione"],"."); |
|
$comma = substr_count($data["importoAggiudicazione"],","); |
|
if ($point > 0) { |
|
if ($comma > 0) { |
|
$data["importoAggiudicazione"] = str_replace(".","",$data["importoAggiudicazione"]); |
|
$data["importoAggiudicazione"] = str_replace(",",".",$data["importoAggiudicazione"]); |
|
} else if ($point > 1) { |
|
$data["importoAggiudicazione"] = str_replace(".","",$data["importoAggiudicazione"]); |
|
} |
|
} else if ($comma > 0) { |
|
$data["importoAggiudicazione"] = str_replace(",",".",$data["importoAggiudicazione"]); |
|
} |
|
$tmp["importoAggiudicazione"] = $data["importoAggiudicazione"]; |
|
$tmp["tempiCompletamento"] = ["dataInizio"=>date2mysql($data["inizioContratto"]),"dataUltimazione"=>date2mysql($data["fineContratto"])]; |
|
$point = substr_count($data["importoLiquidato"],"."); |
|
$comma = substr_count($data["importoLiquidato"],","); |
|
if ($point > 0) { |
|
if ($comma > 0) { |
|
$data["importoLiquidato"] = str_replace(".","",$data["importoLiquidato"]); |
|
$data["importoLiquidato"] = str_replace(",",".",$data["importoLiquidato"]); |
|
} else if ($point > 1) { |
|
$data["importoLiquidato"] = str_replace(".","",$data["importoLiquidato"]); |
|
} |
|
} else if ($comma > 0) { |
|
$data["importoLiquidato"] = str_replace(",",".",$data["importoLiquidato"]); |
|
} |
|
$tmp["importoSommeLiquidate"] = $data["importoLiquidato"]; |
|
if (!empty($partecipanti[$data["cig"]])) { |
|
$tmp["partecipanti"] = []; |
|
$singoli = $partecipanti[$data["cig"]] ?? []; |
|
$raggruppamenti = $raggruppamenti[$data["cig"]] ?? []; |
|
$aggiudicatario = []; |
|
$aggiudicatario_raggruppamenti = []; |
|
foreach($singoli AS $key => $singolo) { |
|
if (empty($raggruppamenti[$singolo["codice_fiscale"]])) { |
|
if ($singolo["aggiudicatario"] == "S") $aggiudicatario[] = $partecipante; |
|
} else { |
|
unset($raggruppamenti[$singolo["codice_fiscale"]]); |
|
} |
|
} |
|
if (!empty($raggruppamenti)) { |
|
$keysRaggruppamenti = array_keys($raggruppamenti); |
|
$tmp["partecipanti"]["raggruppamento"] = []; |
|
foreach($keysRaggruppamenti AS $raggruppamento) { |
|
if ($raggruppamento[0]["aggiudicatario"] == "S") $aggiudicatario_raggruppamenti[] = $raggruppamento; |
|
$raggr = []; |
|
foreach($raggruppamento AS $membro) { |
|
$t = []; |
|
if ($membro["stato"] == "IT") { |
|
$t["codiceFiscale"] = $membro["codice_fiscale"]; |
|
} else { |
|
$t["identificativoFiscaleEstero"] = $membro["codice_fiscale"]; |
|
} |
|
$t["ragioneSociale"] = $membro["ragione_sociale"]; |
|
$t["ruolo"] = $membro["ruolo"] ?? "04-CAPOGRUPPO"; |
|
$raggr[] = $t; |
|
} |
|
$tmp["partecipanti"]["raggruppamento"][] = ["membro"=>$raggr]; |
|
} |
|
} |
|
if (!empty($singoli)) { |
|
$tmp["partecipanti"]["partecipante"] = []; |
|
foreach($singoli AS $membro) { |
|
$t = []; |
|
if ($membro["stato"] == "IT") { |
|
$t["codiceFiscale"] = $membro["codice_fiscale"]; |
|
} else { |
|
$t["identificativoFiscaleEstero"] = $membro["codice_fiscale"]; |
|
} |
|
$t["ragioneSociale"] = $membro["ragione_sociale"]; |
|
$tmp["partecipanti"]["partecipante"][] = $t; |
|
} |
|
} |
|
if (!empty($aggiudicatario) || !empty($aggiudicatario_raggruppamenti)) { |
|
$tmp["aggiudicatari"] = []; |
|
if (!empty($aggiudicatario)) { |
|
$tmp["aggiudicatari"]["aggiudicatario"] = []; |
|
foreach($aggiudicatario AS $membro) { |
|
$t = []; |
|
if ($membro["stato"] == "IT") { |
|
$t["codiceFiscale"] = $membro["codice_fiscale"]; |
|
} else { |
|
$t["identificativoFiscaleEstero"] = $membro["codice_fiscale"]; |
|
} |
|
$t["ragioneSociale"] = $membro["ragione_sociale"]; |
|
$tmp["aggiudicatari"]["aggiudicatario"][] = $t; |
|
} |
|
} |
|
if (!empty($aggiudicatario_raggruppamenti)) { |
|
$tmp["aggiudicatari"]["aggiudicatarioRaggruppamento"] = []; |
|
foreach($aggiudicatario_raggruppamenti AS $group) { |
|
$raggr = []; |
|
foreach($group as $membro) { |
|
$t = []; |
|
if ($membro["stato"] == "IT") { |
|
$t["codiceFiscale"] = $membro["codice_fiscale"]; |
|
} else { |
|
$t["identificativoFiscaleEstero"] = $membro["codice_fiscale"]; |
|
} |
|
$t["ragioneSociale"] = $membro["ragione_sociale"]; |
|
$t["ruolo"] = $membro["ruolo"] ?? "04-CAPOGRUPPO"; |
|
$raggr[] = $t; |
|
} |
|
$tmp["aggiudicatari"]["aggiudicatarioRaggruppamento"][] = ["membro"=>$raggr]; |
|
} |
|
} |
|
} |
|
} |
|
$lotti[] = $tmp; |
|
} |
|
if (!empty($lotti)) { |
|
$errors += anac::massiveImport($_SESSION["ente"]->codice,$anno,$lotti); |
|
} |
|
} |
|
} |
|
if (empty($errors)) { |
|
?> |
|
swal({title:js_dict["success-msg"],type:"success"}).then(function(){ |
|
window.location.reload(); |
|
}); |
|
<? |
|
} else { |
|
ob_start(); |
|
?> |
|
<div class="table-responsive"> |
|
<table class="table table-striped"> |
|
<thead> |
|
<tr> |
|
<td><?= __("errore") ?></td> |
|
</tr> |
|
</thead> |
|
<tbody> |
|
<? |
|
foreach($errors AS $errore) { |
|
?> |
|
<tr> |
|
<td><strong><?= $errore ?></strong></td> |
|
</tr> |
|
<? |
|
} |
|
?> |
|
</tbody> |
|
</table> |
|
</div> |
|
<? |
|
$table = ob_get_clean(); |
|
?> |
|
swal({title:js_dict.error,type:"error",html: "<?= preg_replace("/[^\\\<\>A-Za-z0-9 ]/","",$table) ?>"}).then(function(){ |
|
window.location.reload(); |
|
}); |
|
<? |
|
} |
|
} |
|
} |
|
if ($error) { |
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
} |
|
?>
|
|
|