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';
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
@ -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("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);
}
@ -2209,7 +2213,7 @@ else
{
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 '</a> &nbsp; ';
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'))
{
// Add line with link to add new file or attach to an existing file
$colspan = 12;
// Add line with link to add new file or attach line to an existing file
$colspan = 10;
if (! empty($conf->projet->enabled)) $colspan++;
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++;
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 img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly');
print '</a>';
@ -2355,7 +2363,9 @@ else
}
// 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;
if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++;
@ -2399,10 +2409,10 @@ else
jQuery(".trattachnewfilenow").toggle();
jQuery(".truploadnewfilenow").hide();
return false;
});';
if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array')))
});'."\n";
if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array')) && $action != 'updateline')
{
print 'jQuery(".trattachnewfilenow").toggle();'."\n";
print 'jQuery(".trattachnewfilenow").show();'."\n";
}
print '
});

View File

@ -17,35 +17,41 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '<tr class="trattachnewfilenow'.(empty($tredited)?' oddeven nohover':' '.$tredited).'"'.(! GETPOSTISSET('sendit') && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display: none"':'').'>';
print '<td colspan="'.$colspan.'">';
//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):'').'/';
$filei=0;
foreach($arrayoffiles as $file)
{
print '<div class="inline-block margintoponly marginleftonly marginrightonly center">';
$fileinfo = pathinfo($file['name']);
$urlforhref=array();
$filei++;
print '<div class="inline-block margintoponly marginleftonly marginrightonly center valigntop">';
$fileinfo = pathinfo($file['fullname']);
if (image_format_supported($file['name']) > 0)
{
$minifile=getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case however) than original
//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)) {
$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">';
} else {
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 '</div>';
print '</a>';
}
else
{
$modulepart='expensereport';
print '<a href=""><div class="photoref">';
$thumbshown=0;
$error=0;
$thumbshown='';
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'];
$fileimage = $conf->expensereport->dir_output.'/'.$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 (file_exists($fileimage))
{
$thumbshown=1;
print '<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercu'.$modulepart.'&amp;file='.urlencode($relativepathimage).'">';
$thumbshown='<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercu'.$modulepart.'&amp;file='.urlencode($relativepathimage).'">';
}
}
}
if (! $thumbshown)
{
print img_mime($minifile);
if (empty($urlforhref) || empty($thumbshown)) {
print '<a href="#" class="aphoto" target="_blank">';
} 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 '<br>';
@ -106,9 +116,19 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
$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 '<script>';
print '$(document).ready(function() {';
print "$('.checkboxattachfile').on('change', function() { $('.checkboxattachfile').not(this).prop('checked', false); });";
print '});';
print '</script>';
print '</td></tr>';
}
else

View File

@ -446,7 +446,15 @@ textarea.centpercent {
.cursornotallowed {
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); ?>
.borderrightlight

View File

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