From 13e5c8ff7ac61bd3b22810d06a229f7c7d768166 Mon Sep 17 00:00:00 2001 From: fappels Date: Mon, 26 Jun 2017 22:44:56 +0200 Subject: [PATCH 1/6] Create patch Add Number of supplier prices and wap columns --- .../fourn/class/fournisseur.product.class.php | 28 ++++++++--- htdocs/langs/en_US/suppliers.lang | 1 + htdocs/product/list.php | 49 ++++++++++++++++++- 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 4f576148099..e8a63e252d7 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -699,17 +699,33 @@ class ProductFournisseur extends Product /** * Display price of product * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip + * @param int $showunitprice Show "Unit price" into output string + * @param int $showsuptitle Show "Supplier" into output string + * @param int $maxlen Max length of name + * @param integer $notooltip 1=Disable tooltip + * @param array $productFournList list of ProductFournisseur objects to display in table format. * @return string String with supplier price */ - function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0) + function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0, $productFournList=array()) { global $langs; + + $out = ''; $langs->load("suppliers"); - $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + if (count($productFournList) > 0) { + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + foreach ($productFournList as $productFourn) { + $out.= ''; + $out.= ''; + $out.= ''; + } + $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; + } else { + $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + } return $out; } diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index d84925d0676..079b588167f 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -43,3 +43,4 @@ NotTheGoodQualitySupplier=Wrong quality ReputationForThisProduct=Reputation BuyerName=Buyer name AllProductServicePrices=All product / service prices +BuyingPriceNumShort=Nbr of Buying prices diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 74f9c59cff3..fa0ee2cace7 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -164,6 +164,8 @@ $arrayfields=array( 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled))), 'p.sellprice'=>array('label'=>$langs->trans("SellingPrice"), 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)), 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))), + 'p.numbuyprice'=>array('label'=>$langs->trans("BuyingPriceNumShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), + 'p.pmp'=>array('label'=>$langs->trans("PMPValueShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), 'p.seuil_stock_alerte'=>array('label'=>$langs->trans("StockLimit"), 'checked'=>0, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), @@ -266,7 +268,7 @@ else $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; $sql.= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; $sql.= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy,'; - $sql.= ' p.datec as date_creation, p.tms as date_update,'; + $sql.= ' p.datec as date_creation, p.tms as date_update, p.pmp,'; //$sql.= ' pfp.ref_fourn as ref_supplier, '; $sql.= ' MIN(pfp.unitprice) as minsellprice'; if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) { @@ -335,7 +337,7 @@ else $sql.=$hookmanager->resPrint; $sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; $sql.= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; - $sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy'; + $sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy, p.pmp'; if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) { $sql .= ', pac.rowid'; } @@ -563,6 +565,20 @@ else print ''; print ' '; print ''; + } + // Number buying Price + if (! empty($arrayfields['p.numbuyprice']['checked'])) + { + print ''; + print ' '; + print ''; + } + // Number buying Price + if (! empty($arrayfields['p.pmp']['checked'])) + { + print ''; + print ' '; + print ''; } // Limit for alert if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) @@ -640,6 +656,8 @@ else if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); @@ -703,6 +721,7 @@ else $product_static->status_buy = $obj->tobuy; $product_static->status = $obj->tosell; $product_static->entity = $obj->entity; + $product_static->pmp = $obj->pmp; if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) // To optimize call of load_stock { @@ -798,6 +817,32 @@ else print ''; } + // Number of buy prices + if (! empty($arrayfields['p.numbuyprice']['checked'])) + { + print ''; + if ($obj->tobuy) + { + if (($productFournList = $product_fourn->list_product_fournisseur_price($product_fourn->id)) > 0) + { + $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); + print $form->textwithpicto(count($productFournList),$htmltext); + } + } + print ''; + } + + // WAP + if (! empty($arrayfields['p.pmp']['checked'])) + { + print ''; + if ($obj->tobuy) + { + print price($product_static->pmp, 1, $langs, 1, 2, 1, 'auto'); + } + print ''; + } + // Limit alert if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) { From 7d4a093d9ebd49be669e43061e037dff7280f2d5 Mon Sep 17 00:00:00 2001 From: fappels Date: Fri, 30 Jun 2017 10:52:54 +0200 Subject: [PATCH 2/6] WAP alway decimal 2 digits --- .../fourn/class/fournisseur.product.class.php | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 38a1ea366c5..bcbaf18e9f5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -699,12 +699,13 @@ class ProductFournisseur extends Product /** * Display price of product * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects to display in table format. - * @return string String with supplier price + * @param int $showunitprice Show "Unit price" into output string + * @param int $showsuptitl Show "Supplier" into output string + * @param int $maxlen Max length of name + * @param integer $notooltip 1=Disable tooltip + * @param array $productFournList list of ProductFournisseur objects + * to display in table format. + * @return string String with supplier price */ function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0, $productFournList=array()) { @@ -713,16 +714,18 @@ class ProductFournisseur extends Product $out = ''; $langs->load("suppliers"); if (count($productFournList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; foreach ($productFournList as $productFourn) { $out.= ''; + $out.= ''; $out.= ''; $out.= ''; } - $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.($showunitprice?$langs->trans("QtyMin"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').''.($showunitprice?$productFourn->fourn_qty:'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; + $out .= ''; } else { $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); } From d0599cd9528dd9ad9e3e45d4930cf61bd6dd9159 Mon Sep 17 00:00:00 2001 From: fappels Date: Fri, 30 Jun 2017 10:54:04 +0200 Subject: [PATCH 3/6] Revert "WAP alway decimal 2 digits" This reverts commit 7d4a093d9ebd49be669e43061e037dff7280f2d5. --- .../fourn/class/fournisseur.product.class.php | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index bcbaf18e9f5..38a1ea366c5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -699,13 +699,12 @@ class ProductFournisseur extends Product /** * Display price of product * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitl Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects - * to display in table format. - * @return string String with supplier price + * @param int $showunitprice Show "Unit price" into output string + * @param int $showsuptitle Show "Supplier" into output string + * @param int $maxlen Max length of name + * @param integer $notooltip 1=Disable tooltip + * @param array $productFournList list of ProductFournisseur objects to display in table format. + * @return string String with supplier price */ function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0, $productFournList=array()) { @@ -714,18 +713,16 @@ class ProductFournisseur extends Product $out = ''; $langs->load("suppliers"); if (count($productFournList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.($showunitprice?$langs->trans("QtyMin"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'; + $out .= ''; + $out .= ''; + $out .= ''; foreach ($productFournList as $productFourn) { $out.= ''; - $out.= ''; $out.= ''; $out.= ''; } - $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').''.($showunitprice?$productFourn->fourn_qty:'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; + $out .= ''; } else { $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); } From 574590a59860e3cda4189a4d0e59573fd4996fc1 Mon Sep 17 00:00:00 2001 From: fappels Date: Fri, 30 Jun 2017 10:55:45 +0200 Subject: [PATCH 4/6] Add minimum qty column --- .../fourn/class/fournisseur.product.class.php | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 38a1ea366c5..bcbaf18e9f5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -699,12 +699,13 @@ class ProductFournisseur extends Product /** * Display price of product * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects to display in table format. - * @return string String with supplier price + * @param int $showunitprice Show "Unit price" into output string + * @param int $showsuptitl Show "Supplier" into output string + * @param int $maxlen Max length of name + * @param integer $notooltip 1=Disable tooltip + * @param array $productFournList list of ProductFournisseur objects + * to display in table format. + * @return string String with supplier price */ function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0, $productFournList=array()) { @@ -713,16 +714,18 @@ class ProductFournisseur extends Product $out = ''; $langs->load("suppliers"); if (count($productFournList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; foreach ($productFournList as $productFourn) { $out.= ''; + $out.= ''; $out.= ''; $out.= ''; } - $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.($showunitprice?$langs->trans("QtyMin"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').''.($showunitprice?$productFourn->fourn_qty:'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; + $out .= ''; } else { $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); } From 989084e4dece898320c368ac34f2561f8cb245eb Mon Sep 17 00:00:00 2001 From: fappels Date: Fri, 30 Jun 2017 10:56:05 +0200 Subject: [PATCH 5/6] WAP always 2 decimals --- htdocs/langs/en_US/suppliers.lang | 2 +- htdocs/product/list.php | 46 +++++++++++++++---------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index 079b588167f..28c5fe39d0d 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -43,4 +43,4 @@ NotTheGoodQualitySupplier=Wrong quality ReputationForThisProduct=Reputation BuyerName=Buyer name AllProductServicePrices=All product / service prices -BuyingPriceNumShort=Nbr of Buying prices +BuyingPriceNumShort=Supplier prices diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 50bd61fad17..cb31de75892 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -829,31 +829,31 @@ else } // Number of buy prices - if (! empty($arrayfields['p.numbuyprice']['checked'])) - { - print ''; - if ($obj->tobuy) - { - if (($productFournList = $product_fourn->list_product_fournisseur_price($product_fourn->id)) > 0) - { - $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); - print $form->textwithpicto(count($productFournList),$htmltext); - } - } - print ''; - } + if (! empty($arrayfields['p.numbuyprice']['checked'])) + { + print ''; + if ($obj->tobuy) + { + if (($productFournList = $product_fourn->list_product_fournisseur_price($product_fourn->id)) > 0) + { + $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); + print $form->textwithpicto(count($productFournList),$htmltext); + } + } + print ''; + } // WAP - if (! empty($arrayfields['p.pmp']['checked'])) - { - print ''; - if ($obj->tobuy) - { - print price($product_static->pmp, 1, $langs, 1, 2, 1, 'auto'); - } - print ''; - } - + if (! empty($arrayfields['p.pmp']['checked'])) + { + print ''; + if ($obj->tobuy) + { + print price($product_static->pmp, 1, $langs, 1, 2, 2, 'auto'); + } + print ''; + } + // Limit alert if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) { From 857e45baf31b1e27367d6498ec0c22a4a78bcd67 Mon Sep 17 00:00:00 2001 From: fappels Date: Thu, 6 Jul 2017 15:34:10 +0200 Subject: [PATCH 6/6] Fix comment --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index cb31de75892..f9037c32517 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -573,7 +573,7 @@ else print ' '; print ''; } - // Number buying Price + // WAP if (! empty($arrayfields['p.pmp']['checked'])) { print '';