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.
124 righe
6.4 KiB
124 righe
6.4 KiB
<? |
|
if (isset($this) && is_a($this,"anac") && !empty($cig)) { |
|
$codice_gestore = $this->info["codice_gestore"]; |
|
$codice_ente = $this->info["codice_ente"]; |
|
$sql = "SELECT b_gare.codice, b_gare_lotti.codice AS codice_lotto |
|
FROM b_gare |
|
JOIN b_gare_lotti ON b_gare_lotti.codice_gara = b_gare.codice |
|
WHERE b_gare_lotti.cig = :cig "; |
|
$codici = $this->db->go($sql,[":cig"=>$cig]); |
|
if ($codici->rowCount() > 0) { |
|
while($id = $codici->fetch(PDO::FETCH_ASSOC)) { |
|
$gara = gara::init($id["codice"]); |
|
if (!empty($gara)) { |
|
$gara->setLotto($id["codice_lotto"]); |
|
// scheda pubblicazione |
|
$pubblicazione = []; |
|
if (!empty($gara->round["pubblicazione"])) { |
|
$pubblicazione["dataPubblicazione"] = mysql2date($gara->round["pubblicazione"]); |
|
} |
|
if (!empty($gara->round["scadenza"])) { |
|
$scadenza = explode(" ",$gara->round["scadenza"]); |
|
$pubblicazione["dataScadenzaPag"] = mysql2date($scadenza[0]) ?? ""; |
|
$pubblicazione["oraScadenza"] = substr($scadenza[1] ?? "",0,5); |
|
} |
|
$data["pubblicazione"][] = ["source"=>"gare","data"=>$pubblicazione]; |
|
|
|
// dati 190 |
|
$xml190 = []; |
|
$xml190["190importoAggiudicato"] = ($gara->lotto["importoAggiudicazione"] > 0) ? number_format($gara->lotto["importoAggiudicazione"],2,".","") : ""; |
|
|
|
// scheda dati comuni |
|
$data["190"][] = ["source"=>"gare","data"=>$xml190]; |
|
|
|
if ($gara->lotto["stato"] == 95) { |
|
$data["comuni"][] = ["source"=>"gare","data"=>["ESITO_PROCEDURA"=>"3"]]; |
|
} else if ($gara->lotto["stato"] == 90) { |
|
$data["comuni"][] = ["source"=>"gare","data"=>["ESITO_PROCEDURA"=>"2"]]; |
|
} else if ($gara->lotto["stato"] >= 35) { |
|
$data["comuni"][] = ["source"=>"gare","data"=>["ESITO_PROCEDURA"=>"1"]]; |
|
} |
|
|
|
// scheda appalto |
|
|
|
$partecipanti = $gara->getPartecipanti(); |
|
$esclusi = 0; |
|
$aggiudicatari = []; |
|
if (!empty($partecipanti)) { |
|
$data["partecipanti"][] = ["source"=>"gare","data"=>$gara->arrangePartecipantiForANAC($partecipanti)]; |
|
foreach($partecipanti AS $partecipante) { |
|
if ($partecipante["escluso"] == "S") { $esclusi++; } |
|
if ($partecipante["aggiudicatario"] == "S") { $aggiudicatari[] = $partecipante; } |
|
} |
|
$appalto = []; |
|
$appalto["NUM_IMPRESE_INVITATE"] = count($gara->getInvitati()); |
|
$appalto["NUM_IMPRESE_OFFERENTI"] = count($partecipanti); |
|
$appalto["NUM_OFFERTE_AMMESSE"] = count($partecipanti) - $esclusi; |
|
$appalto["NUM_OFFERTE_ESCLUSE"] = $esclusi; |
|
$dati = $gara->getExtraInfo()["round"] ?? []; |
|
if (!empty($dati["estremi_definitiva"])) { |
|
preg_match('/[0-9]{2}\/[0-9]{2}\/[0-9]{4}/',$dati["estremi_definitiva"],$dataAggiudicazione); |
|
} |
|
$appalto["DATA_VERB_AGGIUDICAZIONE"] = (!empty($dataAggiudicazione[0])) ? $dataAggiudicazione[0] : ""; |
|
$appalto["DATA_SCADENZA_PRES_OFFERTA"] = $pubblicazione["dataScadenzaPag"] ?? null; |
|
$appalto["IMPORTO_AGGIUDICAZIONE"] = $xml190["190importoAggiudicato"] ?? null; |
|
$appalto["IMPORTO_SERVIZI"] = number_format($gara->info["prezzoRiferimento"],2,".",""); |
|
if (!empty($appalto["IMPORTO_AGGIUDICAZIONE"]) && !empty($gara->info["prezzoRiferimento"])) { $appalto["PERC_RIBASSO_AGG"] = 100 - ($appalto["IMPORTO_AGGIUDICAZIONE"] / $appalto["IMPORTO_SERVIZI"] * 100); } |
|
if ($gara->round["numero"] > 1) { $appalto["DATA_INVITO"] = mysql2date($gara->round["pubblicazione"]); } |
|
$data["appalto"][] = ["source"=>"gare","data"=>$appalto]; |
|
|
|
// scheda aggiudicatari |
|
if (!empty($aggiudicatari)) { |
|
$indiceRaggruppamento = 0; |
|
foreach($aggiudicatari AS $tmp) { |
|
$offertaEconomica = 0; |
|
if (count($aggiudicatari) === 1 && !empty($gara->lotto["importoAggiudicazione"])) { |
|
$offertaEconomica = $gara->lotto["importoAggiudicazione"]; |
|
} |
|
$aggiudicatario = []; |
|
$aggiudicatario["ID_TIPOAGG"] = 3; |
|
$aggiudicatario["RUOLO"] = ""; |
|
$aggiudicatario["ID_GRUPPO"] = ""; |
|
$aggiudicatario["CODICE_FISCALE_AGGIUDICATARIO"] = $tmp["codice_fiscale"]; |
|
$aggiudicatario["CODICE_STATO"] = $tmp["stato"]; |
|
if (!empty($gara->lotto["importoBase"])) { |
|
$aggiudicatario["PERC_RIBASSO_AGG"] = number_format(100 - ($offertaEconomica / $gara->lotto["importoBase"] * 100),2); |
|
} |
|
$aggiudicatario["IMPORTO DI AGGIUDICAZIONE"] = $offertaEconomica; |
|
$raggruppamento = $gara->getRaggruppamento($tmp["codice"]); |
|
if (!empty($raggruppamento)) { |
|
$indiceRaggruppamento++; |
|
$aggiudicatario["RUOLO"] = 1; |
|
$aggiudicatario["ID_GRUPPO"] = $indiceRaggruppamento; |
|
$first = true; |
|
foreach($raggruppamento AS $tmp) { |
|
if ($first) { |
|
$first = false; |
|
if (stripos($tmp["ruolo"],"cons") !== false) { |
|
$aggiudicatario["ID_TIPOAGG"] = 2; |
|
} else { |
|
$aggiudicatario["ID_TIPOAGG"] = 1; |
|
} |
|
$data["aggiudicatari"][] = ["source"=>"gare","data"=>$aggiudicatario]; |
|
} |
|
$membro = []; |
|
$membro["ID_TIPOAGG"] = $aggiudicatario["ID_TIPOAGG"]; |
|
$membro["RUOLO"] = 2; |
|
$membro["ID_GRUPPO"] = $indiceRaggruppamento; |
|
$membro["CODICE_FISCALE_AGGIUDICATARIO"] = $tmp["codice_fiscale_impresa"]; |
|
$membro["CODICE_STATO"] = $tmp["stato"]; |
|
$membro["PERC_RIBASSO_AGG"] = $aggiudicatario["PERC_RIBASSO_AGG"]; |
|
$membro["IMPORTO DI AGGIUDICAZIONE"] = $offertaEconomica; |
|
$data["aggiudicatari"][] = ["source"=>"gare","data"=>$membro]; |
|
} |
|
} else { |
|
$data["aggiudicatari"][] = ["source"=>"gare","data"=>$aggiudicatario]; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
?>
|