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.
85 righe
3.9 KiB
85 righe
3.9 KiB
<?php |
|
|
|
|
|
Utils::checkLogin(); |
|
require_once ROOT . 'lib/modules/pdfMerge/tcpdf/PDFMerger.php'; |
|
|
|
$msg = "Accesso non autorizzato"; |
|
if (Utils::isStatoSportelloPreparazione(true)) { |
|
|
|
|
|
|
|
$domanda = Domanda::loadDomandaFromAccount(); |
|
$account = new Account($domanda->ID_ACCOUNT); |
|
$filePath = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_PRESENTAZIONE); |
|
$filePath = $filePath . "/domanda_generata/" . $domanda->ALLEGATO_GENERATO; |
|
if (!DOWNLOAD_PDFMERGE && !isset($_POST['assign'])) { |
|
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 if (!DOWNLOAD_PDFMERGE && isset($_POST['assign'])) { |
|
$filePathProtocollo = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_PRESENTAZIONE); |
|
$filePathProtocollo = $filePathProtocollo . "/domanda_protocollo/" . $domanda->FILEPATH_PROTOCOLLO; |
|
if (file_exists($filePathProtocollo) && filesize($filePathProtocollo) > 0) { |
|
header('Content-Description: File Transfer'); |
|
header('Content-Type: application/octet-stream'); |
|
header('Content-Disposition: attachment; filename=' . File::GetValidFilename($domanda->FILEPATH_PROTOCOLLO)); |
|
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($filePathProtocollo)); |
|
ob_clean(); |
|
flush(); |
|
readfile($filePathProtocollo); |
|
exit; |
|
} else { |
|
echo "Si prega di procedere alla generazione del file."; |
|
} |
|
} else if (DOWNLOAD_PDFMERGE && !isset($_POST['assign']) && intval($domanda->NUMERO_PROTOCOLLO) <= 0) { |
|
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 { |
|
$filePathProtocollo = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_PRESENTAZIONE); |
|
$filePathProtocollo = $filePathProtocollo . "/domanda_protocollo/" . $domanda->FILEPATH_PROTOCOLLO; |
|
if (file_exists($filePath) && filesize($filePath) > 0 && file_exists($filePathProtocollo) && filesize($filePathProtocollo) > 0) { |
|
ob_end_clean(); |
|
$pdf = new PDFMerger; // or use $pdf = new \PDFMerger; for Laravel |
|
$pdf->addPDF($filePath, 'all'); |
|
$pdf->addPDF($filePathProtocollo, 'all'); |
|
$pdf->merge('download', 'Istanza_'.$account->CODICE_FISCALE.'_'.$domanda->ID.'.pdf'); // force download |
|
exit; |
|
} else { |
|
|
|
echo "Si prega di procedere alla generazione del file."; |
|
} |
|
} |
|
|
|
}
|
|
|