FIX Position was lost when we edit the line of template invoice

This commit is contained in:
Laurent Destailleur 2019-07-21 16:15:13 +02:00
parent 932530bd37
commit 4f34a8b6e8
2 changed files with 9 additions and 7 deletions

View File

@ -774,7 +774,7 @@ if (empty($reshook))
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
$objectline = new FactureLigneRec($db); $objectline = new FactureLigneRec($db);
if ($objectline->fetch(GETPOST('lineid'))) if ($objectline->fetch(GETPOST('lineid', 'int')))
{ {
$objectline->array_options=$array_options; $objectline->array_options=$array_options;
$result=$objectline->insertExtraFields(); $result=$objectline->insertExtraFields();
@ -784,6 +784,8 @@ if (empty($reshook))
} }
} }
$position = ($objectline->rang >= 0 ? $objectline->rang : 0);
// Unset extrafield // Unset extrafield
if (is_array($extralabelsline)) if (is_array($extralabelsline))
{ {
@ -795,8 +797,8 @@ if (empty($reshook))
} }
// Define special_code for special lines // Define special_code for special lines
$special_code=GETPOST('special_code'); $special_code=GETPOST('special_code', 'int');
if (! GETPOST('qty')) $special_code=3; if (! GETPOST('qty', 'alpha')) $special_code=3;
/*$line = new FactureLigne($db); /*$line = new FactureLigne($db);
$line->fetch(GETPOST('lineid')); $line->fetch(GETPOST('lineid'));
@ -832,11 +834,11 @@ if (empty($reshook))
$error ++; $error ++;
} }
} else { } else {
$type = GETPOST('type'); $type = GETPOST('type', 'int');
$label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
// Check parameters // Check parameters
if (GETPOST('type') < 0) { if (GETPOST('type', 'int') < 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$error ++; $error ++;
} }
@ -868,7 +870,7 @@ if (empty($reshook))
0, 0,
0, 0,
$type, $type,
0, $position,
$special_code, $special_code,
$label, $label,
GETPOST('units'), GETPOST('units'),

View File

@ -66,7 +66,7 @@ $(document).ready(function(){
var fk_element = "<?php echo $fk_element; ?>"; var fk_element = "<?php echo $fk_element; ?>";
var element_id = "<?php echo $id; ?>"; var element_id = "<?php echo $id; ?>";
var filepath = "<?php echo urlencode($filepath); ?>"; var filepath = "<?php echo urlencode($filepath); ?>";
var token = "<?php echo $_SESSION["token"]; ?>"; // We use old 'token' and not 'newtoken' for such ajax call because the ajax page has the NOTOKENRENEWAL constant set. var token = "<?php echo $_SESSION["token"]; ?>"; // We use old 'token' and not 'newtoken' for Ajax call because the ajax page has the NOTOKENRENEWAL constant set.
$.post("<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php", $.post("<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php",
{ {
roworder: roworder, roworder: roworder,