2021-02-23 11:34:37 +01:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
|
|
* Copyright (C) DevCode s.r.l.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-03-04 13:57:46 +01:00
|
|
|
use Modules\Fatture\Fattura;
|
2021-02-23 11:34:37 +01:00
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
2021-03-04 13:57:46 +01:00
|
|
|
$fattura = Fattura::find($id_record);
|
|
|
|
$file = $fattura->uploads()->where('name', 'Fattura Elettronica')->first();
|
2021-02-23 11:34:37 +01:00
|
|
|
|
|
|
|
if (empty($file)) {
|
2022-03-11 19:16:10 +01:00
|
|
|
echo '<div class="text-center">'.tr('Questo documento non possiede una fattura elettronica associata').'</div>';
|
2023-08-04 14:54:28 +02:00
|
|
|
} else {
|
2022-03-11 19:16:10 +01:00
|
|
|
if ($file->isFatturaElettronica()) {
|
|
|
|
$content = file_get_contents(base_dir().'/'.$file->filepath);
|
2023-08-04 14:54:28 +02:00
|
|
|
|
2022-03-11 19:16:10 +01:00
|
|
|
// Individuazione stylesheet
|
|
|
|
$default_stylesheet = 'asso-invoice';
|
2023-08-04 14:54:28 +02:00
|
|
|
|
2022-03-11 19:16:10 +01:00
|
|
|
$name = basename($file->original_name);
|
|
|
|
$filename2 = explode('.', $name)[0];
|
|
|
|
$pieces = explode('_', $filename2);
|
|
|
|
$stylesheet = $pieces[2];
|
2023-08-04 14:54:28 +02:00
|
|
|
|
2022-03-11 19:16:10 +01:00
|
|
|
$stylesheet = base_dir().'/plugins/xml/'.$stylesheet.'.xsl';
|
|
|
|
$stylesheet = file_exists($stylesheet) ? $stylesheet : base_dir().'/plugins/xml/'.$default_stylesheet.'.xsl';
|
|
|
|
|
|
|
|
// XML
|
|
|
|
$xml = new DOMDocument();
|
|
|
|
$xml->loadXML($content);
|
|
|
|
|
|
|
|
// XSL
|
|
|
|
$xsl = new DOMDocument();
|
|
|
|
$xsl->load($stylesheet);
|
|
|
|
|
|
|
|
// XSLT
|
|
|
|
$xslt = new XSLTProcessor();
|
|
|
|
$xslt->importStylesheet($xsl);
|
|
|
|
echo $xslt->transformToXML($xml);
|
2023-08-04 14:54:28 +02:00
|
|
|
|
2021-02-23 11:34:37 +01:00
|
|
|
echo '
|
2022-03-11 19:16:10 +01:00
|
|
|
<style>
|
|
|
|
#notifica {
|
|
|
|
min-width: 860px !important;
|
2021-02-23 11:34:37 +01:00
|
|
|
}
|
2022-03-11 19:16:10 +01:00
|
|
|
table.tbFoglio td {
|
|
|
|
border-bottom: solid 1px #000000;
|
|
|
|
}
|
|
|
|
</style>';
|
|
|
|
} else {
|
2021-02-23 11:34:37 +01:00
|
|
|
echo '
|
2022-03-11 19:16:10 +01:00
|
|
|
<style>
|
|
|
|
body, iframe, img{
|
|
|
|
border: 0;
|
|
|
|
margin: 0;
|
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
iframe{
|
|
|
|
width:100%;
|
|
|
|
height:100%;
|
|
|
|
min-height: 500px;
|
|
|
|
}
|
|
|
|
</style>';
|
2023-08-04 14:54:28 +02:00
|
|
|
|
2022-03-11 19:16:10 +01:00
|
|
|
$link = base_path().'/'.$file->filepath;
|
2023-08-04 14:54:28 +02:00
|
|
|
|
2022-03-11 19:16:10 +01:00
|
|
|
if ($file->isImage()) {
|
|
|
|
echo '
|
|
|
|
<img src="'.$link.'"></img>';
|
|
|
|
} else {
|
|
|
|
if ($file->isPDF()) {
|
2024-01-15 15:30:45 +01:00
|
|
|
$src = Prints::getPDFLink($file->filepath);
|
2022-03-11 19:16:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<iframe src="'.($link ?: $src).'">
|
|
|
|
<a src="'.$link.'">'.tr('Il browser non supporta i contenuti iframe: clicca qui per raggiungere il file originale').'</a>
|
|
|
|
</iframe>';
|
|
|
|
}
|
2021-02-23 11:34:37 +01:00
|
|
|
}
|
2023-08-04 14:54:28 +02:00
|
|
|
}
|