From c0774485f99c8e9a895d29d15992f7b57266a576 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 20 Nov 2011 12:55:28 +0100 Subject: [PATCH] Qual: Uniformize code --- htdocs/fourn/commande/fiche.php | 41 +++++++++------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index f4a76a7eeb3..77b08dae967 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -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'],