WIP Attach document to expense report lines
This commit is contained in:
parent
1409d1a2c8
commit
a950d8389e
@ -1382,25 +1382,25 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
|
||||
|
||||
$filepath = $dir_output . $subdir . "/";
|
||||
|
||||
$file = $filepath . $objectref . ".pdf";
|
||||
$filepdf = $filepath . $objectref . ".pdf";
|
||||
$relativepath = $subdir.'/'.$objectref.'.pdf';
|
||||
|
||||
// Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png")
|
||||
$fileimage = $file.'_preview.png';
|
||||
$fileimage = $filepdf.'_preview.png';
|
||||
$relativepathimage = $relativepath.'_preview.png';
|
||||
|
||||
$pdfexists = file_exists($file);
|
||||
$pdfexists = file_exists($filepdf);
|
||||
|
||||
// If PDF file exists
|
||||
if ($pdfexists)
|
||||
{
|
||||
// Conversion du PDF en image png si fichier png non existant
|
||||
if (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($file)))
|
||||
if (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf)))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experience trouble with pdf thumb generation and imagick, you can disable here.
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$ret = dol_convert_file($file, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png
|
||||
$ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png
|
||||
if ($ret < 0) $error++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ $quality = 80;
|
||||
* Return if a filename is file name of a supported image format
|
||||
*
|
||||
* @param string $file Filename
|
||||
* @return int -1=Not image filename, 0=Image filename but format not supported by PHP, 1=Image filename with format supported
|
||||
* @return int -1=Not image filename, 0=Image filename but format not supported by PHP, 1=Image filename with format supported by this PHP
|
||||
*/
|
||||
function image_format_supported($file)
|
||||
{
|
||||
|
||||
@ -2361,8 +2361,7 @@ else
|
||||
$fileinfo = pathinfo($file['name']);
|
||||
if (image_format_supported($file['name']) > 0)
|
||||
{
|
||||
$minifile=getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original
|
||||
//if (! dol_is_file($file['path'].'/'.$minifile)) $minifile=getImageFileNameForSize($file['name'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension
|
||||
$minifile=getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case however) than original
|
||||
//print $file['path'].'/'.$minifile.'<br>';
|
||||
$urlforhref=getAdvancedPreviewUrl($modulepart, $fileinfo['relativename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity));
|
||||
if (empty($urlforhref)) {
|
||||
@ -2378,9 +2377,50 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
$modulepart='expensereport';
|
||||
//$conf->global->MAIN_DISABLE_PDF_THUMBS=1;
|
||||
|
||||
print '<a href=""><div class="photoref">';
|
||||
//print '<img class="photoexpensereport photorefcenter" height="16" src="'.DOL_URL_ROOT.'/theme/eldy/img/object_trip.png" title="">';
|
||||
print img_mime($relativepath.$minifile);
|
||||
$thumbshown=0;
|
||||
if (preg_match('/\.pdf$/i', $file['name']))
|
||||
{
|
||||
$filepdf = $conf->expensereport->dir_output.'/'.$relativepath.$file['name'];
|
||||
$fileimage = $conf->expensereport->dir_output.'/'.$relativepath.$file['name'].'_preview.png';
|
||||
$relativepathimage = $relativepath.$file['name'].'_preview.png';
|
||||
|
||||
$pdfexists = file_exists($filepdf);
|
||||
|
||||
if ($pdfexists)
|
||||
{
|
||||
// Conversion du PDF en image png si fichier png non existant
|
||||
if (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf)))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experience trouble with pdf thumb generation and imagick, you can disable here.
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png
|
||||
if ($ret < 0) $error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($pdfexists && ! $error)
|
||||
{
|
||||
$heightforphotref=70;
|
||||
if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60;
|
||||
// If the preview file is found
|
||||
if (file_exists($fileimage))
|
||||
{
|
||||
$thumbshown=1;
|
||||
print '<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercu'.$modulepart.'&file='.urlencode($relativepathimage).'">';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $thumbshown)
|
||||
{
|
||||
print img_mime($minifile);
|
||||
}
|
||||
print '</div></a>';
|
||||
}
|
||||
print '<br>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user