3 if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES))
5 print '<!-- expensereport_linktofile.tpl.php -->'.
"\n";
7 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
8 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
9 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
12 $nbFiles = count($arrayoffiles);
13 $nbLinks =
Link::count($db, $object->element, $object->id);
17 print '<tr class="trattachnewfilenow'.(empty($tredited) ?
' oddeven nohover' :
' '.$tredited).
'"'.(!
GETPOSTISSET(
'sendit') && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ?
' style="display: none"' :
'').
'>';
18 print '<td colspan="'.$colspan.
'">';
20 $modulepart =
'expensereport'; $maxheightmini = 48;
23 foreach ($arrayoffiles as $file)
25 $urlforhref = array();
28 print '<div class="inline-block margintoponly marginleftonly marginrightonly center valigntop">';
29 $fileinfo = pathinfo($file[
'fullname']);
34 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
35 if (empty($urlforhref)) {
36 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($fileinfo[
'relativename'].
'.'.strtolower($fileinfo[
'extension']));
37 print '<a href="'.$urlforhref.
'" class="aphoto" target="_blank">';
39 print '<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
41 print '<div class="photoref backgroundblank">';
42 print '<img class="photoexpensereport photorefcenter" height="'.$maxheightmini.
'" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($relativepath.$minifile).
'" title="">';
49 if (preg_match(
'/\.pdf$/i', $file[
'name']))
51 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
53 $filepdf = $conf->expensereport->dir_output.
'/'.$relativepath.$file[
'name'];
54 $fileimage = $conf->expensereport->dir_output.
'/'.$relativepath.$file[
'name'].
'_preview.png';
55 $relativepathimage = $relativepath.$file[
'name'].
'_preview.png';
57 $pdfexists = file_exists($filepdf);
62 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf)))
64 if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS))
66 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
68 if ($ret < 0) $error++;
73 if ($pdfexists && !$error)
75 $heightforphotref = 70;
76 if (!empty($conf->dol_optimize_smallscreen)) $heightforphotref = 60;
78 if (file_exists($fileimage))
80 $thumbshown =
'<img height="'.$heightforphotref.
'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
85 if (empty($urlforhref) || empty($thumbshown)) {
86 print '<a href="#" class="aphoto" target="_blank">';
88 print '<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
90 print '<div class="photoref backgroundblank">';
100 if (is_array($_FILES[
'userfile'][
'name'])) {
101 foreach ($_FILES[
'userfile'][
'name'] as $tmpfile)
105 $checked =
' checked';
107 } elseif ($file[
'relativename'] && in_array($file[
'relativename'],
GETPOST(
'attachfile',
'array'))) {
108 $checked =
' checked';
114 if (!empty($filenamelinked) && $filenamelinked == $file[
'relativename'])
116 $checked =
' checked';
118 print '<div class="margintoponly maxwidth150"><input type="checkbox"'.$checked.
' id="radio'.$filei.
'" name="attachfile[]" class="checkboxattachfile" value="'.$file[
'relativename'].
'">';
119 print '<label class="wordbreak checkboxattachfilelabel" for="radio'.$filei.
'"> '.$file[
'relativename'].
'</label>';
126 print '$(document).ready(function() {';
127 print "$('.checkboxattachfile').on('change', function() { $('.checkboxattachfile').not(this).prop('checked', false); });";
133 print '<tr class="oddeven nohover trattachnewfilenow"'.(!
GETPOSTISSET(
'sendit') && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ?
' style="display: none"' :
'').
'>';
134 print '<td colspan="'.$colspan.
'">';
135 print '<span class="opacitymedium">'.$langs->trans(
"NoFilesUploadedYet").
'</span>';
dol_convert_file($fileinput, $ext= 'png', $fileoutput= '', $page= '')
Convert an image file into another format.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_mime($file, $titlealt= '', $morecss= '')
Show MIME img of a file.
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
getImageFileNameForSize($file, $extName, $extImgTarget= '')
Return the filename of file to get the thumbs.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
static count($db, $objecttype, $objectid)
Return nb of links.
print
Draft customers invoices.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param= '')
Return URL we can use for advanced preview links.