From 76ee014b52f005433c37e4f6b388e0743e659df4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Sep 2021 16:32:32 +0200 Subject: [PATCH] Fix add a hidden solution to fix a corrupted value for AWP. --- htdocs/product/class/product.class.php | 1 - htdocs/product/fournisseurs.php | 42 +++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bb80dcba862..d746bf4a812 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1008,7 +1008,6 @@ class Product extends CommonObject $this->accountancy_code_sell_export = trim($this->accountancy_code_sell_export); - $this->db->begin(); $result = 0; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 96c7cf5f8c3..9aaa0aa2c8c 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2021 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2012 Juanjo Menent @@ -54,7 +54,9 @@ $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'pricesuppliercard'; $socid = GETPOST('socid', 'int'); -$cost_price = GETPOST('cost_price', 'alpha'); +$cost_price = price2num(GETPOST('cost_price', 'alpha'), '', 2); +$pmp = price2num(GETPOST('pmp', 'alpha'), '', 2); + $backtopage = GETPOST('backtopage', 'alpha'); $error = 0; @@ -147,13 +149,29 @@ if (empty($reshook)) { } } } + if ($action == 'setpmp') { + if ($id) { + $result = $object->fetch($id); + $object->pmp = price2num($pmp); + $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".((float) $object->pmp)." WHERE rowid = ".((int) $id); + $resql = $db->query($sql); + //$result = $object->update($object->id, $user); + if ($resql) { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + $action = ''; + } else { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } if ($action == 'confirm_remove_pf') { if ($rowid) { // id of product supplier price to remove $action = ''; $result = $object->remove_product_fournisseur_price($rowid); if ($result > 0) { - $db->query("DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = $rowid"); + $db->query("DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = ".((int) $rowid)); setEventMessages($langs->trans("PriceRemoved"), null, 'mesgs'); } else { $error++; @@ -425,11 +443,25 @@ if ($id > 0 || $ref) { print ''; // PMP - print ''.$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).''; + $usercaneditpmp = 0; + if (!empty($conf->global->PRODUCT_CAN_EDIT_WAP)) { + $usercaneditpmp = $usercancreate; + } + print ''; + $textdesc = $langs->trans("AverageUnitPricePMPDesc"); + $text = $form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $textdesc, 1, 'help', ''); + print $form->editfieldkey($text, 'pmp', $object->pmp, $object, $usercaneditpmp, 'amount:6'); + print ''; + print $form->editfieldval($text, 'pmp', ($object->pmp > 0 ? $object->pmp : ''), $object, $usercaneditpmp, 'amount:6'); + if ($object->pmp > 0) { + print ' '.$langs->trans("HT"); + } + /* + .$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).''; print ''; if ($object->pmp > 0) { print price($object->pmp).' '.$langs->trans("HT"); - } + }*/ print ''; print '';