From 4f34a8b6e84aaf8ede4e4b4ceee96769b01a7964 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Jul 2019 16:15:13 +0200 Subject: [PATCH] FIX Position was lost when we edit the line of template invoice --- htdocs/compta/facture/fiche-rec.php | 14 ++++++++------ htdocs/core/tpl/ajaxrow.tpl.php | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index dd4a2af11ee..9b50e782454 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -774,7 +774,7 @@ if (empty($reshook)) $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); $objectline = new FactureLigneRec($db); - if ($objectline->fetch(GETPOST('lineid'))) + if ($objectline->fetch(GETPOST('lineid', 'int'))) { $objectline->array_options=$array_options; $result=$objectline->insertExtraFields(); @@ -784,6 +784,8 @@ if (empty($reshook)) } } + $position = ($objectline->rang >= 0 ? $objectline->rang : 0); + // Unset extrafield if (is_array($extralabelsline)) { @@ -795,8 +797,8 @@ if (empty($reshook)) } // Define special_code for special lines - $special_code=GETPOST('special_code'); - if (! GETPOST('qty')) $special_code=3; + $special_code=GETPOST('special_code', 'int'); + if (! GETPOST('qty', 'alpha')) $special_code=3; /*$line = new FactureLigne($db); $line->fetch(GETPOST('lineid')); @@ -832,11 +834,11 @@ if (empty($reshook)) $error ++; } } else { - $type = GETPOST('type'); + $type = GETPOST('type', 'int'); $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); // Check parameters - if (GETPOST('type') < 0) { + if (GETPOST('type', 'int') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); $error ++; } @@ -868,7 +870,7 @@ if (empty($reshook)) 0, 0, $type, - 0, + $position, $special_code, $label, GETPOST('units'), diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index 071db6a82ee..0b92df1e519 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -66,7 +66,7 @@ $(document).ready(function(){ var fk_element = ""; var element_id = ""; var filepath = ""; - var token = ""; // We use old 'token' and not 'newtoken' for such ajax call because the ajax page has the NOTOKENRENEWAL constant set. + var token = ""; // We use old 'token' and not 'newtoken' for Ajax call because the ajax page has the NOTOKENRENEWAL constant set. $.post("/core/ajax/row.php", { roworder: roworder,