WIP file attachment on expense report lines
This commit is contained in:
parent
5ff76e2c13
commit
fad6efd86c
@ -1828,19 +1828,18 @@ function deleteFilesIntoDatabaseIndex($dir, $file, $mode = 'uploaded')
|
|||||||
function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '')
|
function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
if (class_exists('Imagick'))
|
if (class_exists('Imagick'))
|
||||||
{
|
{
|
||||||
$image=new Imagick();
|
$image=new Imagick();
|
||||||
try {
|
try {
|
||||||
$ret = $image->readImage($fileinput);
|
$ret = $image->readImage($fileinput);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
dol_syslog("Failed to read image using Imagick. Try to install package 'apt-get install ghostscript'.", LOG_WARNING);
|
dol_syslog("Failed to read image using Imagick (Try to install package 'apt-get install ghostscript'): ".$e->getMessage(), LOG_WARNING);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ($ret)
|
if ($ret)
|
||||||
{
|
{
|
||||||
$ret = $image->setImageFormat($ext);
|
$ret = $image->setImageFormat($ext);
|
||||||
if ($ret)
|
if ($ret)
|
||||||
{
|
{
|
||||||
if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext;
|
if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext;
|
||||||
|
|||||||
@ -1390,7 +1390,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
|
|||||||
$fileimagebis = $file.'_preview-0.png'; // If PDF has more than one page
|
$fileimagebis = $file.'_preview-0.png'; // If PDF has more than one page
|
||||||
$relativepathimage = $relativepath.'_preview.png';
|
$relativepathimage = $relativepath.'_preview.png';
|
||||||
|
|
||||||
// Si fichier PDF existe
|
// If PDF file exists
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$encfile = urlencode($file);
|
$encfile = urlencode($file);
|
||||||
@ -1399,7 +1399,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
|
|||||||
&& (! file_exists($fileimagebis) || (filemtime($fileimagebis) < filemtime($file)))
|
&& (! file_exists($fileimagebis) || (filemtime($fileimagebis) < filemtime($file)))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
|
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';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
$ret = dol_convert_file($file, 'png', $fileimage);
|
$ret = dol_convert_file($file, 'png', $fileimage);
|
||||||
@ -1428,7 +1428,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
|
|||||||
}
|
}
|
||||||
elseif (! $phototoshow)
|
elseif (! $phototoshow)
|
||||||
{
|
{
|
||||||
$phototoshow = $form->showphoto($modulepart, $object, 0, 0, 0, 'photoref', 'small', 1, 0, $maxvisiblephotos);
|
$phototoshow.= $form->showphoto($modulepart, $object, 0, 0, 0, 'photoref', 'small', 1, 0, $maxvisiblephotos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($phototoshow)
|
if ($phototoshow)
|
||||||
@ -1441,7 +1441,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
|
|||||||
|
|
||||||
if (! $phototoshow) // Show No photo link (picto of pbject)
|
if (! $phototoshow) // Show No photo link (picto of pbject)
|
||||||
{
|
{
|
||||||
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">';
|
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">';
|
||||||
if ($object->element == 'action')
|
if ($object->element == 'action')
|
||||||
{
|
{
|
||||||
$width=80;
|
$width=80;
|
||||||
@ -7336,13 +7336,6 @@ function printCommonFooter($zone = 'private')
|
|||||||
if (! empty($user->rights->debugbar->read) && is_object($debugbar))
|
if (! empty($user->rights->debugbar->read) && is_object($debugbar))
|
||||||
{
|
{
|
||||||
$debugbar['time']->stopMeasure('pageaftermaster');
|
$debugbar['time']->stopMeasure('pageaftermaster');
|
||||||
|
|
||||||
/*foreach($conf->logbuffer as $logline)
|
|
||||||
{
|
|
||||||
//print $logline."<br>\n";
|
|
||||||
//$debugbar['log']->addMessage($logline, 'ERR', false);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
print '<!-- Output debugbar data -->'."\n";
|
print '<!-- Output debugbar data -->'."\n";
|
||||||
print $debugbar->getRenderer()->render();
|
print $debugbar->getRenderer()->render();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -203,6 +203,7 @@ class DolLogsCollector extends MessagesCollector
|
|||||||
$class = new ReflectionClass(new LogLevel());
|
$class = new ReflectionClass(new LogLevel());
|
||||||
$levels = $class->getConstants();
|
$levels = $class->getConstants();
|
||||||
$levels['ERR'] = 'error';
|
$levels['ERR'] = 'error';
|
||||||
|
$levels['WARN'] = 'warning';
|
||||||
|
|
||||||
return $levels;
|
return $levels;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2282,10 +2282,12 @@ else
|
|||||||
print '$(document).ready(function() {
|
print '$(document).ready(function() {
|
||||||
$( ".auploadnewfilenow" ).click(function() {
|
$( ".auploadnewfilenow" ).click(function() {
|
||||||
jQuery(".truploadnewfilenow").toggle();
|
jQuery(".truploadnewfilenow").toggle();
|
||||||
|
jQuery(".trattachnewfilenow").hide();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$( ".aattachtodoc" ).click(function() {
|
$( ".aattachtodoc" ).click(function() {
|
||||||
jQuery(".trattachnewfilenow").toggle();
|
jQuery(".trattachnewfilenow").toggle();
|
||||||
|
jQuery(".truploadnewfilenow").hide();
|
||||||
return false;
|
return false;
|
||||||
});';
|
});';
|
||||||
if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array')))
|
if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array')))
|
||||||
@ -2299,14 +2301,12 @@ else
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Add line to upload new file
|
// Add line to upload new file
|
||||||
print '<tr class="oddeven truploadnewfilenow"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display: none"':'').'>';
|
print '<tr class="oddeven nohover truploadnewfilenow"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display: none"':'').'>';
|
||||||
print '<td colspan="'.$colspan.'">';
|
print '<td colspan="'.$colspan.'">';
|
||||||
|
|
||||||
$modulepart = 'expensereport';
|
$modulepart = 'expensereport';
|
||||||
$permission = $user->rights->expensereport->creer;
|
$permission = $user->rights->expensereport->creer;
|
||||||
|
|
||||||
$formfile=new FormFile($db);
|
|
||||||
|
|
||||||
// We define var to enable the feature to add prefix of uploaded files
|
// We define var to enable the feature to add prefix of uploaded files
|
||||||
$savingdocmask='';
|
$savingdocmask='';
|
||||||
if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX))
|
if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX))
|
||||||
@ -2351,7 +2351,7 @@ else
|
|||||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||||
if ($nbFiles >= 0)
|
if ($nbFiles >= 0)
|
||||||
{
|
{
|
||||||
print '<tr class="oddeven trattachnewfilenow"'.(! GETPOSTISSET('sendit') && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display: none"':'').'>';
|
print '<tr class="oddeven nohover trattachnewfilenow"'.(! GETPOSTISSET('sendit') && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display: none"':'').'>';
|
||||||
print '<td colspan="'.$colspan.'">';
|
print '<td colspan="'.$colspan.'">';
|
||||||
//print '<span class="opacitymedium">'.$langs->trans("AttachTheNewLineToTheDocument").'</span><br>';
|
//print '<span class="opacitymedium">'.$langs->trans("AttachTheNewLineToTheDocument").'</span><br>';
|
||||||
$modulepart='expensereport';$maxheightmini=48;
|
$modulepart='expensereport';$maxheightmini=48;
|
||||||
@ -2372,10 +2372,18 @@ else
|
|||||||
} else {
|
} else {
|
||||||
print '<a href="'.$urlforhref['url'].'" class="'.$urlforhref['css'].'" target="'.$urlforhref['target'].'" mime="'.$urlforhref['mime'].'">';
|
print '<a href="'.$urlforhref['url'].'" class="'.$urlforhref['css'].'" target="'.$urlforhref['target'].'" mime="'.$urlforhref['mime'].'">';
|
||||||
}
|
}
|
||||||
print '<img class="photo" height="'.$maxheightmini.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$minifile).'" title="">';
|
print '<div class="photoref">';
|
||||||
|
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="">';
|
||||||
|
print '</div>';
|
||||||
print '</a>';
|
print '</a>';
|
||||||
}
|
}
|
||||||
else print ' ';
|
else
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
print '</div></a>';
|
||||||
|
}
|
||||||
print '<br>';
|
print '<br>';
|
||||||
$checked='';
|
$checked='';
|
||||||
//var_dump(GETPOST($file['relativename'])); var_dump($file['relativename']); var_dump($_FILES['userfile']['name']);
|
//var_dump(GETPOST($file['relativename'])); var_dump($file['relativename']); var_dump($_FILES['userfile']['name']);
|
||||||
@ -2391,7 +2399,7 @@ else
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '<input type="checkbox"'.$checked.' name="attachfile[]" value="'.$file['relativename'].'"> '.$file['relativename'];
|
print '<div class="margintoponly"><input type="checkbox"'.$checked.' name="attachfile[]" value="'.$file['relativename'].'"> '.$file['relativename'].'</div>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user