';
print '';
} else {
$error = 0;
$thumbshown = '';
if (preg_match('/\.pdf$/i', $file['name'])) {
$urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
$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 = '';
}
}
}
if (empty($urlforhref) || empty($thumbshown)) {
print '';
} else {
print '';
}
print '
';
if (empty($urlforhref) || empty($thumbshown)) {
print '';
} else {
print '';
}
}
print ' ';
$checked = '';
//var_dump(GETPOST($file['relativename']));
//var_dump($file['relativename']);
//var_dump($_FILES['userfile']['name']);
// If a file was just uploaded, we check to preselect it
if (is_array($_FILES['userfile']['name'])) {
foreach ($_FILES['userfile']['name'] as $tmpfile) {
if ($file['relativename'] == (GETPOST('savingdocmask', 'alpha') ? dol_sanitizeFileName($object->ref.'-') : '').$tmpfile) {
$checked = ' checked';
break;
} elseif ($file['relativename'] && in_array($file['relativename'], GETPOST('attachfile', 'array'))) {
$checked = ' checked';
break;
}
}
}
// If we edit a line already linked, then $filenamelinked is defined to the filename (without path) of linked file
if (!empty($filenamelinked) && $filenamelinked == $file['relativename']) {
$checked = ' checked';
}
print '