This commit is contained in:
Laurent Destailleur 2019-04-23 15:54:24 +02:00
parent 633eb1d6c6
commit 72025f6d5d
4 changed files with 72 additions and 25 deletions

View File

@ -145,7 +145,11 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
if (GETPOST('sendit', 'alpha')) $action=''; if (GETPOSTISSET('sendit')) // If we just submit a file
{
if ($action == 'updateline') $action='editline'; // To avoid to make the updateline now
else $action=''; // To avoid to make the addline now
}
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
@ -2004,7 +2008,7 @@ else
print '<tr><td colspan="' . $nbcols . '" class="right">'.$langs->trans("AmountExpected").':</td><td class="right">'.price($object->total_ttc).'</td><td></td></tr>'; print '<tr><td colspan="' . $nbcols . '" class="right">'.$langs->trans("AmountExpected").':</td><td class="right">'.price($object->total_ttc).'</td><td></td></tr>';
print '<tr><td colspan="' . $nbcols . '" class="right">'.$langs->trans("RemainderToPay").':</td>'; print '<tr><td colspan="' . $nbcols . '" class="right">'.$langs->trans("RemainderToPay").':</td>';
print '<td align="right'.($resteapayeraffiche?' amountremaintopay':(' '.$cssforamountpaymentcomplete)).'">'.price($resteapayeraffiche).'</td><td></td></tr>'; print '<td class="right'.($resteapayeraffiche?' amountremaintopay':(' '.$cssforamountpaymentcomplete)).'">'.price($resteapayeraffiche).'</td><td></td></tr>';
$db->free($resql); $db->free($resql);
} }
@ -2209,7 +2213,7 @@ else
{ {
print '<td class="nowrap right">'; print '<td class="nowrap right">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;rowid='.$line->rowid.'#'.$line->rowid.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;rowid='.$line->rowid.'">';
print img_edit(); print img_edit();
print '</a> &nbsp; '; print '</a> &nbsp; ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete_line&amp;rowid='.$line->rowid.'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete_line&amp;rowid='.$line->rowid.'">';
@ -2224,14 +2228,18 @@ else
if ($action == 'editline' && $line->rowid == GETPOST('rowid', 'int')) if ($action == 'editline' && $line->rowid == GETPOST('rowid', 'int'))
{ {
// Add line with link to add new file or attach line to an existing file
// Add line with link to add new file or attach to an existing file $colspan = 10;
$colspan = 12;
if (! empty($conf->projet->enabled)) $colspan++; if (! empty($conf->projet->enabled)) $colspan++;
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++;
print '<tr class="tredited">'; print '<tr class="tredited">';
print '<td colspan="'.$colspan.'" class="liste_titre">';
print '<td class="center">';
print $numline;
print '</td>';
print '<td colspan="'.($colspan-1).'" class="liste_titre">';
print '<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans("UploadANewFileNow"); print '<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans("UploadANewFileNow");
print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly');
print '</a>'; print '</a>';
@ -2355,7 +2363,9 @@ else
} }
// Add a line // Add a line
if (($object->fk_statut == ExpenseReport::STATUS_DRAFT || $object->fk_statut == ExpenseReport::STATUS_REFUSED) && $action != 'editline' && $user->rights->expensereport->creer) if (($object->fk_statut == ExpenseReport::STATUS_DRAFT || $object->fk_statut == ExpenseReport::STATUS_REFUSED)
&& $action != 'editline'
&& $user->rights->expensereport->creer)
{ {
$colspan = 11; $colspan = 11;
if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++; if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++;
@ -2399,10 +2409,10 @@ else
jQuery(".trattachnewfilenow").toggle(); jQuery(".trattachnewfilenow").toggle();
jQuery(".truploadnewfilenow").hide(); jQuery(".truploadnewfilenow").hide();
return false; return false;
});'; });'."\n";
if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array'))) if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array')) && $action != 'updateline')
{ {
print 'jQuery(".trattachnewfilenow").toggle();'."\n"; print 'jQuery(".trattachnewfilenow").show();'."\n";
} }
print ' print '
}); });

View File

@ -19,33 +19,39 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
//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;
$relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/'; $relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/';
$filei=0;
foreach($arrayoffiles as $file) foreach($arrayoffiles as $file)
{ {
print '<div class="inline-block margintoponly marginleftonly marginrightonly center">'; $urlforhref=array();
$fileinfo = pathinfo($file['name']); $filei++;
print '<div class="inline-block margintoponly marginleftonly marginrightonly center valigntop">';
$fileinfo = pathinfo($file['fullname']);
if (image_format_supported($file['name']) > 0) if (image_format_supported($file['name']) > 0)
{ {
$minifile=getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case however) than original $minifile=getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case however) than original
//print $file['path'].'/'.$minifile.'<br>'; //print $file['path'].'/'.$minifile.'<br>';
$urlforhref=getAdvancedPreviewUrl($modulepart, $fileinfo['relativename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity));
if (empty($urlforhref)) { if (empty($urlforhref)) {
$urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($fileinfo['relativename'].'.'.strtolower($fileinfo['extension'])); $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($fileinfo['relativename'].'.'.strtolower($fileinfo['extension']));
print '<a href="'.$urlforhref.'" class="aphoto" target="_blank">'; print '<a href="'.$urlforhref.'" class="aphoto" target="_blank">';
} 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 '<div class="photoref">'; print '<div class="photoref backgroundblank">';
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 '<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 '</div>';
print '</a>'; print '</a>';
} }
else else
{ {
$modulepart='expensereport'; $error=0;
print '<a href=""><div class="photoref">'; $thumbshown='';
$thumbshown=0;
if (preg_match('/\.pdf$/i', $file['name'])) 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']; $filepdf = $conf->expensereport->dir_output.'/'.$relativepath.$file['name'];
$fileimage = $conf->expensereport->dir_output.'/'.$relativepath.$file['name'].'_preview.png'; $fileimage = $conf->expensereport->dir_output.'/'.$relativepath.$file['name'].'_preview.png';
$relativepathimage = $relativepath.$file['name'].'_preview.png'; $relativepathimage = $relativepath.$file['name'].'_preview.png';
@ -73,16 +79,20 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
// If the preview file is found // If the preview file is found
if (file_exists($fileimage)) if (file_exists($fileimage))
{ {
$thumbshown=1; $thumbshown='<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercu'.$modulepart.'&amp;file='.urlencode($relativepathimage).'">';
print '<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercu'.$modulepart.'&amp;file='.urlencode($relativepathimage).'">';
} }
} }
} }
if (! $thumbshown) if (empty($urlforhref) || empty($thumbshown)) {
{ print '<a href="#" class="aphoto" target="_blank">';
print img_mime($minifile); } else {
print '<a href="'.$urlforhref['url'].'" class="'.$urlforhref['css'].'" target="'.$urlforhref['target'].'" mime="'.$urlforhref['mime'].'">';
} }
print '<div class="photoref backgroundblank">';
print $thumbshown ? $thumbshown : img_mime($minifile);
print '</div></a>'; print '</div></a>';
} }
print '<br>'; print '<br>';
@ -106,9 +116,19 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{ {
$checked=' checked'; $checked=' checked';
} }
print '<div class="margintoponly"><input type="radio"'.$checked.' name="attachfile[]" value="'.$file['relativename'].'"> '.$file['relativename'].'</div>'; print '<div class="margintoponly maxwidth150"><input type="checkbox"'.$checked.' id="radio'.$filei.'" name="attachfile[]" class="checkboxattachfile" value="'.$file['relativename'].'">';
print '<label class="wordbreak checkboxattachfilelabel" for="radio'.$filei.'"> '.$file['relativename'].'</label>';
print '</div>';
print '</div>'; print '</div>';
} }
print '<script>';
print '$(document).ready(function() {';
print "$('.checkboxattachfile').on('change', function() { $('.checkboxattachfile').not(this).prop('checked', false); });";
print '});';
print '</script>';
print '</td></tr>'; print '</td></tr>';
} }
else else

View File

@ -446,7 +446,15 @@ textarea.centpercent {
.cursornotallowed { .cursornotallowed {
cursor: not-allowed; cursor: not-allowed;
} }
.backgroundblank {
background-color: #fff;
}
.checkboxattachfilelabel {
font-size: 0.85em;
opacity: 0.7;
}
/* Themes for badges */
<?php include dol_buildpath($path.'/theme/'.$theme.'/badges.inc.php', 0); ?> <?php include dol_buildpath($path.'/theme/'.$theme.'/badges.inc.php', 0); ?>
.borderrightlight .borderrightlight

View File

@ -659,6 +659,15 @@ textarea.centpercent {
.cursornotallowed { .cursornotallowed {
cursor: not-allowed; cursor: not-allowed;
} }
.backgroundblank {
background-color: #fff;
}
.checkboxattachfilelabel {
font-size: 0.85em;
opacity: 0.7;
}
/* Themes for badges */
.badge { .badge {
display: inline-block; display: inline-block;
min-width: 10px; min-width: 10px;