Fix Esporta stampe FE

This commit is contained in:
Luca 2022-03-11 19:16:10 +01:00
parent 7ee71b8fde
commit b023cd02a7
3 changed files with 70 additions and 67 deletions

View File

@ -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

View File

@ -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)
{ {

View File

@ -25,22 +25,21 @@ $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';
@ -50,17 +49,17 @@ if ($file->isFatturaElettronica()) {
$xml = new DOMDocument(); $xml = new DOMDocument();
$xml->loadXML($content); $xml->loadXML($content);
// XSL // XSL
$xsl = new DOMDocument(); $xsl = new DOMDocument();
$xsl->load($stylesheet); $xsl->load($stylesheet);
// XSLT // XSLT
$xslt = new XSLTProcessor(); $xslt = new XSLTProcessor();
$xslt->importStylesheet($xsl); $xslt->importStylesheet($xsl);
echo $xslt->transformToXML($xml); echo $xslt->transformToXML($xml);
echo ' echo '
<style> <style>
#notifica { #notifica {
@ -71,7 +70,7 @@ if ($file->isFatturaElettronica()) {
} }
</style>'; </style>';
exit;
} else { } else {
echo ' echo '
<style> <style>
@ -87,6 +86,8 @@ exit;
} }
</style>'; </style>';
$link = base_path().'/'.$file->filepath;
if ($file->isImage()) { if ($file->isImage()) {
echo ' echo '
<img src="'.$link.'"></img>'; <img src="'.$link.'"></img>';
@ -101,3 +102,4 @@ exit;
</iframe>'; </iframe>';
} }
} }
}