Suite et casi fin de la gestion des arrondis
This commit is contained in:
parent
0b665020f5
commit
dba3aa6bde
@ -137,7 +137,8 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree
|
|||||||
$_POST['qty'],
|
$_POST['qty'],
|
||||||
$tva_tx,
|
$tva_tx,
|
||||||
$_POST['idprod'],
|
$_POST['idprod'],
|
||||||
$_POST['remise_percent']
|
$_POST['remise_percent'],
|
||||||
|
'HT'
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
@ -535,7 +536,7 @@ else
|
|||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'commande')
|
if ($_GET["action"] == 'commande')
|
||||||
{
|
{
|
||||||
$date_com = mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
|
$date_com = dolibarr_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
|
||||||
$html->form_confirm("fiche.php?id=".$commande->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"],
|
$html->form_confirm("fiche.php?id=".$commande->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"],
|
||||||
$langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dolibarr_print_date($date_com,'day')),"confirm_commande");
|
$langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dolibarr_print_date($date_com,'day')),"confirm_commande");
|
||||||
print '<br />';
|
print '<br />';
|
||||||
@ -657,7 +658,7 @@ else
|
|||||||
print ' - '.$objp->label;
|
print ' - '.$objp->label;
|
||||||
if ($objp->description) print '<br>'.nl2br($objp->description);
|
if ($objp->description) print '<br>'.nl2br($objp->description);
|
||||||
print "</td>";
|
print "</td>";
|
||||||
print '<td align="center">'.$objp->tva_tx.'%</td>';
|
print '<td align="center">'.vatrate($objp->tva_tx).'%</td>';
|
||||||
print '<td align="center">'.$objp->qty.'</td>';
|
print '<td align="center">'.$objp->qty.'</td>';
|
||||||
if ($objp->remise_percent > 0)
|
if ($objp->remise_percent > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.product.class.php");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,7 +169,7 @@ class Fournisseur extends Societe
|
|||||||
|
|
||||||
if ($idc > 0)
|
if ($idc > 0)
|
||||||
{
|
{
|
||||||
$prod = new Product($this->db);
|
$prod = new ProductFournisseur($this->db);
|
||||||
$prod->fetch($fk_product);
|
$prod->fetch($fk_product);
|
||||||
$prod->fetch_fourn_data($this->id);
|
$prod->fetch_fourn_data($this->id);
|
||||||
|
|
||||||
|
|||||||
@ -645,12 +645,14 @@ class CommandeFournisseur extends Commande
|
|||||||
* \param txtva Taux tva
|
* \param txtva Taux tva
|
||||||
* \param fk_product Id produit
|
* \param fk_product Id produit
|
||||||
* \param remise_percent Remise
|
* \param remise_percent Remise
|
||||||
|
* \param price_base_type HT or TTC
|
||||||
* \param int <0 si ko, >0 si ok
|
* \param int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function addline($desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0)
|
function addline($desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
|
// Clean parameters
|
||||||
$qty = price2num($qty);
|
$qty = price2num($qty);
|
||||||
$pu = price2num($pu);
|
$pu = price2num($pu);
|
||||||
$desc = trim($desc);
|
$desc = trim($desc);
|
||||||
@ -704,9 +706,11 @@ class CommandeFournisseur extends Commande
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$subprice = price2num($pu,'MU');
|
||||||
|
|
||||||
|
// Champ obsolete
|
||||||
$remise = 0;
|
$remise = 0;
|
||||||
$price = price2num($pu);
|
$price = $subprice;
|
||||||
$subprice = $price;
|
|
||||||
if ($remise_percent > 0)
|
if ($remise_percent > 0)
|
||||||
{
|
{
|
||||||
$remise = round(($pu * $remise_percent / 100), 2);
|
$remise = round(($pu * $remise_percent / 100), 2);
|
||||||
@ -714,7 +718,7 @@ class CommandeFournisseur extends Commande
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet (fk_commande,label,description,fk_product, price, qty, tva_tx, remise_percent, subprice, remise, ref)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet (fk_commande,label,description,fk_product, price, qty, tva_tx, remise_percent, subprice, remise, ref)";
|
||||||
$sql .= " VALUES ($this->id, '" . addslashes($label) . "','" . addslashes($desc) . "',".$fk_product.",".price2num($price).", '$qty', $txtva, $remise_percent,'".price2num($subprice)."','".price2num($remise)."','".$ref."') ;";
|
$sql .= " VALUES ($this->id, '" . addslashes($label) . "','" . addslashes($desc) . "',".$fk_product.",".price2num($price,'MU').", '$qty', $txtva, $remise_percent,'".price2num($subprice,'MU')."','".price2num($remise)."','".$ref."') ;";
|
||||||
dolibarr_syslog('Fournisseur.commande.class::addline sql='.$sql);
|
dolibarr_syslog('Fournisseur.commande.class::addline sql='.$sql);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -731,6 +735,8 @@ class CommandeFournisseur extends Commande
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatch un element de la commande dans un stock
|
* Dispatch un element de la commande dans un stock
|
||||||
*
|
*
|
||||||
|
|||||||
@ -27,15 +27,14 @@
|
|||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT."/product.class.php";
|
||||||
|
require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.class.php";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class Product
|
\class Product
|
||||||
\brief Classe permettant la gestion des produits prédéfinis
|
\brief Classe permettant la gestion des produits prédéfinis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT."/product.class.php";
|
|
||||||
require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.product.class.php";
|
|
||||||
|
|
||||||
class ProductFournisseur extends Product
|
class ProductFournisseur extends Product
|
||||||
{
|
{
|
||||||
var $db ;
|
var $db ;
|
||||||
@ -44,50 +43,77 @@ class ProductFournisseur extends Product
|
|||||||
var $fourn_ref;
|
var $fourn_ref;
|
||||||
var $fourn;
|
var $fourn;
|
||||||
|
|
||||||
|
|
||||||
function ProductFournisseur($db)
|
function ProductFournisseur($db)
|
||||||
{
|
{
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
|
|
||||||
$this->fourn = new Fournisseur($this->db);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch ($id, $id_fourn)
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Délie un fournisseur au produit/service
|
||||||
|
* \param user utilisateur qui défait le lien
|
||||||
|
* \param id_fourn id du fournisseur
|
||||||
|
* \return int < 0 si erreur, > 0 si ok
|
||||||
|
*/
|
||||||
|
function remove_fournisseur($id_fourn)
|
||||||
{
|
{
|
||||||
Product::Fetch($id);
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur ";
|
||||||
$this->fourn->fetch($id_fourn);
|
$sql.= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn;
|
||||||
|
|
||||||
|
dolibarr_syslog("ProductFournisseur::remove_fournisseur sql=".$sql);
|
||||||
$sql = "SELECT ref_fourn";
|
$resql=$this->db->query($sql);
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur";
|
if ($resql)
|
||||||
$sql .=" WHERE fk_soc = ".$this->fourn->id;
|
|
||||||
$sql .= " AND fk_product = ".$this->id;
|
|
||||||
|
|
||||||
$resql = $this->db->query($sql) ;
|
|
||||||
|
|
||||||
if ( $resql )
|
|
||||||
{
|
{
|
||||||
$result = $this->db->fetch_array($resql);
|
return 1;
|
||||||
|
|
||||||
$this->fourn_ref = $result["ref_fourn"];
|
|
||||||
|
|
||||||
$this->db->free($resql);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "Errir";
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
function remove_product_fournisseur($rowid)
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur";
|
||||||
|
$sql.= " WHERE rowid = ".$rowid;
|
||||||
|
|
||||||
|
dolibarr_syslog("ProductFournisseur::remove_product_fournisseur sql=".$sql);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
* \return int <0 si KO, 0 si non trouve, >0 si efface
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
function get_buyprice($qty)
|
function remove_product_fournisseur_price($rowid)
|
||||||
{
|
{
|
||||||
Product::get_buyprice($this->fourn->id, $qty);
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||||
|
$sql.= " WHERE rowid = ".$rowid;
|
||||||
|
|
||||||
|
dolibarr_syslog("ProductFournisseur::remove_product_fournisseur_price sql=".$sql);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
if ($this->db->affected_rows() > 0) return 1;
|
||||||
|
else return 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -99,7 +125,7 @@ class ProductFournisseur extends Product
|
|||||||
|
|
||||||
/* Mise à jour du prix */
|
/* Mise à jour du prix */
|
||||||
|
|
||||||
Product::update_buyprice($this->fourn->id, $qty, $buyprice, $user);
|
$this->update_buyprice($this->fourn->id, $qty, $buyprice, $user);
|
||||||
|
|
||||||
/* Mise à jour de la référence */
|
/* Mise à jour de la référence */
|
||||||
|
|
||||||
@ -111,5 +137,171 @@ class ProductFournisseur extends Product
|
|||||||
$resql = $this->db->query($sql) ;
|
$resql = $this->db->query($sql) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Modifie le prix d'achat pour un fournisseur
|
||||||
|
* \param id_fourn Id du fournisseur
|
||||||
|
* \param qty Quantite pour lequel le prix est valide
|
||||||
|
* \param buyprice Prix d'achat pour la quantité
|
||||||
|
* \param user Objet user de l'utilisateur qui modifie
|
||||||
|
* \param price_base_type HT or TTC
|
||||||
|
*/
|
||||||
|
function update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type='HT')
|
||||||
|
{
|
||||||
|
$error=0;
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
// Supprime prix courant du fournisseur pour cette quantité
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price ";
|
||||||
|
$sql .= " WHERE ";
|
||||||
|
$sql .= " fk_product = ".$this->id;
|
||||||
|
$sql .= " AND fk_soc = ".$id_fourn;
|
||||||
|
$sql .= " AND quantity = ".$qty;
|
||||||
|
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
// Ajoute prix courant du fournisseur pour cette quantité
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||||
|
$sql .= " SET datec = now()";
|
||||||
|
$sql .= " ,fk_product = ".$this->id;
|
||||||
|
$sql .= " ,fk_soc = ".$id_fourn;
|
||||||
|
$sql .= " ,fk_user = ".$user->id;
|
||||||
|
$sql .= " ,price = ".price2num($buyprice);
|
||||||
|
$sql .= " ,quantity = ".$qty;
|
||||||
|
$sql .= " ,unitprice = ".price2num($buyprice/$qty,'MU');
|
||||||
|
|
||||||
|
dolibarr_syslog("ProductFournisseur::update_buyprice sql=".$sql);
|
||||||
|
if (! $this->db->query($sql))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error) {
|
||||||
|
// Ajoute modif dans table log
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log ";
|
||||||
|
$sql .= " SET datec = now()";
|
||||||
|
$sql .= " ,fk_product = ".$this->id;
|
||||||
|
$sql .= " ,fk_soc = ".$id_fourn;
|
||||||
|
$sql .= " ,fk_user = ".$user->id;
|
||||||
|
$sql .= " ,price = ".price2num($buyprice);
|
||||||
|
$sql .= " ,quantity = ".$qty;
|
||||||
|
|
||||||
|
if (! $this->db->query($sql))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error()." sql=".$sql;
|
||||||
|
$this->db->rollback();
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error()." sql=".$sql;
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Modifie le prix d'achat pour un fournisseur par la référecne du produit chez le fournisseur
|
||||||
|
\param id_fourn Id du fournisseur
|
||||||
|
\param product_fourn_ref Ref du produit chez le fournisseur
|
||||||
|
\param qty Quantite pour lequel le prix est valide
|
||||||
|
\param buyprice Prix d'achat pour la quantité
|
||||||
|
\param user Objet user de l'utilisateur qui modifie
|
||||||
|
\return int <0 si KO, >0 si OK
|
||||||
|
*/
|
||||||
|
function UpdateBuyPriceByFournRef($id_fourn, $product_fourn_ref, $qty, $buyprice, $user, $price_base_type='HT')
|
||||||
|
{
|
||||||
|
$result=0;
|
||||||
|
|
||||||
|
// Recherche id produit pour cette ref et fournisseur
|
||||||
|
$sql = "SELECT fk_product";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur";
|
||||||
|
$sql.= " WHERE fk_soc ='".$id_fourn."'";
|
||||||
|
$sql.= " AND ref_fourn='".$product_fourn_ref."'";
|
||||||
|
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
if ($obj = $this->db->fetch_object($resql))
|
||||||
|
{
|
||||||
|
// Met a jour prix pour la qté
|
||||||
|
$this->id = $obj->fk_product;
|
||||||
|
$result = $this->update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Charge les informations relatives à un fournisseur
|
||||||
|
* \param fournid id du fournisseur
|
||||||
|
* \return int < 0 si erreur, > 0 si ok
|
||||||
|
*/
|
||||||
|
function fetch_fourn_data($fournid)
|
||||||
|
{
|
||||||
|
$sql = "SELECT rowid, ref_fourn";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur ";
|
||||||
|
$sql.= " WHERE fk_product = ".$this->id;
|
||||||
|
$sql.= " AND fk_soc = ".$fournid;
|
||||||
|
|
||||||
|
dolibarr_syslog("Product::fetch_fourn_data sql=".$sql);
|
||||||
|
$result = $this->db->query($sql) ;
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$result = $this->db->fetch_array();
|
||||||
|
$this->ref_fourn = $result["ref_fourn"];
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
dolibarr_syslog("Product::fetch_fourn_data error=".$this->error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Charge les informations relatives à un prix de fournisseur
|
||||||
|
* \param rowid id ligne
|
||||||
|
* \return int < 0 si erreur, > 0 si ok
|
||||||
|
*/
|
||||||
|
function fetch_product_fournisseur_price($rowid)
|
||||||
|
{
|
||||||
|
$sql = "SELECT rowid, fk_soc, ref_fourn, price, quantity, unitprice";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||||
|
$sql.= " WHERE rowid = ".$rowid;
|
||||||
|
|
||||||
|
dolibarr_syslog("Product::fetch_product_fournisseur_price sql=".$sql);
|
||||||
|
$resql = $this->db->query($sql) ;
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$this->fourn_ref = $obj->ref_fourn;
|
||||||
|
$this->fourn_price = $obj->price;
|
||||||
|
$this->fourn_qty = $obj->qty;
|
||||||
|
$this->fourn_unitprice = $obj->unitprice;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
dolibarr_syslog("Product::fetch_product_fournisseur_price error=".$this->error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -150,7 +150,7 @@ if ($_POST["action"] == 'add_fourn' && $_POST["cancel"] <> $langs->trans("Cancel
|
|||||||
}
|
}
|
||||||
if ($_GET["action"] == 'remove_fourn')
|
if ($_GET["action"] == 'remove_fourn')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new ProductFournisseur($db);
|
||||||
if( $product->fetch($_GET["id"]) )
|
if( $product->fetch($_GET["id"]) )
|
||||||
{
|
{
|
||||||
if ($product->remove_fournisseur($user, $_GET["id_fourn"]) > 0)
|
if ($product->remove_fournisseur($user, $_GET["id_fourn"]) > 0)
|
||||||
|
|||||||
@ -60,8 +60,7 @@ if ($_GET["id"])
|
|||||||
{
|
{
|
||||||
$product = new ProductFournisseur($db);
|
$product = new ProductFournisseur($db);
|
||||||
$result = $product->fetch($_GET["id"], $_GET["id_fourn"]);
|
$result = $product->fetch($_GET["id"], $_GET["id_fourn"]);
|
||||||
|
$product->get_buyprice($_GET["id_fourn"],1);
|
||||||
$product->get_buyprice(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $result == 0)
|
if ( $result == 0)
|
||||||
|
|||||||
@ -1114,11 +1114,9 @@ class Form
|
|||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration";
|
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,";
|
||||||
//$sql.= ", pf.ref_fourn";
|
$sql.= " pfp.price as fprice, pfp.quantity, pfp.unitprice";
|
||||||
$sql.= ", pfp.price as fprice, pfp.quantity";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product";
|
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
|
||||||
$sql.= " WHERE p.envente = 1";
|
$sql.= " WHERE p.envente = 1";
|
||||||
if ($socid) $sql.= " AND pfp.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND pfp.fk_soc = ".$socid;
|
||||||
@ -1167,12 +1165,12 @@ class Form
|
|||||||
$opt.= dolibarr_trunc($objp->label,18).' - ';
|
$opt.= dolibarr_trunc($objp->label,18).' - ';
|
||||||
if ($objp->fprice != '')
|
if ($objp->fprice != '')
|
||||||
{
|
{
|
||||||
$opt.= $objp->fprice;
|
$opt.= price($objp->fprice);
|
||||||
$opt.= $langs->trans("Currency".$conf->monnaie)."/".$objp->quantity.$langs->trans("Units");
|
$opt.= $langs->trans("Currency".$conf->monnaie)."/".$objp->quantity.$langs->trans("Units");
|
||||||
if ($objp->quantity > 1)
|
if ($objp->quantity > 1)
|
||||||
{
|
{
|
||||||
$opt.=" - ";
|
$opt.=" - ";
|
||||||
$opt.= round($objp->fprice/$objp->quantity,4).$langs->trans("Currency".$conf->monnaie)."/".$langs->trans("Unit");
|
$opt.= price($objp->unitprice).$langs->trans("Currency".$conf->monnaie)."/".$langs->trans("Unit");
|
||||||
}
|
}
|
||||||
if ($objp->duration) $opt .= " - ".$objp->duration;
|
if ($objp->duration) $opt .= " - ".$objp->duration;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -659,7 +659,7 @@ class Product
|
|||||||
function get_buyprice($fourn_id, $qty)
|
function get_buyprice($fourn_id, $qty)
|
||||||
{
|
{
|
||||||
$result = 0;
|
$result = 0;
|
||||||
$sql = "SELECT pf.price as price, pf.quantity as quantity";
|
$sql = "SELECT pf.rowid, pf.price as price, pf.quantity as quantity";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pf";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pf";
|
||||||
$sql.= " WHERE pf.fk_soc = ".$fourn_id;
|
$sql.= " WHERE pf.fk_soc = ".$fourn_id;
|
||||||
$sql.= " AND pf.fk_product =" .$this->id;
|
$sql.= " AND pf.fk_product =" .$this->id;
|
||||||
@ -719,112 +719,6 @@ class Product
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Modifie le prix d'achat pour un fournisseur
|
|
||||||
* \param id_fourn Id du fournisseur
|
|
||||||
* \param qty Quantite pour lequel le prix est valide
|
|
||||||
* \param buyprice Prix d'achat pour la quantité
|
|
||||||
* \param user Objet user de l'utilisateur qui modifie
|
|
||||||
* \param price_base_type HT or TTC
|
|
||||||
*/
|
|
||||||
function update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type='HT')
|
|
||||||
{
|
|
||||||
$error=0;
|
|
||||||
$this->db->begin();
|
|
||||||
|
|
||||||
// Supprime prix courant du fournisseur pour cette quantité
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price ";
|
|
||||||
$sql .= " WHERE ";
|
|
||||||
$sql .= " fk_product = ".$this->id;
|
|
||||||
$sql .= " AND fk_soc = ".$id_fourn;
|
|
||||||
$sql .= " AND quantity = ".$qty;
|
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
|
||||||
{
|
|
||||||
// Ajoute prix courant du fournisseur pour cette quantité
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price";
|
|
||||||
$sql .= " SET datec = now()";
|
|
||||||
$sql .= " ,fk_product = ".$this->id;
|
|
||||||
$sql .= " ,fk_soc = ".$id_fourn;
|
|
||||||
$sql .= " ,fk_user = ".$user->id;
|
|
||||||
$sql .= " ,price = ".price2num($buyprice);
|
|
||||||
$sql .= " ,quantity = ".$qty;
|
|
||||||
|
|
||||||
if (! $this->db->query($sql))
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error) {
|
|
||||||
// Ajoute modif dans table log
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log ";
|
|
||||||
$sql .= " SET datec = now()";
|
|
||||||
$sql .= " ,fk_product = ".$this->id;
|
|
||||||
$sql .= " ,fk_soc = ".$id_fourn;
|
|
||||||
$sql .= " ,fk_user = ".$user->id;
|
|
||||||
$sql .= " ,price = ".price2num($buyprice);
|
|
||||||
$sql .= " ,quantity = ".$qty;
|
|
||||||
|
|
||||||
if (! $this->db->query($sql))
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
|
||||||
{
|
|
||||||
$this->db->commit();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->error=$this->db->error()." sql=".$sql;
|
|
||||||
$this->db->rollback();
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->error=$this->db->error()." sql=".$sql;
|
|
||||||
$this->db->rollback();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief Modifie le prix d'achat pour un fournisseur par la référecne du produit chez le fournisseur
|
|
||||||
\param id_fourn Id du fournisseur
|
|
||||||
\param product_fourn_ref Ref du produit chez le fournisseur
|
|
||||||
\param qty Quantite pour lequel le prix est valide
|
|
||||||
\param buyprice Prix d'achat pour la quantité
|
|
||||||
\param user Objet user de l'utilisateur qui modifie
|
|
||||||
\return int <0 si KO, >0 si OK
|
|
||||||
*/
|
|
||||||
function UpdateBuyPriceByFournRef($id_fourn, $product_fourn_ref, $qty, $buyprice, $user, $price_base_type='HT')
|
|
||||||
{
|
|
||||||
$result=0;
|
|
||||||
|
|
||||||
// Recherche id produit pour cette ref et fournisseur
|
|
||||||
$sql = "SELECT fk_product";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur";
|
|
||||||
$sql.= " WHERE fk_soc ='".$id_fourn."'";
|
|
||||||
$sql.= " AND ref_fourn='".$product_fourn_ref."'";
|
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
|
||||||
{
|
|
||||||
if ($obj = $this->db->fetch_object($resql))
|
|
||||||
{
|
|
||||||
// Met a jour prix pour la qté
|
|
||||||
$this->id = $obj->fk_product;
|
|
||||||
$result = $this->update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Modifie le prix d'un produit/service
|
\brief Modifie le prix d'un produit/service
|
||||||
\param id Id du produit/service à modifier
|
\param id Id du produit/service à modifier
|
||||||
@ -919,7 +813,8 @@ class Product
|
|||||||
if ($id) $sql.= " WHERE rowid = '".$id."'";
|
if ($id) $sql.= " WHERE rowid = '".$id."'";
|
||||||
if ($ref) $sql.= " WHERE ref = '".addslashes($ref)."'";
|
if ($ref) $sql.= " WHERE ref = '".addslashes($ref)."'";
|
||||||
|
|
||||||
$result = $this->db->query($sql) ;
|
dolibarr_syslog("Product::fetch sql=".$sql);
|
||||||
|
$result = $this->db->query($sql);
|
||||||
if ( $result )
|
if ( $result )
|
||||||
{
|
{
|
||||||
$result = $this->db->fetch_array();
|
$result = $this->db->fetch_array();
|
||||||
@ -1742,28 +1637,6 @@ class Product
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Délie un fournisseur au produit/service
|
|
||||||
* \param user utilisateur qui défait le lien
|
|
||||||
* \param id_fourn id du fournisseur
|
|
||||||
* \return int < 0 si erreur, > 0 si ok
|
|
||||||
*/
|
|
||||||
function remove_fournisseur($user, $id_fourn)
|
|
||||||
{
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur ";
|
|
||||||
$sql.= " WHERE fk_product = $this->id AND fk_soc = $id_fourn;";
|
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($this->db);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Recopie les prix d'un produit/service sur un autre
|
* \brief Recopie les prix d'un produit/service sur un autre
|
||||||
* \param fromId Id produit source
|
* \param fromId Id produit source
|
||||||
@ -2245,30 +2118,6 @@ class Product
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Charge les informations relatives à un fournisseur
|
|
||||||
* \param fournid id du fournisseur
|
|
||||||
* \return int < 0 si erreur, > 0 si ok
|
|
||||||
*/
|
|
||||||
function fetch_fourn_data($fournid)
|
|
||||||
{
|
|
||||||
$sql = "SELECT rowid, ref_fourn";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur ";
|
|
||||||
$sql.= " WHERE fk_product = ".$this->id;
|
|
||||||
$sql.= " AND fk_soc = ".$fournid;
|
|
||||||
$result = $this->db->query($sql) ;
|
|
||||||
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
$result = $this->db->fetch_array();
|
|
||||||
$this->ref_fourn = $result["ref_fourn"];
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Déplace fichier uploadé sous le nom $files dans le répertoire sdir
|
* \brief Déplace fichier uploadé sous le nom $files dans le répertoire sdir
|
||||||
|
|||||||
@ -33,7 +33,7 @@ require("./pre.inc.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.product.class.php";
|
||||||
|
|
||||||
$langs->load("products");
|
$langs->load("products");
|
||||||
$langs->load("suppliers");
|
$langs->load("suppliers");
|
||||||
@ -57,24 +57,19 @@ if ($conf->use_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && $_POST['id
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($_GET["action"] == 'remove_fourn')
|
if ($_GET["action"] == 'remove_pf')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new ProductFournisseur($db);
|
||||||
if( $product->fetch($_GET["id"]) )
|
if ($product->fetch($_GET["id"]) > 0)
|
||||||
{
|
{
|
||||||
if ($_GET["qty"]) { // On supprime une quantité
|
if ($_GET["rowid"] && $product->remove_product_fournisseur_price($_GET["rowid"]) > 0)
|
||||||
if ($product->remove_price($user, $_GET["id_fourn"], $_GET["qty"]) > 0)
|
|
||||||
{
|
{
|
||||||
$_GET["action"] = '';
|
$_GET["action"] = '';
|
||||||
$mesg = '<div class="ok">'.$langs->trans("PriceRemoved").'.</div>';
|
$mesg = '<div class="ok">'.$langs->trans("PriceRemoved").'.</div>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$_GET["action"] = '';
|
if ($product->remove_fournisseur($_GET["socid"]) > 0)
|
||||||
}
|
|
||||||
}
|
|
||||||
else { // On supprime un fournisseur
|
|
||||||
if ($product->remove_fournisseur($user, $_GET["id_fourn"]) > 0)
|
|
||||||
{
|
{
|
||||||
$_GET["action"] = '';
|
$_GET["action"] = '';
|
||||||
$mesg = '<div class="ok">'.$langs->trans("SupplierRemoved").'.</div>';
|
$mesg = '<div class="ok">'.$langs->trans("SupplierRemoved").'.</div>';
|
||||||
@ -90,8 +85,9 @@ if ($_GET["action"] == 'remove_fourn')
|
|||||||
if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||||
{
|
{
|
||||||
|
|
||||||
$product = new Product($db);
|
$product = new ProductFournisseur($db);
|
||||||
if( $product->fetch($_GET["id"]) )
|
$result=$product->fetch($_REQUEST["id"]);
|
||||||
|
if ($result)
|
||||||
{
|
{
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
@ -105,14 +101,8 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc
|
|||||||
$error++;
|
$error++;
|
||||||
$mesg='<div class="error">'.$product->error.'</div>';
|
$mesg='<div class="error">'.$product->error.'</div>';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error && $_POST["qty"])
|
if ($_POST["qty"])
|
||||||
{
|
{
|
||||||
if ($_POST["price"] >= 0)
|
if ($_POST["price"] >= 0)
|
||||||
{
|
{
|
||||||
@ -138,12 +128,20 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc
|
|||||||
$error++;
|
$error++;
|
||||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'</div>';
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'</div>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,9 +164,10 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
{
|
{
|
||||||
if ($_GET["action"] <> 're-edit')
|
if ($_GET["action"] <> 're-edit')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new ProductFournisseur($db);
|
||||||
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
|
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
|
||||||
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
|
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
|
||||||
|
$product->fetch_fourn_data($_GET["socid"]);
|
||||||
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +222,7 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
{
|
{
|
||||||
$langs->load("suppliers");
|
$langs->load("suppliers");
|
||||||
|
|
||||||
if ($_GET["id_fourn"]) {
|
if ($_GET["rowid"]) {
|
||||||
print_fiche_titre($langs->trans("ChangeSupplierPrice"));
|
print_fiche_titre($langs->trans("ChangeSupplierPrice"));
|
||||||
} else {
|
} else {
|
||||||
print_fiche_titre($langs->trans("AddSupplierPrice"));
|
print_fiche_titre($langs->trans("AddSupplierPrice"));
|
||||||
@ -232,25 +231,45 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print '<form action="fournisseurs.php?id='.$product->id.'" method="post">';
|
print '<form action="fournisseurs.php?id='.$product->id.'" method="post">';
|
||||||
print '<input type="hidden" name="action" value="updateprice">';
|
print '<input type="hidden" name="action" value="updateprice">';
|
||||||
|
|
||||||
if ($_GET["id_fourn"]) {
|
if ($_GET["rowid"])
|
||||||
print '<input type="hidden" name="id_fourn" value="'.$_GET["id_fourn"].'">';
|
{
|
||||||
$product->fetch_fourn_data($_GET["id_fourn"]);
|
print '<input type="hidden" name="id_fourn" value="'.$_GET["socid"].'">';
|
||||||
print '<input type="hidden" name="ref_fourn" value="'.$product->ref_fourn.'">';
|
print '<input type="hidden" name="ref_fourn" value="'.$product->ref_fourn.'">';
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="5">';
|
print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="5">';
|
||||||
$html=new Form($db);
|
$html=new Form($db);
|
||||||
$html->select_societes('','id_fourn','fournisseur=1');
|
$html->select_societes('','id_fourn','fournisseur=1');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Ref").'</td><td>';
|
print '<tr><td>'.$langs->trans("SupplierRef").'</td><td>';
|
||||||
print '<input class="flat" name="ref_fourn" size="12" value="">';
|
if ($_GET["rowid"])
|
||||||
|
{
|
||||||
|
print $product->ref_fourn;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input class="flat" name="ref_fourn" size="12" value="'.$product->ref_fourn.'">';
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>'.$langs->trans("QtyMin").'</td>';
|
print '<td>'.$langs->trans("QtyMin").'</td>';
|
||||||
$quantity = $_GET["qty"] ? $_GET["qty"] : "1";
|
$quantity = $_GET["qty"] ? $_GET["qty"] : "1";
|
||||||
print '<td><input class="flat" name="qty" size="5" value="'.$quantity.'"></td>';
|
print '<td>';
|
||||||
|
if ($_GET["rowid"])
|
||||||
|
{
|
||||||
|
print '<input type="hidden" name="qty" value="'.$quantity.'">';
|
||||||
|
print $quantity;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input class="flat" name="qty" size="5" value="'.$quantity.'">';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
print '<td>'.$langs->trans("PriceQtyHT").'</td>';
|
print '<td>'.$langs->trans("PriceQtyHT").'</td>';
|
||||||
print '<td><input class="flat" name="price" size="8" value="'.price($_GET["price"]).'"></td></tr>';
|
$product->fetch_product_fournisseur_price($_GET["rowid"]);
|
||||||
|
print '<td><input class="flat" name="price" size="8" value="'.price($product->fourn_price).'"></td></tr>';
|
||||||
|
|
||||||
print '<tr><td colspan="6" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">';
|
print '<tr><td colspan="6" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">';
|
||||||
print ' ';
|
print ' ';
|
||||||
@ -272,7 +291,7 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
if ($user->rights->produit->creer)
|
if ($user->rights->produit->creer)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$product->id.'&action=add_price">';
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$product->id.'&action=add_price">';
|
||||||
print $langs->trans("AddSupplier").'</a>';
|
print $langs->trans("AddSupplierPrice").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -281,14 +300,15 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
if ($user->rights->fournisseur->lire) {
|
if ($user->rights->fournisseur->lire)
|
||||||
|
{
|
||||||
// Titre liste des fournisseurs
|
// Titre liste des fournisseurs
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
if ($product->isproduct()) $nblignefour=4;
|
if ($product->isproduct()) $nblignefour=4;
|
||||||
else $nblignefour=4;
|
else $nblignefour=4;
|
||||||
print '<tr class="liste_titre"><td valign="top">';
|
print '<tr class="liste_titre"><td valign="top">';
|
||||||
print $langs->trans("Suppliers").'</td>';
|
print $langs->trans("Suppliers").'</td>';
|
||||||
print '<td>'.$langs->trans("Ref").'</td>';
|
print '<td>'.$langs->trans("SupplierRef").'</td>';
|
||||||
print '<td align="center">'.$langs->trans("QtyMin").'</td>';
|
print '<td align="center">'.$langs->trans("QtyMin").'</td>';
|
||||||
print '<td align="right">'.$langs->trans("PriceQtyHT").'</td>';
|
print '<td align="right">'.$langs->trans("PriceQtyHT").'</td>';
|
||||||
print '<td align="right">'.$langs->trans("UnitPriceHT").'</td>';
|
print '<td align="right">'.$langs->trans("UnitPriceHT").'</td>';
|
||||||
@ -297,7 +317,8 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
|
|
||||||
// Liste des fournisseurs
|
// Liste des fournisseurs
|
||||||
$sql = "SELECT s.nom, s.rowid as socid,";
|
$sql = "SELECT s.nom, s.rowid as socid,";
|
||||||
$sql.= "pf.ref_fourn, pfp.price, pfp.quantity";
|
$sql.= " pf.ref_fourn,";
|
||||||
|
$sql.= " pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||||
$sql.= " ON pf.fk_soc = pfp.fk_soc AND pf.fk_product = pfp.fk_product";
|
$sql.= " ON pf.fk_soc = pfp.fk_soc AND pf.fk_product = pfp.fk_product";
|
||||||
@ -335,15 +356,15 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
|
|
||||||
// Prix unitaire
|
// Prix unitaire
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
print $objp->quantity?price($objp->price / $objp->quantity):" ";
|
print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):" ");
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Modifier-Supprimer
|
// Modifier-Supprimer
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
if ($user->rights->produit->creer) {
|
if ($user->rights->produit->creer)
|
||||||
print '<a href="fournisseurs.php?id='.$product->id.'&action=add_price&id_fourn='.$objp->socid.'&qty='.$objp->quantity.'&price='.$objp->price.'">'.img_edit()."</a>";
|
{
|
||||||
print '<a href="fournisseurs.php?id='.$product->id.'&action=remove_fourn&id_fourn='.$objp->socid.'&qty='.$objp->quantity.'">';
|
print '<a href="fournisseurs.php?id='.$product->id.'&socid='.$objp->socid.'&action=add_price&rowid='.$objp->rowid.'">'.img_edit()."</a>";
|
||||||
print img_disable($langs->trans("Remove")).'</a>';
|
print '<a href="fournisseurs.php?id='.$product->id.'&socid='.$objp->socid.'&action=remove_pf&rowid='.$objp->rowid.'">'.img_disable($langs->trans("Remove")).'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -742,6 +742,9 @@ drop table if exists `llx_accountingsystem_det`;
|
|||||||
|
|
||||||
update llx_bank set label='(InitialBankBalance)' where fk_type='SOLD' and label in ('Balance','(Balance)','Solde','(Solde)');
|
update llx_bank set label='(InitialBankBalance)' where fk_type='SOLD' and label in ('Balance','(Balance)','Solde','(Solde)');
|
||||||
|
|
||||||
|
alter table llx_product_fournisseur_price add unitprice double(16,8);
|
||||||
|
alter table llx_product_fournisseur_price add ref_fourn varchar(30) after fk_soc;
|
||||||
|
update llx_product_fournisseur_price set unitprice = ROUND(price/quantity,8) where unitprice IS NULL;
|
||||||
|
|
||||||
update llx_fichinter set tms=datec where tms < datec;
|
update llx_fichinter set tms=datec where tms < datec;
|
||||||
update llx_fichinter set tms=date_valid where tms < date_valid;
|
update llx_fichinter set tms=date_valid where tms < date_valid;
|
||||||
|
|||||||
@ -27,8 +27,10 @@ create table llx_product_fournisseur_price
|
|||||||
tms timestamp,
|
tms timestamp,
|
||||||
fk_product integer,
|
fk_product integer,
|
||||||
fk_soc integer, -- lien sur llx_societe
|
fk_soc integer, -- lien sur llx_societe
|
||||||
|
ref_fourn varchar(30),
|
||||||
price double(16,8),
|
price double(16,8),
|
||||||
quantity double,
|
quantity double,
|
||||||
|
unitprice double(16,8),
|
||||||
fk_user integer
|
fk_user integer
|
||||||
|
|
||||||
)type=innodb;
|
)type=innodb;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user