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.
170 righe
6.2 KiB
170 righe
6.2 KiB
<?php |
|
if (isset($this) && (is_a($this,"eFormsManager") || is_a($this,"NuovaPiattaformaAppalti")) && !empty($this->info["codice_elemento"]) && !empty($this->info["modulo"]) |
|
&& $this->info["modulo"] == "gare" |
|
&& isset($_SESSION["utente"]) |
|
&& $_SESSION["utente"]->permission($this->info["modulo"],$this->info["codice_elemento"])) { |
|
|
|
// Otteniamo info sulla gara |
|
$gara = gara::init($this->info["codice_elemento"]); |
|
|
|
if ($gara) { |
|
$retval = ["MODULO" => $this->info["modulo"]]; |
|
|
|
|
|
// Prepariamo la struttura dati per gara |
|
$general = $gara->info; |
|
// Togliamo la versione serializzata in JSON |
|
unset($general->info["extraInfo"]); |
|
$general["extraInfo"] = $gara->getExtraInfo(); |
|
// Info sui round (Scadenze) |
|
$general["round"] = $gara->round; |
|
|
|
$retval["ROUNDS"] = []; |
|
foreach($gara->getRounds() as $round) { |
|
$tmpGara = Gara::init($gara->info["codice"], $round["codice"]); |
|
$retval["ROUNDS"][$round["codice"]] = $tmpGara->round; |
|
$tmpGara = null; |
|
} |
|
|
|
$general["codiceAppalto"] = $gara->getPublicIdentifier(); |
|
|
|
// Tipologia e CPV |
|
switch($general["tipologia"]) { |
|
case "ST": |
|
case "S": |
|
$general["tipologia"] = "services"; |
|
break; |
|
case "F": |
|
$general["tipologia"] = "supplies"; |
|
break; |
|
default: |
|
$general["tipologia"] = "works"; break; |
|
} |
|
|
|
$general["CPV_CODES"] = $gara->getCategorieMerceologiche(); |
|
$retval["GENERAL"] = $general; |
|
// Caricamento dell'ente |
|
if (!empty($retval["GENERAL"]["codice_ente"])) { |
|
$tmp = Ente::getInfoFromID($retval["GENERAL"]["codice_ente"]); |
|
if(! empty($tmp)) { |
|
$tmp = reset($tmp); |
|
if (!empty($tmp["cf"])) { |
|
$ente = $tmp; |
|
} else if (!empty($tmp["sua"]) && $tmp["ufficio"] == "S") { |
|
$tmp = Ente::getInfoFromID($tmp["sua"]); |
|
if(! empty($tmp)) { |
|
$tmp = reset($tmp); |
|
if (!empty($tmp["cf"])) { |
|
$tmp = reset($tmp); |
|
$ente = $tmp; |
|
} |
|
} |
|
} |
|
} |
|
if (!empty($ente)) { |
|
|
|
$retval["STAZIONEAPPALTANTE"] = $ente; |
|
} |
|
|
|
} |
|
// Prendiamo l'url pubblico |
|
$retval["PUBLIC_URL"] = $gara->getPublicExternalURL(); |
|
// Prendiamo le info sulla procedura |
|
$retval["PROCEDURA"] = $gara->getProcedura(); |
|
// Prepariamo le info sui partecipanti che saranno popolate in base ai lotto |
|
$retval["PARTECIPANTI"] = []; |
|
|
|
// Incaricati |
|
$incaricati = $gara->getManagerIncarichi()->getIncaricati(); |
|
if (!empty($incaricati)) { |
|
foreach($incaricati AS $incaricato) { |
|
if (($incaricato["ruolo"] ?? null) == 14) { // 14: ruolo RUP |
|
$rup = $incaricato; |
|
if(isset($rup["extraInfo"])) { |
|
$rup = array_merge($rup["extraInfo"], $rup); |
|
unset($rup["extraInfo"]); |
|
} |
|
$retval["CONTRACTING_BODY"]["CONTACT_POINTS"][] = $rup; |
|
} |
|
} |
|
} |
|
$retval["LOT"] = []; |
|
// Lotti |
|
$lotti = $gara->getLotti(); |
|
|
|
foreach($lotti AS $lotto) { |
|
$gara->setLotto($lotto["codice"]); |
|
$lotto = $gara->lotto; |
|
if(is_a($this, "eFormsManager") && !empty($this->npa)) { |
|
$npa = $this->npa; |
|
$ignoreDeserta = false; |
|
if(isset($npa->scheda["id_scheda"])) { |
|
$idScheda = $npa->scheda["id_scheda"]; |
|
$metadata = $npa->metadataSchede[$idScheda]; |
|
$ignoreDeserta = $metadata['categoria'] === 'affidamento'; |
|
} |
|
|
|
if($ignoreDeserta && ($lotto["stato"] == 95 || $lotto["importoAggiudicazione"] == null)) { |
|
continue; |
|
} |
|
} |
|
$importoRibassabile = $lotto["importoRibassabile"] ?? 0; |
|
$importoNonRibassabile = $lotto["importoNonRibassabile"] ?? 0; |
|
$importoOpzioni = $lotto["importoOpzioni"] ?? 0; |
|
$lotto["importoTotale"] = $importoRibassabile + $importoNonRibassabile + $importoOpzioni; |
|
|
|
$lotto["PARTECIPANTI"] = $gara->getPartecipanti(); |
|
$lotto["VINCITORI"] = $gara->getAggiudicatari(); |
|
foreach( $gara->getCriteri() as $criterio_i => $criterio) { |
|
$criterio["codice_gara"] = $gara->info["codice"]; |
|
$criterio["codice_lotto"] = $lotto["codice"]; |
|
$criterio["formule"] = $gara::getFormule(); |
|
$lotto["CRITERI"][$criterio_i] = $criterio; |
|
$lotto["OFFERTE"][$criterio_i] = $gara->getOfferte($criterio["codice"]); |
|
} |
|
$lotto["CAT_SOA"] = $gara->getSOA(); |
|
|
|
// Assicuriamoci che tutti i partecipanti siano nell'array principale dei partecipanti |
|
// senza duplicati |
|
foreach($lotto["PARTECIPANTI"] as $partecipante_lotto) { |
|
$found = false; |
|
// Verifichiamo in partecipanti se esiste già |
|
foreach($retval["PARTECIPANTI"] as $partecipante) { |
|
$reference = "codice_operatore"; |
|
if(($partecipante[$reference] ?? 0) == 0) { $reference = "codice_fiscale"; } |
|
if($partecipante[$reference] === $partecipante_lotto[$reference] ) { |
|
$found = true; |
|
break; |
|
} |
|
} |
|
// Se non c'è, lo settiamo |
|
if(!$found) { |
|
$partecipante_lotto["vincitore"] = false; |
|
$retval["PARTECIPANTI"][] = $partecipante_lotto; |
|
$group = $gara->getRaggruppamento($partecipante_lotto["codice"]); |
|
if (!empty($group)) { |
|
foreach($group as $subPartecipante) { |
|
$subPartecipante["codice_fiscale"] = $subPartecipante["codice_fiscale_impresa"]; |
|
$subPartecipante["raggruppamento"] = true; |
|
$retval["PARTECIPANTI"][] = $subPartecipante; |
|
} |
|
} |
|
} |
|
} |
|
$retval["LOT"][] = $lotto; |
|
} |
|
|
|
// Assicuriamoci che i lotti siano ordinati in base al numero |
|
usort($retval["LOT"], function ($a, $b) { |
|
return ($a["numero"] ?? 0) > ($b["numero"] ?? 0); |
|
}); |
|
|
|
// Ripuliamo i valori vuoti |
|
if(empty($retval["PARTECIPANTI"])) {unset($retval["PARTECIPANTI"]);} |
|
if(empty($retval["VINCITORI"])) {unset($retval["VINCITORI"]);} |
|
if(empty($retval["LOT"])) {unset($retval["LOT"]);} |
|
|
|
return $retval; |
|
} |
|
} |
|
?>
|