29@phan-var-force int $colspan
34 print
'<!-- expensereport_linktofile.tpl.php -->'.
"\n";
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
41 $nbFiles = count($arrayoffiles);
45 print
'<tr class="trattachnewfilenow'.(empty($tredited) ?
' oddeven nohover' :
' '.$tredited).
'"'.(!GETPOSTISSET(
'sendit') && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
' style="display: none"' :
'').
'>';
48 if ($action ==
'editline') {
53 print
'<td colspan="'.($action ==
'editline' ? $colspan - 1 : $colspan).
'">';
55 $modulepart =
'expensereport';
61 foreach ($arrayoffiles as $file) {
62 $urlforhref = array();
65 print
'<div class="inline-block margintoponly marginleftonly marginrightonly center valigntop">';
66 $fileinfo = pathinfo($file[
'fullname']);
70 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(empty(
$object->entity) ? $conf->entity :
$object->entity));
71 if (empty($urlforhref)) {
72 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(empty(
$object->entity) ? $conf->entity :
$object->entity).
'&file='.urlencode($file[
'relativename'].
'.'.strtolower($fileinfo[
'extension']));
73 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
75 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
77 print
'<div class="photoref backgroundblank">';
78 print
'<img class="photoexpensereport photorefcenter" height="'.$maxheightmini.
'" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(empty(
$object->entity) ? $conf->entity :
$object->entity).
'&file='.urlencode($relativepath.$minifile).
'" title="">';
85 if (preg_match(
'/\.pdf$/i', $file[
'name'])) {
86 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(empty(
$object->entity) ? $conf->entity :
$object->entity));
88 $filepdf = $conf->expensereport->dir_output.
'/'.$relativepath.$file[
'name'];
89 $fileimage = $conf->expensereport->dir_output.
'/'.$relativepath.$file[
'name'].
'_preview.png';
90 $relativepathimage = $relativepath.$file[
'name'].
'_preview.png';
92 $pdfexists = file_exists($filepdf);
96 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
98 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
107 if ($pdfexists && !$error) {
108 $heightforphotref = 70;
109 if (!empty($conf->dol_optimize_smallscreen)) {
110 $heightforphotref = 60;
113 if (file_exists($fileimage)) {
114 $thumbshown =
'<img height="'.$heightforphotref.
'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.urlencode($modulepart).
'&file='.urlencode($relativepathimage).
'">';
119 if (empty($urlforhref) || empty($thumbshown)) {
120 print
'<span href="" class="aphoto" target="_blank" rel="noopener noreferrer">';
122 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
124 print
'<div class="photoref backgroundblank">';
127 print $thumbshown ? $thumbshown : (empty($minifile) ?
'' :
img_mime($minifile));
130 if (empty($urlforhref) || empty($thumbshown)) {
142 if (is_array($_FILES[
'userfile']) && is_array($_FILES[
'userfile'][
'name'])) {
143 foreach ($_FILES[
'userfile'][
'name'] as $tmpfile) {
145 $checked =
' checked';
147 } elseif ($file[
'relativename'] && in_array($file[
'relativename'],
GETPOST(
'attachfile',
'array'))) {
148 $checked =
' checked';
154 if (!empty($filenamelinked) && $filenamelinked == $file[
'relativename']) {
155 $checked =
' checked';
157 print
'<div class="margintoponly minwidth150 maxwidth150 divoverflow"><input type="checkbox"'.$checked.
' id="radio'.$filei.
'" name="attachfile[]" class="checkboxattachfile valignmiddle" value="'.$file[
'relativename'].
'">';
158 print
'<label class="wordbreak checkboxattachfilelabel paddingrightonly valignmiddle" for="radio'.$filei.
'" title="'.
dol_escape_htmltag($file[
'relativename']).
'">'.$file[
'relativename'].
'</label>';
165 print
'$(document).ready(function() {';
166 print
"$('.checkboxattachfile').on('change', function() { $('.checkboxattachfile').not(this).prop('checked', false); });";
172 if (empty($tredited)) {
173 $css =
'oddeven nohover trattachnewfilenow';
174 $newcolspan = $colspan;
176 $css =
'trattachnewfilenow tredited';
177 $newcolspan = $colspan - 1;
179 print
'<tr class="'.$css.
'"'.(!GETPOSTISSET(
'sendit') && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
' style="display: none"' :
'').
'>';
180 if (!empty($tredited)) {
183 print
'<td colspan="'.($newcolspan).
'">';
184 print
'<span class="opacitymedium">'.$langs->trans(
"NoFilesUploadedYet").
'...</span>';
if(! $sortfield) if(! $sortorder) $object
static count($dbs, $objecttype, $objectid)
Return nb of links.
dol_convert_file($fileinput, $ext='png', $fileoutput='', $page='')
Convert an image file or a PDF into another image format.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.