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.
182 righe
7.0 KiB
182 righe
7.0 KiB
<?php |
|
|
|
$mode = $_REQUEST['action']; |
|
switch ($mode) { |
|
case "listNucleo": |
|
listNucleo(); |
|
break; |
|
case "confirmNucleo": |
|
confirmNucleo(); |
|
break; |
|
case "addComponente": |
|
addComponente(); |
|
break; |
|
case "deleteComponente": |
|
deleteComponente(); |
|
break; //fine caso deleteComponente |
|
} |
|
|
|
function listNucleo() { |
|
global $LoggedAccount, $RAPPORTI_PARENTELA; |
|
$domanda = Domanda::loadDomandaFromAccount(); |
|
$draw = $_POST['draw']; |
|
$row = $_POST['start']; |
|
$rowperpage = $_POST['length']; // Rows display per page |
|
$columnIndex = $_POST['order'][0]['column']; // Column index |
|
$columnName = $_POST['columns'][$columnIndex]['data']; // Column name |
|
$columnSortOrder = $_POST['order'][0]['dir']; // asc or desc |
|
$searchValue = $_POST['search']['value']; // Search value |
|
$data = array(); |
|
$searchArray = array(); |
|
$searchQuery = ""; |
|
$searchQuery .= " AND ID_ACCOUNT = :ID_DOMANDA"; // |
|
$searchArray = array( |
|
'ID_DOMANDA' => $domanda->ID_ACCOUNT, |
|
); |
|
$resTot = AccountNucleoFamiliare::load(-1); |
|
//$resConfermati = AccountNucleoFamiliare::load(0); |
|
$resConfermati = 0; |
|
$nr = 0; |
|
foreach ($resTot as $row) { |
|
$nr++; |
|
$btn = ''; |
|
if(intval($row['CONFERMATO'])==0){ |
|
$resConfermati++; |
|
} |
|
if ($domanda->STATO == STATO_DOMANDA_IN_PREPARAZIONE && Utils::isStatoSportelloPreparazione() && $row['CODICE_FISCALE'] != $LoggedAccount->CODICE_FISCALE) { |
|
$dataNascita = new DateTime($row['DATA_NASCITA']); |
|
$dataNascitaEng = $dataNascita->format("Y-m-d"); |
|
$row['DT_ENG'] = $dataNascitaEng; |
|
$btn .= '<button class="btn btn-sm btn-warning" onclick="editComponente(\'' . base64_encode(json_encode($row)) . '\');" alt="Aggiorna Utente" title="Aggiorna Utente"><i class="fas fa-edit"></i> Modifica</button> <button class="btn btn-sm btn-danger" onclick="deleteComponente(\'' . $row['ID'] . '\');" alt="Elimina Utente" title="Elimina"><i class="fas fa-trash"></i> Elimina</button>'; |
|
} |
|
// $btn = '';//da rimuovere se voglio generare i bottoni lato server |
|
$data[] = array( |
|
"NR" => $nr, |
|
"ID" => $row['ID'], |
|
"COGNOME" => $row['COGNOME'], |
|
"NOME" => $row['NOME'], |
|
"CODICE_FISCALE" => $row['CODICE_FISCALE'], |
|
"DATA_NASCITA" => Date::dateOracleDate($row['DATA_NASCITA']), |
|
"COMUNE_NASCITA" => $row['COMUNE_NASCITA'], |
|
"RAPPORTO_PARENTELA" => $RAPPORTI_PARENTELA[$row['RAPPORTO_PARENTELA']], |
|
"OP" => $btn |
|
); |
|
} |
|
|
|
## Response |
|
$response = array( |
|
"draw" => intval($draw), |
|
"iTotalRecords" => count($resTot), |
|
"iTotalDisplayRecords" => count($resTot), |
|
"countConfermati" => ($resConfermati >= 1 ? 1 : $resConfermati), |
|
"aaData" => $data |
|
); |
|
exit(json_encode($response)); |
|
} |
|
|
|
function confirmNucleo() { |
|
global $LoggedAccount, $con; |
|
if (!Utils::isStatoSportelloPreparazione()) { |
|
$return['erroreDescrizione'] = "Accesso non consentito (0)"; |
|
exit(json_encode($return)); |
|
} |
|
$return = Utils::initDefaultResponse(); |
|
$transaction = false; |
|
$con->db_transactionStart(); |
|
$return = AccountNucleoFamiliare::setConfermatoForAccount(); |
|
if ($return['esito'] == 1) { |
|
$transaction = true; |
|
} |
|
if ($transaction) { |
|
$return['esito'] = 1; |
|
$con->db_transactionCommit(); |
|
} else { |
|
$return['erroreDescrizione'] = ($return['erroreDescrizione'] != "" ? $return['erroreDescrizione'] : "Attenzione , riprovare o contattare il Personale Tecnico"); |
|
$con->db_transactionRollback(); |
|
} |
|
exit(json_encode($return)); |
|
} |
|
|
|
function addComponente() { |
|
global $LoggedAccount, $con; |
|
$response = Utils::initDefaultResponse(-999, ''); |
|
if (!Utils::isStatoSportelloPreparazione()) { |
|
$response['erroreDescrizione'] = "Accesso non consentito (0)"; |
|
exit(json_encode($response)); |
|
} |
|
$transaction = false; |
|
$con->db_transactionStart(); |
|
if (intval($_POST['ID']) > 0) { |
|
$dettaglio = new AccountNucleoFamiliare(intval($_POST['ID'])); |
|
if ($dettaglio->ID_ACCOUNT == $LoggedAccount->ID) { |
|
AccountNucleoFamiliare::checkVerificaDatiPreSalvataggio(); |
|
Utils::FillObjectFromRow($dettaglio, $_POST); |
|
} else { |
|
$return['erroreDescrizione'] = "Salvataggio non consentito"; |
|
exit(json_encode($return)); |
|
} |
|
} else { |
|
AccountNucleoFamiliare::checkVerificaDatiPreSalvataggio(); |
|
$dettaglio = new AccountNucleoFamiliare($_POST); |
|
} |
|
$dettaglio->CONFERMATO = 1; |
|
$controlliDomanda = $dettaglio->checkDatiPreSave(); |
|
if ($controlliDomanda['checkDati']) { |
|
$confermoTutti = AccountNucleoFamiliare::setConfermatoForAccount(); |
|
if ($confermoTutti['esito'] == 1) { |
|
$response = $dettaglio->Save(); |
|
if ($response['esito'] == 1) { |
|
$transaction = true; |
|
} |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = ("<b>" . $controlliDomanda['txt_dati_mancanti'] . "</b>"); |
|
} |
|
if ($transaction) { |
|
$response['esito'] = 1; |
|
$con->db_transactionCommit(); |
|
} else { |
|
$response['erroreDescrizione'] = ($response['erroreDescrizione'] != "" ? $response['erroreDescrizione'] : "Attenzione , riprovare o contattare il Personale Tecnico"); |
|
$con->db_transactionRollback(); |
|
} |
|
exit(json_encode($response)); |
|
} |
|
|
|
function deleteComponente() { |
|
global $con, $LoggedAccount; |
|
$response = Utils::initDefaultResponse(); |
|
if (!Utils::isStatoSportelloPreparazione()) { |
|
$response['erroreDescrizione'] = "Accesso non consentito (0)"; |
|
exit(json_encode($response)); |
|
} |
|
$transaction = false; |
|
if (isset($_POST["id"])) { |
|
$dettaglio = new AccountNucleoFamiliare($_POST["id"]); |
|
$domanda = Domanda::loadDomandaFromAccount(); |
|
if ($domanda->ID > 0) { |
|
if ($domanda->STATO < STATO_DOMANDA_PRESENTATA) { |
|
$controlloDomanda = true; |
|
} |
|
} else { |
|
$controlloDomanda = true; |
|
} |
|
if ($controlloDomanda && $LoggedAccount->ID == $dettaglio->ID_ACCOUNT && $dettaglio->RAPPORTO_PARENTELA != RAPPORTO_PARENTELA_DEFAULT) { |
|
$con->db_transactionStart(); |
|
$response = $dettaglio->Delete(); |
|
if ($response['esito'] == 1) { |
|
$transaction = true; |
|
} |
|
if ($transaction) { |
|
$response['esito'] = 1; |
|
$response['domanda'] = $domanda->ID; |
|
$con->db_transactionCommit(); |
|
} else { |
|
$response['erroreDescrizione'] = ($response['erroreDescrizione'] != "" ? $response['erroreDescrizione'] : "Attenzione , riprovare o contattare il Personale Tecnico"); |
|
$con->db_transactionRollback(); |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = 'Operazione non consentita in questa fase'; |
|
} |
|
} |
|
exit(json_encode($response)); |
|
}
|
|
|