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.
173 righe
7.0 KiB
173 righe
7.0 KiB
<?php |
|
|
|
//exit(); |
|
|
|
switch ($_POST['action']) { |
|
case 'download': |
|
downloadFile(); |
|
break; |
|
case 'download_istanza': |
|
downloadIstanza(); |
|
break; |
|
case 'download_sconti': |
|
downloadSconti(); |
|
break; |
|
} |
|
|
|
function downloadFile(){ |
|
global $LoggedAccount; |
|
$id_allegato = intval($_POST['id']); |
|
if($id_allegato>0){ |
|
|
|
$allegato = new Allegati($id_allegato); |
|
if(isset($_POST['file'])){ |
|
$fileName = trim($_POST['file']); |
|
}else{ |
|
$fileName = $allegato->FILEPATH; |
|
} |
|
$domanda = new Domanda($allegato->ID_DOMANDA); |
|
$LoggedAccount->checkAuthShowDomandaPage($domanda->ID); |
|
|
|
$documenti_bando = new DocumentiBando($allegato->ID_DOCUMENTO); |
|
$pathInfo = $documenti_bando->getPathInfoDocumento(); |
|
$folder = $domanda->generateDirForUpload(ROOT_UPLOAD_PRESENTAZIONE, $pathInfo["PATH_DOCUMENTO"]); |
|
$filePath = $folder .'/'. $fileName; |
|
if (file_exists($filePath) && filesize($filePath) > 0) { |
|
header('Content-Description: File Transfer'); |
|
header('Content-Type: application/octet-stream'); |
|
header('Content-Disposition: attachment; filename="' . $fileName.'"'); |
|
header('Content-Transfer-Encoding: binary'); |
|
header('Expires: 0'); |
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
header('Pragma: public'); |
|
header('Content-Length: ' . filesize($filePath)); |
|
ob_clean(); |
|
flush(); |
|
readfile($filePath); |
|
exit; |
|
} |
|
} |
|
exit; |
|
} |
|
|
|
|
|
function downloadSconti(){ |
|
global $LoggedAccount; |
|
//Utils::print_array($_POST);exit(); |
|
$id_sconto = intval($_POST['id']); |
|
if($id_sconto>0){ |
|
$sconto = new DomandaSconti($id_sconto); |
|
if(isset($_POST['type'])){ |
|
if($_POST['type'] == 'biglietto'){ |
|
$fileName = trim($sconto->FILEPATH_BIGLIETTO); |
|
}elseif ($_POST['type'] == 'imbarco'){ |
|
$fileName = trim($sconto->FILEPATH_CARTAIMBARCO); |
|
} |
|
} |
|
$istanza = Domanda::loadDomandaFromAccount(); |
|
$LoggedAccount->checkAuthShowDomandaPage($istanza->ID); |
|
if($istanza->ID == $sconto->ID_DOMANDA){ |
|
$folder = $istanza->generateDirForUpload(ROOT_UPLOAD_PRESENTAZIONE, 'biglietti'); |
|
$filePath = $folder .'/'. $fileName; |
|
if (file_exists($filePath) && filesize($filePath) > 0) { |
|
header('Content-Description: File Transfer'); |
|
header('Content-Type: application/octet-stream'); |
|
header('Content-Disposition: attachment; filename="' . $fileName.'"'); |
|
header('Content-Transfer-Encoding: binary'); |
|
header('Expires: 0'); |
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
header('Pragma: public'); |
|
header('Content-Length: ' . filesize($filePath)); |
|
ob_clean(); |
|
flush(); |
|
readfile($filePath); |
|
exit; |
|
} |
|
} |
|
} |
|
exit; |
|
} |
|
|
|
function downloadIstanza(){ |
|
global $LoggedAccount; |
|
$response = Utils::initDefaultResponse(); |
|
$domanda = Domanda::loadDomandaFromAccount(); |
|
|
|
if (Utils::isStatoSportelloPreparazione(true) && $domanda->STATO == PREPARATA) { |
|
|
|
$filePath = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_PRESENTAZIONE); |
|
$filePath .= "/domanda_generata/". $domanda->ALLEGATO_GENERATO; |
|
if (file_exists($filePath) && filesize($filePath) > 0) { |
|
header('Content-Description: File Transfer'); |
|
header('Content-Type: application/octet-stream'); |
|
header('Content-Disposition: attachment; filename=' . File::GetValidFilename($domanda->ALLEGATO_GENERATO)); |
|
header('Content-Transfer-Encoding: binary'); |
|
header('Expires: 0'); |
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
header('Pragma: public'); |
|
header('Content-Length: ' . filesize($filePath)); |
|
ob_clean(); |
|
flush(); |
|
readfile($filePath); |
|
exit; |
|
} else { |
|
echo "Si prega di procedere alla generazione del file."; |
|
} |
|
} else { |
|
$response['erroreDescrizione'] = 'Operazione non consentita in questa fase.'; |
|
} |
|
} |
|
|
|
function printAllegato($allegato, $domanda) { |
|
global $LoggedAccount; |
|
if (!empty($allegato) && !empty($domanda)) { |
|
if ($allegato->FILEPATH != "") { |
|
$file = $allegato->FILEPATH; |
|
if ($LoggedAccount->checkIstitutoFromLoggedAccount($domanda->CODICE_ISTITUTO)) { // controllo proprietario domanda |
|
switch ($allegato->TIPO_DOCUMENTO) { |
|
case TIPO_UPLOAD_OBBLIGATORIO: |
|
$basePath = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_PRESENTAZIONE); |
|
$basePath .= '/obbligatori/'; |
|
break; |
|
case TIPO_UPLOAD_OPZIONALE: |
|
$basePath = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_PRESENTAZIONE); |
|
$basePath .= '/opzionali/'; |
|
break; |
|
case TIPO_UPLOAD_ISTANZA: |
|
$basePath = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_PRESENTAZIONE); |
|
$basePath .= '/istanza/'; |
|
break; |
|
case TIPO_UPLOAD_CONTRIBUTO: |
|
$basePath = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_EROGAZIONE); |
|
$basePath .= '/contributo/'; |
|
break; |
|
} |
|
$filePath = $basePath . $file; |
|
if (file_exists($filePath) && filesize($filePath) > 0) { |
|
header('Content-Description: File Transfer'); |
|
header('Content-Type: application/octet-stream'); |
|
header('Content-Disposition: attachment; filename=' . File::GetValidFilename($file)); |
|
header('Content-Transfer-Encoding: binary'); |
|
header('Expires: 0'); |
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
header('Pragma: public'); |
|
header('Content-Length: ' . filesize($filePath)); |
|
ob_clean(); |
|
flush(); |
|
readfile($filePath); |
|
exit; |
|
} else { |
|
$msg = "Non è possibile visualizzare il file richiesto, contattare il supporto tecnico (1316)."; |
|
} |
|
} else { |
|
$msg = "Accesso non autorizzato"; |
|
} |
|
} else { |
|
$msg = "Non è possibile visualizzare il file richiesto, contattare il supporto tecnico (1321)."; |
|
} |
|
} else { |
|
$msg = "Non è possibile visualizzare il file richiesto, contattare il supporto tecnico (1325)."; |
|
} |
|
|
|
echo $msg; |
|
}
|
|
|