Fix: Restore compatibility. Try to isolate "charges" feature with
a condition (i did not understand what it means and goal, i'm afraid other users should not understand too).
This commit is contained in:
parent
758d613908
commit
de621f0567
@ -137,22 +137,25 @@ class ProductFournisseur extends Product
|
|||||||
* @param float $buyprice Purchase price for the quantity min
|
* @param float $buyprice Purchase price for the quantity min
|
||||||
* @param User $user Object user user made changes
|
* @param User $user Object user user made changes
|
||||||
* @param string $price_base_type HT or TTC
|
* @param string $price_base_type HT or TTC
|
||||||
* @param string $charges costs affering to product
|
|
||||||
* @param Societe $fourn Supplier
|
* @param Societe $fourn Supplier
|
||||||
* @param int $availability Product availability
|
* @param int $availability Product availability
|
||||||
* @param string $ref_fourn Supplier ref
|
* @param string $ref_fourn Supplier ref
|
||||||
* @param float $tva_tx VAT rate
|
* @param float $tva_tx VAT rate
|
||||||
|
* @param string $charges costs affering to product
|
||||||
* @return int >0 if KO, >0 if OK
|
* @return int >0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function update_buyprice($qty, $buyprice, $charges, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx)
|
function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0)
|
||||||
{
|
{
|
||||||
global $conf,$mysoc;
|
global $conf,$mysoc;
|
||||||
|
|
||||||
// Clean parameter
|
// Clean parameter
|
||||||
|
if (empty($qty)) $qty=0;
|
||||||
|
if (empty($buyprice)) $buyprice=0;
|
||||||
|
if (empty($charges)) $charges=0;
|
||||||
|
if (empty($availability)) $availability=0;
|
||||||
$buyprice=price2num($buyprice);
|
$buyprice=price2num($buyprice);
|
||||||
$charges=price2num($charges);
|
$charges=price2num($charges);
|
||||||
$qty=price2num($qty);
|
$qty=price2num($qty);
|
||||||
if (empty($availability)) $availability=0;
|
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
@ -174,15 +177,15 @@ class ProductFournisseur extends Product
|
|||||||
$sql.= " SET fk_user = " . $user->id." ,";
|
$sql.= " SET fk_user = " . $user->id." ,";
|
||||||
$sql.= " price = ".price2num($buyprice).",";
|
$sql.= " price = ".price2num($buyprice).",";
|
||||||
$sql.= " quantity = ".$qty.",";
|
$sql.= " quantity = ".$qty.",";
|
||||||
$sql.= " charges = ".price2num($charges).",";
|
|
||||||
$sql.= " unitprice = ".$unitBuyPrice.",";
|
$sql.= " unitprice = ".$unitBuyPrice.",";
|
||||||
$sql.= " unitcharges = ".$unitCharges.",";
|
$sql.= " unitcharges = ".$unitCharges.",";
|
||||||
$sql.= " tva_tx = ".$tva_tx.",";
|
$sql.= " tva_tx = ".$tva_tx.",";
|
||||||
$sql.= " fk_availability = ".$availability.",";
|
$sql.= " fk_availability = ".$availability.",";
|
||||||
$sql.= " entity = ".$conf->entity;
|
$sql.= " entity = ".$conf->entity.",";
|
||||||
$sql .= " WHERE rowid = ".$this->product_fourn_price_id;
|
$sql.= " charges = ".($charges != ''?price2num($charges):"null");
|
||||||
|
$sql.= " WHERE rowid = ".$this->product_fourn_price_id;
|
||||||
|
|
||||||
$resql = $this->db->query($sql) ;
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
@ -198,14 +201,13 @@ class ProductFournisseur extends Product
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Supprime prix courant du fournisseur pour cette quantite
|
// Delete price for this quantity
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||||
$sql.= " WHERE rowid = ".$this->product_fourn_price_id;
|
$sql.= " WHERE rowid = ".$this->product_fourn_price_id;
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
// Add price for this quantity to supplier
|
||||||
// Ajoute prix courant du fournisseur pour cette quantite
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
|
||||||
$sql.= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, unitprice, tva_tx, fk_availability, entity)";
|
$sql.= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, unitprice, tva_tx, fk_availability, entity)";
|
||||||
$sql.= " values('".$this->db->idate($now)."',";
|
$sql.= " values('".$this->db->idate($now)."',";
|
||||||
|
|||||||
@ -155,7 +155,7 @@ if ($action == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
|||||||
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']);
|
||||||
|
|
||||||
$ret=$product->update_buyprice($quantity, $_POST["price"], $_POST["charges"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx);
|
$ret=$product->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"]);
|
||||||
if ($ret < 0)
|
if ($ret < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
@ -348,9 +348,15 @@ if ($id || $ref)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// Charges ????
|
||||||
|
if (! empty($conf->global->PRODUCT_LOAD))
|
||||||
|
{
|
||||||
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans("Charges").'</td>';
|
print '<td>'.$langs->trans("Charges").'</td>';
|
||||||
print '<td><input class="flat" name="charges" size="8" value="'.($_POST["charges"]?$_POST["charges"]:price($product->fourn_charges)).'">';
|
print '<td colspan="3"><input class="flat" name="charges" size="8" value="'.($_POST["charges"]?$_POST["charges"]:price($product->fourn_charges)).'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
@ -397,9 +403,11 @@ if ($id || $ref)
|
|||||||
print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"],"pfp.quantity","",$param,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"],"pfp.quantity","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
print '<td class="liste_titre" align="right">'.$langs->trans("VATRate").'</td>';
|
print '<td class="liste_titre" align="right">'.$langs->trans("VATRate").'</td>';
|
||||||
print '<td class="liste_titre" align="right">'.$langs->trans("PriceQtyMinHT").'</td>';
|
print '<td class="liste_titre" align="right">'.$langs->trans("PriceQtyMinHT").'</td>';
|
||||||
print '<td align="right">'.$langs->trans("Charges").'</td>';
|
// Charges ????
|
||||||
|
if (! empty($conf->global->PRODUCT_LOAD)) print '<td align="right">'.$langs->trans("Charges").'</td>';
|
||||||
print_liste_field_titre($langs->trans("UnitPriceHT"),$_SERVER["PHP_SELF"],"pfp.unitprice","",$param,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("UnitPriceHT"),$_SERVER["PHP_SELF"],"pfp.unitprice","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
print '<td align="right">'.$langs->trans("UnitCharges").'</td>';
|
// Charges ????
|
||||||
|
if (! empty($conf->global->PRODUCT_LOAD)) print '<td align="right">'.$langs->trans("UnitCharges").'</td>';
|
||||||
print '<td class="liste_titre"></td>';
|
print '<td class="liste_titre"></td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
@ -444,10 +452,13 @@ if ($id || $ref)
|
|||||||
print $productfourn->fourn_price?price($productfourn->fourn_price):"";
|
print $productfourn->fourn_price?price($productfourn->fourn_price):"";
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Charges
|
// Charges ????
|
||||||
|
if (! empty($conf->global->PRODUCT_LOAD))
|
||||||
|
{
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
print $productfourn->fourn_charges?price($productfourn->fourn_charges):"";
|
print $productfourn->fourn_charges?price($productfourn->fourn_charges):"";
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
// Unit price
|
// Unit price
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
@ -455,10 +466,13 @@ if ($id || $ref)
|
|||||||
//print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):" ");
|
//print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):" ");
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Unit Charges
|
// Unit Charges ???
|
||||||
|
if (! empty($conf->global->PRODUCT_LOAD))
|
||||||
|
{
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
print $productfourn->fourn_unitcharges?price($productfourn->fourn_unitcharges) : ($productfourn->fourn_qty?price($productfourn->fourn_charges/$productfourn->fourn_qty):" ");
|
print $productfourn->fourn_unitcharges?price($productfourn->fourn_unitcharges) : ($productfourn->fourn_qty?price($productfourn->fourn_charges/$productfourn->fourn_qty):" ");
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
// Modify-Remove
|
// Modify-Remove
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user