mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-18 04:20:50 +01:00
Fix Esporta stampe FE
This commit is contained in:
parent
7ee71b8fde
commit
b023cd02a7
@ -90,11 +90,11 @@ switch (post('op')) {
|
|||||||
} else {
|
} else {
|
||||||
$print_name = 'Fattura elettronica di acquisto';
|
$print_name = 'Fattura elettronica di acquisto';
|
||||||
}
|
}
|
||||||
$print = $dbo->SelectOne('zz_prints', 'id', ['name' => $print_name]);
|
$id_print = Prints::getPrints()[$print_name];
|
||||||
|
|
||||||
if (!empty($id_records)) {
|
if (!empty($id_records)) {
|
||||||
foreach ($id_records as $id_record) {
|
foreach ($id_records as $id_record) {
|
||||||
Prints::render($print['id'], $id_record, $dir.'tmp/');
|
Prints::render( $id_print, $id_record, $dir.'tmp/', false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creazione zip
|
// Creazione zip
|
||||||
|
@ -138,6 +138,7 @@ class Prints
|
|||||||
* @param int $id_record
|
* @param int $id_record
|
||||||
* @param string $directory
|
* @param string $directory
|
||||||
* @param bool $return_string
|
* @param bool $return_string
|
||||||
|
* @param bool $overwrite
|
||||||
*/
|
*/
|
||||||
public static function render($print, $id_record, $directory = null, $return_string = false, $overwrite = true)
|
public static function render($print, $id_record, $directory = null, $return_string = false, $overwrite = true)
|
||||||
{
|
{
|
||||||
|
@ -25,79 +25,81 @@ $fattura = Fattura::find($id_record);
|
|||||||
$file = $fattura->uploads()->where('name', 'Fattura Elettronica')->first();
|
$file = $fattura->uploads()->where('name', 'Fattura Elettronica')->first();
|
||||||
|
|
||||||
if (empty($file)) {
|
if (empty($file)) {
|
||||||
|
|
||||||
echo '<div class="text-center">'.tr('Questo documento non possiede una fattura elettronica associata').'</div>';
|
echo '<div class="text-center">'.tr('Questo documento non possiede una fattura elettronica associata').'</div>';
|
||||||
|
|
||||||
return;
|
}else{
|
||||||
}
|
|
||||||
|
|
||||||
$link = base_path().'/'.$file->filepath;
|
if ($file->isFatturaElettronica()) {
|
||||||
|
|
||||||
if ($file->isFatturaElettronica()) {
|
$content = file_get_contents(base_dir().'/'.$file->filepath);
|
||||||
$content = file_get_contents(base_dir().'/'.$file->filepath);
|
|
||||||
|
|
||||||
// Individuazione stylesheet
|
// Individuazione stylesheet
|
||||||
$default_stylesheet = 'asso-invoice';
|
$default_stylesheet = 'asso-invoice';
|
||||||
|
|
||||||
$name = basename($file->original_name);
|
$name = basename($file->original_name);
|
||||||
$filename = explode('.', $name)[0];
|
$filename2 = explode('.', $name)[0];
|
||||||
$pieces = explode('_', $filename);
|
$pieces = explode('_', $filename2);
|
||||||
$stylesheet = $pieces[2];
|
$stylesheet = $pieces[2];
|
||||||
|
|
||||||
$stylesheet = base_dir().'/plugins/xml/'.$stylesheet.'.xsl';
|
$stylesheet = base_dir().'/plugins/xml/'.$stylesheet.'.xsl';
|
||||||
$stylesheet = file_exists($stylesheet) ? $stylesheet : base_dir().'/plugins/xml/'.$default_stylesheet.'.xsl';
|
$stylesheet = file_exists($stylesheet) ? $stylesheet : base_dir().'/plugins/xml/'.$default_stylesheet.'.xsl';
|
||||||
|
|
||||||
// XML
|
// XML
|
||||||
$xml = new DOMDocument();
|
$xml = new DOMDocument();
|
||||||
$xml->loadXML($content);
|
$xml->loadXML($content);
|
||||||
|
|
||||||
// XSL
|
|
||||||
$xsl = new DOMDocument();
|
|
||||||
$xsl->load($stylesheet);
|
|
||||||
|
|
||||||
// XSLT
|
|
||||||
$xslt = new XSLTProcessor();
|
|
||||||
$xslt->importStylesheet($xsl);
|
|
||||||
echo $xslt->transformToXML($xml);
|
|
||||||
|
|
||||||
|
|
||||||
|
// XSL
|
||||||
|
$xsl = new DOMDocument();
|
||||||
|
$xsl->load($stylesheet);
|
||||||
|
|
||||||
echo '
|
|
||||||
<style>
|
|
||||||
#notifica {
|
|
||||||
min-width: 860px !important;
|
|
||||||
}
|
|
||||||
table.tbFoglio td {
|
|
||||||
border-bottom: solid 1px #000000;
|
|
||||||
}
|
|
||||||
</style>';
|
|
||||||
|
|
||||||
exit;
|
// XSLT
|
||||||
} else {
|
$xslt = new XSLTProcessor();
|
||||||
echo '
|
$xslt->importStylesheet($xsl);
|
||||||
<style>
|
echo $xslt->transformToXML($xml);
|
||||||
body, iframe, img{
|
|
||||||
border: 0;
|
|
||||||
margin: 0;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
iframe{
|
|
||||||
width:100%;
|
|
||||||
height:100%;
|
|
||||||
min-height: 500px;
|
|
||||||
}
|
|
||||||
</style>';
|
|
||||||
|
|
||||||
if ($file->isImage()) {
|
|
||||||
echo '
|
echo '
|
||||||
<img src="'.$link.'"></img>';
|
<style>
|
||||||
} else {
|
#notifica {
|
||||||
if ($file->isPDF()) {
|
min-width: 860px !important;
|
||||||
$src = \Prints::getPDFLink($file->filepath);
|
|
||||||
}
|
}
|
||||||
|
table.tbFoglio td {
|
||||||
|
border-bottom: solid 1px #000000;
|
||||||
|
}
|
||||||
|
</style>';
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
echo '
|
echo '
|
||||||
<iframe src="'.($link ?: $src).'">
|
<style>
|
||||||
<a src="'.$link.'">'.tr('Il browser non supporta i contenuti iframe: clicca qui per raggiungere il file originale').'</a>
|
body, iframe, img{
|
||||||
</iframe>';
|
border: 0;
|
||||||
|
margin: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
iframe{
|
||||||
|
width:100%;
|
||||||
|
height:100%;
|
||||||
|
min-height: 500px;
|
||||||
|
}
|
||||||
|
</style>';
|
||||||
|
|
||||||
|
$link = base_path().'/'.$file->filepath;
|
||||||
|
|
||||||
|
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>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user