1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-25 15:22:24 +01:00
openstamanager/view.php

95 lines
2.4 KiB
PHP
Raw Normal View History

2019-01-17 16:11:10 +01:00
<?php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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/>.
*/
2019-01-17 16:11:10 +01:00
include_once __DIR__.'/core.php';
$file_id = filter('file_id');
$file = Models\Upload::find($file_id);
if (empty($file)) {
return;
}
$link = base_path().'/'.$file->filepath;
2019-01-17 16:11:10 +01:00
if ($file->isFatturaElettronica()) {
$content = file_get_contents(base_dir().'/'.$file->filepath);
2019-01-17 16:11:10 +01:00
2019-03-02 21:04:06 +01:00
// Individuazione stylesheet
$default_stylesheet = 'asso-invoice';
2019-02-20 16:07:42 +01:00
2019-07-19 18:11:07 +02:00
$name = basename($file->original_name);
2019-02-20 16:07:42 +01:00
$filename = explode('.', $name)[0];
$pieces = explode('_', $filename);
2019-03-15 11:05:28 +01:00
$stylesheet = $pieces[2];
2019-01-17 16:11:10 +01:00
$stylesheet = base_dir().'/plugins/xml/'.$stylesheet.'.xsl';
$stylesheet = file_exists($stylesheet) ? $stylesheet : base_dir().'/plugins/xml/'.$default_stylesheet.'.xsl';
2019-02-20 16:07:42 +01:00
// XML
2019-03-01 17:13:13 +01:00
$xml = new DOMDocument();
2019-02-25 13:10:11 +01:00
$xml->loadXML($content);
2019-03-01 17:13:13 +01:00
// XSL
$xsl = new DOMDocument();
$xsl->load($stylesheet);
2019-01-17 16:11:10 +01:00
2019-03-01 17:13:13 +01:00
// XSLT
$xslt = new XSLTProcessor();
$xslt->importStylesheet($xsl);
2019-02-20 16:07:42 +01:00
echo '
<style>
#notifica {
min-width: 860px !important;
}
</style>';
2019-01-17 16:11:10 +01:00
echo $xslt->transformToXML($xml);
} else {
echo '
<style>
body, iframe, img{
border: 0;
margin: 0;
max-width: 100%;
}
iframe{
width:100%;
height:100%;
min-height: 500px;
}
</style>';
if ($file->isImage()) {
echo '
<img src="'.$link.'"></img>';
} else {
if ($file->isPDF()) {
$src = \Prints::getPDFLink($file->filepath);
}
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>';
}
}