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.
738 righe
32 KiB
738 righe
32 KiB
<?php |
|
|
|
$mode = $_REQUEST['action']; |
|
switch ($mode) { |
|
case 'newDomanda': |
|
newDomanda(); |
|
break; |
|
case "searchComune": |
|
$term = Utils::getFromReq("term", ""); |
|
searchComune($term); |
|
break; |
|
case 'saveDomanda': |
|
saveDomanda(); |
|
break; |
|
case 'generaRichiestaDomanda': |
|
generaRichiestaDomanda(); |
|
break; |
|
case 'saveDocumento': |
|
saveDocumento(); |
|
break; |
|
case 'listDomande': |
|
listDomande(); |
|
break; |
|
case 'modifica_domanda': |
|
modificaDomanda(); |
|
break; |
|
case 'saveDettaglio': |
|
saveDettaglio(); |
|
break; |
|
case 'deleteDettaglio': |
|
deleteDettaglio(); |
|
break; |
|
case 'saveAllegato': |
|
saveAllegato(); |
|
break; |
|
case 'deleteAllegato': |
|
deleteAllegato(); |
|
break; |
|
case 'saveAllegato2': |
|
saveAllegato2(); |
|
break; |
|
case 'saveAllegato3': |
|
saveAllegato3(); |
|
break; |
|
case 'listAllegati': |
|
listAllegati(); |
|
break; |
|
case 'presentaDomanda': |
|
presentaDomanda(); |
|
break; |
|
case 'riapriDomanda': |
|
riapriDomanda(); |
|
break; |
|
case 'listCambioIban': |
|
listCambioIban(); |
|
break; |
|
case 'saveIban': |
|
saveCambioIban(); |
|
break; |
|
} |
|
|
|
function newDomanda() { |
|
global $con, $LoggedAccount; |
|
$response = Utils::initDefaultResponse(); |
|
if (Utils::isStatoSportelloPreparazione()) { |
|
$transaction = false; |
|
$con->db_transactionStart(); |
|
|
|
$domanda = new Domanda(); |
|
$domanda->STATO = INPREPARAZIONE; |
|
$domanda->ID_ACCOUNT = $LoggedAccount->ID; |
|
$response = $domanda->Save(); |
|
if ($response['esito'] == 1) { |
|
$response['domanda'] = $domanda->ID; |
|
$transaction = true; |
|
} else { |
|
$response['erroreDescrizione'] = Utils::getServiceErrorText($response['descrizioneErrore']); |
|
} |
|
if ($transaction) { |
|
$con->db_transactionCommit(); |
|
} else { |
|
$con->db_transactionRollback(); |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = "Operazione non consentita in questa fase"; |
|
} |
|
exit(json_encode($response)); |
|
} |
|
|
|
function searchComune($term) { |
|
|
|
$return = Comune::autocomplete($term); |
|
exit(html_entity_decode(json_encode($return))); |
|
} |
|
|
|
function saveDomanda() { |
|
global $con, $LoggedAccount; |
|
$transaction = false; |
|
$controllo = true; |
|
$con->db_transactionStart(); |
|
$response = Utils::initDefaultResponse(-999, ''); |
|
// VERIFICO SE SONO NEL PERIODO DELLA PRESENTAZIONE DELLA DOMANDA |
|
|
|
|
|
$verificaCsrf = Utils::verifyCsrfToken($_SESSION['Token'], 'csrf_domanda', $_POST['csrf_domanda']); |
|
if (!$verificaCsrf) { |
|
$return['erroreDescrizione'] = "Operazione non consentita - 159"; |
|
exit(json_encode($return)); |
|
} |
|
|
|
if (!Utils::isStatoSportelloPreparazione()) { |
|
$return['erroreDescrizione'] = "Accesso non consentito (0)"; |
|
exit(json_encode($return)); |
|
} |
|
Domanda::checkVerificaDatiPreSalvataggio(); |
|
$domanda = Domanda::loadDomandaFromAccount(); |
|
Utils::FillObjectFromRow($domanda, $_POST); |
|
$domanda->dichiarazioni = $dichiarazioni = $_POST['dichiarazione']; |
|
|
|
$controlliDomanda = $domanda->checkDatiPreSave(); |
|
|
|
if ($controlliDomanda['checkDati']) { |
|
$domanda_dichiarazioni = new DomandaDichiarazioni(); |
|
$domanda_dichiarazioni->ID_DOMANDA = $domanda->ID; |
|
$resp_delete = $domanda_dichiarazioni->Delete(); |
|
if ($resp_delete['esito'] == 1) { |
|
foreach ($domanda->dichiarazioni as $k => $s) { |
|
$domanda_dichiarazioni->ID_ANAG_DICHIARAZIONI = $s; |
|
$response = $domanda_dichiarazioni->Save(); |
|
} |
|
if ($response['esito'] == 1) { |
|
$response = $domanda->Save(); |
|
if ($response['esito'] == 1) { |
|
$transaction = true; |
|
} |
|
} |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = ("Verificare i seguenti campi: " . $controlliDomanda['txt_dati_mancanti']); |
|
} |
|
|
|
if ($transaction) { |
|
$con->db_transactionCommit(); |
|
} else { |
|
$con->db_transactionRollback(); |
|
} |
|
exit(json_encode($response)); |
|
} |
|
|
|
function listDomande() { |
|
global $bando_setup, $LoggedAccount, $STATI_DOMANDA; |
|
$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(); |
|
$datas = array(); |
|
$searchArray = array(); |
|
$data_modifica = ""; |
|
$data_sottoMissione = ""; |
|
|
|
## Order |
|
$columnName = 'ID'; |
|
$columnSortOrder = 'DESC'; |
|
## Search |
|
$searchQuery = " AND ( ID_ACCOUNT = :ID_ACCOUNT ) AND STATO < 6 "; |
|
$searchArray = array( |
|
'ID_ACCOUNT' => $LoggedAccount->ID |
|
); |
|
|
|
$res = Domanda::LoadDataTableRiepilogo($searchQuery, $searchArray, $columnName, $columnSortOrder, $row, $rowperpage); |
|
$checkAteco = array(); |
|
foreach ($res['empRecords'] as $row) { |
|
$fnModifica = ""; |
|
/* |
|
* Per ora commento il controllo del periodo di preparazione ma va inserito nel campo |
|
*/ |
|
if (Utils::isStatoSportelloPreparazione()) { |
|
if ($row["STATO"] >= STATO_DOMANDA_PREPARATA) { |
|
$fnModifica = '<button type="button" class="btn btn-secondary tooltipped" data-toggle="tooltip" data-position="top" title="Visualizza domanda" onclick=\'redirectDomanda("' . $row['ID'] . '")\'><i class="far fa-eye"></i></button>'; |
|
} else { |
|
$fnModifica = '<button type="button" class="btn btn-success tooltipped" data-toggle="tooltip" data-position="top" title="Modifica domanda" onclick=\'redirectDomanda("' . $row['ID'] . '")\'><i class="far fa-edit"></i></button>'; |
|
} |
|
} |
|
|
|
$datas[] = array( |
|
"ID" => "D" . date('Ym', strtotime($row['DATA_REGISTRAZIONE'])) . str_pad($row['ID'], 6, '0', STR_PAD_LEFT), //$row['ID'], |
|
"CODICE_ATECO" => $row['CODICE_ATECO'], |
|
"CODICE_FISCALE_IMPRESA" => $row['CODICE_FISCALE_IMPRESA'], |
|
"PIVA" => $row['PIVA'], |
|
"DATA_REGISTRAZIONE" => $row['DATA_REGISTRAZIONE'], |
|
"DATA_PRESENTAZIONE" => $row['DATA_PRESENTAZIONE'], |
|
"PROTOCOLLO" => $row['PROTOCOLLO'], |
|
"DATA_PROTOCOLLO" => Date::dateOracleTimeStamp($row['DATA_PROTOCOLLO'], 'd-m-Y H:i'), |
|
"STATO" => $STATI_DOMANDA[$row['STATO']], |
|
"GESTIONE" => '<div class="btn-group" role="group" aria-label="Gestione">' . $fnModifica . '</div>' |
|
); |
|
} |
|
|
|
## Response |
|
$response = array( |
|
"draw" => intval($draw), |
|
"iTotalRecords" => $res['iTotalRecords'], |
|
"iTotalDisplayRecords" => $res['iTotalDisplayRecords'], |
|
"aaData" => $datas |
|
); |
|
|
|
exit(json_encode($response)); |
|
} |
|
|
|
function saveDettaglio() { |
|
global $con, $LoggedAccount; |
|
|
|
$response = Utils::initDefaultResponse(-999, ''); |
|
$transaction = false; |
|
|
|
if (!Utils::isStatoSportelloPreparazione()) { |
|
$return['erroreDescrizione'] = "Accesso non consentito (0)"; |
|
exit(json_encode($return)); |
|
} |
|
|
|
|
|
if (isset($_POST["ID_DOMANDA"])) { |
|
$con->db_transactionStart(); |
|
DomandaDichiarazioni::checkVerificaDatiPreSalvataggio(); |
|
$dettaglio = new DomandaDichiarazioni($_POST); |
|
$domanda = new Domanda($_POST["ID_DOMANDA"]); |
|
if ($domanda->ID > 0) { |
|
$LoggedAccount->checkAuthShowDomandaPage($domanda->ID); |
|
} |
|
|
|
|
|
$controlliDomanda = $dettaglio->checkDatiPreSave($domanda); |
|
|
|
if ($controlliDomanda['checkDati']) { |
|
|
|
$piva_ateco = new PivaAtecoAnno(); |
|
$piva_ateco->ATECO = $domanda->CODICE_ATECO; |
|
//$piva_ateco->PIVA = $domanda->CODICE_FISCALE_IMPRESA; |
|
$piva_ateco->PIVA = ($domanda->TIPO_ISTANZA == ISTANZA_COOPERATIVA ? $dettaglio->INTESTATARIO_CF : $domanda->CODICE_FISCALE_IMPRESA ); |
|
$piva_ateco->TARGA = ($domanda->CODICE_ATECO == '49.32.10' ? $dettaglio->LICENZA_AUTORIZZAZIONE_N : $dettaglio->TARGA ); |
|
if (!$piva_ateco->existsOldCompetition($domanda->TIPO_ISTANZA)) { |
|
$response = $dettaglio->Save(); |
|
// Utils::print_array($response); |
|
if ($response['esito'] == 1) { |
|
$domanda->ResetPdfGenerato(); |
|
$response = $domanda->Save(); |
|
if ($response['esito'] == 1) { |
|
|
|
$response = Allegati::resetHashIstanza($domanda->ID, true); |
|
|
|
if ($response['esito'] == 1) { |
|
$transaction = true; |
|
} |
|
} |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = "Mezzo già ammesso a contributo - Art.5 comma 1 lettera d)"; |
|
} |
|
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'] = ("<b>" . $controlliDomanda['txt_dati_mancanti'] . "</b>"); |
|
} |
|
} |
|
exit(json_encode($response)); |
|
} |
|
|
|
function deleteDettaglio() { |
|
global $con; |
|
$response = Utils::initDefaultResponse(); |
|
$transaction = false; |
|
if (isset($_POST["id"])) { |
|
|
|
$dettaglio = new DomandaDichiarazioni($_POST["id"]); |
|
$domanda = new Domanda($dettaglio->ID_DOMANDA); |
|
if ($domanda->Stato < STATO_DOMANDA_PRESENTATA) { |
|
$con->db_transactionStart(); |
|
$response = $dettaglio->Delete(); |
|
if ($response['esito'] == 1) { |
|
$response = Allegati::resetHashIstanza($domanda->ID, true); |
|
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)); |
|
} |
|
|
|
function saveAllegato() { |
|
global $con, $LoggedAccount, $codiciErroreNoControll; |
|
$verificaCsrf = Utils::verifyCsrfToken($_SESSION['Token'], 'csrf_allegati', $_POST['csrf_allegati']); |
|
if (!$verificaCsrf) { |
|
$return['erroreDescrizione'] = "Operazione non consentita - 159"; |
|
exit(json_encode($return)); |
|
} |
|
$uploadedName = 'documento'; // default $FILES param |
|
$filenameoriginale = ($_FILES[$uploadedName]['name']); |
|
$transaction = false; |
|
$transactionLogs = false; |
|
/* controlli preliminari */ |
|
$documenti_bando = new DocumentiBando($_POST['ID_DOCUMENTO']); |
|
$pathInfo = $documenti_bando->getPathInfoDocumento(); |
|
$domanda = Domanda::loadDomandaFromAccount(); |
|
$_POST['ID_DOMANDA'] = $domanda->ID; |
|
$response = Allegati::checkControlliPreliminariUploadObbligatorio($_POST['ID_DOCUMENTO'], $uploadedName, $pathInfo["TIPO_DOCUMENTO"], $documenti_bando->ESTENZIONE_FILE); |
|
$con->db_transactionStart(); |
|
if ($response['esito'] == 1) { |
|
$domanda = $response['rows']; |
|
$_POST['NOTE'] = Utils::get_filter_string_POST('NOTE'); |
|
$_POST['NOTE'] = mb_substr(trim($_POST['NOTE']), 0, LUNGHEZZA_INDIRIZZO); |
|
$allegato = new Allegati($_POST); |
|
$folder = $domanda->generateDirForUpload(ROOT_UPLOAD_PRESENTAZIONE, $pathInfo["PATH_DOCUMENTO"]); |
|
if ($folder) { |
|
$fileName = time() . "_" . File::GetValidFilename($_FILES[$uploadedName]['name']); |
|
$nomeFileTmp = md5((time() . "_" . $domanda->ID)); |
|
if (is_uploaded_file($_FILES[$uploadedName]['tmp_name'])) { |
|
if (intval($documenti_bando->VERIFICA_FIRMA_P7M) && VERIFICA_FIRMA_P7M) { |
|
$fileFullPath = $folder . "/" . $fileName; |
|
$fileFullPathEstratto = $folder . "/" . $nomeFileTmp . ".pdf"; |
|
$fileFullPathEstrattoPem = $folder . "/" . $nomeFileTmp . ".pem"; |
|
if (copy($_FILES[$uploadedName]['tmp_name'], $fileFullPath)) { //move_uploaded_file |
|
if (File::checkMd5File($_FILES[$uploadedName]['tmp_name'], $fileFullPath)) { |
|
$codicefiscaleFirmatario = $LoggedAccount->CODICE_FISCALE; |
|
$hashfileDaControllare = $domanda->HASH_ALLEGATO2; |
|
$response = File::checkCertificatoP7m($fileFullPath, $fileFullPathEstratto, $fileFullPathEstrattoPem, $codicefiscaleFirmatario, $hashfileDaControllare); |
|
if ($response['esito'] == 1) { |
|
$allegato->FILEPATH = $fileName; |
|
$allegato->FILESIZE = filesize($fileFullPath); |
|
$allegato->TIPO_DOCUMENTO = $pathInfo["TIPO_DOCUMENTO"]; |
|
$allegato->NOMEFILEORIGINALE = $filenameoriginale; |
|
$response = $allegato->Save(); |
|
} else { |
|
$responseLogs = File::copyFileandSaveLogs($fileName, $domanda, $fileFullPath, $fileFullPathEstrattoPem, $response['erroreDescrizione']); |
|
if ($responseLogs['esito'] == 1) { |
|
$transactionLogs = true; |
|
} |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = "Al momento non è possibile allegare il file, contattare un amministratore!"; |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = "Al momento non è possibile allegare il file, contattare un amministratore!"; |
|
} |
|
} else { |
|
$fileFullPath = $folder . "/" . $fileName; |
|
$md5File = File::getSha256File($_FILES[$uploadedName]['tmp_name']); |
|
if (copy($_FILES[$uploadedName]['tmp_name'], $fileFullPath)) { |
|
$allegato->FILEPATH = $fileName; |
|
$allegato->FILESIZE = filesize($fileFullPath); |
|
$allegato->TIPO_DOCUMENTO = $pathInfo["TIPO_DOCUMENTO"]; |
|
$allegato->NOMEFILEORIGINALE = $filenameoriginale; |
|
$allegato->HASH_FILE = $md5File; |
|
$response = $allegato->Save(); |
|
} else { |
|
$response['esito'] = -999; |
|
$response['erroreDescrizione'] = "Al momento non è possibile allegare il file, contattare un amministratore! (10996)"; |
|
} |
|
} |
|
} else { |
|
$response['esito'] = -999; |
|
$response['erroreDescrizione'] = "Al momento non è possibile allegare il file, contattare un amministratore! (10995)"; |
|
} |
|
} else { |
|
$response['esito'] = -999; |
|
$response['erroreDescrizione'] = "Al momento non è possibile allegare il file, contattare un amministratore! (10994)"; |
|
} |
|
|
|
if ($response['esito'] == 1) { |
|
$transaction = true; |
|
} else { |
|
$response['erroreDescrizione'] = ($response['erroreDescrizione'] != "" ? $response['erroreDescrizione'] : "Al momento non è possibile allegare il file, contattare un amministratore (1521)"); |
|
} |
|
} |
|
unset($response['rows']); // rimuovo info domanda |
|
|
|
if (!$transactionLogs) { |
|
if ($transaction) { |
|
$finalCheck = File::checkFileConsistency($fileFullPath); |
|
if ($finalCheck) { |
|
$con->db_transactionCommit(); |
|
File::deleteFileTemp('', $fileFullPathEstratto, $fileFullPathEstrattoPem); |
|
} else { |
|
$con->db_transactionRollback(); |
|
File::deleteFileTemp($fileFullPath, $fileFullPathEstratto, $fileFullPathEstrattoPem); |
|
} |
|
} else { |
|
$con->db_transactionRollback(); |
|
File::deleteFileTemp($fileFullPath, $fileFullPathEstratto, $fileFullPathEstrattoPem); |
|
} |
|
} else { |
|
$con->db_transactionCommit(); |
|
} |
|
|
|
exit(json_encode($response)); |
|
} |
|
|
|
function deleteAllegato() { |
|
global $con, $LoggedAccount; |
|
$response = Utils::initDefaultResponse(); |
|
$transaction = false; |
|
if (Utils::isStatoSportelloPreparazione()) { |
|
$con->db_transactionStart(); |
|
$allegato = new Allegati($_POST['id']); |
|
$response = $allegato->checkFaseDocumento(); |
|
if ($response['esito'] == 1) { |
|
$response = $allegato->deleteAllegato(); |
|
if ($response['esito'] == 1 && $allegato->documento_bando->OBBLIGO == 1) { |
|
$response = Allegati::resetHashIstanza($allegato->ID_DOMANDA); |
|
if ($response['esito'] == 1) { |
|
$transaction = true; |
|
} |
|
} else if ($response['esito'] == 1) { |
|
$transaction = true; |
|
} |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = 'Operazione non consentita in questa fase.'; |
|
} |
|
|
|
if ($transaction) { |
|
$con->db_transactionCommit(); |
|
$response['domanda'] = $allegato->ID_DOMANDA; |
|
} else { |
|
$con->db_transactionRollback(); |
|
} |
|
exit(json_encode($response)); |
|
} |
|
|
|
function listAllegati() { |
|
global $LoggedAccount; |
|
$response = array(); |
|
$domanda = Domanda::loadDomandaFromAccount(); |
|
$idDomanda = $domanda->ID; |
|
if ($idDomanda > 0 && Utils::isStatoSportelloPreparazione(true)) { |
|
|
|
$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(); |
|
$data_modifica = ""; |
|
//$countAllegatiCompleti = 0; |
|
//$iTotalRecordsObbligatori = 0; |
|
## Search |
|
$totCount = false; |
|
$searchQuery = ""; |
|
$searchQuery .= " AND DOCUMENTO_CANCELLATO = 0 AND FASE <=1 AND OBBLIGO <= 2 "; // |
|
$searchArray = array( |
|
'ID_DOMANDA' => $domanda->ID |
|
); |
|
if ($searchValue != '') { |
|
$searchQuery .= " AND ( REGEXP_LIKE(DOCUMENTO_NOME,:DOCUMENTO_NOME,'i')) "; |
|
$searchArray['DOCUMENTO_NOME'] = $searchValue; |
|
} |
|
$iTotalRecordsObbligatori = $domanda->CountDocObbligatori(); |
|
$countAllegatiCompleti = $domanda->CountDocObbligatoriAllegati(); |
|
$chekGeneraIstanza = $domanda->CanGenPdf(); |
|
$res = Allegati::LoadDataTableAllegati($searchQuery, $searchArray, $columnName, $columnSortOrder, $row, $rowperpage, $totCount); |
|
$genera_istanza = false; |
|
$checkAllFile['esito'] = false; |
|
$checkAllFile['allegato'] = ''; |
|
|
|
foreach ($res['empRecords'] as $row) { |
|
|
|
|
|
$btn = ''; |
|
$btn_genera = ''; |
|
$btn_genera_istanza = ''; |
|
$debug = ""; |
|
|
|
$stato_allegato = "<b class='text-danger'>Da presentare</b>"; |
|
|
|
if ($row['OBBLIGO_CONDIZIONATO'] != "") { |
|
$split = explode("|", $row['OBBLIGO_CONDIZIONATO']); |
|
$table = trim($split[0]); |
|
$column = trim($split[1]); |
|
$value = trim($split[2]); |
|
if ($table == DomandaContratti::TABLE_NAME) { |
|
foreach ($domanda->contratti as $contratto) { |
|
if ($contratto[$column] == $value) { |
|
$row["OBBLIGO"] = 1; |
|
} |
|
} |
|
} else if ($table == DomandaDichiarazioni::TABLE_NAME) { |
|
foreach ($domanda->dichiarazioni as $dichiarazione) { |
|
if ($dichiarazione[$column] == $value) { |
|
$row["OBBLIGO"] = 1; |
|
} |
|
} |
|
} |
|
} |
|
/* |
|
if ($row["OBBLIGO"] >= 1) { |
|
$iTotalRecordsObbligatori++; |
|
} */ |
|
if (intval($row["ID"]) <= 0) { |
|
if ($domanda->STATO < PREPARATA && Utils::isStatoSportelloPreparazione()) { |
|
|
|
if (intval($row['FILE_DA_GENERARE']) && FILE_DA_GENERARE && intval($row['OBBLIGO']) > 0) { |
|
|
|
if ($row['MODULE'] == GENERA_ALLEGATO_3) { |
|
|
|
$btn_genera = '<button type="button" class="btn btn-sm btn-warning" type="button" onclick="generaAllegato(\'' . $row['MODULE'] . '\', \'' . $domanda->ID . '\', \'' . $row['DOCUMENTO_ID'] . '\', \'' . intval($row['ID']) . '\');" alt="Genera documento" title="Genera documento"><i class="fas fa-file-download"></i> Genera pdf</button>'; |
|
} else if ($row['MODULE'] == GENERA_ALLEGATO_2 && $countAllegatiCompleti == ($iTotalRecordsObbligatori - 1) && $genera_istanza) { |
|
$btn_genera = '<button type="button" class="btn btn-sm btn-warning" type="button" onclick="generaAllegato(\'' . $row['MODULE'] . '\', \'' . $domanda->ID . '\', \'' . $row['DOCUMENTO_ID'] . '\', \'' . intval($row['ID']) . '\');" alt="Genera documento" title="Genera documento"><i class="fas fa-file-download"></i> Genera pdf</button>'; |
|
} |
|
} else { |
|
if ($row['OBBLIGO'] <= 1) { |
|
$btn = '<button type="button" class="btn btn-sm btn-primary" type="button" data-toggle="modal" data-target="#allegatiModal" onclick="assegnaValue(\'' . $row['DOCUMENTO_ID'] . '\', \'' . $row['OBBLIGO'] . '\', \'' . $row['ESTENZIONE_FILE'] . '\');" alt="Allega documento" title="Allega documento"><i class="fas fa-paper-plane"></i> Allega</button>'; |
|
} |
|
} |
|
|
|
|
|
$debug = "[" . $countAllegatiCompleti . "][" . ($iTotalRecordsObbligatori - 1) . "] "; |
|
} |
|
} else { |
|
/* if (trim($row['FILEPATH']) != "") { |
|
echo $row['ID']."<br>"; |
|
echo $row['FILEPATH']."<br>"; |
|
$countAllegatiCompleti++; |
|
} */ |
|
if (intval($row['FILE_DA_GENERARE']) && FILE_DA_GENERARE && intval($row['OBBLIGO']) > 0 && $row['FILEPATH'] == "" && $row['MODULE'] != "") { |
|
if (($chekGeneraIstanza && $row['MODULE'] == GENERA_ALLEGATO_2) || ($row['MODULE'] == GENERA_ALLEGATO_3)) { |
|
$btn_genera = '<button type="button" class="btn btn-sm btn-warning" type="button" onclick="generaAllegato(\'' . $row['MODULE'] . '\', \'' . $domanda->ID . '\', \'' . $row['DOCUMENTO_ID'] . '\', \'' . intval($row['ID']) . '\');" alt="Genera documento" title="Genera documento"><i class="fas fa-file-download"></i> Genera pdf</button>'; |
|
if ($row['HASH_FILE'] != "") { |
|
$btn = '<button type="button" class="btn btn-sm btn-primary" type="button" data-toggle="modal" data-target="#allegatiModal" onclick="assegnaValue(\'' . $row['DOCUMENTO_ID'] . '\', \'' . $row['OBBLIGO'] . '\', \'' . $row['ESTENZIONE_FILE'] . '\', \'' . $row['ID'] . '\');" alt="Allega documento" title="Allega documento"><i class="fas fa-paper-plane"></i> Allega</button>'; |
|
} |
|
} |
|
} else { |
|
$btn = '<button type="button" class="btn btn-sm btn-success" onclick="openStreamer(\'' . $row['ID'] . '\');" alt="Download allegato" title="Download"><i class="fas fa-download"></i> Download</button>'; |
|
if ($domanda->STATO < PREPARATA && Utils::isStatoSportelloPreparazione()) { |
|
$btn .= ' <button type="button" class="btn btn-sm btn-danger" onclick="deleteAllegato(\'' . $row['ID'] . '\');" alt="Elimina allegato" title="Elimina"><i class="fas fa-trash"></i> Elimina</button>'; |
|
} |
|
} |
|
} |
|
|
|
$note = ''; |
|
if ($row['NOTE'] != "") { |
|
$note = '<br><small><em>' . $row['NOTE'] . '</em></small>'; |
|
} |
|
|
|
if (intval($row['ID']) <= 0 && intval($row['FILE_DA_GENERARE']) && FILE_DA_GENERARE) { |
|
$debug .= "-"; |
|
if ($row['MODULE'] == GENERA_ALLEGATO_2) { |
|
$stato_allegato = "<b class='text-warning'>Da generare, firmare e allegare</b>"; |
|
} else { |
|
$stato_allegato = "<b class='text-warning'>Da generare, compilare, firmare e allegare 1</b>"; |
|
} |
|
} else if (intval($row['ID']) > 0 && intval($row['FILE_DA_GENERARE']) == 0) { |
|
$debug .= "--"; |
|
$stato_allegato = "<b class='text-success'>Presentato</b>"; |
|
} else if (intval($row['ID']) > 0 && intval($row['FILE_DA_GENERARE']) && FILE_DA_GENERARE && $row['HASH_FILE'] == "") { |
|
$debug .= "---"; |
|
if ($row['MODULE'] == GENERA_ALLEGATO_2) { |
|
$stato_allegato = "<b class='text-warning'>Da generare, firmare e allegare</b>"; |
|
} else { |
|
$stato_allegato = "<b class='text-warning'>Da generare, compilare, firmare e allegare 2</b>"; |
|
} |
|
} else if (intval($row['ID']) > 0 && intval($row['FILE_DA_GENERARE']) && FILE_DA_GENERARE && $row['HASH_FILE'] != "" && $row['FILEPATH'] == "") { |
|
$debug .= "----"; |
|
$stato_allegato = "<b class='text-primary'>Da allegare</b>"; |
|
} else if (intval($row['ID']) > 0 && intval($row['FILE_DA_GENERARE']) && FILE_DA_GENERARE && $row['HASH_FILE'] != "" && $row['FILEPATH'] != "") { |
|
$debug .= "-----"; |
|
$genera_istanza = true; |
|
if ($row['MODULE'] == GENERA_ALLEGATO_2) { |
|
$checkAllFile['esito'] = true; |
|
} |
|
$stato_allegato = "<b class='text-success'>Presentato</b>"; |
|
} |
|
$checkAllFile['allegato'] = $row['DOCUMENTO_NOME']; |
|
|
|
if ($chekGeneraIstanza) { |
|
$debug = "<br>FILE COMPLETI[" . $countAllegatiCompleti . "][" . ($iTotalRecordsObbligatori) . "] "; |
|
} else { |
|
$debug = "<br>FILE NON COMPLETI " . intval($row['ID']) . "[" . $countAllegatiCompleti . "][" . ($iTotalRecordsObbligatori) . "] "; |
|
} |
|
if ($row["OBBLIGO"] >= 1 || ($row["OBBLIGO"] == 0 && trim($row["OBBLIGO_CONDIZIONATO"]) == "")) { |
|
$data[] = array( |
|
"PRIORITA" => $row['PRIORITA'], |
|
"ID" => $row['ID'], |
|
"ID_DOMANDA" => $row['ID_DOMANDA'], |
|
"ID_DOCUMENTO" => $row['DOCUMENTO_ID'], |
|
"DOCUMENTO" => $row['DOCUMENTO_NOME'] . $note, |
|
"TIPO" => ($row['OBBLIGO'] >= 1 ? "<b class='text-warning'>Obbligatorio</b>" : "<b class='text-primary'>Non obbligatorio</b>") . " <i>(." . $row['ESTENZIONE_FILE'] . ")</i>", |
|
"STATO" => $stato_allegato, |
|
"OP" => $btn_genera . $btn//($domanda->STATO > STATO_DOMANDA_IN_PREPARAZIONE ? '' : $btn_genera . $btn) |
|
); |
|
} |
|
} |
|
$msg = ''; |
|
$diff = ($iTotalRecordsObbligatori - ($countAllegatiCompleti)); |
|
|
|
if ($chekGeneraIstanza) { |
|
if ($checkAllFile['esito']) { |
|
$msg = "Gli allegati risultano caricati correttamente. Ora puoi procedere alla conferma della preparazione dell'istanza, cliccando sul tasto in alto 'Preparazione istanza'."; |
|
} elseif ((!$checkAllFile['esito'] && $diff == 0)) { |
|
$msg = "Gli allegati risultano caricati correttamente."; |
|
} else { |
|
$msg = "Devi ancora completare l'allegato <b><i class='text-danger'>" . $checkAllFile['allegato'] . "</i></b> prima di poter confermare la preparazione dell'istanza."; |
|
} |
|
} else { |
|
|
|
if ($diff > 1) { |
|
$des = ' documenti obbligatori'; |
|
} else { |
|
$des = ' documento obbligatoro'; |
|
} |
|
if ($diff > 0) { |
|
$msg = 'Devi ancora allegare N.' . ($iTotalRecordsObbligatori - ($countAllegatiCompleti)) . $des; |
|
} else { |
|
$msg = 'Devi ancora compleatere il caricamento degli allegati obbligatori'; |
|
} |
|
} |
|
|
|
## Response |
|
$response = array( |
|
"draw" => intval($draw), |
|
"iTotalRecords" => $res['iTotalRecords'], |
|
"iTotalDisplayRecords" => $res['iTotalDisplayRecords'], |
|
"iTotalRecordsObbligatori" => $iTotalRecordsObbligatori, |
|
"iCountAllegatiCompleti" => $countAllegatiCompleti, |
|
"allAllegatiCompleti" => $checkAllFile['esito'], |
|
"msg_allegati" => $msg, |
|
"aaData" => $data |
|
); |
|
// |
|
} |
|
exit(json_encode($response)); |
|
} |
|
|
|
function presentaDomanda() { |
|
global $con, $LoggedAccount; |
|
|
|
$verificaCsrf = Utils::verifyCsrfToken($_SESSION['Token'], 'csrf_presentazione', $_POST['csrf_presentazione']); |
|
if (!$verificaCsrf) { |
|
$return['erroreDescrizione'] = "Operazione non consentita - 159"; |
|
exit(json_encode($return)); |
|
} |
|
|
|
$response = Utils::initDefaultResponse(); |
|
$domanda = Domanda::loadDomandaFromAccount(); |
|
|
|
if (Utils::isStatoSportelloPreparazione() && $domanda->STATO == INPREPARAZIONE) { |
|
if ($domanda->CheckCompletata()) { |
|
$response = $domanda->presentaDomanda(); |
|
} else { |
|
$response['erroreDescrizione'] = 'La verifica di controllo sulla presenza degli allegati obbligatori non è andata a buon fine'; |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = 'Operazione non consentita in questa fase.'; |
|
} |
|
exit(json_encode($response)); |
|
} |
|
|
|
function riapriDomanda() { |
|
global $con, $LoggedAccount; |
|
|
|
$verificaCsrf = Utils::verifyCsrfToken($_SESSION['Token'], 'csrf_riapertura', $_POST['csrf_riapertura']); |
|
if (!$verificaCsrf) { |
|
$return['erroreDescrizione'] = "Operazione non consentita - 159"; |
|
exit(json_encode($return)); |
|
} |
|
|
|
$response = Utils::initDefaultResponse(); |
|
$domanda = Domanda::loadDomandaFromAccount(); |
|
|
|
if (Utils::isStatoSportelloPreparazione() && $domanda->STATO == PREPARATA) { |
|
$response = $domanda->riapriDomanda(); |
|
} else { |
|
$response['erroreDescrizione'] = 'Operazione non consentita in questa fase.'; |
|
} |
|
exit(json_encode($response)); |
|
} |
|
|
|
function saveCambioIban() { |
|
global $con, $LoggedAccount; |
|
$transaction = false; |
|
$con->db_transactionStart(); |
|
$response = Utils::initDefaultResponse(-999, ''); |
|
// VERIFICO SE SONO NEL PERIODO DELLA PRESENTAZIONE DELLA DOMANDA |
|
if (!Utils::isStatoSportelloCambioIban()) { |
|
$return['erroreDescrizione'] = "Accesso non consentito (0)"; |
|
exit(json_encode($return)); |
|
} |
|
//Utils::print_array($_POST); |
|
DomandaIban::checkVerificaDatiPreSalvataggio(); |
|
$iban = new DomandaIban($_POST); |
|
|
|
$controlliIban = $iban->checkDatiPreSave(); |
|
if ($controlliIban['checkDati']) { |
|
$cronologia = $iban->SaveCronologia(); |
|
if ($cronologia['esito'] == 1) { |
|
$response = $iban->Save(); |
|
if ($response['esito'] == 1) { |
|
$transaction = true; |
|
} |
|
} else { |
|
$response['esito'] = -999; |
|
$response['erroreDescrizione'] = $cronologia['erroreDescrizione']; |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = ("Verificare i seguenti campi: " . $controlliIban['txt_dati_mancanti']); |
|
} |
|
|
|
if ($transaction) { |
|
$con->db_transactionCommit(); |
|
} else { |
|
$con->db_transactionRollback(); |
|
} |
|
exit(json_encode($response)); |
|
}
|
|
|