db = $pdo; $this->directory = static::getDirectory(); $this->mainTable = static::getMainTable(); $this->oeTable = static::getOeTable(); $this->cpvTable = static::getCpvTable(); $this->richiesteTable = static::getRichiesteTable(); $this->formTable = static::getFormTable(); $this->chiarimentiTable = static::getChiarimentiTable(); $this->sopralluogoTable = static::getSopralluogoTable(); $this->busteTable = static::getBusteTable(); $this->modulo = static::getModulo(); $this->internalUsers = false; } private static function extensionExists($class) { if (isset($_SESSION["ente"])) { $pathExtender = $_SESSION["ente"]->getExtensionPath() . DIRECTORY_SEPARATOR . "{$class}.extender.class.php"; $extenderName = "{$class}Extender{$_SESSION["ente"]->codice}"; if (file_exists($pathExtender)) { include_once $pathExtender; return $extenderName; } } } public static function getDirectory() { return ""; } public static function getMainTable() { return ""; } public static function getOeTable() { return ""; } public static function getRichiesteTable() { return ""; } public static function getFormTable() { return ""; } public static function getModulo() { return ""; } public static function getCpvTable() { return ""; } public static function getChiarimentiTable() { return ""; } public static function getSopralluogoTable() { return ""; } public static function getBusteTable() { return ""; } public static function tipologieNoRevisione() { return []; } public static function tipologieObbligoScadenza() { return []; } public static function tipologieShowPartecipanti() { return []; } public static function tipologieConSOA() { return []; } public static function tipologieConServiziTecnici() { return []; } public static function tipologieEsitiCumulativi() { return []; } public static function refPartecipante() { return "operatore"; } public function canShowPartecipanti() { return (in_array($this->info["tipologia"],static::tipologieShowPartecipanti())); } public function showPartecipanti() { if ($this->canShowPartecipanti() && $this->info["visualizza_elenco"] == "S") { return true; } return false; } public static function extraPreliminary() { $return = []; $return["atto_indizione"] = ["label"=>"Provvedimento di indizione","type"=>"text","rel"=>"N;0;0;A","col"=>"col-12 col-xl-6"]; $return["data_atto_indizione"] = ["label"=>"Data del provvedimento di indizione","type"=>"text","rel"=>"N;10;10;D","col"=>"col-12 col-xl-6","class"=>"datepick"]; $return["servizio"] = ["label"=>"Servizio","type"=>"text","rel"=>"N;0;0;A","col"=>"col-12 col-xl-6"]; $return["responsabile_servizio"] = ["label"=>"Responsabile del servizio","type"=>"text","rel"=>"N;0;0;A","col"=>"col-12 col-xl-6"]; return $return; } public static function printEditForm($record, $cpv, $lock = true, $tipologie = []) { if (!empty($record)) { include(__DIR__ . "/views/edit.php"); } } public function printElaborazioneForm() { include(__DIR__ . "/views/elaborazione.php"); } public function printPubblicaForm() { include(__DIR__ . "/views/pubblica.php"); } public function printSospendiForm() { include(__DIR__ . "/views/sospendi.php"); } public static function printIndexTable() { $print = true; include(__DIR__ . "/views/table.php"); } public function printIndexPartecipanti() { $print = true; include(__DIR__ . "/views/partecipanti/table.php"); } public function printModalAddUser() { $print = true; include(__DIR__ . "/views/partecipanti/searchUser.php"); } public function printPanelPartecipante($codice) { $print = true; $partecipante = $this->getPartecipante($codice); if (!empty($partecipante)) { include(__DIR__ . "/views/partecipanti/dettaglio.php"); } else { alertManager::printAlertBox(__("Errore richiesta")); } } public function addUser($email) { $esito = ["error"=>true,"msg"=>"Errore generico"]; if ($this->internalUsers) { $utente = $this->db->go("SELECT codice FROM b_utenti WHERE ruolo = 'USR' AND email = :email",[":email"=>$email])->fetch(PDO::FETCH_COLUMN); if (!empty($utente)) { if ($this->db->go("SELECT codice FROM " . $this->oeTable . " WHERE codice_operatore = :utente AND codice_elenco = :elenco",[":utente"=>$utente,":elenco"=>$this->info["codice"]])->rowCount() === 0) { $partecipante = array(); $partecipante["codice_elenco"] = $this->info["codice"]; $partecipante["codice_operatore"] = $utente; $partecipante["ammesso"] = "S"; $partecipante["valutato"] = "S"; $partecipante["conferma"] = "S"; $partecipante["timestamp_creazione"] = date("Y-m-d H:i:s"); $partecipante["utente_creazione"] = $_SESSION["utente"]->codice; $partecipante["timestamp_abilitazione"] = date("Y-m-d H:i:s"); $partecipante["utente_abilitazione"] = $_SESSION["utente"]->codice; $salva = new salva(); $salva->debug = false; $salva->nome_tabella = $this->oeTable; $salva->operazione = "INSERT"; $salva->oggetto = $partecipante; if ($salva->save()) { $esito["error"] = false; } else { $esito["msg"] = "Errore salvataggio"; } } else { $esito["msg"] = "Utente giĆ  associato"; } } else { $esito["msg"] = "Utente sconosciuto"; } } else { $esito["msg"] = "Elenco non compatibile"; } return $esito; } public static function getTotaliPartecipanti($elenco) { global $pdo; $return = []; $bind = [":elenco"=>$elenco]; $base = "SELECT COUNT(codice) AS tot FROM " . static::getOeTable() . " WHERE codice_elenco = :elenco "; $return["nuovi"] = $pdo->go($base . " AND conferma = 'S' AND ammesso = 'N' AND valutato = 'N'",$bind)->fetch(PDO::FETCH_COLUMN); $return["aggiornamenti"] = $pdo->go($base . " AND conferma = 'S' AND ammesso = 'S' AND valutato = 'N'",$bind)->fetch(PDO::FETCH_COLUMN); $return["ammessi"] = $pdo->go($base . " AND conferma = 'S' AND ammesso = 'S'",$bind)->fetch(PDO::FETCH_COLUMN); $return["respinti"] = $pdo->go($base . " AND conferma = 'S' AND ammesso = 'N' AND valutato = 'S'",$bind)->fetch(PDO::FETCH_COLUMN); $return["integrazioni"] = $pdo->go($base . " AND conferma = 'S' AND integrazioni IS NOT NULL AND integrazioni <> 'N'",$bind)->fetch(PDO::FETCH_COLUMN); $return["generale"] = $pdo->go($base . " AND conferma = 'S'",$bind)->fetch(PDO::FETCH_COLUMN); return $return; } public static function getDataTableJSON($input) { if (isset($input["draw"])) { global $pdo; $return = array(); $return["draw"] = (int)$input["draw"]; $return["recordsTotal"] = (int)0; $return["recordsFiltered"] = (int)0; $filters = []; if (isset($input["tipologia"]) && $input["tipologia"] !== "") { $filters[static::getMainTable() . ".tipologia"] = $input["tipologia"]; } $total = static::getList($filters, [], 0, -1); if (!empty($total)) { $tipologie = static::getTipologie(); $return["recordsTotal"] = (int)count($total); if (!empty($input["search"]["value"])) { $filters["*"] = $input["search"]["value"]; } if (isset($input["stato"]) && $input["stato"] !== "") { $filters[static::getMainTable() . ".stato"] = $input["stato"]; } if (isset($input["ente"]) && $input["ente"] !== "") { $filters[static::getMainTable() . ".codice_ente"] = $input["ente"]; } $order = []; if (isset($input["order"][0]["column"])) { switch ($input["order"][0]["column"]) { case "3": $orderKey = static::getMainTable() . ".badge"; break; case "4": $orderKey = static::getMainTable() . ".tipologia"; break; case "5": $orderKey = static::getMainTable() . ".oggetto"; break; default: $orderKey = static::getMainTable() . ".id"; break; } if ($input["order"][0]["dir"] == "desc") { $order[$orderKey] = "DESC"; } else { $order[$orderKey] = "ASC"; } } $risultati = static::getList($filters, $order, $input["start"], $input["length"]); if (count($risultati) > 0) { if (!empty($input["search"]["value"])) { $return["recordsFiltered"] = (int)count($risultati); } else { $return["recordsFiltered"] = $return["recordsTotal"]; } $return["data"] = array(); $stati = static::getStati(); foreach ($risultati AS $record) { $stato = $stati[$record["stato"]]; if ($record["stato"] == 20 && strtotime($record["pubblicazione"]) > time()) { $stato["titolo"] = "Programmata pubblicazione"; } $panelHref = "/backend/".static::getDirectory()."/panel.php?codice={$record["codice"]}"; $row = array(); $row[] = '
'; $row[] = __($stato["titolo"]); $row[] = $record["id"]; $row[] = ($record["badge"] > 0) ? "" . $record["badge"] . " " : ""; $row[] = __($tipologie[$record["tipologia"]]); $row[] = "" . $record["oggetto"] . ""; $count = static::getTotaliPartecipanti($record["codice"]); foreach($count AS $num) { $row[] = $num; } $row[] = ""; $return["data"][] = $row; } } else { $return["data"] = array(); } } else { $return["data"] = array(); } return $return; } } public static function getList($filters=[],$order=[],$start=0,$length=1) { $tabella = static::getMainTable(); global $pdo; $select = "SELECT {$tabella}.codice, {$tabella}.badge, {$tabella}.codice_ente, {$tabella}.id, {$tabella}.stato, {$tabella}.tipologia, {$tabella}.oggetto, {$tabella}.pubblicazione "; $from = " FROM {$tabella} "; $bind = []; $where = " WHERE {$tabella}.codice > 0 "; if ($_SESSION["utente"]->gerarchia > 10) { $ids = Utente::getPermissionsInModulo($_SESSION["ente"]->codice,$_SESSION["utente"]->codice,static::getModulo()); $ids = implode(",",$ids); $where .= " AND {$tabella}.codice IN ({$ids}) "; } if (!$_SESSION["utente"]->fromHere()) { $where .= " AND {$tabella}.codice_ente = :codice_ente"; $bind[":codice_ente"] = $_SESSION["utente"]->codice_ente; } if (!empty($filters)) { $keys = ["{$tabella}.id","{$tabella}.oggetto","{$tabella}.descrizione"]; $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 (!empty($addWhere)) { $where .= " AND (" . implode(" OR ",$addWhere) . ") "; } if (isset($filters["{$tabella}.codice_ente"])) { $bind[":codice_ente"] = (int)$filters["{$tabella}.codice_ente"]; $where .= " AND {$tabella}.codice_ente = :codice_ente "; } if (isset($filters["{$tabella}.stato"])) { $bind[":stato"] = (int)$filters["{$tabella}.stato"]; $where .= " AND {$tabella}.stato = :stato "; } if (isset($filters["{$tabella}.tipologia"])) { $bind[":tipologia"] = $filters["{$tabella}.tipologia"]; $where .= " AND {$tabella}.tipologia = :tipologia "; } if (isset($filters["{$tabella}.codice"])) { $bind[":codice"] = (int)$filters["{$tabella}.codice"]; $where .= " AND {$tabella}.codice = :codice "; } } $sort = "ORDER BY {$tabella}.id DESC "; if (!empty($order)) { $keys = ["{$tabella}.id","{$tabella}.badge","{$tabella}.stato","{$tabella}.oggetto"]; $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 {$tabella}.codice ".$sort.$limit,$bind)->fetchAll(PDO::FETCH_ASSOC); return $return; } public function getCategorieMerceologiche() { $codici_categoria = []; $sql_categoria = "SELECT codice FROM {$this->cpvTable} WHERE codice_elenco = :codice "; $ris_custom = $this->db->go($sql_categoria, array(":codice" => $this->info["codice"])); if ($ris_custom->rowCount() > 0) { while ($categoria = $ris_custom->fetch(PDO::FETCH_ASSOC)) { if (!empty($categoria)) { $codici_categoria[] = $categoria["codice"]; } } } $codici_categoria = array_unique($codici_categoria); return $codici_categoria; } public static function getIstanzeOE(int $codice_oe) : ?array { if (!empty(static::getMainTable())) { $mainTable = static::getMainTable(); $partecipantiTable = static::getOeTable(); global $pdo; return $pdo->go("SELECT {$partecipantiTable}.*, {$mainTable}.tipologia,{$mainTable}.oggetto FROM {$partecipantiTable} JOIN {$mainTable} ON {$partecipantiTable}.codice_elenco = {$mainTable}.codice WHERE {$partecipantiTable}.codice_operatore = :oe AND {$partecipantiTable}.conferma = 'S'",[":oe"=>$codice_oe])->fetchAll(PDO::FETCH_ASSOC); } } public function getIstanzeAffini(int $codice_oe) : ? array { $return = []; if (in_array($this->info["tipologia"],static::tipologieEsitiCumulativi())) { $altreIstanze = static::getIstanzeOE($codice_oe); if (!empty($altreIstanze)) { foreach($altreIstanze AS $istanza) { if ($istanza["tipologia"] == $this->info["tipologia"] && $istanza["valutato"] == "N" && $istanza["codice_elenco"] != $this->info["codice"] && ($_SESSION["utente"]->permission($this->modulo,$istanza["codice_elenco"],"partecipanti"))) { $return[] = $istanza; } } } } return $return; } public function saveMainData(array $input) { $data = ["codice"=>$this->info["codice"]]; $data = $data + $input; $salva = new salva(); $salva->debug = false; $salva->nome_tabella = static::getMainTable(); $salva->operazione = "UPDATE"; $salva->oggetto = $data; return ($salva->save()); } public static function save($data) { if (!empty(static::getMainTable()) && !empty(static::getCpvTable())) { global $pdo; $entiAbilitati = $_SESSION["utente"]->getEntiBeneficiari(); if ($_SESSION["ente"]->checkLimite(static::getModulo()) || $data["codice"] > 0) { $checkEnte = false; $return = false; foreach ($entiAbilitati as $ente) { if ($data["codice_ente"] == $ente["codice"]) { $checkEnte = true; break; } } if ($checkEnte) { $operazione = empty($data["codice"]) ? "INSERT" : "UPDATE"; if ($operazione == "INSERT") { $data["id"] = 1; $data["utente_creazione"] = $_SESSION["utente"]->codice ?? -1; $data["timestamp_creazione"] = date("Y-m-d H:i:s"); $sql = "SELECT id FROM " . static::getMainTable() . " ORDER BY id DESC LIMIT 0,1 "; $ris = $pdo->go($sql); if ($ris->rowCount() === 1) { $rec = $ris->fetch(PDO::FETCH_ASSOC); $data["id"] = $rec["id"] + 1; } } $salva = new salva(); $salva->debug = false; $salva->nome_tabella = static::getMainTable(); $salva->operazione = $operazione; $salva->oggetto = $data; $codice = $salva->save(); if ($codice !== false) { if ($operazione == "INSERT") { if ($_SESSION["utente"]->gerarchia > 15) { $utenti = [$_SESSION["utente"]->codice]; } if (!empty($utenti)) { foreach ($utenti as $utente) { $permesso = []; $permesso["sezione"] = static::getModulo(); $permesso["codice_elemento"] = $codice; $permesso["codice_gestore"] = $_SESSION["ente"]->codice; $permesso["funzione"] = "0"; $permesso["codice_utente"] = $utente; $salva = new salva(); $salva->debug = false; $salva->nome_tabella = "r_permessi"; $salva->operazione = "INSERT"; $salva->oggetto = $permesso; $salva->save(); } } } $elenco = static::init($codice); if (!empty($elenco)) { $elenco->addToLog($operazione,__("Dati preliminari") . " #{$codice}"); if (!empty($data["extra"])) { if (!empty($elenco)) { foreach($data["extra"] AS $key => $value) { $elenco->saveExtraInfo($key,$value); } } } } $bind = array(":codice" => $codice); $strsql = "DELETE FROM " . static::getCpvTable() . " WHERE codice_elenco = :codice"; $pdo->go($strsql, $bind); scriviLog(static::getCpvTable(), "DELETE", $pdo->getSQL()); if (!empty($data["cpv"])) { $data["cpv"] = array_unique($data["cpv"]); foreach ($data["cpv"] as $codice_categoria) { if ($codice_categoria != "") { $bind = array(":codice" => $codice, ":codice_categoria" => $codice_categoria, ":codice_utente" => $_SESSION["utente"]->codice); $strsql = "INSERT INTO " . static::getCpvTable() . " (codice_elenco,codice,utente_modifica) VALUES (:codice,:codice_categoria,:codice_utente)"; $pdo->go($strsql, $bind); scriviLog(static::getCpvTable(), "INSERT", $pdo->getSQL()); } } } if (!$_SESSION["ente"]->checkLimite(static::getModulo()) && empty($data["codice"])) { $_SESSION["ente"]->sendAlertLimite(static::getModulo()); } return $codice; } } } } } public function updateStato($stato) { if (!empty($this->mainTable)) { if ($this->info["stato"] < $stato) { $this->db->go("UPDATE {$this->mainTable} SET stato = :stato WHERE codice = :codice", [":stato" => $stato, ":codice" => $this->info["codice"]]); } if (isset($_SESSION["ente"])) { $_SESSION["ente"]->manageUpdates($this->modulo,$this->info["codice"],$this); } } } public function switchShowPartecipanti() { if ($this->canShowPartecipanti()) { $new = ($this->info["visualizza_elenco"] == "S") ? "N" : "S"; $this->db->go("UPDATE {$this->mainTable} SET visualizza_elenco = :stato WHERE codice = :codice", [":stato" => $new, ":codice" => $this->info["codice"]]); $this->addToLog(($this->info["visualizza_elenco"] == "S") ? "NASCONDI" : "VISUALIZZA",__("Elenco partecipanti")); return true; } } public function getManagerRegistro() { return new registriManager($this->getModulo(), $this->info["codice"]); } public function addToLog($operazione, $oggetto) { return $this->getManagerRegistro()->addToLog($operazione, $oggetto); } public function getLog($start = 0, $length = -1) { return $this->getManagerRegistro()->getLog($start, $length); } public function saveExtraInfo($chiave, $valore) { $extraInfo = $this->getExtraInfo(); $extraInfo[$chiave] = $valore; $this->info["extraInfo"] = $extraInfo = json_encode($extraInfo); $salva = new salva(); $salva->debug = false; $salva->nome_tabella = $this->mainTable; $salva->operazione = "UPDATE"; $salva->oggetto = ["codice" => $this->info["codice"], "extraInfo" => $extraInfo]; if (!empty($salva->save())) { return true; } return false; } public function getExtraInfo() { if (!empty($this->info["extraInfo"])) { return json_decode($this->info["extraInfo"], true); } return false; } public static function getStati() { global $beRoot; return jsonToArray($beRoot . "/" . static::getDirectory() . "/stati.json"); } public function getDestinatari() { $destinatari = $this->getPartecipanti([],[],0,-1) ?? []; return array_column($destinatari,"codice_operatore"); } public function getDestinatariInterni(bool $onlyCode = false) { $return = []; $utenti = $this->getManagerRegistro()->getUtentiCoinvolti(); if (!empty($utenti)) { $info = Utente::getInfoFromID($utenti); if (!empty($info)) { foreach($info AS $u) { if ($u["ruolo"] == "USR") { $return[] = ($onlyCode) ? $u["codice"] : $u["email"]; } } } } return $return; } protected static function initInstance($codice,$class) { if (!empty($codice) && !empty($_SESSION["ente"]) && !empty($_SESSION["utente"])) { global $pdo; $bind = [":codice" => $codice]; $sql = "SELECT * FROM " . static::getMainTable() . " WHERE codice = :codice "; if (! defined("__CMDS_JOB_EXEC") && ! $_SESSION["utente"]->fromHere()) { $sql .= " AND codice_ente = :codice_ente"; $bind[":codice_ente"] = $_SESSION["utente"]->codice_ente; } $elenco = $pdo->go($sql, $bind)->fetch(PDO::FETCH_ASSOC); if (!empty($elenco)) { if (!defined("__CMDS_JOB_EXEC")) { $continua = $_SESSION["utente"]->permission(static::getModulo(),$elenco["codice"],"0",true); } else { $continua = true; } if ($continua) { $extensionClass= self::extensionExists($class); if (!empty($extensionClass)) { $instance = new $extensionClass(); } else { $instance = new $class(); } $instance->info = $elenco; if (isset($instance->info) && $instance->info["stato"] == 20 && !empty($instance->info["scadenza"]) && strtotime($instance->info["scadenza"]) < time()) { $instance->updateStato(21); } return $instance; } } } return false; } private static function defaultAutenticationLevel() { return $_SESSION["ente"]->defaultAutenticationLevel(); } public function checkLock($id_cmd) { $return = true; $stato = $this->info["stato"]; if ($_SESSION["utente"]->readOnly) { return true; } else { if ($_SESSION["utente"]->hasSuperPowers()) { $return = false; } else { if (($stato >= 0) && !empty($id_cmd) && $_SESSION["utente"]->unlockSupporto()) { $cmd = $this->getInfoModulo($id_cmd); if ($cmd !== false) { $loa = $cmd["authenticationLevel"] ?? self::defaultAutenticationLevel(); if ($_SESSION["utente"]->authenticationLevel < $loa) { return true; } if (($stato >= $cmd["stato_minimo"] || $cmd["stato_minimo"] == null) && ($stato <= $cmd["stato_massimo"] || $cmd["stato_massimo"] === null)) { $return = false; } } } } } return $return; } public function soaObbligatorie() { return $this->info["obbligo_soa"] == "S"; } public function serviziTecniciObbligatori() { return $this->info["obbligo_servizi_tecnici"] == "S"; } public function soaRichiedibili() { $tipolgie = static::tipologieConSOA(); return (in_array($this->info["tipologia"],$tipolgie)); } public function serviziTecniciRichiedibili() { $tipolgie = static::tipologieConServiziTecnici(); return (in_array($this->info["tipologia"],$tipolgie)); } public function getForms() { return $this->db->go("SELECT codice_form FROM " . $this->getFormTable() . " WHERE codice_elenco = :elenco",[":elenco"=>$this->info["codice"]])->fetchAll(PDO::FETCH_COLUMN); } public function getRichiestaQuestionari() { $richieste = $this->getRichieste(); foreach($richieste AS $richiesta) { if ($richiesta["locked"] == "S") { return $richiesta; } } } public function associaForm($forms,string $requireSignature = "N") { $this->db->go("DELETE FROM " . $this->getFormTable() . " WHERE codice_elenco = :elenco",[":elenco"=>$this->info["codice"]]); $this->db->go("UPDATE ". $this->getMainTable(). " SET richiedi_firma = 'N' WHERE codice = :elenco",[":elenco"=>$this->info["codice"]]); $richiestaQuestionari = $this->getRichiestaQuestionari(); $deleteRequestQuestionari = false; if (!empty($forms)) { $salva = new salva(); $salva->debug = false; $salva->nome_tabella = $this->getFormTable(); $salva->operazione = "INSERT"; foreach($forms AS $form) { $salva->oggetto = ["codice_elenco"=>$this->info["codice"],"codice_form"=>$form]; $salva->save(); } if ($requireSignature == "S") { $this->db->go("UPDATE ". $this->getMainTable(). " SET richiedi_firma = 'S' WHERE codice = :elenco",[":elenco"=>$this->info["codice"]]); if (empty($richiestaQuestionari)) { $this->saveRichiesta([ "ordinamento" => 0, "titolo" => "Questionari sottoscritti", "descrizione" => "Carica la versione sottoscritta del PDF contenente i questionari compilati", "controllo" => "F", "locked" => "S" ]); } else if (isset($richiestaQuestionari["archiviato"]) && $richiestaQuestionari["archiviato"] == "S") { $this->db->go("UPDATE " . $this->richiesteTable . " SET archiviato = 'N' WHERE codice = :codice", [":codice"=>$richiestaQuestionari["codice"]]); } } else { $deleteRequestQuestionari = true; } } else { $deleteRequestQuestionari = true; } if ($deleteRequestQuestionari) { if (!empty($richiestaQuestionari)) { if (isset($richiestaQuestionari["archiviato"])) { $this->db->go("UPDATE " . $this->richiesteTable . " SET archiviato = 'S' WHERE codice = :codice", [":codice"=>$richiestaQuestionari["codice"]]); } else { $this->db->go("DELETE FROM " . $this->richiesteTable . " WHERE codice = :codice", [":codice"=>$richiestaQuestionari["codice"]]); } } } $this->valutaElaborazione(); } public function getRichieste() { $bind = [":codice" => $this->info["codice"]]; $sql = "SELECT {$this->richiesteTable}.* FROM {$this->richiesteTable} WHERE codice_elenco = :codice ORDER BY {$this->richiesteTable}.ordinamento, {$this->richiesteTable}.codice "; return $this->db->go($sql, $bind)->fetchAll(PDO::FETCH_ASSOC); } public function getRichiesta($codice) { $richieste = $this->getRichieste(); if (!empty($richieste)) { foreach($richieste AS $richiesta) { if ($richiesta["codice"] == $codice) { return $richiesta; } } } return false; } public function addDGUERequest() { if (!$this->checkLock("elaborazione") && $this->db->go("SELECT codice FROM {$this->richiesteTable} WHERE titolo = 'DGUE' AND codice_elenco = :codice", [":codice" => $this->info["codice"]]) ->rowCount() == 0 ) { $richiesta = []; $richiesta["ordinamento"] = 0; $richiesta["titolo"] = "DGUE"; $richiesta["descrizione"] = __("Documento di Gara Unico Europeo"); $richiesta["controllo"] = "F"; return $this->saveRichiesta($richiesta); } } public function deleteDGUERequest() { if (!$this->checkLock("elaborazione")) { $this->db->go("DELETE FROM {$this->richiesteTable} WHERE titolo = 'DGUE' AND codice_elenco = :codice", [":codice" => $this->info["codice"]]); } } public function saveRichiesta($richiesta,$allegati = []) { $richiesta["codice_elenco"] = $this->info["codice"]; $salva = new salva(); $salva->debug = false; $salva->nome_tabella = $this->richiesteTable; $salva->operazione = (!empty($richiesta["codice"])) ? "UPDATE" : "INSERT"; $salva->oggetto = $richiesta; $cod_richiesta = $salva->save(); if (!empty($cod_richiesta)) { if (!empty($allegati)) { foreach($allegati as $allegato) { filesManager::saveFile($allegato["filename"],$cod_richiesta,$this->getModulo()."-richiesta",$allegato["nome"] ?? "","A",$allegato["classificazione"] ?? ""); } } $this->addToLog($salva->operazione,__("Richiesta").": " . $richiesta["titolo"]); $this->valutaElaborazione(); return $cod_richiesta; } } public function valutaElaborazione() { if ($this->info["stato"] < 10) { if (!empty($this->getRichieste()) || !empty($this->getForms())) { $this->updateStato(10); } } } public function getManagerRichieste($partecipante) { $managerRichieste = new richiesteOE($this->modulo, $this->info["codice"],$partecipante); if (!empty($managerRichieste)) { $this->managerRichieste = $managerRichieste; } return $this->managerRichieste; } public function getPartecipanti($filters = [],$order = [], $start=0, $length = 1) { $bind = [":codice_elenco" => $this->info["codice"]]; $sql = "SELECT * FROM {$this->oeTable} WHERE codice_elenco = :codice_elenco AND conferma = 'S' "; if (!empty($filters["codice"])) { $sql .= " AND codice = :codice_partecipante "; $bind[":codice_partecipante"] = $filters["codice"]; } if (!empty($filters["stato"])) { switch($filters["stato"]) { case "nuovi": $sql .= " AND ammesso = 'N' AND valutato = 'N' "; break; case "aggiornamenti": $sql .= " AND ammesso = 'S' AND valutato = 'N' "; break; case "ammessi": $sql .= " AND ammesso = 'S' "; break; case "respinti": $sql .= " AND ammesso = 'N' AND valutato = 'S' "; break; case "integrazioni": $sql .= " AND integrazioni IS NOT NULL AND integrazioni <> 'N' "; break; default: break; } } if (!empty($filters["stato_integrazioni"])) { switch($filters["stato_integrazioni"]) { case "no-richieste": $sql .= " AND (integrazioni IS NULL OR integrazioni = 'N') "; break; case "richieste": $sql .= " AND integrazioni IS NOT NULL AND integrazioni <> 'N' "; break; case "no-risposte": $sql .= " AND integrazioni = 'S' "; break; case "risposte": $sql .= " AND integrazioni = 'R' "; break; default: break; } } $tmp = $this->db->go($sql, $bind)->fetchAll(PDO::FETCH_ASSOC); $return = []; if (!empty($tmp)) { $ids = array_column($tmp,"codice_operatore"); } if (!empty($ids)) { if (static::refPartecipante() == "operatore") { $infos = oeManager::getOE($ids); } else { $usrs = Utente::getInfoFromID($ids); $infos = []; if (!empty($usrs)) { foreach($usrs AS $usr) { $infos[$usr["codice"]] = $usr; } } } foreach($tmp AS $partecipazione) { $infoPartecipante = $infos[$partecipazione["codice_operatore"]]; $insert = true; if (!empty($filters["*"])) { $insert = false; if (static::refPartecipante() == "operatore") { if (stripos($infoPartecipante["codice_fiscale_impresa"],$filters["*"]) !== false || stripos($infoPartecipante["ragione_sociale"],$filters["*"]) !== false) { $insert = true; } } else { if (stripos($infoPartecipante["cf"],$filters["*"]) !== false || stripos($infoPartecipante["cognome"],$filters["*"]) !== false || stripos($infoPartecipante["nome"],$filters["*"]) !== false) { $insert = true; } } } if ($insert) { if (static::refPartecipante() == "operatore") { $partecipazione["codice_fiscale"] = $infoPartecipante["codice_fiscale_impresa"]; $partecipazione["ragione_sociale"] = $infoPartecipante["ragione_sociale"]; $partecipazione["ruolo"] = "OPE"; } else { $partecipazione["codice_fiscale"] = $infoPartecipante["cf"]; $partecipazione["ragione_sociale"] = $infoPartecipante["cognome"] . " " . $infoPartecipante["nome"]; $partecipazione["ruolo"] = $infoPartecipante["ruolo"]; } $badgeIntegrazioni = ""; if (isset($filters["stato"]) && $filters["stato"] != "integrazioni") { if($partecipazione["integrazioni"] == "S") { $badgeIntegrazioni = "Richiesta integrazione
"; } if($partecipazione["integrazioni"] == "R") { $badgeIntegrazioni = "Risposto integrazione
"; } } $partecipazione["ragione_sociale"] = $badgeIntegrazioni . $partecipazione["ragione_sociale"]; $partecipazione["timestamp_scadenza"] = ""; $partecipazione["gg"] = ""; if (isset($filters["stato"])) { if (!empty($this->info["mesi_revisione"]) && $filters["stato"] != "nuovi" && !empty($partecipazione["timestamp_abilitazione"])) { $time_scadenza = strtotime("+{$this->info["mesi_revisione"]} months",strtotime($partecipazione["timestamp_abilitazione"])); $partecipazione["timestamp_scadenza"] = date('Y-m-d', $time_scadenza); $partecipazione["gg"] = floor(($time_scadenza - time()) / 60 / 60 / 24); if ($filters["stato"] != "respinti") { if ($partecipazione["gg"] <= 1) { $partecipazione["rowClass"] = "bg-danger"; } else if ($partecipazione["gg"] <= 10) { $partecipazione["rowClass"] = "bg-warning"; } } } else if ($filters["stato"] == "integrazioni") { $partecipazione["gg"] = ($partecipazione["integrazioni"] == "R") ? "" . __("Risposto") . "" : ""; } else if ($filters["stato"] == "nuovi") { $partecipazione["gg"] = floor((time() - strtotime($partecipazione["timestamp_aggiornamento"])) / 60 / 60 / 24); if ($partecipazione["gg"] > 30) { $partecipazione["rowClass"] = "bg-danger"; if ($partecipazione["gg"] <= 90) { $partecipazione["rowClass"] = "bg-warning"; } } } } unset($partecipazione["visto"]); $return[] = $partecipazione; } } } if (!empty($order)) { foreach($order AS $key => $direction) { $sort = array_column($return, $key); array_multisort($sort, ($direction == "DESC") ? SORT_DESC : SORT_ASC, $return); } } if ($length > 0) { $return = array_slice($return,$start,$length,true); } return $return; } public function getPartecipante($codice) { return $this->getPartecipanti(["codice"=>$codice])[0] ?? false; } public function getPartecipantiDataTableJSON($input,$returnFullData = false) { if (isset($input["draw"])) { $return = array(); $return["draw"] = (int)$input["draw"]; $return["recordsTotal"] = (int)0; $return["recordsFiltered"] = (int)0; $total = $this->getPartecipanti([], [], 0, -1); if (!empty($total)) { $return["recordsTotal"] = (int)count($total); $filters = []; if (!empty($input["search"]["value"])) { $filters["*"] = $input["search"]["value"]; } if (isset($input["stato"]) && $input["stato"] !== "") { $filters["stato"] = $input["stato"]; } if (isset($input["stato_integrazioni"]) && $input["stato_integrazioni"] !== "") { $filters["stato_integrazioni"] = $input["stato_integrazioni"]; } $order = []; if (isset($input["order"][0]["column"])) { switch ($input["order"][0]["column"]) { case "0": $orderKey = "codice_fiscale"; break; case "1": $orderKey = "ragione_sociale"; break; case "2": $orderKey = "timestamp_aggiornamento"; break; case "3": $orderKey = "timestamp_abilitazione"; break; case "4": $orderKey = "timestamp_scadenza"; break; case "5": $orderKey = "gg"; break; case "6": $orderKey = "timestamp"; break; default: $orderKey = "timestamp_aggiornamento"; break; } if ($input["order"][0]["dir"] == "desc") { $order[$orderKey] = "DESC"; } else { $order[$orderKey] = "ASC"; } } $risultati = $this->getPartecipanti($filters, $order, $input["start"], $input["length"]); if (count($risultati) > 0) { if (!empty($filters)) { $return["recordsFiltered"] = (int) count($this->getPartecipanti($filters, $order,0,-1)); } else { $return["recordsFiltered"] = $return["recordsTotal"]; } $return["data"] = array(); foreach ($risultati AS $record) { if ($returnFullData) { $row = $record; } else { $row = array(); if (!empty($record["rowClass"])) { $row["DT_RowClass"] = $record["rowClass"]; } $row[] = $record["codice_fiscale"]; $row[] = $record["ragione_sociale"]; $row[] = mysql2datetime($record["timestamp_aggiornamento"]); $row[] = mysql2datetime($record["timestamp_abilitazione"]); $row[] = mysql2date($record["timestamp_scadenza"]); $row[] = $record["gg"]; $row[] = mysql2datetime($record["timestamp"]); if ($record["ruolo"] == "OPE") { $row[] = ""; } else { $row[] = ""; } } $return["data"][] = $row; } } else { $return["data"] = array(); } } else { $return["data"] = array(); } return $return; } } private function initForm($form,$partecipante) { $forms = $this->getForms(); if (!empty($form)) { if (in_array($form,$forms) !== false) { $partecipante = $this->getPartecipante($partecipante); if (!empty($partecipante)) { $formManager = new FormManager; $formManager->stripEnte = true; if ($formManager->init($form,$this->modulo."-".$_SESSION["ente"]->codice,$partecipante["codice"])) { return $formManager; } } } } } public function showFormPartecipante($form,$partecipante) { $formManager = $this->initForm($form,$partecipante); if (!empty($formManager)) { ?>

info["titolo"],true)[$_SESSION["language"]]; ?>

printForm(false); return true; } return false; } public function showVersioneFormPartecipante($form,$partecipante,$codice_versione) { $formManager = $this->initForm($form,$partecipante); if (!empty($formManager)) { $data = $formManager->getVersion($codice_versione); if (!empty($data["data"])) { ?>

info["titolo"],true)[$_SESSION["language"]]; ?>

forcedData = $data["data"]; $formManager->printForm(false); } return true; } return false; } public function showDocumento($richiesta,$partecipante) { $richiesta = $this->getRichiesta($richiesta); if (!empty($richiesta)) { $partecipante = $this->getPartecipante($partecipante); if (!empty($partecipante)) { $busta = $this->getBusta($partecipante["codice"],$richiesta["codice"],true); include_once(__DIR__."/views/partecipanti/documento.php"); if (empty($error)) { return true; } } } return false; } public function showVersioni($richiesta,$partecipante) { $richiesta = $this->getRichiesta($richiesta); if (!empty($richiesta)) { $partecipante = $this->getPartecipante($partecipante); if (!empty($partecipante)) { $versioni = $this->getVersionsBusta($partecipante["codice"],$richiesta["codice"]); include_once(__DIR__."/views/partecipanti/versioni.php"); if (empty($error)) { return true; } } } return false; } public function showVersioniForm($form,$partecipante) { $formMananager = $this->initForm($form,$partecipante); if (!empty($formMananager)) { $form = $formMananager->info; $versioni = $formMananager->listVersions(); include_once(__DIR__."/views/partecipanti/versioni-form.php"); if (empty($error)) { return true; } } return false; } /** * Restituisce un array con le partecipazioni degli OO.EE. specificati * * @param Array $ooee * @return Array */ protected function getPartecipantiFromOE(Array $ooee) : Array { $return = []; if (!empty($ooee)) { $qPartecipanti = $this->db->go("SELECT * FROM {$this->oeTable} WHERE codice_elenco = :elenco AND codice_operatore = :oe"); $qPartecipanti->bindValue(":elenco",$this->info["codice"]); foreach($ooee AS $oe) { $qPartecipanti->bindValue(":oe",$oe); $qPartecipanti->execute(); if ($qPartecipanti->rowCount() > 0) { $return[] = $qPartecipanti->fetch(PDO::FETCH_ASSOC); } } } return $return; } protected function updateStatoIntegrazioni(Array $partecipanti,String $stato) { $salva = new salva(); $salva->debug = false; $salva->nome_tabella = $this->oeTable ; $salva->operazione = "UPDATE"; $salva->expect = array("codice","integrazioni","timestamp_modifica"); foreach($partecipanti AS $partecipante) { $partecipante["integrazioni"] = $stato; $salva->oggetto = $partecipante; $salva->save(); } if ($stato == "N") { $this->updateBadges(); } } /** * Aggiorna la posizione dell'operatore economico per memorizzare l'avvenuta richiesta di integrazione * * @param Array $ooee * @return void */ public function postRichiesteOE(Array $infoRichiesta) { if (!empty($infoRichiesta["destinatari"])) { $partecipanti = $this->getPartecipantiFromOE($infoRichiesta["destinatari"]); if (!empty($partecipanti)) { $this->updateStatoIntegrazioni($partecipanti,"S"); } } } public function updateBadges() { $badge = 0; $sql_bad = "SELECT {$this->chiarimentiTable}.codice FROM {$this->chiarimentiTable} JOIN {$this->mainTable} ON {$this->chiarimentiTable}.codice_elenco = {$this->mainTable}.codice WHERE ({$this->mainTable}.scadenza >= now() OR {$this->mainTable}.scadenza IS NULL) AND {$this->chiarimentiTable}.attivo = 'N' AND {$this->mainTable}.codice = :codice "; $ris_badge = $this->db->go($sql_bad, [":codice" => $this->info["codice"]]); $badge += $ris_badge->rowCount(); $sql_bad = "SELECT {$this->sopralluogoTable}.codice FROM {$this->sopralluogoTable} JOIN {$this->mainTable} ON {$this->sopralluogoTable}.codice_elenco = {$this->mainTable}.codice WHERE ({$this->mainTable}.scadenza >= now() OR {$this->mainTable}.scadenza IS NULL) AND {$this->sopralluogoTable}.attivo = 'P' AND {$this->mainTable}.codice = :codice "; $ris_badge = $this->db->go($sql_bad, [":codice" => $this->info["codice"]]); $badge += $ris_badge->rowCount(); $sql_bad = "SELECT {$this->oeTable}.codice FROM {$this->oeTable} WHERE conferma = 'S' AND (integrazioni = 'R' OR valutato = 'N') AND codice_elenco = :codice"; $ris_badge = $this->db->go($sql_bad, [":codice" => $this->info["codice"]]); $badge += $ris_badge->rowCount(); $this->db->go("UPDATE {$this->mainTable} SET badge = :badge WHERE codice = :codice", [":badge" => $badge, ":codice" => $this->info["codice"]]); } static function getModuli($filters = null, $stato = null) { global $config; $moduli = jsonToArray($config["jsonFolder"] . "/" . static::getModulo() . "-panel.json"); $tmp = []; foreach ($moduli as $id_modulo => $modulo) { $insert = true; if (is_array($filters) && !empty($filters)) { foreach ($filters as $key => $value) { if ($modulo[$key] !== $value) { $insert = false; } } } if ($insert && $stato !== null) { if ($modulo["stato_minimo"] > $stato) { $insert = false; } } if (is_array($modulo["stati_esclusi"]) && in_array($stato, $modulo["stati_esclusi"]) !== false) { $insert = false; } if ($insert) { $tmp[$id_modulo] = $modulo; } $moduli = $tmp; } return $moduli; } static function getTipologie() { return []; } static function getTipologiePannello($filters=null) { $moduli = self::getModuli($filters); $tmp = []; foreach($moduli AS $modulo) { $tmp[] = $modulo["tipo"]; } $tmp = array_unique($tmp); if (!empty($tmp)) { $tipologie = []; global $config; $conf = jsonToArray($config["jsonFolder"]."/".static::getModulo()."-tipologie.json"); foreach($tmp AS $tipo) { $tipologie[$tipo] = $conf[$tipo]; } return $tipologie; } else { return false; } } static function getInfoModulo($radice) { $return = false; if (!empty($radice)) { $moduli = static::getModuli(); if (!empty($moduli[$radice])) { $return = $moduli[$radice]; $return["id"] = $radice; $return["titolo"] = __($return["titolo"]); $return["descrizione"] = __($return["descrizione"]); } } return $return; } public function getManagerIncarichi() { $manager = new Incarichi($this->getModulo(), $this->info["codice"]); if (!empty($manager)) { $this->managerIncarichi = $manager; } return $this->managerIncarichi; } public function getManagerDGUE() { $manager = new DGUE($this->getModulo(), $this->info["codice"]); if (!empty($manager)) { $this->managerDGUE = $manager; } return $this->managerDGUE; } public function getManagerAvvisi() { if (empty($this->managerAvvisi)) { $avvisiProcedura = new avvisiProcedura($_SESSION["ente"]->codice, $this->getModulo(), $this->info["codice"]); if (!empty($avvisiProcedura)) { $this->managerAvvisi = $avvisiProcedura; } } return $this->managerAvvisi; } public function getAvvisi() { return $this->getManagerAvvisi()->getAvvisi("N"); } public function printAvvisi() { return $this->getManagerAvvisi()->printPublic(); } public function getChiarimenti(int $codice = NULL) { $bind = [":codice_elenco" => $this->info["codice"]]; $sql_chiarimenti = "SELECT {$this->chiarimentiTable}.* FROM {$this->chiarimentiTable} WHERE {$this->chiarimentiTable}.codice_elenco = :codice_elenco "; if (!empty($codice)) { $sql_chiarimenti .= " AND {$this->chiarimentiTable}.codice = :codice "; $bind[":codice"] = $codice; } $sql_chiarimenti .= " ORDER BY {$this->chiarimentiTable}.timestamp "; $tmp = $this->db->go($sql_chiarimenti, $bind)->fetchAll(PDO::FETCH_ASSOC); $return = []; if (!empty($tmp)) { $i = 0; foreach ($tmp as $t) { $i++; $t["count"] = $i; $oeInfo = oeManager::getOE($t["codice_richiedente"]); $t["ragione_sociale"] = $oeInfo["ragione_sociale"]; $return[] = $t; } } if (!empty($codice) && !empty($return)) { $return = $return[0]; } return $return; } public function saveRispostaChiarimento($input) { if (!$this->checkLock("chiarimenti")) { $record = $this->info; $salva = new salva(); $salva->debug = false; $salva->nome_tabella = $this->chiarimentiTable ; $salva->operazione = "UPDATE"; $salva->oggetto = $input; $salva->expect = array("codice","revisione","risposta","attivo"); $codice = $salva->save(); if ($codice !== false) { $this->updateBadges(); if (isset($input["allegato"])) { foreach($input["allegato"] as $allegato) { filesManager::saveFile($allegato["filename"],$codice,$this->modulo."-risposte",$allegato["nome"] ?? "","A",$allegato["classificazione"] ?? ""); } } $sql = "SELECT * FROM {$this->chiarimentiTable} WHERE codice = :codice"; $ris = $this->db->go($sql,[":codice"=>$codice]); if ($ris->rowCount() > 0) { $error = false; $chiarimento = $ris->fetch(PDO::FETCH_ASSOC); if ($chiarimento["attivo"] != "N") { $corpo = "

" . __("Elenco") . " #" . $record["id"] . "

"; $corpo .= "

" . $record["oggetto"] . "

"; $corpo .= $chiarimento["revisione"] . "

"; $corpo .= "" . $chiarimento["risposta"] . ""; ob_start(); filesManager::printList($chiarimento["codice"],$this->modulo."-risposte","A",0,false); $files = ob_get_clean(); if (!empty(trim($files))) { $corpo .= "

" . $files; } $destinatari = $chiarimento["codice_richiedente"]; $mailer = new Communicator(); $mailer->oggetto = __('Risposta a chiarimento'); $mailer->comunicazione_tecnica = false; $mailer->corpo = $corpo; $mailer->codice_pec = $record["codice_pec"]; $mailer->comunicazione = true; $mailer->sezione = $this->modulo; $mailer->codice_gara = $record["codice"]; $mailer->coda = true; $mailer->destinatari = $destinatari; $esito = $mailer->send(); } $this->addToLog("UPDATE",__("Risposta chiarimento") . " #{$codice}"); return true; } } } } public function getSopralluoghi(int $codice = NULL) { $bind = [":codice_elenco" => $this->info["codice"]]; $sql_sopralluoghi = "SELECT {$this->sopralluogoTable}.* FROM {$this->sopralluogoTable} WHERE {$this->sopralluogoTable}.codice_elenco = :codice_elenco "; if (!empty($codice)) { $sql_sopralluoghi .= " AND {$this->sopralluogoTable}.codice = :codice "; $bind[":codice"] = $codice; } $sql_sopralluoghi .= " ORDER BY {$this->sopralluogoTable}.timestamp "; $tmp = $this->db->go($sql_sopralluoghi, $bind)->fetchAll(PDO::FETCH_ASSOC); $return = []; if (!empty($tmp)) { foreach ($tmp as $t) { $oeInfo = oeManager::getOE($t["codice_richiedente"]); $t["ragione_sociale"] = $oeInfo["ragione_sociale"]; $return[] = $t; } } if (!empty($codice) && !empty($return)) { $return = $return[0]; } return $return; } public function saveRispostaSopralluogo($input) { if (!$this->checkLock("sopralluogo")) { $record = $this->info; $salva = new salva(); $salva->debug = false; $salva->nome_tabella = $this->sopralluogoTable; $salva->operazione = "UPDATE"; $salva->oggetto = $input; $salva->expect = array("codice","appuntamento","risposta","attivo"); $codice = $salva->save(); if ($codice !== false) { $this->updateBadges(); if (isset($input["allegato"])) { foreach($input["allegato"] as $allegato) { filesManager::saveFile($allegato["filename"],$codice,$this->modulo."-sopralluogo",$allegato["nome"] ?? "","A",$allegato["classificazione"] ?? ""); } } $sql = "SELECT * FROM {$this->sopralluogoTable} WHERE codice = :codice"; $ris = $this->db->go($sql,[":codice"=>$codice]); if ($ris->rowCount() > 0) { $sopralluogo = $ris->fetch(PDO::FETCH_ASSOC); $corpo = "

ELENCO #" . $record["id"] . "

"; $corpo .= "

" . $record["oggetto"] . "

"; $corpo .= "" . $sopralluogo["risposta"] . ""; ob_start(); filesManager::printList($sopralluogo["codice"],$this->modulo."-sopralluogo","A",0,false); $files = ob_get_clean(); if (!empty(trim($files))) { $corpo .= "

" . $files; } $destinatari = $sopralluogo["codice_richiedente"]; if ($sopralluogo["attivo"] == "S") { $corpo .= "

".__("Data e ora appuntamento").": " . $sopralluogo["appuntamento"] . ""; $mailer = new Communicator(); $mailer->oggetto = __('Appuntamento sopralluogo'); } else if ($sopralluogo["attivo"] == "N") { $mailer = new Communicator(); $mailer->oggetto = __('Rifiuto richiesta sopralluogo'); } if (isset($mailer)) { $mailer->corpo = $corpo; $mailer->comunicazione_tecnica = false; $mailer->codice_pec = $record["codice_pec"]; $mailer->comunicazione = true; $mailer->sezione = $this->modulo; $mailer->codice_gara = $record["codice"]; $mailer->coda = true; $mailer->destinatari = $destinatari; $esito = $mailer->send(); } $this->addToLog("UPDATE",__("Risposta a richiesta sopralluogo") . " #{$codice}"); return true; } } } } public function getVersionsBusta($partecipante, $richiesta) { $return = false; $sql = "SELECT * FROM {$this->busteTable} WHERE codice_partecipante = :partecipante AND codice_richiesta = :richiesta AND soft_delete = 'S' ORDER BY codice DESC"; $bind = [":partecipante" => $partecipante, ":richiesta" => $richiesta]; $return = $this->db->go($sql, $bind)->fetchAll(PDO::FETCH_ASSOC); return $return; } public function getVersionContentBusta($partecipante, $richiesta, $codice) { $return = false; $sql = "SELECT * FROM {$this->busteTable} WHERE codice_partecipante = :partecipante AND codice_richiesta = :richiesta AND codice = :codice AND soft_delete = 'S'"; $bind = [":partecipante" => $partecipante, ":richiesta" => $richiesta, ":codice" => $codice]; $return = $this->db->go($sql, $bind)->fetchAll(PDO::FETCH_ASSOC); if (!empty($return)) { $return = $return[0]; $return["path"] = $this->getSpecificBustaPath($return); adaptMemoryLimitToFile($return["path"]); $content = file_get_contents($return["path"]); if (!empty($content)) { $content = simple_decrypt($content,base64_decode($return["content"])); $return["content"] = $content; } } return $return; } public function getBusta($partecipante, $richiesta, bool $contenuto = false) { $return = false; $select = "*"; $sql = "SELECT {$select} FROM {$this->busteTable} WHERE codice_partecipante = :partecipante AND codice_richiesta = :richiesta AND soft_delete = 'N'"; $bind = [":partecipante" => $partecipante, ":richiesta" => $richiesta]; $return = $this->db->go($sql, $bind)->fetchAll(PDO::FETCH_ASSOC); if (!empty($return)) { $return = $return[0]; $return["path"] = $this->getSpecificBustaPath($return); if ($contenuto) { adaptMemoryLimitToFile($return["path"]); $content = file_get_contents($return["path"]); if (!empty($content)) { $content = simple_decrypt($content,base64_decode($return["content"])); $return["content"] = $content; } } } return $return; } public function getSpecificBustaPath($busta) { return $this->getBustePath($busta["codice_partecipante"])."/{$busta["codice_richiesta"]}-{$busta["sha1"]}"; } public function getBustePath(int $partecipante = null) { global $config; $path = "{$config["mediaFolder"]}/{$_SESSION["ente"]->codice}/{$this->modulo}-buste/{$this->info["codice"]}"; if (!file_exists($path)) { mkdir($path,0777,true); } if (is_dir($path)) { $return = true; if (!empty($partecipante)) { $return = false; $path .= "/{$partecipante}"; if (!file_exists($path)) { mkdir($path,0777,true); } if (is_dir($path)) { $return = true; } } if ($return) { return $path; } } } public function printPanelIntegrazioni($partecipante) { $print = true; $partecipante = $this->getPartecipante($partecipante); if (!empty($partecipante)) { include(__DIR__ . "/views/integrazioni/pannello.php"); if (empty($error)) { return true; } } return false; } public function ammetti($partecipante) { $partecipante = $this->getPartecipante($partecipante); if (!empty($partecipante)) { $update = ["codice"=>$partecipante["codice"]]; $update["valutato"]= "S"; $update["motivazione"] = ""; $update["ammesso"]= "S"; $update["integrazioni"]= "N"; $update["timestamp_abilitazione"] = date('Y-m-d H:i:s'); $update["utente_abilitazione"] = $_SESSION["utente"]->codice; $salva = new salva(); $salva->debug = false; $salva->nome_tabella = $this->oeTable; $salva->operazione = "UPDATE"; $salva->oggetto = $update; $return = $salva->save(); if (!empty($return)) { $this->updateBadges(); $this->addToLog(__("AMMESSO"),$partecipante["codice_fiscale"] . " - " . $partecipante["ragione_sociale"]); $mailer = new Communicator(); $mailer->oggetto = __('Ammissione') . ' elenco #' . $this->info["id"]; $mailer->corpo = __("Si comunica l'ammissione al seguente elenco") . ":
#{$this->info["id"]} {$this->info["oggetto"]}"; $mailer->codice_pec = $this->info["codice_pec"] ?? -1; $mailer->comunicazione = true; $mailer->sezione = $this->modulo; $mailer->codice_gara = $this->info["codice"]; $mailer->coda = true; $mailer->destinatari = $partecipante["codice_operatore"]; $mailer->send(); return true; } } return false; } public function respingi($partecipante,$motivazione) { $partecipante = $this->getPartecipante($partecipante); if (!empty($partecipante)) { $update = ["codice"=>$partecipante["codice"],"valutato"=>"S","motivazione"=>$motivazione,"ammesso"=>"N","integrazioni"=>"N"]; $salva = new salva(); $salva->debug = false; $salva->nome_tabella = $this->oeTable; $salva->operazione = "UPDATE"; $salva->oggetto = $update; $return = $salva->save(); if (!empty($return)) { $this->db->go("UPDATE {$this->oeTable} SET timestamp_abilitazione = NULL, utente_abilitazione = NULL WHERE codice = :codice",[":codice"=>$partecipante["codice"]]); $this->updateBadges(); $this->addToLog(__("RESPINTO"),$partecipante["codice_fiscale"] . " - " . $partecipante["ragione_sociale"]. " - " . $motivazione); $mailer = new Communicator(); $mailer->oggetto = __('Respinta istanza') . ' elenco #' . $this->info["id"]; $mailer->corpo = __("Si comunica il respingimento dell'istanza per il seguente elenco") . ":
#{$this->info["id"]} {$this->info["oggetto"]}" . "

" . __("Motivazione") . ":
" . $motivazione; $mailer->codice_pec = $this->info["codice_pec"] ?? -1; $mailer->comunicazione = true; $mailer->sezione = $this->modulo; $mailer->codice_gara = $this->info["codice"]; $mailer->coda = true; $mailer->destinatari = $partecipante["codice_operatore"]; $mailer->send(); return true; } } return false; } }