diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 66099c9bcf0..84a6e6eb5ca 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -635,6 +635,7 @@ else if ($action == "addline" && $user->rights->propal->creer) $idprod=GETPOST('idprod', 'int'); $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); $price_ht = GETPOST('price_ht'); + $tva_tx = GETPOST('tva_tx'); if (empty($idprod) && GETPOST('type') < 0) { @@ -674,8 +675,9 @@ else if ($action == "addline" && $user->rights->propal->creer) { $pu_ht=price2num($price_ht, 'MU'); $pu_ttc=price2num(GETPOST('price_ttc'), 'MU'); - $tva_tx=str_replace('*','', GETPOST('tva_tx')); - $tva_npr=preg_match('/\*/', GETPOST('tva_tx'))?1:0; + $tva_npr=(preg_match('/\*/', $tva_tx)?1:0); + $tva_tx=str_replace('*','', $tva_tx); + $desc = $product_desc; } else { @@ -711,13 +713,6 @@ else if ($action == "addline" && $user->rights->propal->creer) $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - } - - if (GETPOST('usenewaddlineform')) { - - $desc = $product_desc; - - } else { // Define output language if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) @@ -747,19 +742,18 @@ else if ($action == "addline" && $user->rights->propal->creer) } else { - $pu_ht= $price_ht; - $pu_ttc=price2num(GETPOST('price_ttc'), 'MU'); - $rate=GETPOST('tva_tx')?GETPOST('tva_tx'):GETPOST('np_tva_tx'); - $tva_tx=str_replace('*','',$rate); - $tva_npr=preg_match('/\*/',$rate)?1:0; - $label=(GETPOST('product_label')?GETPOST('product_label'):''); - $desc=$product_desc; - $type=GETPOST('type'); + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx)?1:0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label')?GETPOST('product_label'):''); + $desc = $product_desc; + $type = GETPOST('type'); } // Margin - $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):(GETPOST('np_fournprice')?GETPOST('np_fournprice'):'')); - $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):(GETPOST('np_buying_price')?GETPOST('np_buying_price'):'')); + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1, $object->client); @@ -832,8 +826,6 @@ else if ($action == "addline" && $user->rights->propal->creer) // old method unset($_POST['np_desc']); unset($_POST['dp_desc']); - unset($_POST['np_fournprice']); - unset($_POST['np_buying_price']); } else { diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 12b43a451a4..cdd57372255 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -527,6 +527,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) $idprod=GETPOST('idprod', 'int'); $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); $price_ht = GETPOST('price_ht'); + $tva_tx = GETPOST('tva_tx'); if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && (GETPOST('qty') < 0)) { @@ -574,12 +575,13 @@ else if ($action == 'addline' && $user->rights->commande->creer) $label = ((GETPOST('product_label') && GETPOST('product_label')!=$prod->label)?GETPOST('product_label'):''); // Update if prices fields are defined - if (GETPOST('usenewaddlineform') && isset($price_ht)) + if (GETPOST('usenewaddlineform')) { $pu_ht=price2num($price_ht, 'MU'); $pu_ttc=price2num(GETPOST('price_ttc'), 'MU'); - $tva_tx=str_replace('*','', GETPOST('tva_tx')); - $tva_npr=preg_match('/\*/', GETPOST('tva_tx'))?1:0; + $tva_npr=(preg_match('/\*/', $tva_tx)?1:0); + $tva_tx=str_replace('*','', $tva_tx); + $desc = $product_desc; } else { @@ -615,13 +617,6 @@ else if ($action == 'addline' && $user->rights->commande->creer) $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - } - - if (GETPOST('usenewaddlineform')) { - - $desc = $product_desc; - - } else { // Define output language if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) @@ -651,19 +646,18 @@ else if ($action == 'addline' && $user->rights->commande->creer) } else { - $pu_ht=($price_ht?$price_ht:$np_price); - $pu_ttc=price2num(GETPOST('price_ttc'), 'MU'); - $rate=GETPOST('tva_tx')?GETPOST('tva_tx'):GETPOST('np_tva_tx'); - $tva_tx=str_replace('*','',$rate); - $tva_npr=preg_match('/\*/',$rate)?1:0; - $label=(GETPOST('product_label')?GETPOST('product_label'):''); - $desc=$product_desc; - $type=GETPOST('type'); + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx)?1:0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label')?GETPOST('product_label'):''); + $desc = $product_desc; + $type = GETPOST('type'); } // Margin - $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):(GETPOST('np_fournprice')?GETPOST('np_fournprice'):'')); - $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):(GETPOST('np_buying_price')?GETPOST('np_buying_price'):'')); + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1, $object->client); @@ -741,8 +735,6 @@ else if ($action == 'addline' && $user->rights->commande->creer) // old method unset($_POST['np_desc']); unset($_POST['dp_desc']); - unset($_POST['np_fournprice']); - unset($_POST['np_buying_price']); } else { diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index f642e215dc4..28d616ba82b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -950,6 +950,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $idprod=GETPOST('idprod', 'int'); $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); $price_ht = GETPOST('price_ht'); + $tva_tx = GETPOST('tva_tx'); if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && (GETPOST('qty') < 0)) { @@ -1009,8 +1010,9 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- { $pu_ht=price2num($price_ht, 'MU'); $pu_ttc=price2num(GETPOST('price_ttc'), 'MU'); - $tva_tx=str_replace('*','', GETPOST('tva_tx')); - $tva_npr=preg_match('/\*/', GETPOST('tva_tx'))?1:0; + $tva_npr=(preg_match('/\*/', $tva_tx))?1:0); + $tva_tx=str_replace('*','', $tva_tx); + $desc = $product_desc; } else { @@ -1046,13 +1048,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - } - - if (GETPOST('usenewaddlineform')) { - - $desc = $product_desc; - - } else { // Define output language if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) @@ -1092,19 +1087,18 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- } else { - $pu_ht=($price_ht?$price_ht:$np_price); - $pu_ttc=price2num(GETPOST('price_ttc'), 'MU'); - $rate=GETPOST('tva_tx')?GETPOST('tva_tx'):GETPOST('np_tva_tx'); - $tva_tx=str_replace('*','',$rate); - $tva_npr=preg_match('/\*/',$rate)?1:0; - $label=(GETPOST('product_label')?GETPOST('product_label'):''); - $desc=$product_desc; - $type=GETPOST('type'); + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx)?1:0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label')?GETPOST('product_label'):''); + $desc = $product_desc; + $type = GETPOST('type'); } // Margin - $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):(GETPOST('np_fournprice')?GETPOST('np_fournprice'):'')); - $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):(GETPOST('np_buying_price')?GETPOST('np_buying_price'):'')); + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1, $object->client); @@ -1183,8 +1177,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- // old method unset($_POST['np_desc']); unset($_POST['dp_desc']); - unset($_POST['np_fournprice']); - unset($_POST['np_buying_price']); } else { diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php index dc9a2935dd3..013d6adb8c3 100644 --- a/htdocs/core/tpl/freeproductline_create.tpl.php +++ b/htdocs/core/tpl/freeproductline_create.tpl.php @@ -77,7 +77,7 @@ if (! empty($conf->margin->enabled)) { tva_assuj == "0") echo '0'; - else echo $form->load_tva('np_tva_tx', (isset($_POST["np_tva_tx"])?$_POST["np_tva_tx"]:-1), $seller, $buyer); + else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); ?> "> @@ -87,7 +87,7 @@ if (! empty($conf->margin->enabled)) { $colspan = 4; if (! empty($conf->margin->enabled)) { ?> - "> + "> global->DISPLAY_MARGIN_RATES) $colspan++; diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php index 206e1e9c70e..f0c11c07f87 100644 --- a/htdocs/core/tpl/predefinedproductline_create.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php @@ -96,8 +96,8 @@ $colspan = 4; if (! empty($conf->margin->enabled)) { ?> - - "> + + "> global->DISPLAY_MARGIN_RATES)