From a7f3946d2ba4eeea16e9e749be9b8387a6b66cad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Sep 2024 21:36:17 +0200 Subject: [PATCH 1/7] FIX #31152 --- htdocs/bom/tpl/objectline_create.tpl.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index e55b3c3f83e..aee58884f20 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -185,10 +185,12 @@ if ($filtertype != 1) { print $formproduct->selectMeasuringUnits("fk_unit", "time", $fk_unit_default, 1); print ''; - $coldisplay++; - print ''; - print $formproduct->selectWorkstations('', 'idworkstations', 1); - print ''; + if (isModEnabled('workstation')) { + $coldisplay++; + print ''; + print $formproduct->selectWorkstations('', 'idworkstations', 1); + print ''; + } $coldisplay++; print ''; From 1ee85e5483c70209960d7d03fcd53fe64466db0f Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sat, 28 Sep 2024 12:11:29 +0200 Subject: [PATCH 2/7] Improve new hook afterPDFTotalTable to have posy parameter (#31168) * Improve new hook afterPDFTotalTable to have posy parameter * Also for other model --- htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_octopus.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 2 +- .../core/modules/supplier_invoice/doc/pdf_canelle.modules.php | 2 +- htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index e676722961a..de6d3b05f39 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1355,7 +1355,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index ff76527981e..c958a8549c9 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -1908,7 +1908,7 @@ class pdf_octopus extends ModelePDFFactures $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index c89ea0ef4d9..6466aaa298e 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1999,7 +1999,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index a0cf113f85e..6b75bc4663a 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1432,7 +1432,7 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 526490336d9..6eaafca28db 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -817,7 +817,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 570c8c11f54..a32a6325def 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1106,7 +1106,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetTextColor(0, 0, 0); } - $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index); + $parameters = array('pdf' => &$pdf, 'object' => &$object, 'outputlangs' => $outputlangs, 'index' => &$index, 'posy' => $posy); $reshook = $hookmanager->executeHooks('afterPDFTotalTable', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { From dfd18ef9f74cda6d5079d2a2b573c1a480bdb279 Mon Sep 17 00:00:00 2001 From: atm-adrien <67913809+atm-adrien@users.noreply.github.com> Date: Sat, 28 Sep 2024 12:22:30 +0200 Subject: [PATCH 3/7] FIX : Wrong price for BOM with warkstation (#31142) * FIX : Wrong price for BOM with warkstation * FIX : PR returns --- htdocs/bom/tpl/objectline_view.tpl.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index b03d488e1b0..1bf02f13cad 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -184,6 +184,12 @@ if ($filtertype != 1) { print ''; $coldisplay++; if ($res > 0) { + $unit = new CUnits($object->db); + $fk_defaultUnit = $unit->getUnitFromCode('h', 'short_label', 'time'); + $nbPlannedHour = $unit->unitConverter($line->qty, $line->fk_unit, $fk_defaultUnit); + $line->total_cost = 0; + if ($workstation->thm_machine_estimated) $line->total_cost += $nbPlannedHour * $workstation->thm_machine_estimated; + if ($workstation->thm_operator_estimated) $line->total_cost += $nbPlannedHour * $workstation->thm_operator_estimated; echo $workstation->getNomUrl(1); } print ''; @@ -192,6 +198,7 @@ if ($filtertype != 1) { // Cost $total_cost = 0; + $tmpbom->calculateCosts(); print ''; $coldisplay++; From a69022a3bb711321fb990c38c420e48a71bf64c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 Sep 2024 05:32:27 +0200 Subject: [PATCH 4/7] FIX Debug calculation of the delay of purchase order --- .../class/fournisseur.commande.class.php | 15 ++++++++------- .../fourn/class/fournisseur.product.class.php | 19 ++++++++++--------- htdocs/langs/en_US/suppliers.lang | 2 +- htdocs/langs/fr_FR/suppliers.lang | 2 +- htdocs/product/price_suppliers.php | 2 +- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index eef701fb00d..17d6dbeb749 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3375,16 +3375,17 @@ class CommandeFournisseur extends CommonOrder return ''; } - $obj = new ProductFournisseur($this->db); + $tmpproductfourn = new ProductFournisseur($this->db); $nb = 0; foreach ($this->lines as $line) { if ($line->fk_product > 0) { - $idp = $obj->find_min_price_product_fournisseur($line->fk_product, $line->qty); - if ($idp) { - $obj->fetch($idp); - if ($obj->delivery_time_days > $nb) { - $nb = $obj->delivery_time_days; + // Load delivery_time_days, return id into product_fournisseur_price + $idp = $tmpproductfourn->find_min_price_product_fournisseur($line->fk_product, $line->qty, $this->thirdparty->id); + if ($idp > 0) { + //$tmpproductfourn->fetch_product_fournisseur_price($idp); + if ($tmpproductfourn->delivery_time_days > $nb) { + $nb = $tmpproductfourn->delivery_time_days; } } } @@ -3393,7 +3394,7 @@ class CommandeFournisseur extends CommonOrder if ($nb === 0) { return ''; } else { - return $nb.' '.$langs->trans('Days'); + return $nb.' '.$langs->trans('days'); } } diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index a08f43fd365..089bfbefdb5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -671,7 +671,7 @@ class ProductFournisseur extends Product /** * Loads the price information of a provider * - * @param int $rowid Line id + * @param int $rowid Line id in product_fournisseur_price * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead * @return int Return integer < 0 if KO, 0 if OK but not found, > 0 if OK */ @@ -883,15 +883,13 @@ class ProductFournisseur extends Product * * @param int $prodid Product id * @param float $qty Minimum quantity - * @param int $socid get min price for specific supplier + * @param int $socid Load min price for this specific supplier * @return int Return integer <0 if KO, 0=Not found of no product id provided, >0 if OK * @see list_product_fournisseur_price() */ public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) { // phpcs:enable - global $conf; - if (empty($prodid)) { dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING); return 0; @@ -919,8 +917,8 @@ class ProductFournisseur extends Product $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; - $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; - $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; + $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; + $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql .= " WHERE s.entity IN (".getEntity('societe').")"; $sql .= " AND pfp.entity IN (".getEntity('productsupplierprice').")"; @@ -977,7 +975,9 @@ class ProductFournisseur extends Product $fourn_unitprice_with_discount = $fourn_unitprice * (1 - $record["remise_percent"] / 100); } } + if ($fourn_unitprice < $min || $min == -1) { + $this->id = $prodid; $this->product_fourn_price_id = $record["product_fourn_price_id"]; $this->ref_supplier = $record["ref_fourn"]; $this->ref_fourn = $record["ref_fourn"]; // deprecated @@ -990,23 +990,24 @@ class ProductFournisseur extends Product $this->fourn_unitprice_with_discount = $fourn_unitprice_with_discount; $this->fourn_charges = $record["charges"]; // when getDolGlobalString('PRODUCT_CHARGES') is set $this->fourn_tva_tx = $record["tva_tx"]; - $this->fourn_id = $record["fourn_id"]; + $this->fourn_id = $record["fourn_id"]; // thirdparty id $this->fourn_name = $record["supplier_name"]; $this->delivery_time_days = $record["delivery_time_days"]; $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $this->id = $prodid; $this->fourn_multicurrency_price = $record["multicurrency_price"]; $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; $this->fourn_multicurrency_tx = $record["multicurrency_tx"]; $this->fourn_multicurrency_id = $record["fk_multicurrency"]; $this->fourn_multicurrency_code = $record["multicurrency_code"]; + $min = $fourn_unitprice; } } } $this->db->free($resql); - return 1; + + return $this->product_fourn_price_id; } else { $this->error = $this->db->error(); return -1; diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index 156730ab5aa..96e98f98df8 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -36,7 +36,7 @@ ListOfSupplierProductForSupplier=List of products and prices for vendor %s%s SentToSuppliers=Envoyés aux fournisseurs ListOfSupplierOrders=Liste des commandes fournisseurs MenuOrdersSupplierToBill=Commandes fournisseurs en facture -NbDaysToDelivery=Délai de livraison en jours +NbDaysToDelivery=Délai de livraison DescNbDaysToDelivery=Le plus gros délai de livraison parmi les produits de cette commande SupplierReputation=Réputation du fournisseur ReferenceReputation=Réputation diff --git a/htdocs/product/price_suppliers.php b/htdocs/product/price_suppliers.php index 22c300ce5b9..2f0c7deba4d 100644 --- a/htdocs/product/price_suppliers.php +++ b/htdocs/product/price_suppliers.php @@ -792,7 +792,7 @@ if ($id > 0 || $ref) { // Delivery delay in days print ''; print ''.$langs->trans('NbDaysToDelivery').''; - print ' '.$langs->trans('days').''; + print ' '.$langs->trans('days').''; print ''; // Reputation From 231fc6ce707925f9ea5c9156b65287b98b44131d Mon Sep 17 00:00:00 2001 From: Florian Mortgat <50440633+atm-florianm@users.noreply.github.com> Date: Sun, 29 Sep 2024 15:27:24 +0200 Subject: [PATCH 5/7] FIX: if you call fetchLines several times, your $object->lines contains duplicates (#31167) --- htdocs/core/class/commonobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 547a6029e40..4182c05dde7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9297,6 +9297,7 @@ abstract class CommonObject if ($resql) { $num_rows = $this->db->num_rows($resql); $i = 0; + $this->lines = array(); while ($i < $num_rows) { $obj = $this->db->fetch_object($resql); if ($obj) { From 74b67eb6c6c1274d6e0a8385b3b3a3a375da4875 Mon Sep 17 00:00:00 2001 From: Florian Mortgat <50440633+atm-florianm@users.noreply.github.com> Date: Sun, 29 Sep 2024 15:57:05 +0200 Subject: [PATCH 6/7] FIX - use price() to display qty on a product's stats tab to avoid showing too many decimals when rounding errors are possible (#31165) --- htdocs/core/lib/product.lib.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index f54f39b20f3..003ab66ad2f 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -363,7 +363,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_propale['nb']; print ''; - print $product->stats_propale['qty']; + print price($product->stats_propale['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -381,7 +381,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_proposal_supplier['nb']; print ''; - print $product->stats_proposal_supplier['qty']; + print price($product->stats_proposal_supplier['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -399,7 +399,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_commande['nb']; print ''; - print $product->stats_commande['qty']; + print price($product->stats_commande['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -417,7 +417,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_commande_fournisseur['nb']; print ''; - print $product->stats_commande_fournisseur['qty']; + print price($product->stats_commande_fournisseur['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -435,7 +435,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_facture['nb']; print ''; - print $product->stats_facture['qty']; + print price($product->stats_facture['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -453,7 +453,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_facture_fournisseur['nb']; print ''; - print $product->stats_facture_fournisseur['qty']; + print price($product->stats_facture_fournisseur['qty'], 1, $langs, 0, 0); print ''; print ''; } @@ -472,7 +472,7 @@ function show_stats_for_company($product, $socid) print ''; print $product->stats_contrat['nb']; print ''; - print $product->stats_contrat['qty']; + print price($product->stats_contrat['qty'], 1, $langs, 0, 0); print ''; print ''; } From 385927fe069eace69544fef6fa0d8cb3b2395123 Mon Sep 17 00:00:00 2001 From: Florian Mortgat <50440633+atm-florianm@users.noreply.github.com> Date: Sun, 29 Sep 2024 22:18:18 +0200 Subject: [PATCH 7/7] FIX: box_actions.php still uses fk_user_done which no longer exists (#31190) Co-authored-by: FlorianMortgat <5845502+FlorianMortgat@users.noreply.github.com> --- htdocs/core/boxes/box_actions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index 64a2314560c..1d2f03b11b5 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -106,7 +106,7 @@ class box_actions extends ModeleBoxes $sql .= " AND s.rowid = ".((int) $user->socid); } if (!$user->rights->agenda->allactions->read) { - $sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id).")"; + $sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id).")"; } $sql .= " ORDER BY a.datec DESC"; $sql .= $this->db->plimit($max, 0);