Qual: Uniformize code

This commit is contained in:
Laurent Destailleur 2011-11-20 12:55:28 +01:00
parent 2f100d0d72
commit c0774485f9

View File

@ -126,18 +126,8 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
{
if (($_POST['qty'] || $_POST['pqty']) && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice']))
{
$ret=$object->fetch($id);
if ($ret < 0)
{
dol_print_error($db,$object->error);
exit;
}
if ($object->socid)
{
$societe=new Societe($db);
$societe->fetch($object->socid);
}
if ($object->fetch($id) < 0) dol_print_error($db,$object->error);
if ($object->fetch_thirdparty() < 0) dol_print_error($db,$object->error);
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
@ -149,13 +139,6 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
$productsupplier = new ProductFournisseur($db);
$idprod=$productsupplier->get_buyprice($_POST['idprodfournprice'], $qty);
//$societe='';
/*if ($object->socid)
{
$societe=new Societe($db);
$societe->fetch($object->socid);
}*/
if ($idprod > 0)
{
$res=$productsupplier->fetch($idprod);
@ -170,12 +153,12 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
$remise_percent = $_POST["remise_percent"] ? $_POST["remise_percent"] : $_POST["p_remise_percent"];
$tva_tx = get_default_tva($societe,$mysoc,$productsupplier->id);
$tva_tx = get_default_tva($object->thirdparty,$mysoc,$productsupplier->id);
$type = $productsupplier->type;
// Local Taxes
$localtax1_tx= get_localtax($tva_tx, 1, $societe);
$localtax2_tx= get_localtax($tva_tx, 2, $societe);
$localtax1_tx= get_localtax($tva_tx, 1, $object->thirdparty);
$localtax2_tx= get_localtax($tva_tx, 2, $object->thirdparty);
$result=$object->addline(
$desc,
@ -206,8 +189,8 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
$tva_tx = price2num($_POST['tva_tx']);
// Local Taxes
$localtax1_tx= get_localtax($tva_tx, 1, $societe);
$localtax2_tx= get_localtax($tva_tx, 2, $societe);
$localtax1_tx= get_localtax($tva_tx, 1, $object->thirdparty);
$localtax2_tx= get_localtax($tva_tx, 2, $object->thirdparty);
if (! $_POST['dp_desc'])
{
@ -271,13 +254,11 @@ if ($action == 'updateligne' && $user->rights->fournisseur->commande->creer && $
if ($product->fetch($_POST["elrowid"]) < 0) dol_print_error($db);
}
if ($object->fetch($id) < 0) dol_print_error($db);
if ($object->fetch($id) < 0) dol_print_error($db,$object->error);
if ($object->fetch_thirdparty() < 0) dol_print_error($db,$object->error);
$societe=new Societe($db);
$societe->fetch($object->socid);
$localtax1_tx=get_localtax($_POST['tva_tx'],1,$societe);
$localtax2_tx=get_localtax($_POST['tva_tx'],2,$societe);
$localtax1_tx=get_localtax($_POST['tva_tx'],1,$object->thirdparty);
$localtax2_tx=get_localtax($_POST['tva_tx'],2,$object->thirdparty);
$result = $object->updateline(
$_POST['elrowid'],