gestione gare pubbliche
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.
 
 
 
 
 

532 righe
11 KiB

<?php
use Mtownsend\XmlToArray\XmlToArray;
include_once 'BS4FormGenerator.trait.php';
include_once 'TedEsenderFieldsManager.trait.php';
include_once 'TedEsenderHelpersFuncions.trait.php';
include_once 'TedEsenderApiManager.trait.php';
include_once 'TedEsenderSuggestions.class.php';
include_once 'eSenderManager.class.php';
include_once 'eFormsManager.class.php';
class TedEsender {
use TedEsenderHelpersFuncions, TedEsenderApiManager;
/**
* Ted Version
*
* @var mixed
*/
public $version;
/**
* TedEsender engine
*
* @var mixed
*/
private $engine;
/**
* Notice form identifier
*
* @var String
*/
private $form;
/**
* Notice id
*
* @var Int
*/
private $codice;
/**
* Settings
*
* @var Array
*/
private $settings;
/**
* Errors
*
* @var Array
*/
public $errors;
public const MANDATORY_ASTERISK = "<span class='text-danger text-asterisk text-bold'>*</span>";
/**
* Load XSD Form
*
* @param String $form
* @param String $directory
* @return void
*/
function __construct(String $form, Int $codice = 0) {
$path = dirname(__DIR__);
// Preveniamo eccezioni con numeri negativi
if($codice < 0 ) {
$basepath = explode('?', $_SERVER['REQUEST_URI'], 2)[0];
die("<meta http-equiv='refresh' content='0;URL={$basepath}?codice=0&form=$form'>");
}
$this->form = $form;
$this->codice = $codice;
$this->version = self::getVersion($codice);
if($this->version == "eSender") {
$this->settings = ! empty($this->settings) ? $this->settings : jsonToArray("{$path}/config/settings.json");
$this->engine = new eSenderManager($form, $codice, $this->settings);
}
if($this->version == "eForms") {
$this->settings = ! empty($this->settings) ? $this->settings : jsonToArray("{$path}/config/eforms/settings.json");
$this->engine = new eFormsManager($form, $codice);
}
if(empty($this->engine)) {
throw new Exception("Unable to start TedEsenderEngine.", 1);
}
$this->loadErrors();
}
/**
* Ritorna le pubblicazioni collegate ad una gara o altro modulo
*
* @param string $modulo
* @param integer $elemento
* @return array
*/
public static function moduliCollegati() {
if(self::getVersion() == "eSender") {
return eSenderManager::moduliCollegati();
}
return eFormsManager::moduliCollegati();
}
/**
* Ritorna le pubblicazioni collegate ad una gara o altro modulo
*
* @param string $modulo
* @param integer $elemento
* @return array
*/
public static function getPubblicazioniFromModulo(string $modulo, int $elemento) {
if(self::getVersion() == "eSender") {
return eSenderManager::getPubblicazioniFromModulo($modulo, $elemento);
}
return eFormsManager::getPubblicazioniFromModulo($modulo, $elemento);
}
/**
* Check inaccessible methods
*
* @param String $method
* @param Array $parameters
* @return void
*/
public function __call($method, $parameters)
{
if(method_exists($this->engine, $method)) {
return $this->engine->{$method}(...$parameters);
}
if(method_exists($this, $method)) {
return $this->{$method}(...$parameters);
}
$class = get_class($this->engine);
trigger_error("Call to undefined method {$class}::{$method}()", E_USER_ERROR);
}
/**
* Obtain engine varibles
*
* @return mixed
*/
function &__get(String $name) {
if(property_exists($this, $name)) {
$reflect = new ReflectionProperty($this, $name);
if(! empty($reflect) && $reflect->isPublic()) {
return $this->{$name};
}
$class = get_class($this);
trigger_error("Uncaught Error: Cannot access private property {$class}::{$name}", E_USER_ERROR);
}
if(property_exists($this->engine, $name)) {
$reflect = new ReflectionProperty($this->engine, $name);
if(! empty($reflect) && $reflect->isPublic()) {
return $this->engine->{$name};
}
$class = get_class($this->engine);
trigger_error("Uncaught Error: Cannot access private property {$class}::{$name}", E_USER_ERROR);
}
$class = get_class($this);
trigger_error("Uncaught Error: Cannot access property {$class}::{$name}", E_USER_ERROR);
}
/**
* Set variable value
*
* @param mixed $name
* @param mixed $value
* @return void
*/
function __set($name, $value)
{
$this->engine->{$name} = $value;
$this->{$name} = $value;
}
/**
* List available notices
*
* @return Array
*/
static public function listAvailableNoticeForms(String $version = null) : ?Array {
if(empty($version)) {
$version = self::getVersion();
}
if($version == "eForms") {
return eFormsManager::listAvailableNoticeForms();
}
if($version == "eSender") {
return eSenderManager::listAvailableNoticeForms();
}
}
/**
* Get Settings information
*
* @return Array
*/
static public function getSettings(String $version = null) : ?Array {
$path = dirname(__DIR__);
if(empty($version)) {
$version = self::getVersion();
}
if($version == "eSender") {
return jsonToArray("{$path}/config/settings.json");
}
if($version == "eForms") {
return jsonToArray("{$path}/config/eforms/settings.json");
}
return null;
}
/**
* Get eNotice version: eSender|eForms
*
* @return void
*/
static public function getVersion(Int $codice = 0) : String {
if(! empty($codice)) {
global $pdo;
return $pdo->go("SELECT `version` FROM b_guue WHERE codice = :codice", [":codice" => $codice])->fetch(PDO::FETCH_COLUMN, 0);
}
if(DEVELOP_ENV || strtotime('now') >= strtotime('2023-10-15 00:00:00')) {
return "eForms";
}
return "eSender";
}
/**
* Manage errors
*
* @param Array $errors
* @return void
*/
public function manageErrors(Array $errors) : void {
global $pdo;
$this->errors = $errors;
if (!empty($this->codice)) {
$pdo->go("UPDATE `b_guue` SET errori = :errori WHERE codice = :codice", [":errori" => json_encode($this->errors), ":codice" => $this->codice]);
}
}
/**
* Load errors
*
* @return void
*/
public function loadErrors() : void {
global $pdo;
if (!empty($this->codice)) {
$errors = $pdo->go("SELECT errori FROM `b_guue` WHERE codice = :codice", [":codice" => $this->info["codice"]])->fetch(PDO::FETCH_COLUMN,0);
$this->errors = json_decode($errors, true);
}
}
/**
* Get available states
*
* @return void
*/
public static function getStati() : Array
{
return [
[
'title' => 'BOZZA',
'color' => '#6c757d',
'status' => 0,
],
[
'title' => 'DA TRASMETTERE',
'color' => '#007bff',
'status' => 10
],
[
'title' => 'TRASMESSO',
'color' => '#17a2b8',
'status' => 20
],
[
'title' => 'IN PUBBLICAZIONE',
'color' => '#28a745',
'status' => 97
],
[
'title' => 'NON PUBBLICATO',
'color' => '#fd7e14',
'status' => 98
],
[
'title' => 'RIFIUTATO',
'color' => '#dc3545',
'status' => 99
],
[
'title' => 'PUBBLICATO',
'color' => '#28a745',
'status' => 100
]
];
}
public const CURRENCIES = [
"EUR" => "Euro",
"AED" => "Dirham degli EAU",
"AFN" => "Afghani",
"ALL" => "Lek",
"AMD" => "Dram",
"ANG" => "Fiorino delle Antille olandesi",
"AOA" => "Kwanza",
"ARS" => "Peso argentino",
"AUD" => "Dollaro australiano",
"AWG" => "Fiorino di Aruba",
"AZN" => "Manat azero",
"BAM" => "Marco convertibile",
"BBD" => "Dollaro di Barbados",
"BDT" => "Taka",
"BGN" => "Lev",
"BHD" => "Dinaro del Bahrein",
"BIF" => "Franco del Burundi",
"BMD" => "Dollaro delle Bermuda",
"BND" => "Dollaro del Brunei",
"BOB" => "Boliviano",
"BRL" => "Real",
"BSD" => "Dollaro delle Bahamas",
"BTN" => "Ngultrum",
"BWP" => "Pula",
"BYN" => "Rublo bielorusso",
"BZD" => "Dollaro del Belize",
"CAD" => "Dollaro canadese",
"CDF" => "Franco congolese",
"CHF" => "Franco svizzero",
"CLP" => "Peso cileno",
"CNY" => "Renminbi-yuan",
"COP" => "Peso colombiano",
"CRC" => "Col\u00f3n costaricano",
"CUC" => "Peso convertibile",
"CUP" => "Peso cubano",
"CVE" => "Escudo capoverdiano",
"CZK" => "Corona ceca",
"DJF" => "Franco di Gibuti",
"DKK" => "Corona danese",
"DOP" => "Peso dominicano",
"DZD" => "Dinar algerino",
"EGP" => "Lira egiziana",
"ERN" => "Nakfa",
"ETB" => "Birr",
"FJD" => "Dollaro delle Figi",
"FKP" => "Sterlina delle Falkland",
"GBP" => "Lira sterlina",
"GEL" => "Lari",
"GHS" => "Cedi ghanese",
"GIP" => "Sterlina di Gibilterra",
"GMD" => "Dalasi",
"GNF" => "Franco della Guinea",
"GTQ" => "Quetzal",
"GYD" => "Dollaro della Guyana",
"HKD" => "Dollaro di Hong Kong",
"HNL" => "Lempira",
"HTG" => "Gourde",
"HUF" => "Fiorino ungherese",
"IDR" => "Rupia",
"ILS" => "Shekel",
"INR" => "Rupia indiana",
"IQD" => "Dinaro iracheno",
"IRR" => "Rial iraniano",
"ISK" => "Corona islandese",
"JMD" => "Dollaro giamaicano",
"JOD" => "Dinaro giordano",
"JPY" => "Yen",
"KES" => "Scellino del Kenya",
"KGS" => "Som",
"KHR" => "Riel",
"KMF" => "Franco comoriano",
"KPW" => "Won nordcoreano",
"KRW" => "Won sudcoreano",
"KWD" => "Dinaro kuwaitiano",
"KYD" => "Dollaro delle isole Cayman",
"KZT" => "Tenge",
"LAK" => "Kip",
"LBP" => "Lira libanese",
"LKR" => "Rupia di Sri Lanka",
"LRD" => "Dollaro liberiano",
"LSL" => "Loti",
"LYD" => "Dinaro libico",
"MAD" => "Dirham marocchino",
"MDL" => "Leu moldovo",
"MGA" => "Ariary",
"MKD" => "Denar",
"MMK" => "Kyat",
"MNT" => "Tughrik",
"MOP" => "Pataca",
"MRU" => "Ouguiya",
"MUR" => "Rupia mauriziana",
"MVR" => "Rupia maldiviana",
"MWK" => "Kwacha del Malawi",
"MXN" => "Peso messicano",
"MYR" => "Ringgit",
"MZN" => "Metical",
"NAD" => "Dollaro namibiano",
"NGN" => "Naira",
"NIO" => "C\u00f3rdoba oro",
"NOK" => "Corona norvegese",
"NPR" => "Rupia nepalese",
"NZD" => "Dollaro neozelandese",
"OMR" => "Rial omanita",
"OP_DATPRO" => "Dati provvisori",
"PAB" => "Balboa",
"PEN" => "Sol",
"PGK" => "Kina",
"PHP" => "Peso filippino",
"PKR" => "Rupia pakistana",
"PLN" => "Zloty",
"PYG" => "Guarani",
"QAR" => "Rial qatariano",
"RON" => "Leu rumeno",
"RSD" => "Dinaro serbo",
"RUB" => "Rublo russo",
"RWF" => "Franco ruandese",
"SAR" => "Riyal saudita",
"SBD" => "Dollaro delle Isole Salomone",
"SCR" => "Rupia delle Seychelles",
"SDG" => "Sterlina sudanese",
"SEK" => "Corona svedese",
"SGD" => "Dollaro di Singapore",
"SHP" => "Sterlina di Sant\u2019Elena",
"SLE" => "Leone",
"SLL" => "Leone",
"SOS" => "Scellino somalo",
"SQS" => "Scellino del Somaliland",
"SRD" => "Dollaro del Suriname",
"SSP" => "Sterlina sud-sudanese",
"STN" => "Dobra",
"SVC" => "Col\u00f3n salvadoregno",
"SYP" => "Lira sterlina siriana",
"SZL" => "Lilangeni",
"THB" => "Baht",
"TJS" => "Somoni",
"TMT" => "Manat turkmeno",
"TND" => "Dinaro tunisino",
"TOP" => "Paanga",
"TRY" => "Lira turca",
"TTD" => "Dollaro di Trinidad e Tobago",
"TVD" => "Dollaro di Tuvalu",
"TWD" => "Nuovo dollaro di Taiwan",
"TZS" => "Scellino della Tanzania",
"UAH" => "Hrivna",
"UGX" => "Scellino ugandese",
"USD" => "Dollaro USA",
"USN" => "Dollaro USA",
"UYU" => "Peso uruguaiano",
"UZS" => "Sum",
"VES" => "Bolivar sovrano",
"VND" => "Dong",
"VUV" => "Vatu",
"WST" => "Tala",
"XAF" => "Franco CFA (BEAC)",
"XCD" => "Dollaro dei Caraibi orientali",
"XOF" => "Franco CFA (BCEAO)",
"XPF" => "Franco CFP",
"YER" => "Rial yemenita",
"ZAR" => "Rand",
"ZMW" => "Kwacha zambiano"
];
}