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.
193 righe
9.6 KiB
193 righe
9.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, $PROVINCE_SICILIA; |
|
$return = Utils::initDefaultResponse(); |
|
$resAuth = Utils::initDefaultResponse(1); |
|
$success = false; |
|
|
|
$validateInput = ""; |
|
if (Utils::isStatoSportelloPreparazione() && $LoggedAccount->CountDomande <= 0) { |
|
$arrayString = array('INDIRIZZO_RESIDENZA', 'NOME', 'COGNOME', 'CIVICO_RESIDENZA'); |
|
//$arrayString = array(); |
|
$filteredInput = Utils::requestDati($_POST, $arrayString); |
|
|
|
$filteredInput["AUTORIZZAZIONE_TRATTAMENTO"] = Utils::getCheckInputIntValue($filteredInput, "AUTORIZZAZIONE_TRATTAMENTO"); |
|
$filteredInput["STUDENTE"] = Utils::getCheckInputIntValue($filteredInput, "STUDENTE"); |
|
$filteredInput["FLAG"] = Utils::getCheckInputIntValue($filteredInput, "FLAG"); |
|
$filteredInput["ISEE"] = Utils::getCheckInputIntValue($filteredInput, "ISEE"); |
|
$filteredInput['CODICE_FISCALE'] = trim($LoggedAccount->CODICE_FISCALE); |
|
// |
|
// EXIT(); |
|
$con->db_transactionStart(); |
|
|
|
$campiNonObbligatori = array('ID', 'DATA_MODIFICA', 'PEC', 'SPID_CELLULARE', 'SPID_EMAIL', |
|
'SPID_TIPO_DOCUMENTO', 'SPID_DOCUMENTO', 'SPID_DOCUMENTO_ENTE', |
|
'SPID_DOCUMENTO_RILASCIO', 'SPID_DOCUMENTO_SCADENZA', 'STUDENTE', 'FLAG'); |
|
|
|
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'; |
|
} |
|
|
|
|
|
|
|
|
|
$checkNativoResidente = Utils::isNativoOrResidente($filteredInput['COMUNE_NASCITA'], $filteredInput['COMUNE_RESIDENZA'], $LoggedAccount->CODICE_FISCALE); |
|
if (!$checkNativoResidente) { |
|
$validateInput = false; |
|
$return['erroreDescrizione'] .= REQUISITI_NATIVO; |
|
} |
|
//Utils::print_array($_POST);exit(); |
|
|
|
/* |
|
* Controllo inserito per il cap nascita e residenza |
|
*/ |
|
if ($validateInput) { |
|
$disableEncData = Utils::EncryptString($filteredInput["CODICE_FISCALE"] . "-" . $filteredInput["FLAG"] . "-" . $filteredInput["STUDENTE"]); |
|
$anagrafica = new AccountAnagrafica($filteredInput); |
|
$anagrafica->FLAG = $disableEncData; |
|
if ($anagrafica->ID <= 0) { |
|
$account = Account::load($filteredInput["CODICE_FISCALE"]); |
|
$resAuth = $account->SaveAuth($filteredInput["AUTORIZZAZIONE_TRATTAMENTO"]); |
|
} |
|
if ($resAuth["esito"] == 1) { |
|
$return = $anagrafica->Save(); |
|
if ($return['esito'] == 1) { |
|
$nucleoFamiliare = AccountNucleoFamiliare::loadFromCf($filteredInput["CODICE_FISCALE"]); |
|
$nucleoFamiliare->ID_ACCOUNT = $LoggedAccount->ID; |
|
$nucleoFamiliare->CODICE_FISCALE = $filteredInput["CODICE_FISCALE"]; |
|
$nucleoFamiliare->COGNOME = $filteredInput["COGNOME"]; |
|
$nucleoFamiliare->NOME = $filteredInput["NOME"]; |
|
$nucleoFamiliare->DATA_NASCITA = Date::dateOracleDateNascita($filteredInput["DATA_NASCITA"], "d-M-Y"); |
|
$nucleoFamiliare->COMUNE_RESIDENZA = $filteredInput["COMUNE_RESIDENZA"]; |
|
$nucleoFamiliare->PROV_RESIDENZA = $filteredInput["PROV_RESIDENZA"]; |
|
$nucleoFamiliare->CAP_RESIDENZA = $filteredInput["CAP_RESIDENZA"]; |
|
$nucleoFamiliare->RAPPORTO_PARENTELA = 0; |
|
$nucleoFamiliare->CONFERMATO = 1; |
|
$nucleoFamiliare->DISABILE = $filteredInput["FLAG"]; |
|
$nucleoFamiliare->STUDENTE = $filteredInput["STUDENTE"]; |
|
$nucleoFamiliare->FLAG = $disableEncData; |
|
|
|
if ($filteredInput["STUDENTE"] == 1 || $filteredInput["FLAG"] == 1) { |
|
$nucleoFamiliare->PRIORITY = 1; |
|
} else { |
|
$nucleoFamiliare->PRIORITY = 0; |
|
} |
|
$return = $nucleoFamiliare->Save(); |
|
if ($return['esito'] == 1) { |
|
$istanza = Domanda::loadDomandaFromAccount(); |
|
$istanza->ISEE = $filteredInput["ISEE"]; |
|
if ($istanza->ISEE == 0) { |
|
$return = Allegati::resetDeleteAllegato($istanza->ID, ID_FILE_ISEE); |
|
} |
|
if ($return['esito'] == 1) { |
|
$return = $istanza->Save(); |
|
if ($return['esito'] == 1) { |
|
$success = true; |
|
} |
|
} |
|
} |
|
} |
|
} else { |
|
$return['erroreDescrizione'] = ($return['erroreDescrizione'] != "" ? $return['erroreDescrizione'] : "Verificare i dati inseriti (366)"); |
|
} |
|
} 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)); |
|
}
|
|
|