diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php
index b0dd9713446..af64236db7f 100644
--- a/htdocs/fourn/class/fournisseur.product.class.php
+++ b/htdocs/fourn/class/fournisseur.product.class.php
@@ -877,6 +877,152 @@ class ProductFournisseur extends Product
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
+
+ /**
+ * List supplier prices log of a supplier price
+ *
+ * @param int $fourn_id Id of supplier price
+ * @param string $sortfield Sort field
+ * @param string $sortorder Sort order
+ * @param int $limit Limit
+ * @param int $offset Offset
+ * @return array Array of Log prices
+ */
+ function listProductFournisseurPriceLog($fourn_id, $sortfield='', $sortorder='', $limit=0, $offset=0)
+ {
+ global $conf;
+
+ $sql = "SELECT";
+ $sql.= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,";
+ $sql.= " pfpl.price, pfpl.quantity";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl";
+ $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
+ $sql.= ", ".MAIN_DB_PREFIX."user as u";
+ $sql.= " WHERE pfp.entity IN (".getEntity('productprice').")";
+ $sql.= " AND pfpl.fk_user = u.rowid";
+ $sql.= " AND pfp.rowid = pfpl.fk_product_fournisseur";
+ $sql.= " AND pfpl.fk_product_fournisseur = ".$fourn_id;
+ if (empty($sortfield)) $sql.= " ORDER BY pfpl.datec";
+ else $sql.= $this->db->order($sortfield, $sortorder);
+ $sql.=$this->db->plimit($limit, $offset);
+ dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG);
+
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $retarray = array();
+
+ while ($record = $this->db->fetch_array($resql))
+ {
+ $retarray[]=$record;
+ }
+
+ $this->db->free($resql);
+ return $retarray;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
+
+ /**
+ * Display log price of product supplier price
+ *
+ * @param array $productFournLogList list of ProductFournisseur price log objects
+ * to display in table format.
+ * @return string HTML String with supplier price
+ */
+ function displayPriceProductFournisseurLog($productFournLogList=array())
+ {
+ global $langs;
+
+ $out = '';
+ $langs->load("suppliers");
+ if (count($productFournLogList) > 0) {
+ $out .= '
';
+ $out .= '| '.$langs->trans("Date").' | ';
+ $out .= ''.$langs->trans("Price").' | ';
+ //$out .= ''.$langs->trans("QtyMin").' | ';
+ $out .= ''.$langs->trans("User").' |
';
+ foreach ($productFournLogList as $productFournLog) {
+ $out.= '| '.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').' | ';
+ $out.= ''.price($productFournLog['price']).' | ';
+ //$out.= ''.$productFournLog['quantity'].' | ';
+ $out.= ''.$productFournLog['lastname'].' |
';
+ }
+ $out .= '
';
+ }
+ return $out;
+ }
+
+
+ /**
+ * Return a link to the object card (with optionaly the picto)
+ *
+ * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
+ * @param string $option On what the link point to ('nolink', ...)
+ * @param int $notooltip 1=Disable tooltip
+ * @param string $morecss Add more css on link
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @return string String with URL
+ */
+ function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
+ {
+ global $db, $conf, $langs;
+
+ if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
+
+ $result = '';
+ $companylink = '';
+
+ $label = '' . $langs->trans("SupplierRef") . '';
+ $label.= '
';
+ $label.= '' . $langs->trans('Ref') . ': ' . $this->fourn_ref;
+
+ $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here
+ if (is_array($logPrices) && count($logPrices) > 0) {
+ $label.= '
';
+ $label.= '' . $langs->trans("History") . '';
+ $label.= $this->displayPriceProductFournisseurLog($logPrices);
+ }
+
+ $url = dol_buildpath('/product/fournisseurs.php',1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id;
+
+ if ($option != 'nolink')
+ {
+ // Add param to save lastsearch_values or not
+ $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
+ if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
+ }
+
+ $linkclose='';
+ if (empty($notooltip))
+ {
+ if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ {
+ $label=$langs->trans("SupplierRef");
+ $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+ $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
+ }
+ else $linkclose = ($morecss?' class="'.$morecss.'"':'');
+
+ $linkstart = '';
+ $linkend='';
+
+ $result .= $linkstart;
+ if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
+ if ($withpicto != 2) $result.= $this->fourn_ref;
+ $result .= $linkend;
+ //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
+
+ return $result;
+ }
/**
* Private function to log price history
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index 9605137b838..8556160b767 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -796,7 +796,14 @@ SCRIPT;
print ''.$productfourn->getSocNomUrl(1,'supplier').' | ';
// Supplier ref
- print ''.$productfourn->fourn_ref.' | ';
+ if ($user->rights->produit->creer || $user->rights->service->creer) // change required right here
+ {
+ print ''.$productfourn->getNomUrl().' | ';
+ }
+ else
+ {
+ print ''.$productfourn->fourn_ref.' | ';
+ }
// Availability
if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY))