Fix: Miscellaneous fix in supplier product input
This commit is contained in:
parent
eec2a7b34e
commit
082ee53dae
@ -3088,7 +3088,6 @@ class Form
|
|||||||
|
|
||||||
// Now we get list
|
// Now we get list
|
||||||
$num = $this->load_cache_vatrates($code_pays);
|
$num = $this->load_cache_vatrates($code_pays);
|
||||||
|
|
||||||
if ($num > 0)
|
if ($num > 0)
|
||||||
{
|
{
|
||||||
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
|
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
|
||||||
|
|||||||
@ -157,15 +157,16 @@ class ProductFournisseur extends Product
|
|||||||
if (empty($buyprice)) $buyprice=0;
|
if (empty($buyprice)) $buyprice=0;
|
||||||
if (empty($charges)) $charges=0;
|
if (empty($charges)) $charges=0;
|
||||||
if (empty($availability)) $availability=0;
|
if (empty($availability)) $availability=0;
|
||||||
if ($price_base_type == 'TTC')
|
if (empty($remise_percent)) $remise_percent=0;
|
||||||
|
if ($price_base_type == 'TTC')
|
||||||
{
|
{
|
||||||
$ttx = get_default_tva($fourn,$mysoc,$this->id);
|
//$ttx = get_default_tva($fourn,$mysoc,$this->id); // We must use the VAT rate defined by user and not calculate it
|
||||||
|
$ttx = $tva_tx;
|
||||||
$buyprice = $buyprice/(1+($ttx/100));
|
$buyprice = $buyprice/(1+($ttx/100));
|
||||||
}
|
}
|
||||||
$buyprice=price2num($buyprice,'MU');
|
$buyprice=price2num($buyprice,'MU');
|
||||||
$charges=price2num($charges,'MU');
|
$charges=price2num($charges,'MU');
|
||||||
$qty=price2num($qty);
|
$qty=price2num($qty);
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$unitBuyPrice = price2num($buyprice/$qty,'MU');
|
$unitBuyPrice = price2num($buyprice/$qty,'MU');
|
||||||
@ -190,6 +191,7 @@ class ProductFournisseur extends Product
|
|||||||
$sql.= " entity = ".$conf->entity.",";
|
$sql.= " entity = ".$conf->entity.",";
|
||||||
$sql.= " charges = ".($charges != ''?price2num($charges):"null");
|
$sql.= " charges = ".($charges != ''?price2num($charges):"null");
|
||||||
$sql.= " WHERE rowid = ".$this->product_fourn_price_id;
|
$sql.= " WHERE rowid = ".$this->product_fourn_price_id;
|
||||||
|
// TODO Add price_base_type and price_ttc
|
||||||
|
|
||||||
dol_syslog(get_class($this).'::update_buyprice sql='.$sql);
|
dol_syslog(get_class($this).'::update_buyprice sql='.$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -333,9 +335,11 @@ class ProductFournisseur extends Product
|
|||||||
* List all supplier prices of a product
|
* List all supplier prices of a product
|
||||||
*
|
*
|
||||||
* @param int $prodid Id of product
|
* @param int $prodid Id of product
|
||||||
|
* @param string $sortfield Sort field
|
||||||
|
* @param string $sortorder Sort order
|
||||||
* @return array Array of Products with new properties to define supplier price
|
* @return array Array of Products with new properties to define supplier price
|
||||||
*/
|
*/
|
||||||
function list_product_fournisseur_price($prodid)
|
function list_product_fournisseur_price($prodid, $sortfield='', $sortorder='')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -347,8 +351,8 @@ class ProductFournisseur extends Product
|
|||||||
$sql.= " WHERE pfp.entity IN (".getEntity('product', 1).")";
|
$sql.= " WHERE pfp.entity IN (".getEntity('product', 1).")";
|
||||||
$sql.= " AND pfp.fk_soc = s.rowid";
|
$sql.= " AND pfp.fk_soc = s.rowid";
|
||||||
$sql.= " AND pfp.fk_product = ".$prodid;
|
$sql.= " AND pfp.fk_product = ".$prodid;
|
||||||
$sql.= " ORDER BY s.nom, pfp.quantity, pfp.price";
|
if (empty($sortfield)) $sql.= " ORDER BY s.nom, pfp.quantity, pfp.price";
|
||||||
|
else $sql.= $this->db->order($sortfield,$sortorder);
|
||||||
dol_syslog(get_class($this)."::list_product_fournisseur_price sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::list_product_fournisseur_price sql=".$sql, LOG_DEBUG);
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -469,14 +473,16 @@ class ProductFournisseur extends Product
|
|||||||
* Display supplier of product
|
* Display supplier of product
|
||||||
*
|
*
|
||||||
* @param int $withpicto Add picto
|
* @param int $withpicto Add picto
|
||||||
|
* @param string $option Target of link ('', 'customer', 'prospect', 'supplier')
|
||||||
* @return string String with supplier price
|
* @return string String with supplier price
|
||||||
|
* TODO Remove this method. Use getNomUrl directly.
|
||||||
*/
|
*/
|
||||||
function getSocNomUrl($withpicto=0)
|
function getSocNomUrl($withpicto=0,$option='supplier')
|
||||||
{
|
{
|
||||||
$cust = new Fournisseur($this->db);
|
$cust = new Fournisseur($this->db);
|
||||||
$cust->fetch($this->fourn_id);
|
$cust->fetch($this->fourn_id);
|
||||||
|
|
||||||
return $cust->getNomUrl($withpicto);
|
return $cust->getNomUrl($withpicto,$option);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -145,8 +145,9 @@ Restock=Restock
|
|||||||
ProductSpecial=Special
|
ProductSpecial=Special
|
||||||
QtyMin=Quantity minimum
|
QtyMin=Quantity minimum
|
||||||
PriceQty=Price for this quantity
|
PriceQty=Price for this quantity
|
||||||
PriceQtyMin=Price quantity min.
|
PriceQtyMin=Price quantity min. (without discount)
|
||||||
DiscountQtyMin=Discount quantity min.
|
VATRateForSupplierProduct=VAT Rate (for this supplier/product)
|
||||||
|
DiscountQtyMin=Discount quantity min. (by default)
|
||||||
NoPriceDefinedForThisSupplier=No price/qty defined for this supplier/product
|
NoPriceDefinedForThisSupplier=No price/qty defined for this supplier/product
|
||||||
NoSupplierPriceDefinedForThisProduct=No supplier price/qty defined for this product
|
NoSupplierPriceDefinedForThisProduct=No supplier price/qty defined for this product
|
||||||
RecordedProducts=Products recorded
|
RecordedProducts=Products recorded
|
||||||
|
|||||||
@ -145,8 +145,9 @@ Restock=Réassort
|
|||||||
ProductSpecial=Special
|
ProductSpecial=Special
|
||||||
QtyMin=Quantité minimum
|
QtyMin=Quantité minimum
|
||||||
PriceQty=Prix pour la quantité
|
PriceQty=Prix pour la quantité
|
||||||
PriceQtyMin=Prix quantité min.
|
PriceQtyMin=Prix quantité min. (sans remise)
|
||||||
DiscountQtyMin=Remise quantité min.
|
DiscountQtyMin=Remise par défaut quantité min.
|
||||||
|
VATRateForSupplierProduct=Taux TVA (pour ce produit/fournisseur)
|
||||||
NoPriceDefinedForThisSupplier=Aucun prix/qté défini pour ce fournisseur/produit
|
NoPriceDefinedForThisSupplier=Aucun prix/qté défini pour ce fournisseur/produit
|
||||||
NoSupplierPriceDefinedForThisProduct=Aucun prix/qté fournisseur défini pour ce produit
|
NoSupplierPriceDefinedForThisProduct=Aucun prix/qté fournisseur défini pour ce produit
|
||||||
RecordedProducts=Produits en vente
|
RecordedProducts=Produits en vente
|
||||||
|
|||||||
@ -153,7 +153,6 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
|
|||||||
{
|
{
|
||||||
$supplier=new Fournisseur($db);
|
$supplier=new Fournisseur($db);
|
||||||
$result=$supplier->fetch($id_fourn);
|
$result=$supplier->fetch($id_fourn);
|
||||||
|
|
||||||
if (isset($_POST['ref_fourn_price_id']))
|
if (isset($_POST['ref_fourn_price_id']))
|
||||||
$product->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']);
|
$product->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']);
|
||||||
|
|
||||||
@ -273,7 +272,7 @@ if ($id || $ref)
|
|||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("Supplier").'</td><td colspan="5">';
|
print '<tr><td class="fieldrequired" width="25%">'.$langs->trans("Supplier").'</td><td>';
|
||||||
if ($rowid)
|
if ($rowid)
|
||||||
{
|
{
|
||||||
$supplier=new Fournisseur($db);
|
$supplier=new Fournisseur($db);
|
||||||
@ -298,7 +297,7 @@ if ($id || $ref)
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Ref supplier
|
// Ref supplier
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("SupplierRef").'</td><td colspan="5">';
|
print '<tr><td class="fieldrequired">'.$langs->trans("SupplierRef").'</td><td>';
|
||||||
if ($rowid)
|
if ($rowid)
|
||||||
{
|
{
|
||||||
print $product->fourn_ref;
|
print $product->fourn_ref;
|
||||||
@ -310,18 +309,11 @@ if ($id || $ref)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Vat rate
|
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("VATRate").'</td>';
|
|
||||||
print '<td colspan="3">';
|
|
||||||
//print $form->load_tva('tva_tx',$product->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country
|
|
||||||
print '<input type="text" class="flat" size="5" name="tva_tx" value="'.vatrate(GETPOST("tva_tx")?GETPOST("tva_tx"):$product->tva_tx).'">';
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Availability
|
// Availability
|
||||||
if (! empty($conf->global->FOURN_PRODUCT_AVAILABILITY))
|
if (! empty($conf->global->FOURN_PRODUCT_AVAILABILITY))
|
||||||
{
|
{
|
||||||
$langs->load("propal");
|
$langs->load("propal");
|
||||||
print '<tr><td>'.$langs->trans("Availability").'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans("Availability").'</td><td>';
|
||||||
$form->select_availability($product->fk_availability,"oselDispo",1);
|
$form->select_availability($product->fk_availability,"oselDispo",1);
|
||||||
print '</td></tr>'."\n";
|
print '</td></tr>'."\n";
|
||||||
}
|
}
|
||||||
@ -340,18 +332,41 @@ if ($id || $ref)
|
|||||||
{
|
{
|
||||||
print '<input class="flat" name="qty" size="5" value="'.$quantity.'">';
|
print '<input class="flat" name="qty" size="5" value="'.$quantity.'">';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
|
||||||
|
// Vat rate
|
||||||
|
$default_vat='';
|
||||||
|
|
||||||
|
// We don't have supplier, so we try to guess.
|
||||||
|
// For this we build a fictive supplier with same properties than user but using vat)
|
||||||
|
$mysoc2=dol_clone($mysoc);
|
||||||
|
$mysoc2->tva_assuj=1;
|
||||||
|
$default_vat=get_default_tva($mysoc2, $mysoc, 0, $product->id);
|
||||||
|
|
||||||
|
print '<tr><td class="fieldrequired">'.$langs->trans("VATRateForSupplierProduct").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
//print $form->load_tva('tva_tx',$product->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country
|
||||||
|
if (! empty($socid)) // When update
|
||||||
|
{
|
||||||
|
$supplierselected=new Societe($db);
|
||||||
|
$supplierselected->fetch($socid);
|
||||||
|
$default_vat=get_default_tva($supplier, $mysoc, $product->id);
|
||||||
|
}
|
||||||
|
if ($action == 'add_price' && $socid) $default_vat=$product->tva_tx; // If editing product-fourn
|
||||||
|
print '<input type="text" class="flat" size="5" name="tva_tx" value="'.(GETPOST("tva_tx")?vatrate(GETPOST("tva_tx")):($default_vat!=''?vatrate($default_vat):'')).'">';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
// Price qty min
|
// Price qty min
|
||||||
print '<td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>';
|
||||||
print '<td><input class="flat" name="price" size="8" value="'.(GETPOST('price')?price(GETPOST('price')):(isset($product->fourn_price)?price($product->fourn_price):'')).'">';
|
print '<td><input class="flat" name="price" size="8" value="'.(GETPOST('price')?price(GETPOST('price')):(isset($product->fourn_price)?price($product->fourn_price):'')).'">';
|
||||||
print ' ';
|
print ' ';
|
||||||
print $form->select_PriceBaseType((GETPOST('price_base_type')?GETPOST('price_base_type'):$product->price_base_type), "price_base_type");
|
print $form->select_PriceBaseType((GETPOST('price_base_type')?GETPOST('price_base_type'):$product->price_base_type), "price_base_type");
|
||||||
print '</td>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Discount qty min
|
// Discount qty min
|
||||||
print '<td>'.$langs->trans("DiscountQtyMin").'</td>';
|
print '<tr><td>'.$langs->trans("DiscountQtyMin").'</td>';
|
||||||
print '<td><input class="flat" name="remise_percent" size="8" value="'.(GETPOST('remise_percent')?vatrate(GETPOST('remise_percent')):(isset($product->fourn_remise_percent)?vatrate($product->fourn_remise_percent):'')).'"> %';
|
print '<td><input class="flat" name="remise_percent" size="4" value="'.(GETPOST('remise_percent')?vatrate(GETPOST('remise_percent')):(isset($product->fourn_remise_percent)?vatrate($product->fourn_remise_percent):'')).'"> %';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
@ -360,7 +375,7 @@ if ($id || $ref)
|
|||||||
{
|
{
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans("Charges").'</td>';
|
print '<td>'.$langs->trans("Charges").'</td>';
|
||||||
print '<td colspan="3"><input class="flat" name="charges" size="8" value="'.(GETPOST('charges')?price(GETPOST('charges')):(isset($product->fourn_charges)?price($product->fourn_charges):'')).'">';
|
print '<td><input class="flat" name="charges" size="8" value="'.(GETPOST('charges')?price(GETPOST('charges')):(isset($product->fourn_charges)?price($product->fourn_charges):'')).'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
@ -420,7 +435,7 @@ if ($id || $ref)
|
|||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$product_fourn = new ProductFournisseur($db);
|
$product_fourn = new ProductFournisseur($db);
|
||||||
$product_fourn_list = $product_fourn->list_product_fournisseur_price($product->id);
|
$product_fourn_list = $product_fourn->list_product_fournisseur_price($product->id, $sortfield, $sortorder);
|
||||||
|
|
||||||
if (count($product_fourn_list)>0)
|
if (count($product_fourn_list)>0)
|
||||||
{
|
{
|
||||||
@ -432,7 +447,7 @@ if ($id || $ref)
|
|||||||
|
|
||||||
print "<tr ".$bc[$var].">";
|
print "<tr ".$bc[$var].">";
|
||||||
|
|
||||||
print '<td>'.$productfourn->getSocNomUrl(1).'</td>';
|
print '<td>'.$productfourn->getSocNomUrl(1,'supplier').'</td>';
|
||||||
|
|
||||||
// Supplier
|
// Supplier
|
||||||
print '<td align="left">'.$productfourn->fourn_ref.'</td>';
|
print '<td align="left">'.$productfourn->fourn_ref.'</td>';
|
||||||
@ -476,7 +491,7 @@ if ($id || $ref)
|
|||||||
|
|
||||||
// Discount
|
// Discount
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
print vatrate($productfourn->fourn_remise_percent, $langs);
|
print price2num($productfourn->fourn_remise_percent).'%';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Unit Charges ???
|
// Unit Charges ???
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user