Debug v20 - Fix roworder of stocktransfer

This commit is contained in:
Laurent Destailleur 2024-08-02 14:07:43 +02:00
parent fc2bf8134f
commit f4d841c807
2 changed files with 22 additions and 6 deletions

View file

@ -57,6 +57,7 @@ $roworder = GETPOST('roworder', 'alpha', 3);
$table_element_line = GETPOST('table_element_line', 'aZ09', 3);
$fk_element = GETPOST('fk_element', 'aZ09', 3);
$element_id = GETPOSTINT('element_id', 3);
$action = 'edit';
// Security check
@ -120,6 +121,8 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
$perm = 1;
} elseif ($table_element_line == 'contratdet' && $fk_element == 'fk_contrat' && $user->hasRight('contrat', 'creer')) {
$perm = 1;
} elseif ($table_element_line == 'stocktransfer_stocktransferline' && $fk_element == 'fk_stocktransfer' && $user->hasRight('stocktransfer', 'stocktransfer', 'write')) {
$perm = 1;
} else {
$tmparray = explode('_', $table_element_line);
$tmpmodule = $tmparray[0];
@ -128,6 +131,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
$perm = 1;
}
}
// Overwrite $perm by hook
$parameters = array('roworder' => &$roworder, 'table_element_line' => &$table_element_line, 'fk_element' => &$fk_element, 'element_id' => &$element_id, 'perm' => &$perm);
$row = new GenericObject($db);
$row->table_element_line = $table_element_line;
@ -137,12 +141,14 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
if ($reshook > 0) {
$perm = $hookmanager->resArray['perm'];
}
if (! $perm) {
// We should not be here. If we are not allowed to reorder rows, feature should not be visible on script.
// If we are here, it is a hack attempt, so we report a warning.
print 'Bad permission to modify position of lines for object in table '.$table_element_line;
dol_syslog('Bad permission to modify position of lines for object in table='.$table_element_line.', fk_element='.$fk_element, LOG_WARNING);
accessforbidden('Bad permission to modify position of lines for object in table '.$table_element_line);
//accessforbidden('Bad permission to modify position of lines for object in table '.$table_element_line);
httponly_accessforbidden('Bad permission to modify position of lines for object in table '.$table_element_line);
}
$rowordertab = explode(',', $roworder);

View file

@ -844,21 +844,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</td>';
}
print '<td>';
// Warehouse source
print '<td class="tdoverflowmax150">';
if ($action === 'editline' && $line->id == $lineid) {
print $formproduct->selectWarehouses($line->fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200');
} else {
print $warehousestatics->getNomUrl(1);
}
print '</td>';
print '<td>';
// Warehouse target
print '<td class="tdoverflowmax150">';
if ($action === 'editline' && $line->id == $lineid) {
print $formproduct->selectWarehouses($line->fk_warehouse_destination, 'fk_warehouse_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200');
} else {
print $warehousestatict->getNomUrl(1);
}
print '</td>';
if ($action === 'editline' && $line->id == $lineid) {
print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$line->qty.'"></td>';
} else {
@ -877,9 +880,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="center">';
print price($line->pmp, 0, '', 1, -1, -1, $conf->currency);
print '</td>';
print '<td class="center">';
print price($line->pmp * $line->qty, 0, '', 1, -1, -1, $conf->currency);
print '</td>';
if (empty($object->status) && $permissiontoadd) {
if ($action === 'editline' && $line->id == $lineid) {
//print '<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' . dol_escape_htmltag($langs->trans('Save')) . '"></td>';
@ -967,14 +972,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
}
// On vide le tableau pour qu'il se charge tout seul lors de l'appel à la fonction select_warehouses
// We clean array. It is filled automatically when calling function select_warehouses
$formproduct->cache_warehouses = array();
// In warehouse
print '<td>';
print $formproduct->selectWarehouses(empty($fk_warehouse_source) ? $object->fk_warehouse_source : $fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseSource);
print '</td>';
// On vide le tableau pour qu'il se charge tout seul lors de l'appel à la fonction select_warehouses
// We clean array. It is filled automatically when calling function select_warehouses
$formproduct->cache_warehouses = array();
// Out warehouse
print '<td>';
@ -983,18 +988,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Qty
print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ? 'value="'.$qty.'"' : '').'></td>';
// PMP
print '<td></td>';
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
// Unité
print '<td></td>';
}
// PMP * Qty
print '<td></td>';
// Button to add line
print '<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' . dol_escape_htmltag($langs->trans('Add')) . '"></td>';
// Grad and drop lines
print '<td></td>';
print '</tr>';
}