Fix: Do not show ref supplier title if ref_supplier not set (currently

always the case with 3.5).
This commit is contained in:
Laurent Destailleur 2014-05-25 03:57:13 +02:00
parent 9bc1a6b4f5
commit ae01c785c5
5 changed files with 32 additions and 24 deletions

View File

@ -1032,10 +1032,10 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
if (empty($hideref)) if (empty($hideref))
{ {
if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref if ($issupplierline) $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref
else $ref_prodserv = $prodser->ref; // Show local ref only else $ref_prodserv = $prodser->ref; // Show local ref only
$ref_prodserv .= " - "; if (! empty($libelleproduitservice)) $ref_prodserv .= " - ";
} }
$libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice;

View File

@ -420,7 +420,7 @@ class FactureFournisseur extends CommonInvoice
*/ */
function fetch_lines() function fetch_lines()
{ {
$sql = 'SELECT f.rowid, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx, f.tva'; $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx, f.tva';
$sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 '; $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 ';
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits'; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits';
$sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc';
@ -428,7 +428,7 @@ class FactureFournisseur extends CommonInvoice
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
$sql.= ' WHERE fk_facture_fourn='.$this->id; $sql.= ' WHERE fk_facture_fourn='.$this->id;
dol_syslog("FactureFournisseur::fetch_lines sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch_lines sql=".$sql, LOG_DEBUG);
$resql_rows = $this->db->query($sql); $resql_rows = $this->db->query($sql);
if ($resql_rows) if ($resql_rows)
{ {
@ -443,10 +443,10 @@ class FactureFournisseur extends CommonInvoice
$this->lines[$i] = new stdClass(); $this->lines[$i] = new stdClass();
$this->lines[$i]->rowid = $obj->rowid; $this->lines[$i]->rowid = $obj->rowid;
$this->lines[$i]->description = $obj->description; $this->lines[$i]->description = $obj->description;
$this->lines[$i]->ref = $obj->product_ref; // TODO deprecated
$this->lines[$i]->product_ref = $obj->product_ref; // Internal reference $this->lines[$i]->product_ref = $obj->product_ref; // Internal reference
//$this->lines[$i]->ref_fourn = $obj->ref_fourn; // Reference fournisseur du produit $this->lines[$i]->ref = $obj->product_ref; // TODO deprecated. Replace with next line
$this->lines[$i]->libelle = $obj->label; // Label du produit //$this->lines[$i]->ref_supplier = $obj->ref_supplier; // Reference product supplier TODO Rename field ref into ref_supplier into table llx_facture_fourn_det and update it into updateline
$this->lines[$i]->libelle = $obj->label; // deprecated
$this->lines[$i]->product_desc = $obj->product_desc; // Description du produit $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit
$this->lines[$i]->pu_ht = $obj->pu_ht; $this->lines[$i]->pu_ht = $obj->pu_ht;
$this->lines[$i]->pu_ttc = $obj->pu_ttc; $this->lines[$i]->pu_ttc = $obj->pu_ttc;
@ -474,7 +474,7 @@ class FactureFournisseur extends CommonInvoice
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog('FactureFournisseur::fetch_lines: Error '.$this->error,LOG_ERR); dol_syslog(get_class($this).'::fetch_lines: Error '.$this->error,LOG_ERR);
return -3; return -3;
} }
} }
@ -1127,7 +1127,7 @@ class FactureFournisseur extends CommonInvoice
* Update a line detail into database * Update a line detail into database
* *
* @param int $id Id of line invoice * @param int $id Id of line invoice
* @param string $label Description of line * @param string $desc Description of line
* @param double $pu Prix unitaire (HT ou TTC selon price_base_type) * @param double $pu Prix unitaire (HT ou TTC selon price_base_type)
* @param double $vatrate VAT Rate * @param double $vatrate VAT Rate
* @param double $txlocaltax1 LocalTax1 Rate * @param double $txlocaltax1 LocalTax1 Rate
@ -1141,9 +1141,9 @@ class FactureFournisseur extends CommonInvoice
* @param int $notrigger Disable triggers * @param int $notrigger Disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function updateline($id, $label, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false) function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false)
{ {
dol_syslog(get_class($this)."::updateline $id,$label,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG); dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
$pu = price2num($pu); $pu = price2num($pu);
@ -1192,7 +1192,7 @@ class FactureFournisseur extends CommonInvoice
} }
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
$sql.= " description ='".$this->db->escape($label)."'"; $sql.= " description ='".$this->db->escape($desc)."'";
$sql.= ", pu_ht = ".price2num($pu_ht); $sql.= ", pu_ht = ".price2num($pu_ht);
$sql.= ", pu_ttc = ".price2num($pu_ttc); $sql.= ", pu_ttc = ".price2num($pu_ttc);
$sql.= ", qty = ".price2num($qty); $sql.= ", qty = ".price2num($qty);

View File

@ -40,8 +40,13 @@ class ProductFournisseur extends Product
var $product_fourn_price_id; // id of ligne product-supplier var $product_fourn_price_id; // id of ligne product-supplier
var $id; // product id var $id; // product id
var $fourn_ref; // ref supplier var $fourn_ref; // deprecated
var $fourn_qty; // quantity for price var $ref_supplier; // ref supplier (can be set by get_buyprice)
var $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice)
var $fourn_qty; // quantity for price (can be set by get_buyprice)
var $fourn_pu; // unit price for quantity (can be set by get_buyprice)
var $fourn_price; // price for quantity var $fourn_price; // price for quantity
var $fourn_remise_percent; // discount for quantity (percent) var $fourn_remise_percent; // discount for quantity (percent)
var $fourn_remise; // discount for quantity (amount) var $fourn_remise; // discount for quantity (amount)

View File

@ -593,6 +593,7 @@ elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer)
$type = $productsupplier->type; $type = $productsupplier->type;
// TODO Save the product supplier ref into database into field ref_supplier (must rename field ref into ref_supplier first)
$result=$object->addline($desc, $productsupplier->fourn_pu, $tvatx, $localtax1tx, $localtax2tx, $qty, $idprod, $remise_percent, '', '', 0, $npr); $result=$object->addline($desc, $productsupplier->fourn_pu, $tvatx, $localtax1tx, $localtax2tx, $qty, $idprod, $remise_percent, '', '', 0, $npr);
} }
if ($idprod == 0) if ($idprod == 0)

View File

@ -902,14 +902,14 @@ class Product extends CommonObject
/** /**
* Lit le prix pratique par un fournisseur * Read price used by a provider
* On renseigne le couple prodfournprice/qty ou le triplet qty/product_id/fourn_ref * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref
* *
* @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price
* @param double $qty Quantity asked * @param double $qty Quantity asked
* @param int $product_id Filter on a particular product id * @param int $product_id Filter on a particular product id
* @param string $fourn_ref Filter on a supplier ref * @param string $fourn_ref Filter on a supplier ref
* @return int <-1 if KO, -1 if qty not enough, 0 si ok mais rien trouve, id_product si ok et trouve * @return int <-1 if KO, -1 if qty not enough, 0 si ok mais rien trouve, id_product si ok et trouve. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...)
*/ */
function get_buyprice($prodfournprice,$qty,$product_id=0,$fourn_ref=0) function get_buyprice($prodfournprice,$qty,$product_id=0,$fourn_ref=0)
{ {
@ -940,7 +940,7 @@ class Product extends CommonObject
{ {
// We do same select again but searching with qty, ref and id product // We do same select again but searching with qty, ref and id product
$sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,";
$sql.= " pfp.fk_product, pfp.ref_fourn, pfp.tva_tx"; $sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.ref_fourn = '".$fourn_ref."'"; $sql.= " WHERE pfp.ref_fourn = '".$fourn_ref."'";
$sql.= " AND pfp.fk_product = ".$product_id; $sql.= " AND pfp.fk_product = ".$product_id;
@ -955,9 +955,11 @@ class Product extends CommonObject
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj && $obj->quantity > 0) // If found if ($obj && $obj->quantity > 0) // If found
{ {
$this->buyprice = $obj->price; // \deprecated $this->buyprice = $obj->price; // deprecated
$this->fourn_qty = $obj->quantity; // min quantity for price
$this->fourn_pu = $obj->price / $obj->quantity; // Prix unitaire du produit pour le fournisseur $fourn_id $this->fourn_pu = $obj->price / $obj->quantity; // Prix unitaire du produit pour le fournisseur $fourn_id
$this->ref_fourn = $obj->ref_fourn; // Ref supplier $this->ref_fourn = $obj->ref_supplier; // deprecated
$this->ref_supplier = $obj->ref_supplier; // Ref supplier
$this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier
$result=$obj->fk_product; $result=$obj->fk_product;
return $result; return $result;