From 6750987dcb748f7ca6a15ca3c72c70a9b1346ef9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Jun 2013 00:21:17 +0200 Subject: [PATCH] Qual: id of an instance should not be provided into method of instance --- htdocs/product/admin/product_tools.php | 4 +-- htdocs/product/price.php | 49 ++++++++++++++------------ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 5cb378241dc..de1ae7cdd7c 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -104,7 +104,7 @@ if ($action == 'convert') if (! empty($price_base_type)) { print "$newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr
\n"; - $ret=$objectstatic->updatePrice($objectstatic->id, $newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr); + $ret=$objectstatic->updatePrice($newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr); } // Update multiprice foreach ($objectstatic->multiprices as $level => $multiprices) @@ -128,7 +128,7 @@ if ($action == 'convert') $newlevel=$level; print "$newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr
\n"; - $retm=$objectstatic->updatePrice($objectstatic->id, $newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr); + $retm=$objectstatic->updatePrice($newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr); if ($retm < 0) { $error++; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 2d0a1816982..240844b9f4d 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -51,7 +51,7 @@ $object = new Product($db); if ($action == 'update_price' && ! $_POST["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { $result = $object->fetch($id); - + // MultiPrix if (! empty($conf->global->PRODUIT_MULTIPRICES)) { @@ -88,7 +88,7 @@ if ($action == 'update_price' && ! $_POST["cancel"] && ($user->rights->produit-> $newpsq = empty($newpsq) ? 0 : $newpsq; } - if ($object->updatePrice($object->id, $newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0) + if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0) { $action = ''; $mesg = '
'.$langs->trans("RecordSaved").'
'; @@ -112,8 +112,8 @@ $error=0; if ($action == 'activate_price_by_qty') { // Activating product price by quantity add a new price, specified as by quantity $result = $object->fetch($id); $level=GETPOST('level'); - - $object->updatePrice($object->id, 0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1); + + $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1); } if ($action == 'edit_price_by_qty') { // Edition d'un prix par quantité @@ -131,7 +131,7 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu $quantity=GETPOST('quantity'); $remise_percent=price2num(GETPOST('remise_percent')); $remise=0; // TODO : allow dicsount by amount when available on documents - + if (empty($quantity)) { $error++; @@ -148,10 +148,10 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu { $price = price2num($newprice) / (1 + ($object->tva_tx / 100)); } - + $price = price2num($newprice,'MU'); $unitPrice = price2num($price/$quantity,'MU'); - + // Ajout / mise à jour if($rowid > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."product_price_by_qty SET"; @@ -161,12 +161,12 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu $sql.= " remise_percent=".$remise_percent.","; $sql.= " remise=".$remise; $sql.= " WHERE rowid = ".GETPOST('rowid'); - + $result = $db->query($sql); } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values ("; $sql.= $priceid.','.$price.','.$unitPrice.','.$quantity.','.$remise_percent.','.$remise.')'; - + $result = $db->query($sql); } } @@ -174,19 +174,19 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu if ($action == 'delete_price_by_qty') { $rowid = GETPOST('rowid'); - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; $sql.= " WHERE rowid = ".GETPOST('rowid'); - + $result = $db->query($sql); } if ($action == 'delete_all_price_by_qty') { $priceid=GETPOST('priceid'); - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; $sql.= " WHERE fk_product_price = ".$priceid; - + $result = $db->query($sql); } @@ -325,10 +325,10 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) { print ''.$langs->trans("PriceByQuantity").' '.$i; print ''; - + if($object->prices_by_qty[$i] == 1) { print ''; - + print ''; print ''; print ''; @@ -383,7 +383,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; print ''; } - + print '
'.$langs->trans("PriceByQuantityRange").' '.$i.''.$langs->trans("HT").'
'; } else { print $langs->trans("No"); @@ -422,16 +422,18 @@ else print price($object->price_min).' '.$langs->trans($object->price_base_type); } print ''; - + // Price by quantity - if($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) { + if($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) + { print ''.$langs->trans("PriceByQuantity"); if($object->prices_by_qty[0] == 0) { print ' '.$langs->trans("Activate"); } print ''; - - if($object->prices_by_qty[0] == 1) { + + if ($object->prices_by_qty[0] == 1) + { print ''; print ''; print ''; @@ -440,7 +442,8 @@ else print ''; print ''; print ''; - foreach ($object->prices_by_qty_list[0] as $ii=> $prices) { + foreach ($object->prices_by_qty_list[0] as $ii=> $prices) + { if($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { print ''; print ''; @@ -667,8 +670,8 @@ $sql.= " WHERE fk_product = ".$object->id; $sql.= " AND p.fk_user_author = u.rowid"; if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES)) $sql.= " AND p.price_level = ".$soc->price_level; $sql.= " ORDER BY p.date_price DESC, p.price_level ASC"; -//$sql .= $db->plimit(); +dol_syslog("sql=".$sql); $result = $db->query($sql); if ($result) { @@ -680,7 +683,7 @@ if ($result) // Il doit au moins y avoir la ligne de prix initial. // On l'ajoute donc pour remettre a niveau (pb vieilles versions) - $object->updatePrice($object->id, $object->price, $object->price_base_type, $user, $newprice_min); + $object->updatePrice($object->price, $object->price_base_type, $user, $newprice_min); $result = $db->query($sql); $num = $db->num_rows($result);
'.$langs->trans("PriceByQuantityRange").''.$langs->trans("Discount").'