New: task #11243: Add best supplier price
This commit is contained in:
parent
5183fd9e86
commit
84f7eb9da6
@ -22,7 +22,7 @@
|
|||||||
* \file htdocs/fourn/class/fournisseur.product.class.php
|
* \file htdocs/fourn/class/fournisseur.product.class.php
|
||||||
* \ingroup produit
|
* \ingroup produit
|
||||||
* \brief File of class to manage predefined suppliers products
|
* \brief File of class to manage predefined suppliers products
|
||||||
* \version $Id: fournisseur.product.class.php,v 1.10 2011/08/20 23:56:03 eldy Exp $
|
* \version $Id: fournisseur.product.class.php,v 1.11 2011/08/21 00:27:31 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
|
require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
|
||||||
@ -540,6 +540,16 @@ class ProductFournisseur extends Product
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
|
$this->product_fourn_price_id = '';
|
||||||
|
$this->product_fourn_id = '';
|
||||||
|
$this->fourn_ref = '';
|
||||||
|
$this->fourn_price = '';
|
||||||
|
$this->fourn_qty = '';
|
||||||
|
$this->fourn_unitprice = '';
|
||||||
|
$this->fourn_id = '';
|
||||||
|
$this->fourn_name = '';
|
||||||
|
$this->id = '';
|
||||||
|
|
||||||
$sql = "SELECT s.nom as supplier_name, ";
|
$sql = "SELECT s.nom as supplier_name, ";
|
||||||
$sql.= " s.rowid as fourn_id,";
|
$sql.= " s.rowid as fourn_id,";
|
||||||
$sql.= " pf.ref_fourn,";
|
$sql.= " pf.ref_fourn,";
|
||||||
@ -553,6 +563,7 @@ class ProductFournisseur extends Product
|
|||||||
$sql.= " WHERE s.entity = ".$conf->entity;
|
$sql.= " WHERE s.entity = ".$conf->entity;
|
||||||
$sql.= " AND pf.fk_product = ".$prodid;
|
$sql.= " AND pf.fk_product = ".$prodid;
|
||||||
$sql.= " ORDER BY pfp.unitprice";
|
$sql.= " ORDER BY pfp.unitprice";
|
||||||
|
$sql.= $this->db->plimit(1);
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::find_min_price_product_fournisseur sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::find_min_price_product_fournisseur sql=".$sql, LOG_DEBUG);
|
||||||
|
|
||||||
@ -598,7 +609,7 @@ class ProductFournisseur extends Product
|
|||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("suppliers");
|
$langs->load("suppliers");
|
||||||
$out=price($this->fourn_unitprice).' ('.$langs->trans("Supplier").': '.$this->getSocNomUrl(1).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.')';
|
$out=price($this->fourn_unitprice).' '.$langs->trans("HT").' ('.$langs->trans("Supplier").': '.$this->getSocNomUrl(1).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.')';
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ ShowSupplier=Show supplier
|
|||||||
OrderDate=Order date
|
OrderDate=Order date
|
||||||
BuyingPrice=Buying price
|
BuyingPrice=Buying price
|
||||||
BuyingPriceMin=Minimum buying price
|
BuyingPriceMin=Minimum buying price
|
||||||
|
BuyingPriceMinShort=Min buying price
|
||||||
AddSupplierPrice=Add supplier price
|
AddSupplierPrice=Add supplier price
|
||||||
ChangeSupplierPrice=Change supplier price
|
ChangeSupplierPrice=Change supplier price
|
||||||
ErrorQtyTooLowForThisSupplier=Quantity too low for this supplier or no price defined on this product for this supplier
|
ErrorQtyTooLowForThisSupplier=Quantity too low for this supplier or no price defined on this product for this supplier
|
||||||
|
|||||||
@ -13,6 +13,7 @@ ShowSupplier=Afficher fournisseur
|
|||||||
OrderDate=Date commande
|
OrderDate=Date commande
|
||||||
BuyingPrice=Prix d'achat
|
BuyingPrice=Prix d'achat
|
||||||
BuyingPriceMin=Prix d'achat minimum
|
BuyingPriceMin=Prix d'achat minimum
|
||||||
|
BuyingPriceMinShort=Prix achat min
|
||||||
AddSupplierPrice=Ajouter prix fournisseur
|
AddSupplierPrice=Ajouter prix fournisseur
|
||||||
ChangeSupplierPrice=Modifier prix fournisseur
|
ChangeSupplierPrice=Modifier prix fournisseur
|
||||||
ErrorSupplierCountryIsNotDefined=Le pays de ce fournisseur n'est pas défini. Corriger sur sa fiche.
|
ErrorSupplierCountryIsNotDefined=Le pays de ce fournisseur n'est pas défini. Corriger sur sa fiche.
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
* \file htdocs/product/fournisseurs.php
|
* \file htdocs/product/fournisseurs.php
|
||||||
* \ingroup product
|
* \ingroup product
|
||||||
* \brief Page of tab suppliers for products
|
* \brief Page of tab suppliers for products
|
||||||
* \version $Id: fournisseurs.php,v 1.100 2011/08/20 23:56:04 eldy Exp $
|
* \version $Id: fournisseurs.php,v 1.101 2011/08/21 00:26:31 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../main.inc.php");
|
require("../main.inc.php");
|
||||||
@ -237,7 +237,7 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
$product_fourn = new ProductFournisseur($db);
|
$product_fourn = new ProductFournisseur($db);
|
||||||
if ($product_fourn->find_min_price_product_fournisseur($product->id) > 0)
|
if ($product_fourn->find_min_price_product_fournisseur($product->id) > 0)
|
||||||
{
|
{
|
||||||
if (isset($product_fourn->fourn_unitprice)) print $product_fourn->display_price_product_fournisseur();
|
if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur();
|
||||||
else print $langs->trans("NotDefined");
|
else print $langs->trans("NotDefined");
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
@ -449,5 +449,5 @@ else
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date: 2011/08/20 23:56:04 $ - $Revision: 1.100 $');
|
llxFooter('$Date: 2011/08/21 00:26:31 $ - $Revision: 1.101 $');
|
||||||
?>
|
?>
|
||||||
@ -21,11 +21,12 @@
|
|||||||
* \file htdocs/product/liste.php
|
* \file htdocs/product/liste.php
|
||||||
* \ingroup produit
|
* \ingroup produit
|
||||||
* \brief Page to list products and services
|
* \brief Page to list products and services
|
||||||
* \version $Id: liste.php,v 1.153 2011/08/20 23:56:04 eldy Exp $
|
* \version $Id: liste.php,v 1.154 2011/08/21 00:26:31 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../main.inc.php");
|
require("../main.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');
|
require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.product.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
|
||||||
if ($conf->categorie->enabled) require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
|
if ($conf->categorie->enabled) require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
|
||||||
|
|
||||||
@ -104,6 +105,7 @@ if ($conf->categorie->enabled && GETPOST('catid'))
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$htmlother=new FormOther($db);
|
$htmlother=new FormOther($db);
|
||||||
|
$html=new Form($db);
|
||||||
|
|
||||||
if (! empty($objcanvas->template_dir))
|
if (! empty($objcanvas->template_dir))
|
||||||
{
|
{
|
||||||
@ -295,8 +297,8 @@ if ($resql)
|
|||||||
print_liste_field_titre($langs->trans("DateModification"), $_SERVER["PHP_SELF"], "p.tms",$param,"",'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("DateModification"), $_SERVER["PHP_SELF"], "p.tms",$param,"",'align="center"',$sortfield,$sortorder);
|
||||||
if ($conf->service->enabled && $type != 0) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder);
|
if ($conf->service->enabled && $type != 0) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder);
|
||||||
if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellingPrice"), $_SERVER["PHP_SELF"], "p.price",$param,"",'align="right"',$sortfield,$sortorder);
|
if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellingPrice"), $_SERVER["PHP_SELF"], "p.price",$param,"",'align="right"',$sortfield,$sortorder);
|
||||||
|
print '<td class="liste_titre" align="right">'.$langs->trans("BuyingPriceMinShort").'</td>';
|
||||||
if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1) print '<td class="liste_titre" align="right">'.$langs->trans("PhysicalStock").'</td>';
|
if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1) print '<td class="liste_titre" align="right">'.$langs->trans("PhysicalStock").'</td>';
|
||||||
if ($conf->fournisseur->enabled && $user->rights->fournisseur->lire && $type != 1) print '<td class="liste_titre" align="right">'.$langs->trans("BuyingPriceMin").'</td>';
|
|
||||||
print_liste_field_titre($langs->trans("Sell"), $_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Sell"), $_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Buy"), $_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Buy"), $_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder);
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
@ -335,16 +337,16 @@ if ($resql)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stock
|
// Minimum buying Price
|
||||||
if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1)
|
if ($conf->fournisseur->enabled && $user->rights->fournisseur->lire && $type != 1)
|
||||||
{
|
{
|
||||||
print '<td class="liste_titre">';
|
print '<td class="liste_titre">';
|
||||||
print ' ';
|
print ' ';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Minimum buying Price
|
// Stock
|
||||||
if ($conf->fournisseur->enabled && $user->rights->fournisseur->lire && $type != 1)
|
if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1)
|
||||||
{
|
{
|
||||||
print '<td class="liste_titre">';
|
print '<td class="liste_titre">';
|
||||||
print ' ';
|
print ' ';
|
||||||
@ -363,6 +365,7 @@ if ($resql)
|
|||||||
|
|
||||||
|
|
||||||
$product_static=new Product($db);
|
$product_static=new Product($db);
|
||||||
|
$product_fourn =new ProductFournisseur($db);
|
||||||
|
|
||||||
$var=true;
|
$var=true;
|
||||||
while ($i < min($num,$limit))
|
while ($i < min($num,$limit))
|
||||||
@ -430,6 +433,25 @@ if ($resql)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MinimumPrice
|
||||||
|
print '<td align="right">';
|
||||||
|
if ($conf->fournisseur->enabled && $user->rights->fournisseur->lire && $type != 1)
|
||||||
|
{
|
||||||
|
if ($objp->fk_product_type != 1)
|
||||||
|
{
|
||||||
|
if ($product_fourn->find_min_price_product_fournisseur($objp->rowid))
|
||||||
|
{
|
||||||
|
if ($product_fourn->product_fourn_price_id > 0)
|
||||||
|
{
|
||||||
|
$htmltext=$product_fourn->display_price_product_fournisseur();
|
||||||
|
if ($conf->fournisseur->enabled && $user->rights->fournisseur->lire) print $html->textwithpicto(price($product_fourn->fourn_unitprice),$htmltext);
|
||||||
|
else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
// Show stock
|
// Show stock
|
||||||
if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1)
|
if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1)
|
||||||
{
|
{
|
||||||
@ -448,25 +470,6 @@ if ($resql)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MinimumPrice
|
|
||||||
if ($conf->fournisseur->enabled && $user->rights->fournisseur->lire && $type != 1)
|
|
||||||
{
|
|
||||||
if ($objp->fk_product_type != 1)
|
|
||||||
{
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.product.class.php");
|
|
||||||
|
|
||||||
$product_fourn = new ProductFournisseur($db);
|
|
||||||
if ($product_fourn->find_min_price_product_fournisseur($objp->rowid))
|
|
||||||
{
|
|
||||||
print '<td align="right">'.$product_fourn->display_price_product_fournisseur().'</td>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<td> </td>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Status (to buy)
|
// Status (to buy)
|
||||||
print '<td align="right" nowrap="nowrap">'.$product_static->LibStatut($objp->tosell,5,0).'</td>';
|
print '<td align="right" nowrap="nowrap">'.$product_static->LibStatut($objp->tosell,5,0).'</td>';
|
||||||
|
|
||||||
@ -503,5 +506,5 @@ else
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date: 2011/08/20 23:56:04 $ - $Revision: 1.153 $');
|
llxFooter('$Date: 2011/08/21 00:26:31 $ - $Revision: 1.154 $');
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user