.
*/
include_once __DIR__.'/core.php';
$file_id = filter('file_id');
$file = Models\Upload::find($file_id);
if (empty($file)) {
return;
}
$link = ROOTDIR.'/'.$file->filepath;
if ($file->isFatturaElettronica()) {
$content = file_get_contents(DOCROOT.'/'.$file->filepath);
// Individuazione stylesheet
$default_stylesheet = 'asso-invoice';
$name = basename($file->original_name);
$filename = explode('.', $name)[0];
$pieces = explode('_', $filename);
$stylesheet = $pieces[2];
$stylesheet = DOCROOT.'/plugins/xml/'.$stylesheet.'.xsl';
$stylesheet = file_exists($stylesheet) ? $stylesheet : DOCROOT.'/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 '
';
echo $xslt->transformToXML($xml);
} else {
echo '
';
if ($file->isImage()) {
echo '
';
} else {
if ($file->isPDF()) {
$src = \Prints::getPDFLink($file->filepath);
}
echo '
';
}
}