From 1063772919960d830bd4baffb9d77973b4ae541f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 May 2009 15:52:08 +0000 Subject: [PATCH] Qual: Uniformize code --- htdocs/comm/propal.php | 17 ++++++++----- htdocs/commande/fiche.php | 23 ++++++++++++------ htdocs/compta/facture.php | 25 +++++++++++++------- htdocs/fourn/commande/fiche.php | 17 +++++++++---- htdocs/fourn/facture/fiche.php | 42 ++++++++++++++++++++++++++------- 5 files changed, 91 insertions(+), 33 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 96c5061e47a..232e9b09a63 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -601,7 +601,7 @@ if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer) /* * Ajout d'une ligne produit dans la propale */ -if ($_POST['action'] == "addligne" && $user->rights->propale->creer) +if ($_POST['action'] == "addline" && $user->rights->propale->creer) { if (isset($_POST['qty']) && (($_POST['np_price']!='' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod'])) { @@ -702,13 +702,18 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer) $outputlangs->setDefaultLang($_REQUEST['lang_id']); } propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['np_price']); + unset($_POST['dp_desc']); + unset($_POST['np_tva_tx']); } else { $mesg='
'.$propal->error.'
'; } } - } } @@ -1602,7 +1607,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; print ''; - print ''; + print ''; $var=true; print '\n"; @@ -1632,7 +1637,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print '%'; - print ''; + print ''; print ''; print '
'; @@ -1667,7 +1672,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; print ''; - print ''; + print ''; $var=!$var; @@ -1700,7 +1705,7 @@ if ($id > 0 || ! empty($ref)) print ''; print '%'; - print ''; + print ''; print ''."\n"; print '
'; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 1dcb5256ffa..18e07610339 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -310,7 +310,7 @@ if ($_REQUEST['action'] == 'setremiseabsolue' && $user->rights->facture->creer) /* * Ajout d'une ligne produit dans la commande */ -if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) +if ($_POST['action'] == 'addline' && $user->rights->commande->creer) { $result=0; @@ -434,6 +434,15 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) $outputlangs->setDefaultLang($_REQUEST['lang_id']); } commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprod']); + unset($_POST['remmise_percent']); + unset($_POST['dp_desc']); + unset($_POST['np_desc']); + unset($_POST['pu']); + unset($_POST['tva_tx']); } else { @@ -1785,7 +1794,7 @@ else print '
'; print ''; print ''; - print ''; + print ''; $var=true; print ''; @@ -1824,9 +1833,9 @@ else // Start and end dates selector print ''; print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $html->select_date('','date_start',$usehm,$usehm,1,"addligne"); + print $html->select_date('','date_start',$usehm,$usehm,1,"addline"); print ' '.$langs->trans('to').' '; - print $html->select_date('','date_end',$usehm,$usehm,1,"addligne"); + print $html->select_date('','date_end',$usehm,$usehm,1,"addline"); print ''; print ''; } @@ -1855,7 +1864,7 @@ else print ''; print ''; print ''; - print ''; + print ''; $var=!$var; print ''; @@ -1896,9 +1905,9 @@ else // Start and end dates selector print ''; print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $html->select_date('','date_start_prod',$usehm,$usehm,1,"addligne"); + print $html->select_date('','date_start_prod',$usehm,$usehm,1,"addline"); print ' '.$langs->trans('to').' '; - print $html->select_date('','date_end_prod',$usehm,$usehm,1,"addligne"); + print $html->select_date('','date_end_prod',$usehm,$usehm,1,"addline"); print ''; print ''; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c0113d1eab7..6c3eb49f3b6 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -842,7 +842,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) /* * Ajout d'une ligne produit dans la facture */ -if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && $user->rights->facture->creer) +if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $user->rights->facture->creer) { $result=0; @@ -971,6 +971,15 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && $outputlangs->setDefaultLang($_REQUEST['lang_id']); } facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprod']); + unset($_POST['remmise_percent']); + unset($_POST['dp_desc']); + unset($_POST['np_desc']); + unset($_POST['pu']); + unset($_POST['tva_tx']); } else { @@ -3005,10 +3014,10 @@ else print "\n"; // Add free products/services form - print ''; + print ''; print ''; print ''; - print ''; + print ''; $var=true; print ''; @@ -3045,9 +3054,9 @@ else { print ''; print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $html->select_date('','date_start',$usehm,$usehm,1,"addligne"); + print $html->select_date('','date_start',$usehm,$usehm,1,"addline"); print ' '.$langs->trans('to').' '; - print $html->select_date('','date_end',$usehm,$usehm,1,"addligne"); + print $html->select_date('','date_end',$usehm,$usehm,1,"addline"); print ''; print ''; } @@ -3077,7 +3086,7 @@ else print ''; print ''; print ''; - print ''; + print ''; $var=! $var; print ''; @@ -3115,9 +3124,9 @@ else { print ''; print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $html->select_date('','date_start_predef',$usehm,$usehm,1,"addligne_predef"); + print $html->select_date('','date_start_predef',$usehm,$usehm,1,"addline_predef"); print ' '.$langs->trans('to').' '; - print $html->select_date('','date_end_predef',$usehm,$usehm,1,"addligne_predef"); + print $html->select_date('','date_end_predef',$usehm,$usehm,1,"addline_predef"); print ''; print ''; } diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 6b21b7d123d..2128ba4e3d9 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -83,7 +83,7 @@ if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->fournisseur->com /* * Ajout d'une ligne produit dans la commande */ -if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->creer) +if ($_POST['action'] == 'addline' && $user->rights->fournisseur->commande->creer) { if ($_POST['qty'] && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice'])) { @@ -180,8 +180,17 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree $outputlangs->setDefaultLang($_REQUEST['lang_id']); } supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprodfournprice']); + unset($_POST['remmise_percent']); + unset($_POST['dp_desc']); + unset($_POST['np_desc']); + unset($_POST['pu']); + unset($_POST['tva_tx']); } - else + else if (empty($mesg)) { $mesg='
'.$commande->error.'
'; } @@ -848,7 +857,7 @@ if ($id > 0 || ! empty($ref)) // Add free products/services form print ''; print ''; - print ''; + print ''; print ''; $var=true; @@ -906,7 +915,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - print ''; + print ''; print ''; $var=!$var; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index eab8a7d1b50..84ef42c347c 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -282,7 +282,7 @@ if ($_REQUEST['action'] == 'update_line') } } -if ($_GET['action'] == 'add_ligne') +if ($_GET['action'] == 'addline') { $facfou = new FactureFournisseur($db, '', $_GET['facid']); $ret=$facfou->fetch($_GET['facid']); @@ -292,10 +292,10 @@ if ($_GET['action'] == 'add_ligne') exit; } - if ($_POST['prodfournpriceid']) // > 0 or -1 + if ($_POST['idprodfournprice']) // > 0 or -1 { $product = new ProductFournisseur($db); - $idprod=$product->get_buyprice($_POST['prodfournpriceid'], $_POST['qty']); + $idprod=$product->get_buyprice($_POST['idprodfournprice'], $_POST['qty']); if ($idprod > 0) { $result=$product->fetch($idprod); @@ -337,17 +337,43 @@ if ($_GET['action'] == 'add_ligne') $ht = price2num($_POST['amount']); $price_base_type = 'HT'; //$desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0) - $facfou->addline($_POST['label'], $ht, $tauxtva, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type); + $result=$facfou->addline($_POST['label'], $ht, $tauxtva, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type); } else { $ttc = price2num($_POST['amountttc']); $ht = $ttc / (1 + ($tauxtva / 100)); $price_base_type = 'HT'; - $facfou->addline($_POST['label'], $ht, $tauxtva, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type); + $result=$facfou->addline($_POST['label'], $ht, $tauxtva, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type); } } } + + //print "xx".$tva_tx; exit; + if ($result > 0) + { + $outputlangs = $langs; + if (! empty($_REQUEST['lang_id'])) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + //supplier_invoice_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprodfournprice']); + unset($_POST['remmise_percent']); + unset($_POST['dp_desc']); + unset($_POST['np_desc']); + unset($_POST['pu']); + unset($_POST['tva_tx']); + } + else if (empty($mesg)) + { + $mesg='
'.$facfou->error.'
'; + } + $_GET['action'] = ''; } @@ -957,7 +983,7 @@ else print ''; // Add free products/services form - print ''; + print ''; print ''; print ''; print ''; @@ -1022,7 +1048,7 @@ else print ' '; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -1030,7 +1056,7 @@ else $var=! $var; print ''; print ''; - $html->select_produits_fournisseurs($fac->socid,'','prodfournpriceid','',$filtre); + $html->select_produits_fournisseurs($fac->socid,'','idprodfournprice','',$filtre); print ''; print ''; print ' ';