From b4eb8ae2f29a5371851dc0f0b7894be3a276c097 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Sep 2010 13:51:31 +0000 Subject: [PATCH] Fix: A lot of feature was lost because global variables were not propagated into templates. --- htdocs/comm/propal.php | 2 +- htdocs/commande/fiche.php | 2 +- htdocs/compta/facture.php | 2 +- htdocs/core/class/html.form.class.php | 23 ++++++++++++++------ htdocs/core/tpl/freeproductline_edit.tpl.php | 2 +- htdocs/product/price.php | 4 ++-- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 634c83b9836..e8c5239c8dd 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1385,7 +1385,7 @@ if ($id > 0 || ! empty($ref)) if (!empty($propal->lines)) { $propal->print_title_list(); - $propal->printLinesList(); + $propal->printLinesList(0,$mysoc,$soc); } /* diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 574b40ee048..81803113fae 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1661,7 +1661,7 @@ else if (!empty($commande->lines)) { $commande->print_title_list(); - $commande->printLinesList(); + $commande->printLinesList(0,$mysoc,$soc); } $numlines=sizeof($commande->lines); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 0ee34dc5845..ed5962bf839 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2656,7 +2656,7 @@ else if (!empty($object->lines)) { $object->print_title_list(); - $object->printLinesList(); + $object->printLinesList(0,$mysoc,$soc); } /* diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f2acb217843..f0171d32b4a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2372,17 +2372,18 @@ class Form * \param selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage. * \param societe_vendeuse Objet societe vendeuse * \param societe_acheteuse Objet societe acheteuse - * \param taux_produit Taux par defaut du produit vendu + * \param idprod Id product * \param info_bits Miscellanous information on line + * \param type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined) * \remarks Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. * Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle. * Sinon la TVA proposee par defaut=0. Fin de regle. */ - function select_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='', $info_bits=0) + function select_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='') { - print $this->load_tva($name, $selectedrate, $societe_vendeuse, $societe_acheteuse, $taux_produit, $info_bits); + print $this->load_tva($name, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type); } @@ -2394,13 +2395,14 @@ class Form * \param societe_acheteuse Objet societe acheteuse * \param idprod Id product * \param info_bits Miscellanous information on line + * \param type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined) * \remarks Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. * Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle. * Sinon la TVA proposee par defaut=0. Fin de regle. */ - function load_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0) + function load_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='') { global $langs,$conf,$mysoc; @@ -2429,7 +2431,7 @@ class Form } //var_dump($societe_acheteuse); - //print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->pays_code." buyer=".$societe_acheteuse->pays_code." idprod=$idprod, info_bits=$info_bits"; + //print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->pays_code." buyer=".$societe_acheteuse->pays_code." idprod=$idprod, info_bits=$info_bits type=$type"; //exit; // Get list of all VAT rates to show @@ -2442,10 +2444,17 @@ class Form { $code_pays="'".$mysoc->pays_code."'"; // Pour compatibilite ascendente } - if (! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC)) + if (! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC) && is_object($societe_acheteuse)) { // We also add the buyer - if (! $idprod) // We don't know type of product + if (is_numeric($type)) + { + if ($type == 1) // We know product is a service + { + $code_pays.=",'".$societe_acheteuse->pays_code."'"; + } + } + else if (! $idprod) // We don't know type of product { $code_pays.=",'".$societe_acheteuse->pays_code."'"; } diff --git a/htdocs/core/tpl/freeproductline_edit.tpl.php b/htdocs/core/tpl/freeproductline_edit.tpl.php index b06ead55fae..48a061ea4d0 100644 --- a/htdocs/core/tpl/freeproductline_edit.tpl.php +++ b/htdocs/core/tpl/freeproductline_edit.tpl.php @@ -40,7 +40,7 @@ ?> - select_tva('tva_tx',$line->tva_tx,$seller,$buyer,'',$line->info_bits); ?> + select_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?> diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 3f3302e55ca..846e4eeeccc 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -316,7 +316,7 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user-> // VAT print ''.$langs->trans("VATRate").''; - print $html->select_tva("tva_tx",$product->tva_tx,$mysoc,''); + print $html->select_tva("tva_tx",$product->tva_tx,$mysoc,'',$product->id); print ''; // Price base @@ -376,7 +376,7 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user-> if ($i == 1) { print ''.$langs->trans("VATRate").''; - print $html->select_tva("tva_tx_".$i,$product->multiprices_tva_tx["$i"],$mysoc,''); + print $html->select_tva("tva_tx_".$i,$product->multiprices_tva_tx["$i"],$mysoc,'',$product->id); print ''; } else