22 ha cambiato i file con 5958 aggiunte e 85 eliminazioni
File diff soppresso perché troppo grande
Load Diff
@ -0,0 +1,116 @@
|
||||
<?php |
||||
|
||||
require_once ROOT . "/lib/classes/IDataClass.php"; |
||||
|
||||
class Impersonificazione extends DataClass { |
||||
|
||||
const TABLE_NAME = "IMPERSONIFICAZIONE"; |
||||
const SEQ_NAME = "IMPERSONIFICAZIONE_ID_SEQ"; |
||||
public $ID = 0; |
||||
public $UID_FIREBASE_ADMIN = null; |
||||
public $CODICE_FISCALE = null; |
||||
public $USED = 0; |
||||
|
||||
public function __construct($src = null) { |
||||
global $con; |
||||
if ($src == null) { |
||||
return; |
||||
} |
||||
$stripSlashes = 0; |
||||
if (is_array($src)) { |
||||
if (isset($src['ID']) && $src['ID'] > 0) { |
||||
$this->_loadAndFillObject($src['ID'], self::TABLE_NAME, $src); |
||||
} else { |
||||
$this->_loadByRow($src, $stripSlashes); |
||||
} |
||||
} elseif (intval($src)) { |
||||
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE ID = :id"; |
||||
$query = $con->prepare($sql); |
||||
$query->bindParam(":id", $src); |
||||
try { |
||||
$query->execute(); |
||||
$it = $query->fetchAll(PDO::FETCH_ASSOC); |
||||
Utils::FillObjectFromRow($this, $it[0]); |
||||
} catch (Exception $exc) { |
||||
$exc->getMessage(); |
||||
} |
||||
} |
||||
} |
||||
public static function Count($filter = null) { |
||||
return parent::_count(self::TABLE_NAME, $filter); |
||||
} |
||||
|
||||
public static function LoadDataTable($searchQuery = "", $searchArray = array(), $columnName = array(), $columnSortOrder = array(), $start = 0, $offset = 0, $totCount = false) { |
||||
return parent::_loadDataTable(self::TABLE_NAME, $searchQuery, $searchArray, $columnName, $columnSortOrder, $start, $offset, $totCount); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Funzione di verifica dei dati POST prima del salvataggio |
||||
*/ |
||||
public static function checkVerificaDatiPreSalvataggio() { |
||||
global $LoggedAccount; |
||||
$_POST['CODICE_FISCALE'] = Utils::get_filter_string_POST('CODICE_FISCALE'); |
||||
} |
||||
|
||||
public function checkDatiPreSave() { |
||||
global $LoggedAccount; |
||||
$response = array(); |
||||
|
||||
$controllValidita = true; |
||||
$dati_mancanti = ''; |
||||
if ($this->UID_FIREBASE_ADMIN == "") { |
||||
$controllValidita = false; |
||||
$dati_mancanti .= " <br><b>GUID</b> "; |
||||
} |
||||
if ($this->CODICE_FISCALE == "") { |
||||
$controllValidita = false; |
||||
$dati_mancanti .= " <br><b>Codice Fiscale dell'utente da impersonificare</b> "; |
||||
} |
||||
|
||||
|
||||
$response['checkDati'] = $controllValidita; |
||||
$response['txt_dati_mancanti'] = $dati_mancanti; |
||||
|
||||
return $response; |
||||
} |
||||
|
||||
|
||||
|
||||
public function Save() { |
||||
global $con, $LoggedAccount; |
||||
$vars = get_object_vars($this); |
||||
// unset($vars["DATA_RICHIESTA"]); |
||||
$sql = Utils::prepareQuery(self::TABLE_NAME, $vars); |
||||
/* Utils::print_array($sql); |
||||
Utils::print_array($vars); */ |
||||
$queryabi = $con->prepare($sql); |
||||
foreach ($vars as $k => $v) { |
||||
if ($k == "ID" && $v == 0) { |
||||
continue; |
||||
} |
||||
$queryabi->bindValue(":" . $k, $v); |
||||
} |
||||
try { |
||||
$it = parent::_Save($queryabi); |
||||
if (trim($it['erroreCode']) == 'HY000') { |
||||
$it['erroreDescrizione'] = '<b>Richiesta già inserita!</b><br/> Non è possibile inviare una richiesta di integrazione per la stessa domanda di sconto.'; |
||||
} |
||||
} catch (Exception $exc) { |
||||
$it['erroreDescrizione'] = $exc->getMessage(); |
||||
} |
||||
return $it; |
||||
} |
||||
|
||||
public function Delete() { |
||||
return parent::_Delete(self::TABLE_NAME, "ID = " . $this->ID); |
||||
} |
||||
|
||||
|
||||
public function Parse(&$record, $campo = "") { |
||||
array_push($record, array("Campo" => $campo, "Valore" => $this->$campo)); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,395 @@
|
||||
<?php |
||||
|
||||
require_once ROOT . "lib/classes/IDataClass.php"; |
||||
|
||||
class RichiestaIntegrazione extends DataClass { |
||||
|
||||
const TABLE_NAME = "RICHIESTA_INTEGRAZIONE"; |
||||
const SEQ_NAME = 'RICHIESTA_INTEGRAZIONE_ID_SEQ'; |
||||
|
||||
public $ID = 0; |
||||
public $ID_DOMANDA_SCONTI = 0; |
||||
public $DATA_RICHIESTA = null; |
||||
public $DESCRIZIONE_RICHIESTA = ""; |
||||
public $NUMERO_PROTOCOLLO = ""; |
||||
public $PROTOCOLLO_JSON = null; |
||||
public $DATA_PROTOCOLLO = null; |
||||
public $FILEPATH_PDF_PROTOCOLLATO = ""; |
||||
public $DATA_INVIO_NOTIFICA = null; |
||||
public $SCADENZA = null; |
||||
public $FILEPATH_RISPOSTA = ""; |
||||
public $DATA_CARICAMENTO = null; |
||||
public $STATO = ""; |
||||
public $NOTE_OPERATORE = ""; |
||||
public $DATA_VALIDAZIONE = null; |
||||
public $OPERATORE_VALIDAZIONE = ""; |
||||
public $OPERATORE_RICHIESTA = 0; |
||||
public $NOTE_UTENTE = ""; // Campo aggiunto per le note dell'utente |
||||
|
||||
public function __construct($src = null) { |
||||
global $con; |
||||
if ($src == null) { |
||||
return; |
||||
} |
||||
$stripSlashes = 0; |
||||
if (is_array($src)) { |
||||
if (isset($src['ID']) && $src['ID'] > 0) { |
||||
$this->_loadAndFillObject($src['ID'], self::TABLE_NAME, $src); |
||||
} else { |
||||
$this->_loadByRow($src, $stripSlashes); |
||||
} |
||||
} elseif (intval($src)) { |
||||
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE ID = :id"; |
||||
$query = $con->prepare($sql); |
||||
$query->bindParam(":id", $src); |
||||
try { |
||||
$query->execute(); |
||||
$it = $query->fetchAll(PDO::FETCH_ASSOC); |
||||
Utils::FillObjectFromRow($this, $it[0]); |
||||
} catch (Exception $exc) { |
||||
$exc->getMessage(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static function Count($filter = null) { |
||||
return parent::_count(self::TABLE_NAME, $filter); |
||||
} |
||||
|
||||
public static function LoadDataTable($searchQuery = "", $searchArray = array(), $columnName = array(), $columnSortOrder = array(), $start = 0, $offset = 0) { |
||||
|
||||
return parent::_loadDataTable(self::TABLE_NAME, $searchQuery, $searchArray, $columnName, $columnSortOrder, $start, $offset); |
||||
} |
||||
|
||||
public static function load($id = 0, $stato = "") { |
||||
global $con, $LoggedAccount; |
||||
$rows = array(); |
||||
if (intval($id) > 0) { |
||||
|
||||
if (!empty($stato)) { |
||||
$filter = "AND STATO = :stato "; |
||||
} else { |
||||
$filter = ""; |
||||
} |
||||
|
||||
|
||||
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE ID=:id " . $filter . " ORDER BY ID ASC "; |
||||
$query = $con->prepare($sql); |
||||
$query->bindParam(":id", $id); |
||||
if (!empty($stato)) { |
||||
$query->bindParam(":stato", $stato); |
||||
} |
||||
|
||||
try { |
||||
$query->execute(); |
||||
$rows = $query->fetchAll(PDO::FETCH_ASSOC); |
||||
} catch (Exception $exc) { |
||||
$exc->getMessage(); |
||||
} |
||||
} |
||||
return $rows; |
||||
} |
||||
|
||||
public static function loadFromDomanda($id_domanda = 0, $stato = "") { |
||||
global $con, $LoggedAccount; |
||||
$rows = array(); |
||||
if (intval($id_domanda) > 0) { |
||||
|
||||
if (!empty($stato)) { |
||||
$filter = "AND STATO = :stato "; |
||||
} else { |
||||
$filter = ""; |
||||
} |
||||
|
||||
$integrazione = new RichiestaIntegrazione(); |
||||
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE ID_DOMANDA_SCONTI=:id " . $filter . " ORDER BY ID ASC "; |
||||
$query = $con->prepare($sql); |
||||
$query->bindParam(":id", $id_domanda); |
||||
if (!empty($stato)) { |
||||
$query->bindParam(":stato", $stato); |
||||
} |
||||
|
||||
try { |
||||
$query->execute(); |
||||
$rows = $query->fetch(PDO::FETCH_ASSOC); |
||||
Utils::FillObjectFromRow($integrazione, $rows); |
||||
} catch (Exception $exc) { |
||||
$exc->getMessage(); |
||||
} |
||||
} |
||||
return $integrazione; |
||||
} |
||||
|
||||
public function Save() { |
||||
global $con, $LoggedAccount; |
||||
$vars = get_object_vars($this); |
||||
unset($vars["DATA_RICHIESTA"]); |
||||
$sql = Utils::prepareQuery(self::TABLE_NAME, $vars); |
||||
/* Utils::print_array($sql); |
||||
Utils::print_array($vars); */ |
||||
$queryabi = $con->prepare($sql); |
||||
foreach ($vars as $k => $v) { |
||||
if ($k == "ID" && $v == 0) { |
||||
continue; |
||||
} |
||||
$queryabi->bindValue(":" . $k, $v); |
||||
} |
||||
try { |
||||
$it = parent::_Save($queryabi); |
||||
if (trim($it['erroreCode']) == 'HY000') { |
||||
$it['erroreDescrizione'] = '<b>Richiesta già inserita!</b><br/> Non è possibile inviare una richiesta di integrazione per la stessa domanda di sconto.'; |
||||
} |
||||
} catch (Exception $exc) { |
||||
$it['erroreDescrizione'] = $exc->getMessage(); |
||||
} |
||||
return $it; |
||||
} |
||||
|
||||
public function Parse(&$record, $campo = "") { |
||||
array_push($record, array("Campo" => $campo, "Valore" => $this->$campo)); |
||||
} |
||||
|
||||
public function calcolaScadenzaDaInvio(): void { |
||||
if (!empty($this->DATA_INVIO_NOTIFICA)) { |
||||
try { |
||||
$dataInvio = new DateTime($this->DATA_INVIO_NOTIFICA); |
||||
$dataInvio->modify('+30 days'); |
||||
$this->SCADENZA = $dataInvio->format('d-M-y'); |
||||
$this->DATA_INVIO_NOTIFICA = Date::dateOracleDate($this->DATA_INVIO_NOTIFICA, 'd-M-y'); |
||||
} catch (Exception $e) { |
||||
// Gestione errore se la data è malformata |
||||
error_log("Errore nel calcolo della scadenza: " . $e->getMessage()); |
||||
$this->SCADENZA = null; |
||||
} |
||||
} else { |
||||
// Nessuna data di invio => nessuna scadenza calcolabile |
||||
$this->SCADENZA = null; |
||||
} |
||||
} |
||||
} |
||||
|
||||
class CallSoapProtocollo { |
||||
|
||||
private string $wsdl; |
||||
private string $location; |
||||
private SoapClient $client; |
||||
|
||||
public function __construct(string $wsdl, string $location) { |
||||
$this->wsdl = $wsdl; |
||||
$this->location = $location; |
||||
|
||||
$this->client = new SoapClient($this->wsdl, [ |
||||
'location' => $this->location, |
||||
'style' => SOAP_RPC, |
||||
'use' => SOAP_ENCODED, |
||||
'soap_version' => SOAP_1_1, |
||||
'cache_wsdl' => WSDL_CACHE_NONE, |
||||
'connection_timeout' => 15, |
||||
'encoding' => 'UTF-8', |
||||
'exceptions' => true, |
||||
'stream_context' => stream_context_create([ |
||||
'ssl' => [ |
||||
'verify_peer' => false, |
||||
'verify_peer_name' => false, |
||||
'allow_self_signed' => true |
||||
] |
||||
]), |
||||
'trace' => 1 |
||||
]); |
||||
} |
||||
|
||||
public function inviaRichiesta(string $funzione, array $parametri): ?array { |
||||
try { |
||||
// Chiamata SOAP |
||||
$response = $this->client->__soapCall($funzione, $parametri); |
||||
// echo "=== XML inviato ===\n"; |
||||
// echo $this->client->__getLastRequest(); |
||||
// Ultima risposta XML raw |
||||
$lastResponse = $this->client->__getLastResponse(); |
||||
|
||||
if (empty($lastResponse)) { |
||||
error_log("Risposta SOAP vuota."); |
||||
return null; |
||||
} |
||||
// Carica XML SOAP |
||||
$soap = simplexml_load_string($lastResponse); |
||||
|
||||
// Naviga nel corpo: soap:Body -> InserisciProtocolloEAnagraficheStringResponse -> InserisciProtocolloEAnagraficheStringResult |
||||
$body = $soap->children('http://schemas.xmlsoap.org/soap/envelope/')->Body; |
||||
$risposta = $body->children('http://tempuri.org/')->InserisciProtocolloEAnagraficheStringResponse; |
||||
$resultXmlEscaped = (string) $risposta->InserisciProtocolloEAnagraficheStringResult; |
||||
|
||||
// Decodifica da HTML entities a XML puro |
||||
$resultXml = html_entity_decode($resultXmlEscaped); |
||||
|
||||
// Parsing XML interno |
||||
$internalXml = simplexml_load_string($resultXml); |
||||
if (!$internalXml) { |
||||
error_log("Parsing XML interno fallito."); |
||||
return null; |
||||
} |
||||
// Conversione in array |
||||
return json_decode(json_encode($internalXml), true); |
||||
} catch (SoapFault $e) { |
||||
// Log o gestione errore SOAP |
||||
// error_log("Errore SOAP: " . $e->getMessage()); |
||||
// echo "<pre>" . print_r($e, true) . "</pre>"; |
||||
return null; |
||||
} catch (Exception $e) { |
||||
// Errori generici |
||||
// error_log("Errore generico: " . $e->getMessage()); |
||||
// echo "<pre>" . print_r($e, true) . "</pre>"; |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public function getUltimaRispostaRaw(): string { |
||||
return $this->client->__getLastResponse(); |
||||
} |
||||
} |
||||
|
||||
class IntegrazioniEmailQueue extends DataClass { |
||||
|
||||
const TABLE_NAME = "INTEGRAZIONI_EMAIL_QUEUE"; |
||||
const SEQ_NAME = 'SEQ_EMAIL_QUEUE'; |
||||
|
||||
public $ID = 0; |
||||
public $ID_RICHIESTA = 0; |
||||
public $DESTINATARIO = ""; |
||||
public $OGGETTO = ""; |
||||
public $CORPO = ""; |
||||
public $STATO = 0; //-- 1 = INVIATA, 99 = ERRORE |
||||
public $TENTATIVI = 0; |
||||
public $ERRORE_MESSAGGIO = ""; |
||||
public $DATA_INSERIMENTO = null; |
||||
public $DATA_INVIO = null; |
||||
|
||||
public function __construct($src = null) { |
||||
global $con; |
||||
if ($src == null) { |
||||
return; |
||||
} |
||||
$stripSlashes = 0; |
||||
if (is_array($src)) { |
||||
if (isset($src['ID']) && $src['ID'] > 0) { |
||||
$this->_loadAndFillObject($src['ID'], self::TABLE_NAME, $src); |
||||
} else { |
||||
$this->_loadByRow($src, $stripSlashes); |
||||
} |
||||
} elseif (intval($src)) { |
||||
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE ID = :id"; |
||||
$query = $con->prepare($sql); |
||||
$query->bindParam(":id", $src); |
||||
try { |
||||
$query->execute(); |
||||
$it = $query->fetchAll(PDO::FETCH_ASSOC); |
||||
Utils::FillObjectFromRow($this, $it[0]); |
||||
} catch (Exception $exc) { |
||||
$exc->getMessage(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static function load($id = 0, $stato = "") { |
||||
global $con, $LoggedAccount; |
||||
$rows = array(); |
||||
if (intval($id) > 0) { |
||||
|
||||
if (!empty($stato)) { |
||||
$filter = "AND STATO = :stato "; |
||||
} else { |
||||
$filter = ""; |
||||
} |
||||
|
||||
|
||||
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE ID=:id " . $filter . " ORDER BY ID ASC "; |
||||
$query = $con->prepare($sql); |
||||
$query->bindParam(":id", $id); |
||||
if (!empty($stato)) { |
||||
$query->bindParam(":stato", $stato); |
||||
} |
||||
|
||||
try { |
||||
$query->execute(); |
||||
$rows = $query->fetchAll(PDO::FETCH_ASSOC); |
||||
} catch (Exception $exc) { |
||||
$exc->getMessage(); |
||||
} |
||||
} |
||||
return $rows; |
||||
} |
||||
|
||||
public static function loadQueue($stato = 0) { |
||||
global $con, $LoggedAccount; |
||||
$rows = array(); |
||||
if (!empty($stato)) { |
||||
$filter = "AND STATO = :stato "; |
||||
} else { |
||||
$filter = ""; |
||||
} |
||||
|
||||
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE ID > 0 " . $filter . " ORDER BY DATA_INSERIMENTO ASC "; |
||||
$query = $con->prepare($sql); |
||||
if (!empty($stato)) { |
||||
$query->bindParam(":stato", $stato); |
||||
} |
||||
|
||||
try { |
||||
$query->execute(); |
||||
$rows = $query->fetchAll(PDO::FETCH_ASSOC); |
||||
} catch (Exception $exc) { |
||||
$exc->getMessage(); |
||||
} |
||||
|
||||
return $rows; |
||||
} |
||||
|
||||
public static function Count($filter = null) { |
||||
return parent::_count(self::TABLE_NAME, $filter); |
||||
} |
||||
|
||||
public function Save() { |
||||
global $con, $LoggedAccount; |
||||
$vars = get_object_vars($this); |
||||
unset($vars["DATA_INSERIMENTO"]); |
||||
$sql = Utils::prepareQuery(self::TABLE_NAME, $vars); |
||||
/* Utils::print_array($sql); |
||||
Utils::print_array($vars); */ |
||||
$queryabi = $con->prepare($sql); |
||||
foreach ($vars as $k => $v) { |
||||
if ($k == "ID" && $v == 0) { |
||||
continue; |
||||
} |
||||
$queryabi->bindValue(":" . $k, $v); |
||||
} |
||||
try { |
||||
$it = parent::_Save($queryabi); |
||||
if (trim($it['erroreCode']) == 'HY000') { |
||||
$it['erroreDescrizione'] = '<b>Richiesta già inserita!</b><br/> Non è possibile inviare una richiesta di integrazione per la stessa domanda di sconto.'; |
||||
} |
||||
} catch (Exception $exc) { |
||||
$it['erroreDescrizione'] = $exc->getMessage(); |
||||
} |
||||
return $it; |
||||
} |
||||
|
||||
public function Parse(&$record, $campo = "") { |
||||
array_push($record, array("Campo" => $campo, "Valore" => $this->$campo)); |
||||
} |
||||
|
||||
public function processaCodaEmail() { |
||||
global $con, $LoggedAccount; |
||||
$rows = $this->loadQueue(0); // Stato 0 = In attesa di invio |
||||
|
||||
foreach ($rows as $row) { |
||||
$emailQueue = new IntegrazioniEmailQueue($row['ID']); |
||||
$emailQueue->STATO = 1; // Imposta lo stato a "Inviata" |
||||
$emailQueue->DATA_INVIO = date(FORMAT_TIMESTAMP_ORACLE); |
||||
|
||||
// Invia l'email (logica di invio email non implementata qui) |
||||
// ... |
||||
// Salva lo stato aggiornato |
||||
$emailQueue->Save(); |
||||
} |
||||
} |
||||
} |
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,29 @@
|
||||
<?php |
||||
|
||||
$mode = $_REQUEST['action']; |
||||
switch ($mode) { |
||||
case 'saveRichiesta': |
||||
saveRichiesta(); |
||||
break; |
||||
} |
||||
|
||||
function saveRichiesta() { |
||||
global $con, $LoggedAccount; |
||||
$response = Utils::initDefaultResponse(-999, ''); |
||||
Impersonificazione::checkVerificaDatiPreSalvataggio(); |
||||
$impersonificazione = new Impersonificazione(); |
||||
$impersonificazione->UID_FIREBASE_ADMIN = $LoggedAccount->GUID; |
||||
$impersonificazione->CODICE_FISCALE = $_POST['CODICE_FISCALE']; |
||||
$verifica = $impersonificazione->checkDatiPreSave(); |
||||
if ($verifica['checkDati']) { |
||||
$response = $impersonificazione->Save(); |
||||
if ($response['esito'] == 1) { |
||||
$response['dati']['cf'] = $_POST['CODICE_FISCALE']; |
||||
$response['dati']['guid'] = $LoggedAccount->GUID; |
||||
$response['dati']['id'] = $response['lastId']; |
||||
} |
||||
} else { |
||||
$response['erroreDescrizione'] = ("<b>" . $controlliDomanda['txt_dati_mancanti'] . "</b>"); |
||||
} |
||||
exit(json_encode($response)); |
||||
} |
||||
File diff suppressed because one or more lines are too long
Caricamento…
Reference in new issue