diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php
index 884fcd8d4ad..c6e6f964669 100644
--- a/htdocs/fourn/class/fournisseur.product.class.php
+++ b/htdocs/fourn/class/fournisseur.product.class.php
@@ -419,9 +419,10 @@ class ProductFournisseur extends Product
* Load properties for minimum price
*
* @param int $prodid Product id
+ * @param int $qty Minimum quantity
* @return int <0 if KO, >0 if OK
*/
- function find_min_price_product_fournisseur($prodid)
+ function find_min_price_product_fournisseur($prodid, $qty=0)
{
global $conf;
@@ -444,6 +445,7 @@ class ProductFournisseur extends Product
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
$sql.= " AND pfp.fk_product = ".$prodid;
$sql.= " AND pfp.fk_soc = s.rowid";
+ if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty;
$sql.= " ORDER BY pfp.unitprice";
$sql.= $this->db->plimit(1);
@@ -496,16 +498,18 @@ class ProductFournisseur extends Product
/**
* Display price of product
*
- * @return string String with supplier price
+ * @param int $showunitprice Show "Unit price" into output string
+ * @param int $showsuptitle Show "Supplier" into output string
+ * @return string String with supplier price
*/
- function display_price_product_fournisseur()
+ function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1)
{
global $langs;
$langs->load("suppliers");
- $out=price($this->fourn_unitprice).' '.$langs->trans("HT").' ('.$langs->trans("Supplier").': '.$this->getSocNomUrl(1).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.')';
+ $out=($showunitprice?price($this->fourn_unitprice).' '.$langs->trans("HT").' (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':'');
return $out;
}
}
-?>
+?>
\ No newline at end of file
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 0176effbb18..8a6745da13f 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -2194,9 +2194,9 @@ class Product extends CommonObject
$product = new Product($this->db);
//var_dump($prod);
- foreach($prod as $id_product => $desc_pere) // nom_pere is 0 or id of sub_product
+ foreach($prod as $id_product => $desc_pere) // $id_product is 0 (there is no mode sub_product) or an id of a sub_product
{
- if (is_array($desc_pere)) // If this parent desc is an array, this is an array of childs
+ if (is_array($desc_pere)) // If desc_pere is an array, this means it's a child
{
$id=(! empty($desc_pere[0]) ? $desc_pere[0] :'');
$nb=(! empty($desc_pere[1]) ? $desc_pere[1] :'');
@@ -2205,20 +2205,23 @@ class Product extends CommonObject
if ($multiply < 1) $multiply=1;
//print "XXX We add id=".$id." - label=".$label." - nb=".$nb." - multiply=".$multiply." fullpath=".$compl_path.$label."\n";
- $this->fetch($id);
- $this->load_stock();
+ $this->fetch($id); // Load product
+ $this->load_stock(); // Load stock
$this->res[]= array(
'id'=>$id, // Id product
+ 'ref'=>$this->ref, // Ref product
'nb'=>$nb, // Nb of units that compose parent product
'nb_total'=>$nb*$multiply, // Nb of units for all nb of product
- 'stock'=>$this->stock_warehouse[1]->real, // Stock
+ 'stock'=>$this->stock_reel, // Stock
'stock_alert'=>$this->seuil_stock_alerte, // Stock alert
- 'fullpath' => $compl_path.$label, // Label
+ 'label'=>$label,
+ 'fullpath'=>$compl_path.$label, // Label
'type'=>$type, // Nb of units that compose parent product
- 'desiredstock' => $this->desiredstock
+ 'desiredstock'=>$this->desiredstock,
+ 'level'=>$level
);
- // Recursive call if child is an array
+ // Recursive call if there is childs to child
if (is_array($desc_pere['childs']))
{
//print 'YYY We go down for '.$desc_pere[3]." -> \n";
diff --git a/htdocs/product/composition/fiche.php b/htdocs/product/composition/fiche.php
index b56f3ce6227..f94f831cc63 100644
--- a/htdocs/product/composition/fiche.php
+++ b/htdocs/product/composition/fiche.php
@@ -53,10 +53,11 @@ $mesg = '';
$product = new Product($db);
$productid=0;
-if ($id || $ref)
+if ($id > 0 || ! empty($ref))
{
$result = $product->fetch($id,$ref);
$productid=$product->id;
+ $id=$product->id;
}
@@ -119,6 +120,10 @@ if ($cancel == $langs->trans("Cancel"))
* View
*/
+$product_fourn = new ProductFournisseur($db);
+$productstatic = new Product($db);
+$form = new Form($db);
+
// action recherche des produits par mot-cle et/ou par categorie
if ($action == 'search')
{
@@ -153,8 +158,6 @@ if ($action == 'search')
}
//print $sql;
-$productstatic = new Product($db);
-$form = new Form($db);
llxHeader("","",$langs->trans("CardProduct".$product->type));
@@ -285,9 +288,36 @@ if ($id > 0 || ! empty($ref))
print '
| '.$langs->trans("Label").' | '.$product->libelle.' | ';
print '
';
+ if (empty($conf->global->PRODUIT_MULTIPRICES))
+ {
+ // Price
+ print '| '.$langs->trans("SellingPrice").' | ';
+ if ($object->price_base_type == 'TTC')
+ {
+ print price($object->price_ttc).' '.$langs->trans($object->price_base_type);
+ }
+ else
+ {
+ print price($object->price).' '.$langs->trans($object->price_base_type);
+ }
+ print ' |
';
+
+ // Price minimum
+ print '| '.$langs->trans("MinPrice").' | ';
+ if ($object->price_base_type == 'TTC')
+ {
+ print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type);
+ }
+ else
+ {
+ print price($object->price_min).' '.$langs->trans($object->price_base_type);
+ }
+ print ' |
';
+ }
+
// Number of subproducts
$prodsfather = $product->getFather(); //Parent Products
- $product->get_sousproduits_arbo();
+ $product->get_sousproduits_arbo(); // Defined $product->sousprod
$prods_arbo=$product->get_arbo_each_prod();
$nbofsubproducts=count($prods_arbo);
print '| '.$langs->trans("AssociatedProductsNumber").' | ';
@@ -296,26 +326,55 @@ if ($id > 0 || ! empty($ref))
print ' |
';
// List of subproducts
- if(count($prods_arbo) > 0)
+ if (count($prods_arbo) > 0)
{
print '';
- print ''.$langs->trans("ProductAssociationList").' ';
- print '';
+ print $langs->trans("ProductAssociationList").' ';
+ print '';
foreach($prods_arbo as $value)
{
$productstatic->id=$value['id'];
$productstatic->type=$value['type'];
- $productstatic->ref=$value['fullpath'];
- if (! empty($conf->stock->enabled)) $productstatic->load_stock();
- //var_dump($value);
//print ''.$productstatic->ref.' ';
//print $productstatic->getNomUrl(1).' ';
- //print $value[0]; // This contains a tr line.
+ //var_dump($value);
print '';
- print '| '.$productstatic->getNomUrl(1,'composition').' ('.$value['nb'].')     | ';
- if (! empty($conf->stock->enabled)) print ''.$langs->trans("Stock").' : '.$productstatic->stock_reel.' | ';
+ if ($value['level'] <= 1)
+ {
+ $productstatic->ref=$value['fullpath'];
+ print ''.$productstatic->getNomUrl(1,'composition').' ('.$value['nb'].') | ';
+ print '';
+ if ($product_fourn->find_min_price_product_fournisseur($productstatic->id, $value['nb']) > 0)
+ {
+ print $langs->trans("BuyingPriceMinShort").': ';
+ if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur(0,0);
+ else print $langs->trans("NotDefined");
+ }
+ print ' | ';
+ $totalline=price2num($value['nb'] * $product_fourn->fourn_unitprice, 'MT');
+ $total+=$totalline;
+ print ''.price($totalline,'','',0,0,-1,$conf->currency).' | ';
+ if (! empty($conf->stock->enabled)) print ''.$langs->trans("Stock").': '.$value['stock'].' | '; // Real stock
+ }
+ else {
+ $productstatic->ref=$value['label'];
+ print '';
+ for ($i=0; $i < $value['level']; $i++)
+ {
+ print ' ';
+ }
+ print $productstatic->getNomUrl(1,'composition').' ('.$value['nb'].') | ';
+ print ' | ';
+ print ' | | ';
+ if (! empty($conf->stock->enabled)) print ' | | '; // Real stock
+ }
print ' ';
}
+ print '';
+ print '| '.$langs->trans("BuyingPriceMin").': '.price($total,'','',0,0,-1,$conf->currency).' | ';
+ print ' | ';
+ if (! empty($conf->stock->enabled)) print ' | ';
+ print ' ';
print ' ';
print '';
}
@@ -328,7 +387,7 @@ if ($id > 0 || ! empty($ref))
if (count($prodsfather) > 0)
{
print '';
- print ''.$langs->trans("ProductParentList").' ';
+ print $langs->trans("ProductParentList").' ';
print ' | |