Skip to content

Commit

Permalink
NEW Update expense report card.php to allow pdf preview even without …
Browse files Browse the repository at this point in the history
…thumbnail (#29491)

* Update card.php to allow pdf preview even without thumbnail

In the event of a bug of imagick, PDF are not generating image.png and there is no link to open the PDF reader.

Changing to allow opening of PDF reader by clicking on the icon.

* Eurgh, whitespaces

* Update card.php

* Update card.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
  • Loading branch information
Vaadasch and eldy authored Apr 27, 2024
1 parent 52c414d commit 28bfbcc
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions htdocs/expensereport/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -2204,8 +2204,6 @@
print '<img class="photo" height="'.$maxheightmini.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(empty($object->entity) ? $conf->entity : $object->entity).'&file='.urlencode($relativepath.'/'.$minifile).'" title="">';
print '</a>';
} else {
$modulepart = 'expensereport';
$thumbshown = 0;
if (preg_match('/\.pdf$/i', $ecmfilesstatic->filename)) {
$filepdf = $conf->expensereport->dir_output.'/'.$relativepath.'/'.$ecmfilesstatic->filename;
$fileimage = $conf->expensereport->dir_output.'/'.$relativepath.'/'.$ecmfilesstatic->filename.'_preview.png';
Expand All @@ -2230,20 +2228,18 @@
if (!empty($conf->dol_optimize_smallscreen)) {
$heightforphotref = 60;
}
// If the preview file is found
$urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.'/'.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(empty($object->entity) ? $conf->entity : $object->entity));
print '<a href="'.$urlforhref['url'].'" class="'.$urlforhref['css'].'" target="'.$urlforhref['target'].'" mime="'.$urlforhref['mime'].'">';
// If the preview file is found we display the thumb
if (file_exists($fileimage)) {
$thumbshown = 1;
$urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.'/'.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(empty($object->entity) ? $conf->entity : $object->entity));
print '<a href="'.$urlforhref['url'].'" class="'.$urlforhref['css'].'" target="'.$urlforhref['target'].'" mime="'.$urlforhref['mime'].'">';
print '<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=apercu'.$modulepart.'&amp;file='.urlencode($relativepathimage).'">';
print '</a>';
} else {
// Else, we display an icon
print img_mime($ecmfilesstatic->filename);
}
print '</a>';
}
}

if (!$thumbshown) {
print img_mime($ecmfilesstatic->filename);
}
}
}
}
Expand Down

0 comments on commit 28bfbcc

Please sign in to comment.