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.
764 righe
31 KiB
764 righe
31 KiB
<? |
|
|
|
class publicGara extends gara { |
|
|
|
public $potentialAction; // serve ad identificare se l'utente che ha istanziato l'oggetto può interagire con la gara |
|
private $managerPartecipazione; |
|
private $__proceduraAttiva; |
|
public static function getList($codice_gestore,$filters=[],$order=["b_gare.id"=>"DESC"],$start=0,$length=1) { |
|
global $pdo; |
|
$bind = [":codice_gestore"=>$codice_gestore]; |
|
$select = "SELECT b_gare.codice, b_gare.tipologia, b_gare.procedura, b_gare.codice_ente, b_gare.id, b_gare_round.id AS idFase, b_gare.stato, b_gare.prezzoRiferimento, b_gare.oggetto, b_gare.fase_attiva, b_gare_round.numero, |
|
b_gare_round.codice AS codice_round, b_gare_round.pubblicazione, b_gare_round.chiarimenti, b_gare_round.scadenza, |
|
GROUP_CONCAT(DISTINCT b_gare_lotti.cig) AS cig "; |
|
$from = " FROM b_gare JOIN b_gare_round ON b_gare.codice = b_gare_round.codice_gara AND b_gare.fase_attiva = b_gare_round.numero |
|
JOIN b_gare_lotti ON b_gare.codice = b_gare_lotti.codice_gara "; |
|
$where = " WHERE ((b_gare_round.pubblica = 2 AND b_gare_round.pubblicazione <= now()) "; |
|
if (isset($_SESSION["utente"])) { |
|
$where .= " OR (b_gare_round.pubblica = 1 AND b_gare_round.pubblicazione <= now() "; |
|
if (!empty($_SESSION["utente"]->oe)) { |
|
$idAperte = static::idFasiAperte(); |
|
$idInvito = static::idFasiInvito(); |
|
$bind[":operatore"] = $_SESSION["utente"]->oe["codice"]; |
|
$where .= " AND ("; |
|
$count = 0; |
|
$whereAperte = []; |
|
foreach($idAperte AS $idProcedura => $idFasi) { |
|
foreach($idFasi AS $idFase) { |
|
$bind[":procedura{$count}"] = $idProcedura; |
|
$bind[":fase{$count}"] = $idFase; |
|
$whereAperte[] = "(b_gare.procedura = :procedura{$count} AND b_gare_round.id = :fase{$count})"; |
|
$count++; |
|
} |
|
} |
|
$where .= "(" . implode(" OR ",$whereAperte) . ") OR ("; |
|
$whereInvito = []; |
|
foreach($idInvito AS $idProcedura => $idFasi) { |
|
foreach($idFasi AS $idFase) { |
|
$bind[":procedura{$count}"] = $idProcedura; |
|
$bind[":fase{$count}"] = $idFase; |
|
$whereInvito[] = "(b_gare.procedura = :procedura{$count} AND b_gare_round.id = :fase{$count})"; |
|
$count++; |
|
} |
|
} |
|
$where .= " (" . implode(" OR ",$whereInvito) . ") AND b_gare_round.codice IN (SELECT r_inviti_gare.codice_round FROM r_inviti_gare WHERE r_inviti_gare.codice_operatore = :operatore) "; |
|
$where .= ") )"; |
|
} else if (isset($_SESSION["utente"]) && !$_SESSION["utente"]->isSupportoOrRoot()) { |
|
$visualizzazioneGlobale = settingsManager::getValue("visualizzazioneProcedureRiservateATutti"); |
|
if ($visualizzazioneGlobale != "S") { |
|
if ($_SESSION["utente"]->gerarchia > 10) { |
|
$ids = Utente::getPermissionsInModulo($_SESSION["ente"]->codice,$_SESSION["utente"]->codice,"gare"); |
|
if (empty($ids)) { $ids = [0]; } |
|
$ids = implode(",",$ids); |
|
$where .= " AND b_gare.codice IN ({$ids}) "; |
|
} |
|
if (!$_SESSION["utente"]->fromHere()) { |
|
$where .= " AND codice_ente = :codice_ente "; |
|
$bind[":codice_ente"] = $_SESSION["utente"]->codice_ente; |
|
} |
|
} |
|
} |
|
$where .= ") "; |
|
} |
|
$where .= ") "; |
|
if (!empty($filters)) { |
|
$keys = ["b_gare.id","b_gare.oggetto","b_gare_lotti.oggetto","b_gare_lotti.cig","b_gare_lotti.cup"]; |
|
$addWhere = []; |
|
foreach($keys AS $key) { |
|
if (isset($filters[$key]) || isset($filters["*"])) { |
|
$value = $filters[$key] ?? $filters["*"]; |
|
$sudd = suddivisione_pdo($value,$key); |
|
if (!empty($sudd)) { |
|
$bind = $bind + $sudd["bind"]; |
|
$addWhere[] = $sudd["sql"]; |
|
} |
|
} |
|
} |
|
|
|
if (count($addWhere) > 0) { $where .= " AND (" . implode(" OR ",$addWhere) . ") "; } |
|
if (isset($filters["b_gare.codice_ente"])) { |
|
$bind[":codice_ente"] = (int)$filters["b_gare.codice_ente"]; |
|
$where .= " AND b_gare.codice_ente = :codice_ente "; |
|
} |
|
if (isset($filters["b_gare.procedura"])) { |
|
$bind[":procedura"] = $filters["b_gare.procedura"]; |
|
$where .= " AND b_gare.procedura = :procedura "; |
|
} |
|
if (isset($filters["b_gare.tipologia"])) { |
|
$bind[":tipologia"] = $filters["b_gare.tipologia"]; |
|
$where .= " AND b_gare.tipologia = :tipologia "; |
|
} |
|
if (isset($filters["b_gare.stato"])) { |
|
if (is_numeric($filters["b_gare.stato"])) { |
|
$bind[":stato"] = (int)$filters["b_gare.stato"]; |
|
$where .= " AND b_gare.stato = :stato "; |
|
} else if (!empty($_SESSION["utente"]->oe)) { |
|
$stato = $filters["b_gare.stato"]; |
|
if ($stato == "bozza") { |
|
$bind[":operatore"] = $_SESSION["utente"]->oe["codice"]; |
|
$from .= " JOIN r_partecipanti_gare ON b_gare_round.codice = r_partecipanti_gare.codice_round "; |
|
$where .= " AND r_partecipanti_gare.codice_operatore = :operatore AND b_gare_round.scadenza > now() AND r_partecipanti_gare.conferma = 'N' "; |
|
} else if ($stato == "inviti") { |
|
$bind[":operatore"] = $_SESSION["utente"]->oe["codice"]; |
|
$from .= " JOIN r_inviti_gare ON b_gare_round.codice = r_inviti_gare.codice_round "; |
|
$where .= " AND r_inviti_gare.codice_operatore = :operatore AND b_gare_round.pubblicazione <= now() AND b_gare_round.scadenza > now() AND b_gare_round.pubblica > 0 "; |
|
} else if ($stato == "aggiudicati") { |
|
$bind[":operatore"] = $_SESSION["utente"]->oe["codice"]; |
|
$from .= " JOIN r_partecipanti_gare ON b_gare_round.codice = r_partecipanti_gare.codice_round "; |
|
$from = str_replace("AND b_gare.fase_attiva = b_gare_round.numero","",$from); |
|
$where .= " AND r_partecipanti_gare.codice_operatore = :operatore AND r_partecipanti_gare.aggiudicatario = 'S' AND b_gare.stato >= 35 "; |
|
} else if ($stato == "archivio") { |
|
$bind[":operatore"] = $_SESSION["utente"]->oe["codice"]; |
|
$from .= " JOIN r_partecipanti_gare ON b_gare_round.codice = r_partecipanti_gare.codice_round "; |
|
$from = str_replace("AND b_gare.fase_attiva = b_gare_round.numero","",$from); |
|
$where .= " AND r_partecipanti_gare.codice_operatore = :operatore AND r_partecipanti_gare.conferma = 'S' "; |
|
} |
|
} else { |
|
return []; |
|
} |
|
} |
|
if (isset($filters["b_gare.codice"])) { |
|
$bind[":codice"] = (int)$filters["b_gare.codice"]; |
|
$where .= " AND b_gare.codice = :codice "; |
|
} |
|
} |
|
$sort = "ORDER BY b_gare.codice DESC "; |
|
if (!empty($order)) { |
|
$keys = ["b_gare.codice","b_gare.stato","b_gare.oggetto","b_gare.prezzoRiferimento","b_gare_round.pubblicazione","b_gare_round.chiarimenti","b_gare_round.numero","b_gare_round.scadenza"]; |
|
$sortArray = []; |
|
foreach($keys AS $key) { |
|
if (isset($order[$key])) { |
|
if (strcmp($order[$key],"ASC") === 0) { |
|
$sortArray[] = "{$key} ASC"; |
|
} else { |
|
$sortArray[] = "{$key} DESC"; |
|
} |
|
} |
|
} |
|
if (!empty($sortArray)) { |
|
$sort = " ORDER BY " . implode(",",$sortArray); |
|
} |
|
} |
|
$limit = ""; |
|
if (is_numeric($start) && is_numeric($length) && $length > 0) { |
|
$start = (int)$start; |
|
$length = (int)$length; |
|
$limit = " LIMIT {$start}, {$length}"; |
|
} |
|
$return = $pdo->go($select.$from.$where." GROUP BY b_gare.codice ".$sort.$limit,$bind)->fetchAll(PDO::FETCH_ASSOC); |
|
return $return; |
|
} |
|
|
|
private function __construct() { |
|
global $pdo; |
|
$this->db = $pdo; |
|
$this->commissario = false; |
|
$this->potentialAction = false; |
|
$this->managerPartecipazione = null; |
|
} |
|
|
|
public static function idFasiAperte() { |
|
$procedure = getProcedure(); |
|
$return = []; |
|
if (!empty($procedure)) { |
|
foreach($procedure AS $idProcedura => $procedura) { |
|
if (!empty($procedura["fasi"])) { |
|
foreach($procedura["fasi"] AS $id => $fase) { |
|
if ($fase["aperta"]) { |
|
if (!isset($return[$idProcedura])) { |
|
$return[$idProcedura] = []; |
|
} |
|
if (!in_array($id,$return[$idProcedura])) { |
|
$return[$idProcedura][] = $id; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return $return; |
|
} |
|
|
|
public static function idFasiInvito() { |
|
$procedure = getProcedure(); |
|
$return = []; |
|
if (!empty($procedure)) { |
|
foreach($procedure AS $idProcedura => $procedura) { |
|
if (!empty($procedura["fasi"])) { |
|
foreach($procedura["fasi"] AS $id => $fase) { |
|
if (!$fase["aperta"]) { |
|
if (!isset($return[$idProcedura])) { |
|
$return[$idProcedura] = []; |
|
} |
|
if (!in_array($id,$return[$idProcedura])) { |
|
$return[$idProcedura][] = $id; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return $return; |
|
} |
|
|
|
public function miaPartecipazione() { |
|
if (isset($_SESSION["utente"]) && $_SESSION["utente"]->gerarchia >= 100 && !empty($_SESSION["utente"]->oe) && !empty($this->lotto)) { |
|
$bind = [":codice_round"=>$this->round["codice"]]; |
|
$bind[":codice_operatore"]=$_SESSION["utente"]->oe["codice"]; |
|
$bind[":codice_lotto"]=$this->lotto["codice"]; |
|
$sql = "SELECT * FROM r_partecipanti_gare WHERE codice_round = :codice_round AND codice_lotto = :codice_lotto AND codice_operatore = :codice_operatore"; |
|
return $this->db->go($sql,$bind)->fetchAll(PDO::FETCH_ASSOC)[0] ?? false; |
|
} |
|
} |
|
|
|
public function partecipato($confirmed = null) { |
|
if (isset($_SESSION["utente"]) && $_SESSION["utente"]->gerarchia >= 100 && !empty($_SESSION["utente"]->oe)) { |
|
$bind = [":codice_round"=>$this->round["codice"]]; |
|
$bind[":codice_operatore"]=$_SESSION["utente"]->oe["codice"]; |
|
$sql = "SELECT codice FROM r_partecipanti_gare WHERE codice_round = :codice_round AND codice_operatore = :codice_operatore"; |
|
if (isset($confirmed)) { |
|
$sql .= " AND conferma = :conferma "; |
|
$bind[":conferma"] = ($confirmed) ? "S" : "N"; |
|
} |
|
return ($this->db->go($sql,$bind)->rowCount() > 0) ? true : false; |
|
} |
|
} |
|
|
|
public function listPartecipanti($partecipante=null) { |
|
return parent::listPartecipanti($this->miaPartecipazione()["codice"] ?? false); |
|
} |
|
|
|
public function listPartecipantiSeduta($partecipante=null) { |
|
if ($this->sedutaAperta()) { |
|
return parent::listPartecipanti($partecipante); |
|
} |
|
return false; |
|
} |
|
|
|
public function revoca($delete = false) { |
|
$return = false; |
|
if ($this->partecipazioneAttiva()) { |
|
$partecipante = $this->miaPartecipazione(); |
|
if (!empty($partecipante)) { |
|
if (!$delete) { |
|
$salva = new salva(); |
|
$salva->debug = false; |
|
|
|
$salva->nome_tabella = "r_partecipanti_gare"; |
|
$salva->operazione = "UPDATE"; |
|
$salva->oggetto = ["codice"=>$partecipante["codice"],"conferma"=>"N"]; |
|
$return = $salva->save(); |
|
} else { |
|
$richieste = $this->getRichieste(); |
|
foreach($richieste AS $richiesta) { |
|
$this->deleteBusta($richiesta["codice"]); |
|
} |
|
$ris = $this->db->go("DELETE FROM r_partecipanti_gare WHERE codice = :codice",[":codice"=>$partecipante["codice"]]); |
|
if ($ris->rowCount() > 0) { |
|
$return = true; |
|
scriviLog("r_partecipanti_gare","DELETE",$this->db->getSQL()); |
|
} |
|
} |
|
if (!empty($return)) { |
|
if ($this->modalitaLotti() == "tutti") { |
|
$this->db->go("UPDATE r_partecipanti_gare SET conferma = 'S' WHERE codice_round = :round AND codice_operatore = :operatore",[":round"=>$this->round["codice"],":operatore"=>$_SESSION["utente"]->oe["codice"]]); |
|
scriviLog("r_partecipanti_gare","DELETE",$this->db->getSQL()); |
|
} |
|
if ($partecipante["conferma"] == "S") { |
|
$editor = new editorManager("msg-revoca-gara",0); |
|
$editor->vocabolario["ragione-sociale"] = $_SESSION["utente"]->oe["ragione_sociale"]; |
|
$editor->vocabolario["gara"] = $this->info; |
|
$editor->vocabolario["fase"] = $this->round; |
|
$editor->vocabolario["lotto"] = $this->lotto; |
|
$corpo = $editor->getModello(); |
|
$mailer = new Communicator(); |
|
$mailer->oggetto = __('Revoca partecipazione') . " Gara #" . $this->info["id"]; |
|
if ($this->modalitaLotti() != "tutti") { |
|
$mailer->oggetto .= " - Lotto #" . $this->lotto["numero"]; |
|
} |
|
$mailer->corpo = $corpo; |
|
$mailer->codice_pec = $this->info["codice_pec"] ?? 0; |
|
$mailer->comunicazione = true; |
|
$mailer->sezione = "gare"; |
|
$mailer->codice_gara = $this->info["codice"]; |
|
$mailer->coda = false; |
|
$mailer->destinatari = array($_SESSION["utente"]->oe["codice"]); |
|
$mailer->send(); |
|
|
|
$mailer->codice_pec = -1; |
|
$mailer->comunicazione = false; |
|
$mailer->destinatari = Communicator::getPecAddress($this->info["codice_pec"]); |
|
$mailer->send(); |
|
} |
|
} |
|
} |
|
} |
|
return $return; |
|
} |
|
|
|
public function getPartecipantiSeduta($codice = "") { |
|
if ($this->sedutaAperta()) { |
|
if (empty($codice)) { |
|
return parent::getPartecipanti(); |
|
} else { |
|
return parent::getPartecipante($codice); |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
private function getPartecipanteForBusta($partecipante) { |
|
$caller = debug_backtrace()[2]['function'] ?? null; |
|
if ($caller != "getBustaAccesso") { |
|
$tmp = $this->miaPartecipazione(); |
|
if (!empty($tmp)) { |
|
return $tmp["codice"]; |
|
} |
|
} else { |
|
return $partecipante; |
|
} |
|
} |
|
|
|
public function getBusta($partecipante,$richiesta,$aggiuntive = false,bool $contenuto = false) { |
|
$partecipante = $this->getPartecipanteForBusta($partecipante); |
|
if (!empty($partecipante)) { |
|
return parent::getBusta($partecipante,$richiesta,$aggiuntive,$contenuto); |
|
} |
|
return false; |
|
} |
|
|
|
public function getBustaSecretata($partecipante,$richiesta,$derivazione,bool $contenuto = false) { |
|
$partecipante = $this->getPartecipanteForBusta($partecipante); |
|
if (!empty($partecipante)) { |
|
return parent::getBustaSecretata($partecipante,$richiesta,$derivazione,$contenuto); |
|
} |
|
return false; |
|
} |
|
|
|
public function deleteBusta($codice_richiesta) { |
|
if ($this->partecipazioneAttiva() && !empty($this->miaPartecipazione())) { |
|
$busta = $this->getBusta($this->miaPartecipazione()["codice"],$codice_richiesta,false); |
|
if (!empty($busta)) { |
|
unlink($this->getSpecificBustaPath($busta)); |
|
$sql = "DELETE FROM b_gare_buste WHERE codice_partecipante = :codice_partecipante AND codice_richiesta = :codice_richiesta "; |
|
$this->db->go($sql,[":codice_partecipante"=>$this->miaPartecipazione()["codice"],":codice_richiesta"=>$codice_richiesta]); |
|
scriviLog("b_gare_buste","DELETE",$this->db->getSQL()); |
|
$this->deleteSecretate($codice_richiesta); |
|
} |
|
} |
|
} |
|
|
|
public function deleteSecretate($codice_richiesta) { |
|
if ($this->partecipazioneAttiva() && !empty($this->miaPartecipazione())) { |
|
$derivazione = "busta"; |
|
} else if ($this->emendamentiAttivi()) { |
|
$derivazione = "emendamento"; |
|
} |
|
if (!empty($derivazione)) { |
|
$busta = $this->getBustaSecretata($this->miaPartecipazione()["codice"],$codice_richiesta,$derivazione,false); |
|
if (!empty($busta)) { |
|
unlink($this->getSpecificSecretatePath($busta)); |
|
$sql = "DELETE FROM b_gare_buste_secretate WHERE derivazione = :derivazione AND codice_partecipante = :codice_partecipante AND codice_richiesta = :codice_richiesta "; |
|
$this->db->go($sql,[":codice_partecipante"=>$this->miaPartecipazione()["codice"],":derivazione"=>$derivazione,":codice_richiesta"=>$codice_richiesta]); |
|
scriviLog("b_gare_buste_secretate","DELETE",$this->db->getSQL()); |
|
} |
|
} |
|
} |
|
|
|
public function getEmendamento($partecipante,$richiesta,bool $contenuto = false) { |
|
$partecipante = $this->getPartecipanteForBusta($partecipante); |
|
if (!empty($partecipante)) { |
|
return parent::getEmendamento($partecipante,$richiesta,$contenuto); |
|
} |
|
return false; |
|
} |
|
|
|
public function deleteEmendamento($codice_richiesta) { |
|
if ($this->emendamentiAttivi()) { |
|
$busta = $this->getEmendamento($this->miaPartecipazione(),$codice_richiesta,false); |
|
if (!empty($busta)) { |
|
unlink($this->getSpecificEmendamentoPath($busta)); |
|
$sql = "DELETE FROM b_gare_emendamenti WHERE codice_partecipante = :codice_partecipante AND codice_richiesta = :codice_richiesta "; |
|
$this->db->go($sql,[":codice_partecipante"=>$this->miaPartecipazione()["codice"],":codice_richiesta"=>$codice_richiesta]); |
|
scriviLog("b_gare_emendamenti","DELETE",$this->db->getSQL()); |
|
$this->deleteSecretate($codice_richiesta); |
|
} |
|
} |
|
} |
|
|
|
public function showPanel() { |
|
$return = $this->partecipazioneAttiva(); |
|
if (!$return) { |
|
$return = $this->miaPartecipazione(); |
|
if (!empty($return)) { |
|
if ($return["conferma"] != "S") { |
|
return false; |
|
} |
|
} |
|
} |
|
if (!empty($return)) { |
|
return true; |
|
} |
|
return false; |
|
} |
|
|
|
public function hasInvito() { |
|
if ($this->round["infoFase"]["aperta"]) { |
|
return true; |
|
} else { |
|
$invitati = $this->getInvitati(); |
|
$invitati = array_column($invitati,"codice_operatore"); |
|
if (isset($_SESSION["utente"]) && array_search($_SESSION["utente"]->oe["codice"],$invitati) !== false) { |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
public function partecipazioneAttiva() { |
|
if ($this->potentialAction) { |
|
if (is_null($this->__proceduraAttiva)) { |
|
$this->__proceduraAttiva = false; |
|
if ($this->getModalita()["online"]) { |
|
if ($this->info["stato"] == "20") { |
|
if ($this->info["fase_attiva"] == $this->round["numero"]) { |
|
if (strtotime($this->round["scadenza"]) > time()) { |
|
$this->__proceduraAttiva = true; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($this->__proceduraAttiva) { |
|
if (empty($this->lotto)) { |
|
return true; |
|
} else { |
|
$return = $this->hasInvito(); |
|
if ($return) { |
|
$modalita = $this->modalitaLotti(); |
|
if ($modalita === "singola" && $this->partecipato(true)) { |
|
$return = false; |
|
$partecipazione = $this->miaPartecipazione(); |
|
if (!empty($partecipazione) && $partecipazione["conferma"] == "S") { |
|
$return = true; |
|
} |
|
} |
|
} |
|
return $return; |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
public function canAccessAccessoAttiAutomatico($lotto = null) { |
|
if (empty($this->lotto)) { |
|
$setLotto = true; |
|
if (empty($lotto)) { |
|
$lotti = array_column($this->getLotti(),"codice"); |
|
} else { |
|
$lotti = [$lotto]; |
|
} |
|
} else { |
|
$setLotto = false; |
|
$lotti = [$this->lotto["codice"]]; |
|
} |
|
if (!empty($lotti)) { |
|
foreach($lotti AS $lotto) { |
|
if ($setLotto) { |
|
$this->setLotto($lotto); |
|
} |
|
if ($this->accessoAttiAutomatico($lotto) && $this->pubblicaAtti()) { |
|
$partecipante = $this->miaPartecipazione(); |
|
if (!empty($partecipante) && $partecipante["escluso"] == "N" && $partecipante["conferma"] == "S") { |
|
if ($setLotto) { |
|
$this->lotto = null; |
|
} |
|
return true; |
|
} |
|
} |
|
if ($setLotto) { |
|
$this->lotto = null; |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
public function getBusteSoggetteAccesso() { |
|
$io = $this->miaPartecipazione(); |
|
$return = []; |
|
if ($io["escluso"] == "N") { |
|
$richieste = $this->getRichiestePubblicabili(); |
|
$partecipanti = $this->getPartecipanti(); |
|
if (!empty($richieste) && !empty($partecipanti)) { |
|
foreach($partecipanti AS $partecipante) { |
|
if ($partecipante["codice"] != $io["codice"] && $partecipante["escluso"] == "N" && !empty($partecipante["posizione"]) && ( |
|
((int) $partecipante["posizione"] === 1) || |
|
($io["posizione"] <= 5 && $partecipante["posizione"] <= 5) |
|
)) { |
|
$return[$partecipante["codice"]] = []; |
|
foreach($richieste AS $richiesta) { |
|
$tmp = $this->getBustaAccesso($richiesta["codice"],$partecipante["codice"]); |
|
if (!empty($tmp) && $tmp["pubblica"] == "S") { |
|
$return[$partecipante["codice"]][$richiesta["codice"]] = $tmp; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return $return; |
|
} |
|
|
|
public function emendamentiAttivi() { |
|
if ($this->potentialAction && $this->getModalita()["online"] && $this->info["stato"] == "21" && $this->info["fase_attiva"] == $this->round["numero"] && strtotime($this->round["scadenza"]) < time() && strtotime($this->round["apertura"]) > time() && ((!empty($this->getRisposteElaborazione()["emendamentoOfferte"])) && $this->getRisposteElaborazione()["emendamentoOfferte"] == "S")) { |
|
$partecipazione = $this->miaPartecipazione(); |
|
if (!empty($partecipazione) && $partecipazione["conferma"] == "S") { |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
public function savePartecipante($placeholder = null) { |
|
$return = false; |
|
if (!empty($this->lotto)) { |
|
$partecipante = array(); |
|
$partecipante["codice_round"] = $this->round["codice"]; |
|
$partecipante["codice_lotto"] = $this->lotto["codice"]; |
|
$partecipante["codice_operatore"] = $_SESSION["utente"]->oe["codice"]; |
|
$partecipante["stato"] = $_SESSION["utente"]->oe["stato_legale"]; |
|
$partecipante["codice_fiscale"] = $_SESSION["utente"]->oe["codice_fiscale_impresa"]; |
|
$partecipante["ragione_sociale"] = $_SESSION["utente"]->oe["ragione_sociale"]; |
|
if (!$this->round["infoFase"]["autoAmmissione"]) { |
|
$partecipante["escluso"] = "P"; |
|
} |
|
$salva = new salva(); |
|
$salva->debug = false; |
|
|
|
$salva->nome_tabella = "r_partecipanti_gare"; |
|
$salva->operazione = "INSERT"; |
|
$salva->oggetto = $partecipante; |
|
$salva->oggetto["uuid"] = uuidgen_v4(); |
|
if ($salva->save()) { |
|
$return = $this->miaPartecipazione(); |
|
} |
|
} |
|
return $return; |
|
} |
|
|
|
public function checkFormFill($busta="") { |
|
$return = false; |
|
$partecipante = $this->miaPartecipazione(); |
|
if (!empty($partecipante)) { |
|
$bind = []; |
|
$bind[":partecipante"] = $partecipante["codice"]; |
|
$bind[":busta"] = $busta; |
|
$check = "SELECT codice,md5,sha1,sha256,shaContent,salt FROM b_offerte_gare WHERE codice_partecipante = :partecipante AND tipo = :busta ORDER BY codice DESC"; |
|
$return = $this->db->go($check,$bind)->fetch(PDO::FETCH_ASSOC); |
|
} |
|
return $return; |
|
} |
|
|
|
public function chiarimentiAperti() { |
|
if ($this->potentialAction) { |
|
if ($this->getModalita()["online"]) { |
|
if ($this->info["stato"] == "20") { |
|
if ($this->info["fase_attiva"] == $this->round["numero"]) { |
|
if (strtotime($this->round["chiarimenti"]) > time()) { |
|
return true; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
public function sopralluogoAperti() { |
|
if ($this->potentialAction) { |
|
if ($this->getModalita()["online"]) { |
|
if ($this->info["stato"] == "20") { |
|
if ($this->info["fase_attiva"] == $this->round["numero"]) { |
|
if (!empty(mysql2datetime($this->round["sopralluogo"])) && strtotime($this->round["sopralluogo"]) > time()) { |
|
return true; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
public static function init($codice,$codice_round=NULL,$valutazione=NULL) { |
|
if (!empty($codice) && !empty($_SESSION["ente"])) { |
|
$check = self::getList($_SESSION["ente"]->codice,["b_gare.codice"=>$codice]); |
|
if (!empty($check) && count($check) == 1) { |
|
global $pdo; |
|
$bind = [":codice"=>$codice]; |
|
$sql = "SELECT * FROM b_gare WHERE codice = :codice "; |
|
$gara = $pdo->go($sql,$bind)->fetch(PDO::FETCH_ASSOC); |
|
if (!empty($gara)) { |
|
$continua = false; |
|
$bind = [":codice_gara"=>$codice]; |
|
$sql = "SELECT * FROM b_gare_round WHERE codice_gara = :codice_gara "; |
|
if (!empty($codice_round)) { |
|
$bind[":codice_round"] = $codice_round; |
|
$sql .= " AND codice = :codice_round "; |
|
} |
|
$sql .= " ORDER BY numero DESC"; |
|
$rounds = $pdo->go($sql,$bind); |
|
if ($rounds->rowCount() > 0) { |
|
if (empty($codice_round)) { |
|
while($round = $rounds->fetch(PDO::FETCH_ASSOC)) { |
|
if ($round["numero"] == $gara["fase_attiva"]) { |
|
break; |
|
} |
|
} |
|
} else { |
|
$round = $rounds->fetch(PDO::FETCH_ASSOC); |
|
} |
|
} |
|
if (isset($round)) { |
|
$instance = new publicGara(); |
|
$instance->info = $gara; |
|
$instance->round = $round; |
|
$instance->round["infoFase"] = $instance->getProcedura()["fasi"][$instance->round["id"]]; |
|
$instance->activeRound = false; |
|
$instance->privata = false; |
|
$allRounds = $instance->getRounds(); |
|
$roundRiferimento = reset($allRounds); |
|
$timeRiferimentoNormativo = time(); |
|
if (!empty($roundRiferimento["pubblicazione"])) { |
|
$timeRiferimentoNormativo = strtotime($roundRiferimento["pubblicazione"]); |
|
} |
|
$enteBeneficiario = Ente::getInfoFromID($gara["codice_ente"])[0] ?? null; |
|
if (isset($enteBeneficiario["soggettoPrivato"]) && $enteBeneficiario["soggettoPrivato"] == "S") { |
|
$instance->privata = true; |
|
} |
|
if ($round["numero"] == $gara["fase_attiva"]) { |
|
$instance->activeRound = true; |
|
} |
|
if ($round["numero"] < $gara["fase_attiva"]) { |
|
$instance->info["stato"] = 100; |
|
} else if ($round["numero"] > $gara["fase_attiva"]) { |
|
$instance->info["stato"] = 0; |
|
if ($gara["stato"] > 0) { $instance->info["stato"] = 10; } |
|
} |
|
$extraInfo = $instance->getExtraInfo()["gara"]; |
|
if (!empty($extraInfo["normaRiferimento"]) && !empty(self::riferimentiNormativi()[$extraInfo["normaRiferimento"]])) { |
|
$instance->normaRiferimento = $extraInfo["normaRiferimento"]; |
|
} |
|
if (empty($instance->normaRiferimento)) { |
|
$instance->normaRiferimento = self::findRiferimentoNormativo($timeRiferimentoNormativo); |
|
} |
|
if (isset($_SESSION["utente"])) { |
|
if ($_SESSION["utente"]->gerarchia >= 100 && !empty($_SESSION["utente"]->oe)) { |
|
if ($instance->round["infoFase"]["aperta"]) { |
|
$instance->potentialAction = true; |
|
} else { |
|
if (strtotime($round["pubblicazione"]) <= time()) { |
|
$invitati = $instance->getInvitati(); |
|
foreach($invitati AS $invito) { |
|
if ($invito["codice_operatore"] == $_SESSION["utente"]->oe["codice"]) { |
|
$instance->potentialAction = true; |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($instance->privata && !$instance->potentialAction) { |
|
return false; |
|
} |
|
if ($gara["stato"] == 20 && strtotime($round["scadenza"]) < time() && $instance->activeRound) { |
|
$pdo->go("UPDATE b_gare SET stato = 21 WHERE codice = :codice AND stato = 20",[":codice"=>$gara["codice"]]); |
|
$instance->info["stato"] = 21; |
|
} |
|
return $instance; |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
} |
|
|
|
public function getAsta($object = false) { |
|
$asta = parent::getAsta(); |
|
if (!empty($asta)) { |
|
$istance = new publicAsta($this,$asta); |
|
if (!empty($istance->info)) { |
|
if ($object) { |
|
return $istance; |
|
} else { |
|
return $asta; |
|
} |
|
} |
|
} |
|
} |
|
|
|
public function getChiarimenti($codice = NULL) { |
|
$tmp = parent::getChiarimenti($codice); |
|
$chiarimenti = []; |
|
$codice_oe = $_SESSION["utente"]->oe["codice"] ?? null; |
|
foreach($tmp AS $chiarimento) { |
|
if ($codice_oe == $chiarimento["codice_richiedente"] || (!empty($chiarimento["risposta"]) && $chiarimento["attivo"] == "S")) { |
|
$chiarimenti[] = $chiarimento; |
|
} |
|
} |
|
return $chiarimenti; |
|
} |
|
|
|
public function getSopralluoghi($codice = NULL) { |
|
$tmp = parent::getSopralluoghi($codice); |
|
$sopralluoghi = []; |
|
$codice_oe = $_SESSION["utente"]->oe["codice"] ?? null; |
|
foreach($tmp AS $chiarimento) { |
|
if ($codice_oe == $chiarimento["codice_richiedente"]) { |
|
if ($chiarimento["attivo"] == "P") { |
|
$chiarimento["risposta"] = ""; |
|
$chiarimento["appuntamento"] = null; |
|
} |
|
$sopralluoghi[] = $chiarimento; |
|
} |
|
} |
|
return $sopralluoghi; |
|
} |
|
|
|
public function getAvvisi() { |
|
return parent::getManagerAvvisi()->getAvvisi(); |
|
} |
|
|
|
public function getManagerRichieste() { |
|
$manager = new publicRichiesteOE("gare",$this->info["codice"],$this->lotto["codice"] ?? null); |
|
if (!empty($manager)) { |
|
return $manager; |
|
} |
|
} |
|
|
|
public function getRichiesteIntegrazione() { |
|
$manager = $this->getManagerRichieste(); |
|
if (!empty($manager)) { |
|
return $manager->getRichieste(); |
|
} |
|
} |
|
|
|
public function getManagerPartecipazione() { |
|
if (empty($this->managerPartecipazione)) { |
|
$manager = new busteOE; |
|
$manager->submit = ($this->hasInvito() && $this->partecipazioneAttiva()); |
|
$manager->amend = $this->emendamentiAttivi(); |
|
$manager->obj = $this; |
|
$manager->modulo = "gare"; |
|
$manager->deletable = $this->partecipazioneAttiva(); |
|
$manager->variables = ["codice_gara"=>$this->info["codice"],"codice_lotto"=>$this->lotto["codice"],"codice_round"=>$this->round["codice"]]; |
|
$this->managerPartecipazione = $manager; |
|
} |
|
return $this->managerPartecipazione; |
|
} |
|
|
|
} |
|
|
|
?>
|