8@phan-var-force int $colspan
13 print
'<!-- expensereport_linktofile.tpl.php -->'.
"\n";
15 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
16 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
17 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
20 $nbFiles = count($arrayoffiles);
24 print
'<tr class="trattachnewfilenow'.(empty($tredited) ?
' oddeven nohover' :
' '.$tredited).
'"'.(!GETPOSTISSET(
'sendit') && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
' style="display: none"' :
'').
'>';
27 if ($action ==
'editline') {
32 print
'<td colspan="'.($action ==
'editline' ? $colspan - 1 : $colspan).
'">';
34 $modulepart =
'expensereport';
40 foreach ($arrayoffiles as $file) {
41 $urlforhref = array();
44 print
'<div class="inline-block margintoponly marginleftonly marginrightonly center valigntop">';
45 $fileinfo = pathinfo($file[
'fullname']);
49 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity));
50 if (empty($urlforhref)) {
51 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity).
'&file='.urlencode($file[
'relativename'].
'.'.strtolower($fileinfo[
'extension']));
52 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
54 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
56 print
'<div class="photoref backgroundblank">';
57 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="">';
64 if (preg_match(
'/\.pdf$/i', $file[
'name'])) {
65 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity));
67 $filepdf =
$conf->expensereport->dir_output.
'/'.$relativepath.$file[
'name'];
68 $fileimage =
$conf->expensereport->dir_output.
'/'.$relativepath.$file[
'name'].
'_preview.png';
69 $relativepathimage = $relativepath.$file[
'name'].
'_preview.png';
71 $pdfexists = file_exists($filepdf);
75 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
77 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
86 if ($pdfexists && !$error) {
87 $heightforphotref = 70;
88 if (!empty(
$conf->dol_optimize_smallscreen)) {
89 $heightforphotref = 60;
92 if (file_exists($fileimage)) {
93 $thumbshown =
'<img height="'.$heightforphotref.
'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.urlencode($modulepart).
'&file='.urlencode($relativepathimage).
'">';
98 if (empty($urlforhref) || empty($thumbshown)) {
99 print
'<span href="" class="aphoto" target="_blank" rel="noopener noreferrer">';
101 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
103 print
'<div class="photoref backgroundblank">';
106 print $thumbshown ? $thumbshown : (empty($minifile) ?
'' :
img_mime($minifile));
109 if (empty($urlforhref) || empty($thumbshown)) {
121 if (is_array($_FILES[
'userfile']) && is_array($_FILES[
'userfile'][
'name'])) {
122 foreach ($_FILES[
'userfile'][
'name'] as $tmpfile) {
124 $checked =
' checked';
126 } elseif ($file[
'relativename'] && in_array($file[
'relativename'],
GETPOST(
'attachfile',
'array'))) {
127 $checked =
' checked';
133 if (!empty($filenamelinked) && $filenamelinked == $file[
'relativename']) {
134 $checked =
' checked';
136 print
'<div class="margintoponly minwidth150 maxwidth150 divoverflow"><input type="checkbox"'.$checked.
' id="radio'.$filei.
'" name="attachfile[]" class="checkboxattachfile valignmiddle" value="'.$file[
'relativename'].
'">';
137 print
'<label class="wordbreak checkboxattachfilelabel paddingrightonly valignmiddle" for="radio'.$filei.
'" title="'.
dol_escape_htmltag($file[
'relativename']).
'">'.$file[
'relativename'].
'</label>';
144 print
'$(document).ready(function() {';
145 print
"$('.checkboxattachfile').on('change', function() { $('.checkboxattachfile').not(this).prop('checked', false); });";
151 if (empty($tredited)) {
152 $css =
'oddeven nohover trattachnewfilenow';
153 $newcolspan = $colspan;
155 $css =
'trattachnewfilenow tredited';
156 $newcolspan = $colspan - 1;
158 print
'<tr class="'.$css.
'"'.(!GETPOSTISSET(
'sendit') && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
' style="display: none"' :
'').
'>';
159 if (!empty($tredited)) {
162 print
'<td colspan="'.($newcolspan).
'">';
163 print
'<span class="opacitymedium">'.$langs->trans(
"NoFilesUploadedYet").
'...</span>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...