From 0ad68c180d2b27672e2ede014f9b76700d3737ef Mon Sep 17 00:00:00 2001 From: bahfir abbes Date: Sun, 15 Mar 2020 21:49:35 +0100 Subject: [PATCH 1/5] fix:Show units of products in stocks and hide total units if content is of diffents units --- htdocs/product/stock/card.php | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index d0a1fc5db76..b9a5c430b92 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -509,6 +509,7 @@ else print_liste_field_titre("Product", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Label", "", "p.label", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Units", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + if(!empty($conf->global->PRODUCT_USE_UNITS)) print_liste_field_titre("Unit","", "p.fk_unit","&id=".$id,"",'align="left"',$sortfield,$sortorder); print_liste_field_titre("AverageUnitPricePMPShort", "", "p.pmp", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("EstimatedStockValueShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); if (empty($conf->global->PRODUIT_MULTIPRICES)) { @@ -530,6 +531,7 @@ else $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; $sql .= " ps.reel as value"; + if(!empty($conf->global->PRODUCT_USE_UNITS)) $sql.= ",fk_unit"; $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE ps.fk_product = p.rowid"; $sql .= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) @@ -573,6 +575,7 @@ else $productstatic->type = $objp->type; $productstatic->entity = $objp->entity; $productstatic->status_batch = $objp->tobatch; + $productstatic->fk_unit=$objp->fk_unit; print $productstatic->getNomUrl(1, 'stock', 16); print ''; @@ -585,6 +588,13 @@ else print ''; $totalunit += $objp->value; + if(!empty($conf->global->PRODUCT_USE_UNITS)) { + // Units + print ''; + if(is_null($productstatic->fk_unit))$productstatic->fk_unit=1; + print $langs->trans($productstatic->getLabelOfUnit()); + print ''; + } // Price buy PMP print ''.price(price2num($objp->ppmp, 'MU')).''; @@ -620,15 +630,24 @@ else print ""; } - print ""; - $i++; - } - $db->free($resql); + if ($user->rights->stock->creer) { + print ''; + print $langs->trans("StockCorrection"); + print ""; + } + if(!empty($conf->global->PRODUCT_USE_UNITS)) { + if ($i == 0) $units = $productstatic->fk_unit; + elseif($productstatic->fk_unit !== $units) $sameunits = false; + } + print ""; + $i++; + } + $db->free($resql); print ''.$langs->trans("Total").''; - print ''; - $valtoshow = price2num($totalunit, 'MS'); - print empty($valtoshow) ? '0' : $valtoshow; + print ''; + $valtoshow=price2num($totalunit, 'MS'); + if(empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) print empty($valtoshow)?'0':$valtoshow; print ''; print ' '; print ''.price(price2num($totalvalue, 'MT')).''; From 1f83e5ac5485878e6dcf54717fc82e7902fa2b96 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 15 Mar 2020 21:30:46 +0000 Subject: [PATCH 2/5] Fixing style errors. --- htdocs/product/stock/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index b9a5c430b92..47d8775b163 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -509,7 +509,7 @@ else print_liste_field_titre("Product", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Label", "", "p.label", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Units", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); - if(!empty($conf->global->PRODUCT_USE_UNITS)) print_liste_field_titre("Unit","", "p.fk_unit","&id=".$id,"",'align="left"',$sortfield,$sortorder); + if(!empty($conf->global->PRODUCT_USE_UNITS)) print_liste_field_titre("Unit", "", "p.fk_unit", "&id=".$id, "", 'align="left"', $sortfield, $sortorder); print_liste_field_titre("AverageUnitPricePMPShort", "", "p.pmp", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("EstimatedStockValueShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); if (empty($conf->global->PRODUIT_MULTIPRICES)) { From c9bdefbbe0dc3ee046d4c92f53591375cc2226ef Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Fri, 20 Mar 2020 19:08:24 +0100 Subject: [PATCH 3/5] fix: delete redundant test+fix condition test+display units type if products in warehouse of same nature --- htdocs/product/stock/card.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 47d8775b163..af0703a119e 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -628,16 +628,13 @@ else print ''; print $langs->trans("StockCorrection"); print ""; - } - - if ($user->rights->stock->creer) { print ''; print $langs->trans("StockCorrection"); print ""; } if(!empty($conf->global->PRODUCT_USE_UNITS)) { if ($i == 0) $units = $productstatic->fk_unit; - elseif($productstatic->fk_unit !== $units) $sameunits = false; + elseif($productstatic->fk_unit != $units) $sameunits = false; } print ""; $i++; @@ -649,7 +646,9 @@ else $valtoshow=price2num($totalunit, 'MS'); if(empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) print empty($valtoshow)?'0':$valtoshow; print ''; - print ' '; + print ''; + if(empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) print $langs->trans($productstatic->getLabelOfUnit()); + print ''; print ''.price(price2num($totalvalue, 'MT')).''; if (empty($conf->global->PRODUIT_MULTIPRICES)) { From f7ecc9d60cfdb37bf5e673877c843a71668dfa44 Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Thu, 26 Mar 2020 15:22:24 +0100 Subject: [PATCH 4/5] Fix:The column "print $langs->trans("StockCorrection");" is now duplicated. --- htdocs/product/stock/card.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index af0703a119e..6d74d396306 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -628,9 +628,6 @@ else print ''; print $langs->trans("StockCorrection"); print ""; - print ''; - print $langs->trans("StockCorrection"); - print ""; } if(!empty($conf->global->PRODUCT_USE_UNITS)) { if ($i == 0) $units = $productstatic->fk_unit; From 774137b937caf6333b6e4cf3a43124c9dc7f74e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Mar 2020 20:00:59 +0200 Subject: [PATCH 5/5] Update card.php --- htdocs/product/stock/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 6d74d396306..d625c4b3504 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -639,8 +639,8 @@ else $db->free($resql); print ''.$langs->trans("Total").''; - print ''; - $valtoshow=price2num($totalunit, 'MS'); + print ''; + $valtoshow = price2num($totalunit, 'MS'); if(empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) print empty($valtoshow)?'0':$valtoshow; print ''; print '';