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.
152 righe
6.6 KiB
152 righe
6.6 KiB
<?php |
|
|
|
$mode = $_REQUEST['action']; |
|
switch ($mode) { |
|
case "searchComune": |
|
searchComune(); |
|
break; |
|
case 'saveAnagrafica': |
|
saveAnagrafica(); |
|
break; |
|
case 'calcolaVerificaCf': |
|
calcolaVerificaCodiceFiscale(); |
|
break; |
|
case 'checkAuth'; |
|
checkAuth(); |
|
break; |
|
} |
|
|
|
function searchComune() { |
|
$term = Utils::getFromReq("searchTerm"); |
|
$regione = Utils::getFromReq("regione"); |
|
$campi_fix = Utils::getFromReq("campi_fix"); |
|
$response = array(); |
|
$response = Comune::autocomplete($term, $regione, $campi_fix); |
|
|
|
exit(json_encode($response)); |
|
} |
|
|
|
function saveAnagrafica() { |
|
global $con, $LoggedAccount, $statoSportello; |
|
$return = Utils::initDefaultResponse(); |
|
$resAuth = Utils::initDefaultResponse(); |
|
|
|
$verificaCsrf = Utils::verifyCsrfToken($_SESSION['Token'], 'csrf_account', $_POST['csrf_account']); |
|
if (!$verificaCsrf) { |
|
$return['erroreDescrizione'] = "Operazione non consentita - 159"; |
|
exit(json_encode($return)); |
|
} |
|
|
|
$success = false; |
|
|
|
$validateInput = ""; |
|
if (Utils::isStatoSportelloPreparazione() && $LoggedAccount->CountDomande <= 0) { |
|
$arrayString = array('INDIRIZZO_RESIDENZA', 'NOME', 'COGNOME', 'CIVICO_RESIDENZA', 'SCALA_RESIDENZA', 'PIANO_RESIDENZA', 'INTERNO_RESIDENZA'); |
|
//$arrayString = array(); |
|
$filteredInput = Utils::requestDati($_POST, $arrayString); |
|
|
|
$filteredInput["AUTORIZZAZIONE_TRATTAMENTO"] = Utils::getCheckInputIntValue($filteredInput, "AUTORIZZAZIONE_TRATTAMENTO"); |
|
$filteredInput["PERMESSO_SOGGIORNO"] = Utils::getCheckInputIntValue($filteredInput, "PERMESSO_SOGGIORNO"); |
|
$filteredInput['CODICE_FISCALE'] = trim($LoggedAccount->CODICE_FISCALE); |
|
|
|
|
|
|
|
$con->db_transactionStart(); |
|
|
|
$campiNonObbligatori = array('ID', 'DATA_MODIFICA', 'PEC', 'SCALA_RESIDENZA', 'PIANO_RESIDENZA', 'INTERNO_RESIDENZA', |
|
'PERMESSO_SOGGIORNO', 'SPID_CELLULARE', 'SPID_EMAIL', 'SPID_TIPO_DOCUMENTO', 'SPID_DOCUMENTO', 'SPID_DOCUMENTO_ENTE', |
|
'SPID_DOCUMENTO_RILASCIO', 'SPID_DOCUMENTO_SCADENZA'); |
|
|
|
if ( |
|
Utils::validFieldSave('AccountAnagrafica', $filteredInput, $campiNonObbligatori) && |
|
Utils::validSavedAccount("CODICE_FISCALE", $filteredInput["CODICE_FISCALE"]) |
|
) { |
|
if (Account::checkTrattamento($filteredInput["AUTORIZZAZIONE_TRATTAMENTO"])) { |
|
if (AccountAnagrafica::verificaDatiSPID($filteredInput)) {/* controllo se i dati SPID presenti nel LoggedAccount (ricevuti da SPID) sono uguali a quelli che vengono salvati per evitare manimissioni */ |
|
$validateInput = Utils::validateInput($_POST, array('CAP_NASCITA' => LUNGHEZZA_CAP, 'CAP_RESIDENZA' => LUNGHEZZA_CAP, 'INDIRIZZO_RESIDENZA' => LUNGHEZZA_INDIRIZZO, 'CIVICO_RESIDENZA' => LUNGHEZZA_CAP,)); //inserisco il controllo sui dati con la relativa lunghezza DA poter inserire nelle CONSTANT |
|
|
|
if (!is_numeric($_POST['CAP_NASCITA']) || (is_numeric($_POST['CAP_NASCITA']) && (strlen($_POST['CAP_NASCITA']) < LUNGHEZZA_CAP))) { |
|
$validateInput = false; |
|
$return['erroreDescrizione'] = '<b>CAP</b> del comune di nascita errato'; |
|
} |
|
|
|
if (!is_numeric($_POST['CAP_RESIDENZA']) || (is_numeric($_POST['CAP_RESIDENZA']) && (strlen($_POST['CAP_RESIDENZA']) < LUNGHEZZA_CAP))) { |
|
$validateInput = false; |
|
$return['erroreDescrizione'] .= '<br><b>CAP</b> del comune di residenza errato'; |
|
} |
|
|
|
if (!EmailSms::checkEmail(trim($_POST['EMAIL']))) { |
|
$validateInput = false; |
|
$return['erroreDescrizione'] .= '<br><b>Email</b> non valida'; |
|
} |
|
|
|
//Utils::print_array($_POST);exit(); |
|
|
|
/* |
|
* Controllo inserito per il cap nascita e residenza |
|
*/ |
|
if ($validateInput) { |
|
$anagrafica = new AccountAnagrafica($filteredInput); |
|
$account = Account::load($filteredInput["CODICE_FISCALE"]); |
|
$resAuth = $account->SaveAuth($filteredInput["AUTORIZZAZIONE_TRATTAMENTO"]); |
|
if ($resAuth["esito"] == 1) { |
|
$return = $anagrafica->Save(); |
|
if ($return['esito'] == 1) { |
|
$success = true; |
|
} |
|
} |
|
} else { |
|
$return['erroreDescrizione'] = ($return['erroreDescrizione'] != "" ? $return['erroreDescrizione'] : "Verificare i dati inseriti (365)"); |
|
} |
|
} else { |
|
$return['esito'] = -999; |
|
$return['erroreDescrizione'] = "Verificare i dati inseriti (371)"; |
|
} |
|
} else { |
|
$return['esito'] = -999; |
|
$return['erroreDescrizione'] = "Per proseguire devi autorizzare il trattamento dei dati (REG. UE 679/2016)"; |
|
} |
|
} else { |
|
$return['esito'] = -999; |
|
$return['erroreDescrizione'] = "Dati inseriti non validi"; |
|
} |
|
if ($success) { |
|
$LoggedAccount->reloadSession(); |
|
$con->db_transactionCommit(); |
|
} else { |
|
$con->db_transactionRollback(); |
|
} |
|
} else { |
|
$return['erroreDescrizione'] = 'Operazione non permessa in questa fase'; |
|
} |
|
exit(json_encode($return)); |
|
} |
|
|
|
function calcolaVerificaCodiceFiscale() { |
|
|
|
$calcola = false; |
|
$nome = Utils::getFromReq("NOME"); |
|
$cognome = Utils::getFromReq("COGNOME"); |
|
$data = Utils::getFromReq("DATA_NASCITA"); //(Forma: GG/MM/YYYY) |
|
$sesso = Utils::getFromReq("SESSO"); //'M'; |
|
$comune = Utils::getFromReq("COMUNE_NASCITA"); //'Genova'; |
|
$prov = Utils::getFromReq("PROV_NASCITA"); //'GE'; |
|
$data = Date::FormatDate($data); |
|
$cf = new CodiceFiscale($nome, $cognome, $data, $sesso, $comune, $prov); |
|
$codice = $cf->calcolaFrom(); |
|
$response = array( |
|
"esito" => ($codice != '' ? 1 : -999), |
|
"cf" => $codice, |
|
"erroreDescrizione" => ($codice != '' ? '' : 'Errore nel calcolo') |
|
); |
|
exit(json_encode($response)); |
|
} |
|
|
|
function checkAuth() { |
|
$access = Utils::canAccess(); |
|
$response = array( |
|
"esito" => ($access ? 1 : -999), |
|
"erroreDescrizione" => ($access != '' ? '' : 'Accesso scaduto: si prega di aggiornare la pagina ed effettuare il login al sistema.') |
|
); |
|
exit(json_encode($response)); |
|
}
|
|
|