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.
1143 righe
48 KiB
1143 righe
48 KiB
<? |
|
|
|
define("DGUE_TEMPLATE_PATH",$root . DIRECTORY_SEPARATOR . "dgue" . DIRECTORY_SEPARATOR . "templates"); |
|
class DGUE { |
|
|
|
|
|
public $modulo; |
|
private $gestore; |
|
public $object; |
|
public $version; // Riferimento normativo |
|
public $model; // Modello comunitario di riferimento |
|
public $admin; |
|
public $elemento; |
|
public $lock; |
|
public $oggetto; |
|
public $descrizione; |
|
public $id_appalto; |
|
public $matches; |
|
public $modelInstance; |
|
public $lotti; // Array contenente ["numero"=>"","cig"=>"","oggetto"=>""]; |
|
public $ente; |
|
public $codice_fiscale_ente; |
|
public $styles; |
|
public $tipologia; |
|
public $db; |
|
public $abilitaSwitchVersion; |
|
public $inputsBreadcrumb; |
|
|
|
public static function versions() { |
|
return [ |
|
"2016-50" => [ |
|
"label" => "D.lgs 50/2016", |
|
"inizio" => null, |
|
"fine" => '2023-06-30 23:59:59' |
|
], |
|
"2023-36" => [ |
|
"label" => "D.lgs 36/2023", |
|
"inizio" => '2023-07-01 00:00:00', |
|
"fine" => null |
|
], |
|
]; |
|
} |
|
|
|
public static function gen_uuid() { |
|
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', |
|
// 32 bits for "time_low" |
|
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), |
|
|
|
// 16 bits for "time_mid" |
|
mt_rand( 0, 0xffff ), |
|
|
|
// 16 bits for "time_hi_and_version", |
|
// four most significant bits holds version number 4 |
|
mt_rand( 0, 0x0fff ) | 0x4000, |
|
|
|
// 16 bits, 8 bits for "clk_seq_hi_res", |
|
// 8 bits for "clk_seq_low", |
|
// two most significant bits holds zero and one for variant DCE1.1 |
|
mt_rand( 0, 0x3fff ) | 0x8000, |
|
|
|
// 48 bits for "node" |
|
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) |
|
); |
|
} |
|
|
|
public static function findVersion($time = null) { |
|
if (empty($time)) { |
|
return "2023-36"; |
|
} else { |
|
$versions = self::versions(); |
|
if (!empty($versions)) { |
|
foreach($versions AS $key => $version) { |
|
$start = null; |
|
$end = null; |
|
if (!empty($version["inizio"])) { |
|
$start = strtotime($version["inizio"]); |
|
} |
|
if (!empty($version["fine"])) { |
|
$end = strtotime($version["fine"]); |
|
} |
|
if ((empty($start) || $start < $time) && (empty($end) || $end > $time)) { |
|
return $key; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
public static function getCriteria(string $version,$codici = []) { |
|
global $pdo; |
|
$bind = [":version"=>$version]; |
|
$sql = "SELECT * FROM b_dgue_settings WHERE version = :version "; |
|
if (!empty($codici)) { |
|
if (!is_array($codici)) { $codici = [$codici]; } |
|
$where = []; |
|
$i = 0; |
|
foreach($codici AS $codice) { |
|
$i++; |
|
$bind[":codice_{$i}"] = $codice; |
|
$where[] = "codice = :codice_{$i}"; |
|
} |
|
if (!empty($where)) { |
|
$sql .= " AND (" . implode(" OR ", $where) . ")"; |
|
} |
|
} |
|
$sql .= " ORDER BY codifica_criterio "; |
|
return $pdo->go($sql,$bind)->fetchAll(PDO::FETCH_ASSOC); |
|
} |
|
|
|
public static function moduliAbilitati() { |
|
$return = []; |
|
$return["pcp"] = ["titolo"=>"Appalti pre-commerciali","returnURL"=>"/backend/pcp/panel.php","script"=>"/pcp/dgue/init.php"]; |
|
$return["gare"] = ["titolo"=>"Gare e affidamenti","returnURL"=>"/backend/gare/panel.php","script"=>"/gare/dgue/init.php"]; |
|
$return["albo_fornitori"] = ["titolo"=>"Albo dei fornitori","returnURL"=>"/backend/albo_fornitori/panel.php","script"=>"/albo_fornitori/dgue/init.php"]; |
|
$return["albi_commissione"] = ["titolo"=>"Albo dei commissari","returnURL"=>"/backend/albi_commissione/panel.php","script"=>"/albi_commissione/dgue/init.php"]; |
|
$return["concorsi"] = ["titolo"=>"Concorsi di progettazione","returnURL"=>"/backend/concorsi/panel.php","script"=>"/concorsi/dgue/init.php"]; |
|
return $return; |
|
} |
|
|
|
public static function getStyles() { |
|
$styles = []; |
|
$styles["th"] = "font-weight: bold;background-color:#DDD;"; |
|
return $styles; |
|
} |
|
|
|
public function __construct($modulo,$elemento) |
|
{ |
|
|
|
if (!empty($modulo) && !empty($elemento) && !empty(self::moduliAbilitati()[$modulo])) { |
|
global $pdo,$root; |
|
$this->modulo = $modulo; |
|
$this->elemento = $elemento; |
|
$this->gestore = $_SESSION["ente"]->codice; |
|
$this->db = $pdo; |
|
$this->setVersionFromSelected(); |
|
$this->setModelFromSelected(); |
|
$modelClassPath = __DIR__ . DIRECTORY_SEPARATOR . "models" . DIRECTORY_SEPARATOR . "{$this->model}" . DIRECTORY_SEPARATOR . "dgue.model.class.php"; |
|
$this->setMatchesUUID(); |
|
if (file_exists($modelClassPath) && !class_exists("DGUEModel")) { |
|
include_once $modelClassPath; |
|
} else if (!class_exists("DGUEModel")) { |
|
Throw new Exception("Impossibile trovare la classe per la gestione del modello selezionato"); |
|
} |
|
$this->modelInstance = new DGUEModel($this); |
|
$this->abilitaSwitchVersion = true; |
|
$this->checkAdminPermission(); |
|
$this->styles = self::getStyles(); |
|
return $this; |
|
} |
|
return false; |
|
} |
|
|
|
public static function fixArray($dgue,$nl2br = false) { |
|
ini_set('max_execution_time', 600); |
|
array_walk_recursive($dgue, function (&$value,&$key) use ($nl2br) { |
|
if (!is_array($value)) { |
|
// $value = htmlentities($value); |
|
if ($nl2br) { |
|
$value = nl2br($value); |
|
} |
|
} |
|
}); |
|
if (!empty($dgue["ccv:Criterion"])) { |
|
$criterion = array(); |
|
foreach($dgue["ccv:Criterion"] AS $criteria) { |
|
$_id = ""; |
|
if (!empty($criteria["cbc:ID"]['$'])) { $_id = $criteria["cbc:ID"]['$']; } |
|
if (empty($_id) && isset($criteria["cbc:ID"]) && !is_array($criteria["cbc:ID"])) { $_id = $criteria["cbc:ID"]; } |
|
if (!empty($_id)) { |
|
if (!empty($criterion[$_id])) { |
|
if (!isset($criterion[$_id][0])) { |
|
$tmp = $criterion[$_id]; |
|
$criterion[$_id] = array($tmp); |
|
} |
|
$criterion[$_id][] = $criteria; |
|
} else { |
|
$criterion[$_id] = $criteria; |
|
} |
|
} |
|
} |
|
$dgue["ccv:Criterion"] = $criterion; |
|
} |
|
return $dgue; |
|
} |
|
|
|
public static function getDGUEFromXML($xml) { |
|
$xml = simplexml_load_string($xml); |
|
$xml = xmlToArray($xml); |
|
if (!empty($xml["ESPDResponse"])) { |
|
return self::fixArray($xml["ESPDResponse"]); |
|
} |
|
} |
|
|
|
public static function printUploadButton() { |
|
if (isset($_SESSION["utente"]) && $_SESSION["utente"]->gerarchia < 100) { |
|
include __DIR__."/button.php"; |
|
} |
|
} |
|
|
|
public function printFillButton($pannello=false) { |
|
if (!empty($this->getRequestedCriteria())) { |
|
$editURL = "/dgue/edit.php?" . (($pannello) ? "pannello=1&" : "") . "modulo={$this->modulo}&codice_elemento={$this->elemento}"; |
|
?> |
|
<div class="btn-group btn-block"> |
|
<a href="<?= $editURL ?>" class="btn col-12 col-lg-8 btn-primary"> |
|
<span class="fa fa-edit"></span> <?= __("Compila DGUE"); ?> |
|
</a> |
|
<a href="/dgue/getRequestXML.php?modulo=<?= $this->modulo ?>&codice_elemento=<?= $this->elemento ?>" title="<?= __("Richiesta XML") ?>" target="_blank" class="btn btn-info col-12 col-lg-2"> |
|
<span class="fa fa-code"></span><span class="sr-only"><?= __("Richiesta XML") ?></span> |
|
</a> |
|
<button type="button" class="btn btn-info col-12 col-lg-2" title="<?= __("Condividi link con il raggruppamento") ?>" data-toggle="modal" data-target="#urlModal"> |
|
<span class="fa fa-link"></span><span class="sr-only"><?= __("Condividi link") ?></span> |
|
</button> |
|
</div> |
|
<div class="modal fade" id="urlModal" tabindex="-1" role="dialog" aria-labelledby="modelTitleId" aria-hidden="true"> |
|
<div class="modal-dialog modal-lg" role="document"> |
|
<div class="modal-content"> |
|
<div class="modal-header"> |
|
<h5 class="modal-title"><?= __("Condividi link") ?></h5> |
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
|
<span aria-hidden="true">×</span> |
|
</button> |
|
</div> |
|
<div class="modal-body text-center"> |
|
<?= __("Condividi il link per consentire la compilazione del DGUE agli altri componenti del raggruppamento") ?> |
|
<div class="alert alert-info text-center my-2 p-3"><strong><u><?= $_SESSION["config"]["link_sito"] . $editURL; ?></u></strong></div> |
|
<?= __("Per compilare il DGUE è necessario preventivamente effettuare il login alla piattaforma.") ?><br> |
|
<strong><?= __("Sarà sempre onere del Capogruppo la trasmissione dei documenti di partecipazione di tutti i componenti") ?></strong> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
<? |
|
} |
|
} |
|
|
|
public function getObject() { |
|
if (empty($this->object)) { |
|
global $beRoot; |
|
$returnObject = true; |
|
$path = $beRoot . self::moduliAbilitati()[$this->modulo]["script"]; |
|
if (file_exists($path)) { |
|
include $path; |
|
if (!empty($return)) { |
|
$this->object = $return; |
|
} |
|
} |
|
} |
|
if (!empty($this->object)) { |
|
return $this->object; |
|
} |
|
return false; |
|
} |
|
|
|
public function checkAdminPermission() { |
|
global $beRoot; |
|
$returnObject = false; |
|
$path = $beRoot . self::moduliAbilitati()[$this->modulo]["script"]; |
|
if (file_exists($path)) { |
|
include $path; |
|
return $return; |
|
} |
|
return false; |
|
} |
|
|
|
public static function getTemplatePath(String $template) { |
|
return DGUE_TEMPLATE_PATH . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR; |
|
} |
|
|
|
public static function getCriteriaTemplateDefinition(String $template) { |
|
$definitions = self::getTemplatePath($template) . "definition.json"; |
|
if (file_exists($definitions)) { |
|
return jsonToArray($definitions); |
|
} |
|
} |
|
|
|
public function generateUUID() { |
|
$criterias = $this->getRequestedCriteria(); |
|
$matches = []; |
|
if (!empty($criterias)) { |
|
foreach($criterias AS $criteria) { |
|
$definitions = self::getCriteriaTemplateDefinition($criteria["template"]); |
|
if (!empty($definitions)) { |
|
foreach($definitions AS $group_id => $inputs) { |
|
foreach($inputs AS $input) { |
|
if (isset($input["id"])) { |
|
$matches[$criteria["codice"]][$group_id][$input["id"]] = self::gen_uuid(); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (!empty($matches)) { |
|
$salva = new salva(); |
|
$salva->debug = false; |
|
$salva->nome_tabella = "b_dgue_uuid"; |
|
$salva->operazione = "INSERT"; |
|
$salva->oggetto = [ |
|
"codice_elemento" => $this->elemento, |
|
"modulo" => $this->modulo, |
|
"uuids" => json_encode($matches) |
|
]; |
|
$salva->save(); |
|
} |
|
} |
|
|
|
public function setMatchesUUID() { |
|
$uuids = $this->db->go("SELECT uuids FROM b_dgue_uuid WHERE modulo = :modulo AND codice_elemento = :elemento ", |
|
[ |
|
":modulo" => $this->modulo, |
|
":elemento" => $this->elemento, |
|
])->fetch(PDO::FETCH_COLUMN); |
|
if (!empty($uuids)) { |
|
$this->matches = json_decode($uuids,true); |
|
} |
|
} |
|
|
|
public function getUUIDMatches(Int $criteria) { |
|
return $this->matches[$criteria] ?? null; |
|
} |
|
|
|
public function saveRequest(array $codici) { |
|
$object = $this->getObject(); |
|
$error = false; |
|
if (!empty($codici)) { |
|
$sql = "INSERT INTO r_dgue_request (modelVersion,codice_elemento,modulo,codice_form,utente_modifica) VALUES (:model,:codice_elemento,:modulo,:codice_form,:utente_modifica)"; |
|
$insert = $this->db->prepare($sql); |
|
$bind[":model"] = $this->model; |
|
$bind[":codice_elemento"] = $this->elemento; |
|
$bind[":modulo"] = $this->modulo; |
|
$bind[":utente_modifica"] = $_SESSION["utente"]->codice; |
|
$insert->bindValue(":model",$this->model); |
|
$insert->bindValue(":codice_elemento",$this->elemento); |
|
$insert->bindValue(":codice_elemento",$this->elemento); |
|
$insert->bindValue(":modulo",$this->modulo); |
|
$insert->bindValue(":utente_modifica",$_SESSION["utente"]->codice); |
|
foreach($codici AS $codice) { |
|
$insert->bindValue(":codice_form",$codice); |
|
$bind[":codice_form"] = $codice; |
|
if ($insert->execute()) { |
|
scriviLog("r_dgue_request","INSERT",strtr($sql,$bind)); |
|
} else { |
|
$error = true; |
|
} |
|
} |
|
if ($this->modelInstance->generateUUID()) { |
|
$this->generateUUID(); |
|
} |
|
if (!empty($object) && method_exists($object,"addDGUERequest")) { |
|
$object->addDGUERequest(); |
|
} |
|
} else { |
|
if (!empty($object) && method_exists($object,"deleteDGUERequest")) { |
|
$object->deleteDGUERequest(); |
|
} |
|
} |
|
if (!empty($object) && method_exists($object,"addToLog")) { |
|
$object->addToLog("UPDATE",ucfirst("DGUE")); |
|
} |
|
return $error; |
|
} |
|
|
|
public function availableCriteria() { |
|
$criteria = self::getCriteria($this->version); |
|
if (!empty($this->tipologia)) { |
|
$tmp = $criteria; |
|
$criteria = []; |
|
foreach($tmp AS $criterio) { |
|
if ($criterio["attivo"] == "S") { |
|
$insert = true; |
|
if (!empty($criterio["tipologie"])) { |
|
$insert = false; |
|
$tipologie = explode(",",$criterio["tipologie"]); |
|
if (is_array($tipologie)) { |
|
if (in_array($this->tipologia,$tipologie) !== false) { $insert = true; } |
|
} else if ($tipologie == $this->tipologia) { |
|
$insert = true; |
|
} |
|
} |
|
if ($insert) { |
|
$criteria[] = $criterio; |
|
} |
|
} |
|
} |
|
} |
|
return $criteria; |
|
} |
|
|
|
public function removeDGUE() { |
|
if (isset($this->db)) { |
|
if ($this->checkAdminPermission()) { |
|
$this->db->go("DELETE FROM r_dgue_request WHERE codice_elemento = :codice_elemento AND modulo = :modulo ",[":codice_elemento"=>$this->elemento,":modulo"=>$this->modulo]); |
|
$this->db->go("DELETE FROM b_dgue_uuid WHERE codice_elemento = :codice_elemento AND modulo = :modulo ",[":codice_elemento"=>$this->elemento,":modulo"=>$this->modulo]); |
|
scriviLog("r_dgue_request","DELETE",$this->db->getSQL()); |
|
} |
|
} |
|
} |
|
|
|
public function selectedCriteria() { |
|
if (isset($this->db)) { |
|
$ris = $this->db->go("SELECT codice_form FROM r_dgue_request WHERE codice_elemento = :codice_elemento AND modulo = :modulo ",[":codice_elemento"=>$this->elemento,":modulo"=>$this->modulo]); |
|
if ($ris->rowCount() > 0) { |
|
return $ris->fetchAll(PDO::FETCH_COLUMN); |
|
} |
|
} |
|
return []; |
|
} |
|
|
|
public function setVersionFromSelected() { |
|
$this->version = self::findVersion(); |
|
$selected = $this->selectedCriteria(); |
|
if (!empty($selected)) { |
|
$this->version = $this->db->go("SELECT version FROM b_dgue_settings WHERE codice = :codice",[":codice"=>$selected[0]])->fetch(PDO::FETCH_COLUMN); |
|
} |
|
} |
|
|
|
public function setModelFromSelected() { |
|
$this->model = "2.1.1"; |
|
$selected = $this->db->go("SELECT modelVersion FROM r_dgue_request WHERE codice_elemento = :codice_elemento AND modulo = :modulo LIMIT 0,1",[":codice_elemento"=>$this->elemento,":modulo"=>$this->modulo]); |
|
if (!empty($selected->rowCount())) { |
|
$this->model = $selected->fetch(PDO::FETCH_COLUMN); |
|
} |
|
} |
|
|
|
public function switchVersion(string $to) { |
|
$error = false; |
|
if (!empty(self::versions()[$to])) { |
|
$selected = $this->selectedCriteria(); |
|
if (!empty($selected)) { |
|
$selected = self::getCriteria($this->version,$selected); |
|
$new = []; |
|
|
|
if(!empty($selected)) { |
|
$checkCode = $this->db->prepare("SELECT codice FROM b_dgue_settings WHERE codifica_criterio = :code AND version = :to"); |
|
$checkCode->bindValue(":to",$to); |
|
foreach($selected AS $criteria) { |
|
$checkCode->bindValue(":code",$criteria["codifica_criterio"]); |
|
$checkCode->execute(); |
|
if ($checkCode->rowCount() > 0) { |
|
$new[] = $checkCode->fetch(PDO::FETCH_COLUMN); |
|
} |
|
} |
|
if (empty($new)) { |
|
$checkCode->bindValue(":code","0.3.1"); |
|
$checkCode->execute(); |
|
if ($checkCode->rowCount() > 0) { |
|
$new[] = $checkCode->fetch(PDO::FETCH_COLUMN); |
|
} |
|
} |
|
$this->removeDGUE(); |
|
$error = $this->saveRequest($new); |
|
} |
|
} else { |
|
$error = true; |
|
} |
|
} else { |
|
$error = true; |
|
} |
|
return $error; |
|
} |
|
|
|
public function getRequestedCriteria() { |
|
$criteria = []; |
|
if (!empty($this->version)) { |
|
$all = $this->availableCriteria(); |
|
$selected = $this->selectedCriteria(); |
|
if (!empty($selected)) { |
|
$allSatisfied = false; |
|
foreach($all AS $criterio) { |
|
$insert = false; |
|
if ($criterio["obbligatorio"] == "S") { |
|
$insert = true; |
|
} else { |
|
if (in_array($criterio["codice"],$selected) !== false) { $insert = true; } |
|
if ($insert && $criterio["livello1"] == "SELECTION") { |
|
if ($criterio["uuid"] == "7e7db838-eeac-46d9-ab39-42927486f22d") { |
|
$allSatisfied = true; |
|
} else if ($allSatisfied) { |
|
$insert = false; |
|
} |
|
} |
|
} |
|
if ($insert) { $criteria[] = $criterio; } |
|
} |
|
} |
|
} |
|
return $criteria; |
|
} |
|
|
|
public function getBreadcrumb($breadcrumb = [], $pannello = false, $salva = false) { |
|
if (empty($this->inputsBreadcrumb)) { |
|
$qs = "codice=".$this->elemento; |
|
} else { |
|
$qs = http_build_query($this->inputsBreadcrumb); |
|
} |
|
$breadcrumb["/{$this->modulo}/dettaglio.php?{$qs}"] = __("Dettagli"); |
|
if (!empty($pannello)) { |
|
$breadcrumb["/{$this->modulo}/partecipa/partecipa.php?{$qs}"] = __("Pannello di partecipazione"); |
|
} |
|
return $breadcrumb; |
|
} |
|
|
|
public function printEditor() { |
|
if ($this->checkAdminPermission()) { |
|
$this->admin = true; |
|
include (__DIR__."/backend-manage.php"); |
|
} |
|
return false; |
|
} |
|
|
|
public function getRequestXML() { |
|
$criteria = $this->getRequestedCriteria(); |
|
if (!empty($criteria)) { |
|
$dgue = $this->modelInstance->getRequestArray($criteria); |
|
if (!empty($dgue)) { |
|
array_walk_recursive($dgue, function(&$value) { |
|
if (!is_array($value)) { |
|
$value = html_entity_decode($value,ENT_COMPAT | ENT_HTML401,"UTF-8"); |
|
$value = preg_replace('#&(?=[a-z_0-9]+=)#', '&', $value); |
|
$value = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $value); |
|
$value = utf8_encode($value); |
|
} |
|
}); |
|
return self::getXML($dgue); |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
public static function showDGUE($dgue=[],$criteria = [],$version = null) { |
|
$version = $version ?? self::findVersion(); |
|
if (empty($criteria)) { |
|
$criteria = self::getCriteria($version); |
|
} |
|
if (!empty($dgue)) { |
|
$dgue = self::fixArray($dgue,true); |
|
} |
|
ob_start(); |
|
include __DIR__."/views/versions/{$version}/main.php"; |
|
return ob_get_clean(); |
|
} |
|
|
|
public function showForm($dgue=[],$pannello=false) { |
|
if (!empty($dgue)) { |
|
$dgue = self::fixArray($dgue); |
|
} |
|
include __DIR__."/views/versions/{$this->version}/form.php"; |
|
} |
|
|
|
public function fillContent($dgue) { |
|
$preview = false; |
|
if (!is_array($dgue) && $dgue === "preview") { |
|
$preview = true; |
|
$dgue = ["preview"]; |
|
} |
|
$dgue["cac:ContractingParty"]["cac:Party"]["cac:PartyName"]["cbc:Name"] = $this->ente ?? $_SESSION["ente"]->getInfo()["denominazione"]; |
|
$dgue["cac:AdditionalDocumentReference"][1]["cac:Attachment"]["cac:ExternalReference"]["cbc:FileName"] = htmlentities($this->oggetto, ENT_QUOTES, 'UTF-8'); |
|
$dgue["cac:AdditionalDocumentReference"][1]["cac:Attachment"]["cac:ExternalReference"]["cbc:Description"] = trim(strip_tags($this->descrizione)); |
|
if (!empty($this->id_appalto)) { $dgue["cbc:ContractFolderID"]["$"] = $this->id_appalto; } |
|
$dgue["espd-cac:EconomicOperatorParty"]["cac:Party"]["cac:PartyIdentification"][0]["cbc:ID"] = $_SESSION["utente"]->oe["codice_fiscale_impresa"] ?? ""; |
|
$dgue["espd-cac:EconomicOperatorParty"]["cac:Party"]["cac:PartyName"]["cbc:Name"] = $_SESSION["utente"]->oe["ragione_sociale"] ?? ""; |
|
if (!$preview) { |
|
$dgue["espd-cac:EconomicOperatorParty"]["cac:Party"]["cac:Contact"]["cbc:Name"] = $_SESSION["utente"]->getInfo()["nome"] . " " . $_SESSION["utente"]->getInfo()["cognome"]; |
|
} |
|
$dgue["espd-cac:EconomicOperatorParty"]["cac:Party"]["cac:Contact"]["cbc:Telephone"] = $_SESSION["utente"]->getInfo()["telefono"]; |
|
$dgue["espd-cac:EconomicOperatorParty"]["cac:Party"]["cac:Contact"]["cbc:ElectronicMail"] = $_SESSION["utente"]->oe["pec"] ?? ""; |
|
|
|
if (empty($dgue["espd-cac:EconomicOperatorParty"]["espd-cac:RepresentativeNaturalPerson"])) { |
|
$formInfo = FormManager::getInfoFromID("organizzazione-oe",$this->gestore); |
|
if (!empty($formInfo)) { |
|
$formManager = new FormManager; |
|
$formManager->init($formInfo["codice"],"oe",$_SESSION["utente"]->oe["codice"] ?? -1); |
|
$rappresentanti = $formManager->getValues(); |
|
if (!empty($rappresentanti)) { |
|
$i_r = 0; |
|
foreach($rappresentanti AS $rappresentante) { |
|
foreach($rappresentante AS $data) { |
|
$info = $formManager->getInputInfo($data["codice"]); |
|
switch($info["input"]["id"]) { |
|
case "soggetto-nome": |
|
$dgue["espd-cac:EconomicOperatorParty"]["espd-cac:RepresentativeNaturalPerson"][$i_r]["cac:PowerOfAttorney"]["cac:AgentParty"]["cac:Person"]["cbc:FirstName"] = $data["value"]; |
|
break; |
|
case "soggetto-cognome": |
|
$dgue["espd-cac:EconomicOperatorParty"]["espd-cac:RepresentativeNaturalPerson"][$i_r]["cac:PowerOfAttorney"]["cac:AgentParty"]["cac:Person"]["cbc:FamilyName"] = $data["value"]; |
|
break; |
|
case "soggetto-ruolo": |
|
$info["input"]["opzioni"] = json_decode($info["input"]["opzioni"],true); |
|
if (in_array("tipologieRappresentantiLegali.json",$info["input"]["opzioni"]) !== false) { |
|
global $root; |
|
$opzioni = jsonToArray($root."/backend/form/json/tipologieRappresentantiLegali.json"); |
|
$data["value"] = $opzioni[$data["value"]]["IT"] ?? $data["value"]; |
|
} |
|
$dgue["espd-cac:EconomicOperatorParty"]["espd-cac:RepresentativeNaturalPerson"][$i_r]["espd-cbc:NaturalPersonRoleDescription"] = $data["value"]; |
|
break; |
|
case "soggetto-nascita": |
|
$dgue["espd-cac:EconomicOperatorParty"]["espd-cac:RepresentativeNaturalPerson"][$i_r]["cac:PowerOfAttorney"]["cac:AgentParty"]["cac:Person"]["cbc:BirthDate"] = date2mysql($data["value"]); |
|
break; |
|
case "soggetto-indirizzo": |
|
$indirizzo = json_decode($data["value"],true); |
|
$dgue["espd-cac:EconomicOperatorParty"]["espd-cac:RepresentativeNaturalPerson"][$i_r]["cac:PowerOfAttorney"]["cac:AgentParty"]["cac:Person"]["cac:ResidenceAddress"]["cbc:StreetName"] = $indirizzo["indirizzo"]; |
|
$dgue["espd-cac:EconomicOperatorParty"]["espd-cac:RepresentativeNaturalPerson"][$i_r]["cac:PowerOfAttorney"]["cac:AgentParty"]["cac:Person"]["cac:ResidenceAddress"]["cbc:CityName"] = $indirizzo["citta"]; |
|
$dgue["espd-cac:EconomicOperatorParty"]["espd-cac:RepresentativeNaturalPerson"][$i_r]["cac:PowerOfAttorney"]["cac:AgentParty"]["cac:Person"]["cac:ResidenceAddress"]["cbc:Postbox"] = $indirizzo["cap"]; |
|
break; |
|
} |
|
} |
|
$i_r++; |
|
} |
|
} |
|
} |
|
} |
|
|
|
if (count($dgue["espd-cac:EconomicOperatorParty"]["cac:Party"]["cac:PartyIdentification"]) > 1) { |
|
$i = 0; |
|
foreach($dgue["espd-cac:EconomicOperatorParty"]["cac:Party"]["cac:PartyIdentification"] AS $PartyIdentification) { |
|
if (!empty($dgue["espd-cac:EconomicOperatorParty"]["cac:Party"]["cac:PartyIdentification"][$i]["cbc:ID"])) { $dgue["espd-cac:EconomicOperatorParty"]["cac:Party"]["cac:PartyIdentification"][$i]["cbc:ID"] = $PartyIdentification["cbc:ID"] ?? ""; } |
|
$i++; |
|
} |
|
} |
|
return $dgue; |
|
} |
|
|
|
public static function retrieveResponse($array,$search) { |
|
$requirements = DGUE::filterRequirement($array); |
|
$return = false; |
|
if (is_array($requirements) && count($requirements) > 0) { |
|
foreach($requirements AS $requirement) { |
|
if (!empty($requirement["cbc:ID"])) { |
|
$id = $requirement["cbc:ID"]; |
|
if (!empty($id["$"])) { $id = $id["$"]; } |
|
if ($id == $search) { $return = $requirement; } |
|
} |
|
} |
|
} |
|
return $return; |
|
} |
|
|
|
public static function filterRequirement($array) { |
|
$requirements = array(); |
|
if (is_array($array)) { |
|
foreach($array AS $chiave => $valore) { |
|
if (is_array($valore)) { |
|
if ($chiave == "ccv:Requirement") { |
|
if (empty($valore["cbc:ID"])) { |
|
$requirements = array_merge($requirements,$valore); |
|
} else { |
|
$requirements[] = $valore; |
|
} |
|
} |
|
$requirements = array_merge($requirements,DGUE::filterRequirement($valore)); |
|
} |
|
} |
|
return $requirements; |
|
} |
|
} |
|
|
|
public static function findValues($array,$definition) { |
|
$values = []; |
|
foreach($definition AS $key => $object) { |
|
$values[$key] = array(); |
|
foreach($object AS $sub_key => $settings) { |
|
$valore = ""; |
|
if (!empty($settings["id"]) && !empty($settings["index"])) { |
|
$element = self::retrieveResponse($array,$settings["id"]); |
|
if (!empty($element["ccv:Response"]) && is_array($element["ccv:Response"])) { |
|
$response = $element["ccv:Response"]; |
|
foreach($settings["index"] AS $indice) { |
|
if (!empty($response[$indice])) { $response = $response[$indice]; } |
|
} |
|
if (!empty($response) && !is_array($response)) { $valore = $response; } |
|
} |
|
} |
|
$values[$key][$sub_key] = $valore; |
|
} |
|
} |
|
return $values; |
|
} |
|
|
|
public static function printGroup($criteria,$dgue,$id,$all_satisfied = false) { |
|
global $root; |
|
$styles = self::getStyles(); |
|
$sub_group = ""; |
|
foreach ($criteria AS $criterio) { |
|
if ($criterio["livello1"] == $id) { |
|
unset($values); |
|
$print_row = true; |
|
$show_empty = false; |
|
if ($criterio["livello1"] == "SELECTION" && $criterio["livello2"] != "ALL_SATISFIED" && $all_satisfied) { $print_row = false; } |
|
$first = reset($dgue); |
|
if ($first !== "preview") { |
|
if (empty($dgue["ccv:Criterion"][$criterio["uuid"]])) { |
|
$print_row = false; |
|
} else { |
|
if ($dgue["ccv:Criterion"][$criterio["uuid"]] === "show_empty") { |
|
$show_empty = true; |
|
} |
|
} |
|
} else { |
|
$show_empty = true; |
|
} |
|
if ($print_row && !empty($criterio["template"])) { |
|
if ($criterio["livello2"] != $sub_group) { |
|
$sub_group = $criterio["livello2"]; |
|
if (!empty(self::translateGroup($criterio["version"])[$criterio["livello1"]][$criterio["livello2"]]["it"])) { |
|
$sub_titolo = self::translateGroup($criterio["version"])[$criterio["livello1"]][$criterio["livello2"]]["it"]; |
|
?> |
|
<h2><?= $sub_titolo ?></h2> |
|
<? |
|
} |
|
} |
|
if (!empty($criterio["template"]) && file_exists($root."/dgue/templates/".$criterio["template"]."/show.php")) { |
|
?> |
|
<table> |
|
<tr nobr="true"> |
|
<th width="30%" style="<?= $styles["th"]; ?>"> |
|
<h3><?= $criterio["nome"] ?></h3> |
|
<?= $criterio["descrizione"] ?> |
|
</th> |
|
<td width="70%"> |
|
<? |
|
$json = false; |
|
if (file_exists($root."/dgue/templates/".$criterio["template"]."/definition.json")) { |
|
$json = file_get_contents($root."/dgue/templates/".$criterio["template"]."/definition.json"); |
|
$json = json_decode($json,true); |
|
if (is_array($json)) { |
|
$values = DGUE::findValues(@$dgue["ccv:Criterion"][$criterio["uuid"]],$json); |
|
} |
|
} |
|
include $root."/dgue/templates/".$criterio["template"]."/show.php"; |
|
?> |
|
</td> |
|
</tr> |
|
</table> |
|
<? |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
public function writeForm($criteria,$dgue,$id) { |
|
global $root; |
|
$sub_group = ""; |
|
foreach ($criteria AS $criterio) { |
|
if ($criterio["livello1"] == $id && $criterio["attivo"] == "S") { |
|
unset($values); |
|
if ($criterio["livello2"] != $sub_group) { |
|
$sub_group = $criterio["livello2"]; |
|
if (!empty(self::translateGroup($criterio["version"])[$criterio["livello1"]][$criterio["livello2"]]["it"])) { |
|
$sub_titolo = self::translateGroup($criterio["version"])[$criterio["livello1"]][$criterio["livello2"]]["it"]; |
|
?> |
|
<h2 class="<?= $criterio["livello1"] ?> <?= $criterio["livello2"] ?>"><?= $sub_titolo ?></h2> |
|
<? |
|
} |
|
} |
|
if (!empty($criterio["template"]) && file_exists($root."/dgue/templates/".$criterio["template"]."/form.php")) { |
|
?> |
|
<div class="card <?= $criterio["livello1"] ?> <?= $criterio["livello2"] ?> mb-3"> |
|
<div class="card-body p-0"> |
|
<div class="d-flex align-items-stretch p-0"> |
|
<div class="col-12 col-lg-4 bg-light p-4"> |
|
<strong><?= $criterio["nome"] ?></strong><br> |
|
<?= $criterio["descrizione"] ?> |
|
</div> |
|
<div class="col-12 col-lg-8 py-3 py-lg-5"> |
|
<div id="form_<?= $criterio["uuid"] ?>"> |
|
<? |
|
$json = false; |
|
if (file_exists($root."/dgue/templates/".$criterio["template"]."/definition.json")) { |
|
$json = file_get_contents($root."/dgue/templates/".$criterio["template"]."/definition.json"); |
|
$json = json_decode($json,true); |
|
if (is_array($json)) { |
|
$values = DGUE::findValues(@$dgue["ccv:Criterion"][$criterio["uuid"]],$json); |
|
} |
|
} |
|
include $root."/dgue/templates/".$criterio["template"]."/form.php"; |
|
?> |
|
</div> |
|
<? if ($criterio["ripeti"] == "S") { |
|
?> |
|
<button |
|
class="btn btn-block btn-info" |
|
onClick="aggiungi('/dgue/templates/<?= $criterio["template"] ?>/form.php','#form_<?= $criterio["uuid"] ?>');return false;"> |
|
<span class="fa fa-plus-circle"></span> <strong><?= __("Aggiungi elemento") ?></strong> |
|
</button> |
|
<? |
|
} |
|
?> |
|
</div> |
|
<div class="clear"></div> |
|
</div> |
|
</div> |
|
</div> |
|
<? |
|
} |
|
} |
|
} |
|
} |
|
|
|
public static function getXML($dgue) { |
|
return "<?xml version = \"1.0\" encoding = \"UTF-8\"?>" . PHP_EOL . array2XML($dgue,"",false,false,true); |
|
} |
|
|
|
public static function getResponseXML($dgue) { |
|
$dgue["@xmlns:cac"] = "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"; |
|
$dgue["@xmlns:cbc"] = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"; |
|
$dgue["@xmlns:ccv-cbc"] = "urn:isa:names:specification:ubl:schema:xsd:CCV-CommonBasicComponents-1"; |
|
$dgue["@xmlns:cev-cbc"] = "urn:isa:names:specification:ubl:schema:xsd:CEV-CommonBasicComponents-1"; |
|
$dgue["@xmlns:cev"] = "urn:isa:names:specification:ubl:schema:xsd:CEV-CommonAggregateComponents-1"; |
|
$dgue["@xmlns:espd"] = "urn:grow:names:specification:ubl:schema:xsd:ESPDResponse-1"; |
|
$dgue["@xmlns:ext"] = "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"; |
|
$dgue["@xmlns:espd-cbc"] = "urn:grow:names:specification:ubl:schema:xsd:ESPD-CommonBasicComponents-1"; |
|
$dgue["@xmlns:ccv"] = "urn:isa:names:specification:ubl:schema:xsd:CCV-CommonAggregateComponents-1"; |
|
$dgue["@xmlns:espd-cac"] = "urn:grow:names:specification:ubl:schema:xsd:ESPD-CommonAggregateComponents-1"; |
|
$dgue["cbc:UBLVersionID"]["@schemeAgencyID"] = "OASIS-UBL-TC"; |
|
$dgue["cbc:UBLVersionID"]['$'] = "2.1"; |
|
$dgue["cbc:CustomizationID"]["@schemeName"]="CustomizationID"; |
|
$dgue["cbc:CustomizationID"]["@schemeAgencyID"]="BII"; |
|
$dgue["cbc:CustomizationID"]["@schemeVersionID"]="3.0"; |
|
$dgue["cbc:CustomizationID"]['$'] = "urn:www.cenbii.eu:transaction:biitrns092:ver3.0"; |
|
$dgue["cbc:ID"]["@schemeID"]="ISO/IEC 9834-8:2008 - 4UUID"; |
|
$dgue["cbc:ID"]["@schemeAgencyID"]="EU-COM-GROW"; |
|
$dgue["cbc:ID"]["@schemeAgencyName"] = "DG GROW (European Commission)"; |
|
$dgue["cbc:ID"]["@schemeVersionID"]="1.1"; |
|
$dgue["cbc:ID"]['$'] = "b1bd7c20-b1c1-437b-891a-b96bbc188215"; |
|
$dgue["cbc:CopyIndicator"] = "false"; |
|
$dgue["cbc:VersionID"]["@schemeAgencyID"] = "EU-COM-GROW"; |
|
$dgue["cbc:VersionID"]['$'] = "2016.04.2"; |
|
$dgue["cbc:IssueDate"] = date('Y-m-d'); |
|
$dgue["cbc:IssueTime"] = date('H:i:s'); |
|
|
|
$dgue["cac:AdditionalDocumentReference"][1]["cbc:ID"]["@schemeID"]="COM-GROW-TEMPORARY-ID"; |
|
$dgue["cac:AdditionalDocumentReference"][1]["cbc:ID"]["@schemeAgencyID"]="EU-COM-GROW"; |
|
$dgue["cac:AdditionalDocumentReference"][1]["cbc:ID"]["@schemeAgencyName"]="DG GROW (European Commission)"; |
|
$dgue["cac:AdditionalDocumentReference"][1]["cbc:ID"]["@schemeVersionID"]="1.1"; |
|
$dgue["cac:AdditionalDocumentReference"][1]["cbc:ID"]['$']= "0000/S 000-000000"; |
|
|
|
$dgue["cac:AdditionalDocumentReference"][1]["cbc:DocumentTypeCode"]["@listID"]="ReferencesTypeCodes"; |
|
$dgue["cac:AdditionalDocumentReference"][1]["cbc:DocumentTypeCode"]["@listAgencyID"]="EU-COM-GROW"; |
|
$dgue["cac:AdditionalDocumentReference"][1]["cbc:DocumentTypeCode"]["@listVersionID"]="1.0"; |
|
$dgue["cac:AdditionalDocumentReference"][1]["cbc:DocumentTypeCode"]['$'] = "TED_CN"; |
|
|
|
$dgue["cac:AdditionalDocumentReference"][0]["cbc:ID"]["@schemeID"]="ISO/IEC 9834-8:2008 - 4UUID"; |
|
$dgue["cac:AdditionalDocumentReference"][0]["cbc:ID"]["@schemeAgencyID"] ="EU-COM-GROW"; |
|
$dgue["cac:AdditionalDocumentReference"][0]["cbc:ID"]["@schemeAgencyName"]="DG GROW (European Commission)"; |
|
$dgue["cac:AdditionalDocumentReference"][0]["cbc:ID"]["@schemeVersionID"]="1.1"; |
|
$dgue["cac:AdditionalDocumentReference"][0]["cbc:ID"]['$'] = "7ffae894-7839-4c00-97a9-851e9f471faa"; |
|
|
|
$dgue["cac:AdditionalDocumentReference"][0]["cbc:DocumentTypeCode"]["@listID"]="ReferencesTypeCodes"; |
|
$dgue["cac:AdditionalDocumentReference"][0]["cbc:DocumentTypeCode"]["@listAgencyID"]="EU-COM-GROW"; |
|
$dgue["cac:AdditionalDocumentReference"][0]["cbc:DocumentTypeCode"]["@listVersionID"]="1.0"; |
|
$dgue["cac:AdditionalDocumentReference"][0]["cbc:DocumentTypeCode"]['$']="ESPD_REQUEST"; |
|
$dgue["cac:AdditionalDocumentReference"][0]["cbc:DocumentDescription"] = "ESPDRequest" . $dgue["cbc:ContractFolderID"]['$']; |
|
$dgue["cbc:ContractFolderID"]["@schemeAgencyID"]="TeD"; |
|
/* riassegnazione ordine per lettore */ |
|
$tmp = array(); |
|
$tmp[] = $dgue["cac:AdditionalDocumentReference"][0]; |
|
$tmp[] = $dgue["cac:AdditionalDocumentReference"][1]; |
|
$dgue["cac:AdditionalDocumentReference"] = $tmp; |
|
unset($tmp); |
|
|
|
$dgue["cac:ContractingParty"]["cac:Party"]["cac:PostalAddress"]["cac:Country"]["cbc:IdentificationCode"]["@listAgencyID"]="ISO"; |
|
$dgue["cac:ContractingParty"]["cac:Party"]["cac:PostalAddress"]["cac:Country"]["cbc:IdentificationCode"]["@listName"]="ISO 3166-1"; |
|
$dgue["cac:ContractingParty"]["cac:Party"]["cac:PostalAddress"]["cac:Country"]["cbc:IdentificationCode"]["@listVersionID"]="1.0"; |
|
$dgue["cac:ContractingParty"]["cac:Party"]["cac:PostalAddress"]["cac:Country"]["cbc:IdentificationCode"]['$'] = "IT"; |
|
$dgue = array("espd:ESPDResponse"=>$dgue); |
|
// LA FUNZIONE ELIMINA DALL'ARRAY TUTTI I REQUIREMENT CON ID PERS_ |
|
// $dgue = self::removePersID($dgue); |
|
array_walk_recursive($dgue, function(&$value,&$key) { |
|
if (!is_array($value)) { |
|
$value = html_entity_decode($value,ENT_COMPAT | ENT_HTML401,"UTF-8"); |
|
$value = preg_replace('#&(?=[a-z_0-9]+=)#', '&', $value); |
|
} |
|
}); |
|
$xml = array2XML($dgue); |
|
$xml = str_replace("&", "&", $xml); |
|
$xml = str_replace("&amp;", "&", $xml); |
|
return $xml; |
|
} |
|
|
|
public function getMyDGUE() { |
|
return self::staticgetMyDGUE($this->modulo,$this->elemento); |
|
} |
|
|
|
public function save($post) { |
|
ini_set("max_execution_time", "999"); |
|
$operazione = "INSERT"; |
|
$dgue = $bind = array(); |
|
$dgue["version"] = $this->version; |
|
$dgue["elemento"] = $bind[":elemento"] = $this->elemento; |
|
$dgue["modulo"] = $bind[":modulo"] = $this->modulo; |
|
$dgue["cig"] = $bind[":cig"] = $this->id_appalto; |
|
$dgue["oggetto"] = $bind[":oggetto"] = $this->oggetto; |
|
$dgue["codice_operatore"] = $bind[":codice_operatore"] = $_SESSION["utente"]->oe["codice"]; |
|
|
|
$sql = "SELECT codice FROM b_dgue_compilati WHERE elemento = :elemento AND modulo = :modulo AND codice_operatore = :codice_operatore"; |
|
$ris = $this->db->go($sql,$bind); |
|
if ($ris->rowCount() > 0) { |
|
$operazione = "UPDATE"; |
|
$dgue["codice"] = $ris->fetchAll(PDO::FETCH_ASSOC)[0]["codice"]; |
|
} |
|
|
|
$criterion = array(); |
|
$array = $post["espd"]; |
|
if (!empty($array["ccv:Criterion"]["9b19e869-6c89-4cc4-bd6c-ac9ca8602165"]["ccv:RequirementGroup"][0]["ccv:Requirement"]) && empty($array["ccv:Criterion"]["9b19e869-6c89-4cc4-bd6c-ac9ca8602165"]["ccv:RequirementGroup"][0]["ccv:Requirement"][1]["ccv:Response"]["ccv-cbc:Indicator"])) { $array["ccv:Criterion"]["9b19e869-6c89-4cc4-bd6c-ac9ca8602165"]["ccv:RequirementGroup"][0]["ccv:Requirement"][1]["ccv:Response"]["ccv-cbc:Indicator"] = "false"; } |
|
foreach($array["ccv:Criterion"] AS $id => $criteria) { |
|
if (isset($criteria[0])) { |
|
foreach($criteria AS $elemento) { |
|
$elemento["cbc:ID"]['$'] = $id; |
|
$criterion[] = $elemento; |
|
} |
|
} else { |
|
$criteria["cbc:ID"]['$'] = $id; |
|
$criterion[] = $criteria; |
|
} |
|
} |
|
$array["ccv:Criterion"] = $criterion; |
|
$array = self::convertDate($array); |
|
$dgue["json"] = json_encode($array,JSON_UNESCAPED_LINE_TERMINATORS); |
|
if (isset($post["soa"]["tipo"]) && $post["soa"]["tipo"] != "non_applicabile") { |
|
$dgue["soa"] = json_encode($post["soa"]); |
|
} |
|
if (isset($post["nazionali"])) { |
|
$dgue["nazionali"] = json_encode($post["nazionali"]); |
|
} |
|
if (isset($post["subappalto"])) { |
|
$dgue["subappalto"] = json_encode($post["subappalto"]); |
|
} |
|
$salva = new salva(); |
|
$salva->debug = false; |
|
|
|
$salva->nome_tabella = "b_dgue_compilati"; |
|
$salva->operazione = $operazione; |
|
$salva->oggetto = $dgue; |
|
$codice = $salva->save(); |
|
|
|
if ($codice > 0) { |
|
return $codice; |
|
} |
|
return false; |
|
} |
|
|
|
|
|
public static function convertDate($array) { |
|
foreach($array AS $key => $value) { |
|
if (is_array($value)) { |
|
$array[$key] = self::convertDate($value); |
|
} else { |
|
if (stripos($key, "date") !== false) { $array[$key] = date2mysql($value); } |
|
} |
|
} |
|
return $array; |
|
} |
|
|
|
public static function removePersID($array) { |
|
foreach($array AS $key => $value) { |
|
if (is_array($value)) { |
|
if (!empty($value["cbc:ID"])) { |
|
$unset = false; |
|
if (is_array($value["cbc:ID"])) { |
|
foreach ($value["cbc:ID"] AS $valore) { |
|
if (strpos($valore,"PERS_")===0) { $unset = true; } |
|
} |
|
} else { |
|
if (strpos($value["cbc:ID"],"PERS_")===0) { $unset = true; } |
|
} |
|
if ($unset) { |
|
unset($array[$key]); |
|
} else { |
|
$array[$key] = static::removePersID($value); |
|
} |
|
} else { |
|
$array[$key] = static::removePersID($value); |
|
} |
|
} |
|
} |
|
return $array; |
|
} |
|
|
|
|
|
public static function printTable($action = "") { |
|
include (__DIR__."/frontend-table.php"); |
|
return false; |
|
} |
|
|
|
public static function staticgetMyDGUE($modulo="",$elemento="",$filters=[],$order=[],$start=0,$limit=-1) { |
|
if (!empty($_SESSION["utente"]->oe)) { |
|
$select = "codice,elemento,modulo,cig,oggetto,codice_operatore,timestamp"; |
|
if (!empty($filters["codice"])) { $select = "*"; } |
|
$sql = "SELECT {$select} FROM b_dgue_compilati WHERE codice_operatore = :codice_operatore "; |
|
$bind = [":codice_operatore"=>$_SESSION["utente"]->oe["codice"]]; |
|
if (!empty($modulo)) { |
|
$bind[":modulo"] = $modulo; |
|
$sql .= " AND modulo = :modulo " ; |
|
} |
|
if (!empty($elemento)) { |
|
$bind[":elemento"] = $elemento; |
|
$sql .= " AND elemento = :elemento " ; |
|
} |
|
if (!empty($filters)) { |
|
$keys = ["cig","oggetto"]; |
|
$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)) { $sql .= " AND (" . implode(" OR ",$addWhere) . ") "; } |
|
if (isset($filters["codice"])) { |
|
if (is_numeric($filters["codice"])) { |
|
$bind[":codice"] = (int)$filters["codice"]; |
|
$sql .= " AND codice = :codice "; |
|
} else { |
|
return false; |
|
} |
|
} |
|
} |
|
if (!empty($order)) { |
|
$keys = ["timestamp","oggetto","cig"]; |
|
$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)) { |
|
$sql .= " ORDER BY " . implode(",",$sortArray); |
|
} |
|
} else { |
|
$sql .= " ORDER BY timestamp DESC"; |
|
} |
|
if (is_numeric($limit) && is_numeric($start) && $limit != -1) { |
|
$start = (int)$start; |
|
$limit = (int)$limit; |
|
$sql .= " LIMIT {$start}, {$limit}"; |
|
} |
|
global $pdo; |
|
return $pdo->go($sql,$bind)->fetchAll(PDO::FETCH_ASSOC); |
|
} |
|
} |
|
|
|
public static function translateGroup($version =null) { |
|
$version = $version ?? self::findVersion(); |
|
$dgue_translate_gruppi = array(); |
|
$dgue_translate_gruppi["OTHER"]["it"] = "Parte II - Operatore Economico"; |
|
$dgue_translate_gruppi["OTHER_FINAL"]["it"] = "Parte V - Riduzione del numero di candidati qualificati (Articolo 70 comma 6 del codice)"; |
|
$dgue_translate_gruppi["OTHER_FINAL"]["EO_DATA"]["it"] = $dgue_translate_gruppi["OTHER_FINAL"]["it"]; |
|
$dgue_translate_gruppi["EXCLUSION"]["it"] = "Parte III - Motivi di esclusione (Articoli da 94 a 98 del Codice)"; |
|
$dgue_translate_gruppi["SELECTION"]["it"] = "Parte IV - Criteri di selezione"; |
|
$dgue_translate_gruppi["OTHER"]["EO_DATA"]["it"] = ""; |
|
$dgue_translate_gruppi["EXCLUSION"]["CONVICTIONS"]["it"] = "A: Motivi legati a condanne penali"; |
|
$dgue_translate_gruppi["EXCLUSION"]["CONTRIBUTIONS"]["it"] = "B: Motivi legati al pagamento di imposte o contributi previdenziali"; |
|
$dgue_translate_gruppi["EXCLUSION"]["SOCIAL"]["it"] = "C: Motivi legati a insolvenza, conflitti di interessi o illeciti professionali"; |
|
$dgue_translate_gruppi["EXCLUSION"]["NATIONAL"]["it"] = "D: Motivi di esclusione previsti esclusivamente dalla legislazione nazionale"; |
|
$dgue_translate_gruppi["SELECTION"]["ALL_SATISFIED"]["it"] = "<font face=\"symbol\">a</font>: Indicazione generale per tutti i criteri di selezione"; |
|
$dgue_translate_gruppi["SELECTION"]["SUITABILITY"]["it"] = "A: Idoneità"; |
|
$dgue_translate_gruppi["SELECTION"]["ECONOMIC_FINANCIAL_STANDING"]["it"] = "B: Capacità economica e finanziaria"; |
|
$dgue_translate_gruppi["SELECTION"]["TECHNICAL_PROFESSIONAL_ABILITY"]["it"] = "C: Capacità tecniche e professionali"; |
|
if ($version == "2016-50") { |
|
$dgue_translate_gruppi["EXCLUSION"]["it"] = "Parte III - Motivi di esclusione (Articolo 80 del Codice)"; |
|
$dgue_translate_gruppi["OTHER_FINAL"]["it"] = "Parte V - Riduzione del numero di candidati qualificati (Articolo 91 del codice)"; |
|
} |
|
return $dgue_translate_gruppi; |
|
} |
|
|
|
public static function paesi() { |
|
$paesi = array(); |
|
$paesi[""] = ""; |
|
$paesi["AT"] = "Austria"; |
|
$paesi["BE"] = "Belgio"; |
|
$paesi["BG"] = "Bulgaria"; |
|
$paesi["CY"] = "Cipro"; |
|
$paesi["HR"] = "Croazia"; |
|
$paesi["DK"] = "Danimarca"; |
|
$paesi["EE"] = "Estonia"; |
|
$paesi["FI"] = "Finlandia"; |
|
$paesi["FR"] = "Francia"; |
|
$paesi["DE"] = "Germania"; |
|
$paesi["GR"] = "Grecia"; |
|
$paesi["IE"] = "Irlanda"; |
|
$paesi["IT"] = "Italia"; |
|
$paesi["LV"] = "Lettonia"; |
|
$paesi["LT"] = "Lituania"; |
|
$paesi["LU"] = "Lussemburgo"; |
|
$paesi["MT"] = "Malta"; |
|
$paesi["NL"] = "Paesi Bassi"; |
|
$paesi["PL"] = "Polonia"; |
|
$paesi["PT"] = "Portogallo"; |
|
$paesi["GB"] = "Regno Unito"; |
|
$paesi["CZ"] = "Repubblica ceca"; |
|
$paesi["RO"] = "Romania"; |
|
$paesi["SK"] = "Slovacchia"; |
|
$paesi["SI"] = "Slovenia"; |
|
$paesi["ES"] = "Spagna"; |
|
$paesi["SE"] = "Svezia"; |
|
$paesi["HU"] = "Ungheria"; |
|
$paesi["NO"] = "Norvegia"; |
|
$paesi["CH"] = "Svizzera"; |
|
return $paesi; |
|
} |
|
|
|
public static function valute() { |
|
$valute = array(); |
|
$valute[""] = ""; |
|
$valute["EUR"] = "EUR (Euro)"; |
|
$valute["ALL"] = "ALL (Albanian lek)"; |
|
$valute["AMD"] = "AMD (Armenian dram)"; |
|
$valute["AZN"] = "AZN (Azerbaijani manat)"; |
|
$valute["BAM"] = "BAM (Bosnian convertible mark)"; |
|
$valute["BGN"] = "BGN (Bulgarian lev)"; |
|
$valute["BYR"] = "BYR (Belarusian ruble)"; |
|
$valute["CHF"] = "CHF (Swiss franc)"; |
|
$valute["CZK"] = "CZK (Czech koruna)"; |
|
$valute["DKK"] = "DKK (Danish krone)"; |
|
$valute["GBP"] = "GBP (pound sterling)"; |
|
$valute["GEL"] = "GEL (Georgian lari)"; |
|
$valute["HRK"] = "HRK (Croatian kuna)"; |
|
$valute["HUF"] = "HUF (Hungarian forint)"; |
|
$valute["ISK"] = "ISK (Icelandic króna)"; |
|
$valute["MDL"] = "MDL (Moldovan krone)"; |
|
$valute["PLN"] = "PLN (Polish zloty)"; |
|
$valute["RON"] = "RON (New Romanian leu)"; |
|
$valute["RSD"] = "RSD (Serbian dinar)"; |
|
$valute["RUB"] = "RUB (Russian ruble)"; |
|
$valute["SEK"] = "SEK (Swedish krona)"; |
|
$valute["TRY"] = "TRY (Turkish lira)"; |
|
$valute["UAH"] = "UAH (Ukrainian hryvnia)"; |
|
$valute["USD"] = "USD (US dollar)"; |
|
return $valute; |
|
} |
|
|
|
} |
|
|
|
?>
|