FIX Drag and drop line of files on join files tab

This commit is contained in:
Laurent Destailleur 2022-03-07 16:04:55 +01:00
parent e9eef54b45
commit fb2fb46d17
3 changed files with 32 additions and 26 deletions

View File

@ -81,8 +81,6 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
$perm = 1;
} elseif ($table_element_line == 'facturedet_rec' && $user->rights->facture->creer) {
$perm = 1;
} elseif ($table_element_line == 'ecm_files' && $user->rights->ecm->creer) {
$perm = 1;
} elseif ($table_element_line == 'emailcollector_emailcollectoraction' && $user->admin) {
$perm = 1;
} elseif ($table_element_line == 'bom_bomline' && $user->rights->bom->write) {
@ -95,10 +93,18 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
$perm = 1;
} elseif ($table_element_line == 'facture_fourn_det' && $user->rights->fournisseur->facture->creer) {
$perm = 1;
} elseif ($table_element_line == 'ecm_files' && $fk_element == 'fk_product' && (!empty($user->rights->produit->creer) || !empty($user->rights->service->creer))) {
$perm = 1;
} elseif ($table_element_line == 'ecm_files' && $fk_element == 'fk_ticket' && !empty($user->rights->ticket->write)) {
$perm = 1;
} elseif ($table_element_line == 'ecm_files') { // Used when of page "documents.php"
if (!empty($user->rights->ecm->creer)) {
$perm = 1;
} elseif ($fk_element == 'fk_product' && (!empty($user->rights->produit->creer) || !empty($user->rights->service->creer))) {
$perm = 1;
} elseif ($fk_element == 'fk_ticket' && !empty($user->rights->ticket->write)) {
$perm = 1;
} elseif ($fk_element == 'fk_holiday' && !empty($user->rights->holiday->write)) {
$perm = 1;
} elseif ($fk_element == 'fk_soc' && !empty($user->rights->societe->creer)) {
$perm = 1;
}
} elseif ($table_element_line == 'product_association' && $fk_element == 'fk_product' && (!empty($user->rights->produit->creer) || !empty($user->rights->service->creer))) {
$perm = 1;
} elseif ($table_element_line == 'projet_task' && $fk_element == 'fk_projet' && $user->rights->projet->creer) {

View File

@ -1281,12 +1281,22 @@ class FormFile
}
print '<td></td>';
print '<td></td>';
if (!$disablemove) {
if (empty($disablemove) && count($filearray) > 1) {
print '<td></td>';
}
print "</tr>\n";
}
// Get list of files stored into database for same relative directory
if ($relativedir) {
completeFileArrayWithDatabaseInfo($filearray, $relativedir);
//var_dump($sortfield.' - '.$sortorder);
if ($sortfield && $sortorder) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
$filearray = dol_sort_array($filearray, $sortfield, $sortorder);
}
}
print '<tr class="liste_titre nodrag nodrop">';
//print $url.' sortfield='.$sortfield.' sortorder='.$sortorder;
print_liste_field_titre('Documents2', $url, "name", "", $param, '', $sortfield, $sortorder, 'left ');
@ -1299,21 +1309,11 @@ class FormFile
print_liste_field_titre('');
// Action button
print_liste_field_titre('');
if (!$disablemove) {
if (empty($disablemove) && count($filearray) > 1) {
print_liste_field_titre('');
}
print "</tr>\n";
// Get list of files stored into database for same relative directory
if ($relativedir) {
completeFileArrayWithDatabaseInfo($filearray, $relativedir);
//var_dump($sortfield.' - '.$sortorder);
if ($sortfield && $sortorder) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
$filearray = dol_sort_array($filearray, $sortfield, $sortorder);
}
}
$nboffiles = count($filearray);
if ($nboffiles > 0) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
@ -1508,18 +1508,18 @@ class FormFile
}
print "</td>";
if (empty($disablemove)) {
if (empty($disablemove) && count($filearray) > 1) {
if ($nboffiles > 1 && $conf->browser->layout != 'phone') {
print '<td class="linecolmove tdlineupdown center">';
if ($i > 0) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&rowid='.$line->id.'">'.img_up('default', 0, 'imgupforline').'</a>';
}
if ($i < $nboffiles - 1) {
if ($i < ($nboffiles - 1)) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&rowid='.$line->id.'">'.img_down('default', 0, 'imgdownforline').'</a>';
}
print '</td>';
} else {
print '<td'.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>';
print '<td'.(($conf->browser->layout != 'phone') ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>';
print '</td>';
}
}
@ -1529,7 +1529,7 @@ class FormFile
print '<input type="submit" class="button button-save" name="renamefilesave" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</td>';
if (empty($disablemove)) {
if (empty($disablemove) && count($filearray) > 1) {
print '<td class="right"></td>';
}
}
@ -1540,7 +1540,7 @@ class FormFile
}
if ($nboffiles == 0) {
$colspan = '6';
if (empty($disablemove)) {
if (empty($disablemove) && count($filearray) > 1) {
$colspan++; // 6 columns or 7
}
print '<tr class="oddeven"><td colspan="'.$colspan.'">';
@ -2030,7 +2030,7 @@ class FormFile
print '<form action="'.$_SERVER['PHP_SELF'].($param ? '?'.$param : '').'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<table width="100%" class="liste noborder nobottom">';
print '<table class="liste noborder nobottom centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre(
$langs->trans("Links"),
@ -2115,7 +2115,7 @@ class FormFile
print '<td class="right">';
print '<a href="'.$_SERVER['PHP_SELF'].'?action=update&linkid='.$link->id.$param.'&token='.newToken().'" class="editfilelink editfielda reposition" >'.img_edit().'</a>'; // id= is included into $param
if ($permissiontodelete) {
print ' &nbsp; <a class="deletefilelink" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&linkid='.$link->id.$param.'">'.img_delete().'</a>'; // id= is included into $param
print ' &nbsp; <a class="deletefilelink reposition" href="'.$_SERVER['PHP_SELF'].'?action=deletelink&token='.newToken().'&linkid='.((int) $link->id).$param.'">'.img_delete().'</a>'; // id= is included into $param
} else {
print '&nbsp;';
}

View File

@ -66,7 +66,7 @@ if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket
* Confirm form to delete a file
*/
if ($action == 'deletefile') {
if ($action == 'deletefile' || $action == 'deletelink') {
$langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles
print $form->formconfirm(
$_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOST('linkid', 'int').(empty($param) ? '' : $param),