From 05971f1952f8e21a1dc0c8c1459a1bbc7c7fc799 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Sun, 16 Sep 2012 10:08:41 +0200 Subject: [PATCH 1/2] patch on the dictionnary setup of local taxes table to be able to set localtax type --- htdocs/admin/dict.php | 79 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index fccf5896951..e55643d1a4e 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -7,6 +7,7 @@ * Copyright (C) 2011 Philippe Grand * Copyright (C) 2011 Remy Younes * Copyright (C) 2012 Marcos García + * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -135,7 +136,7 @@ $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.t $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.deductible, p.code as pays_code, p.libelle as pays, a.fk_pays as pays_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_pays as p WHERE a.fk_pays=p.rowid and p.active=1"; $tabsql[8] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_typent"; $tabsql[9] = "SELECT code_iso as code, label as libelle, unicode, active FROM ".MAIN_DB_PREFIX."c_currencies"; -$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1, t.localtax2, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active, t.accountancy_code FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p WHERE t.fk_pays=p.rowid"; +$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active, t.accountancy_code FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid"; $tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; $tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c'; $tabsql[13]= "SELECT id as rowid, code, c.libelle, type, active FROM ".MAIN_DB_PREFIX."c_paiement AS c"; @@ -187,7 +188,7 @@ $tabfield[6] = "code,libelle,type,position"; $tabfield[7] = "code,libelle,pays_id,pays,deductible"; $tabfield[8] = "code,libelle"; $tabfield[9] = "code,libelle,unicode"; -$tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1,localtax2,accountancy_code,note"; +$tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,accountancy_code,note"; $tabfield[11]= "element,source,code,libelle"; $tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage"; $tabfield[13]= "code,libelle,type"; @@ -213,7 +214,7 @@ $tabfieldvalue[6] = "code,libelle,type,position"; $tabfieldvalue[7] = "code,libelle,pays,deductible"; $tabfieldvalue[8] = "code,libelle"; $tabfieldvalue[9] = "code,libelle,unicode"; -$tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1,localtax2,accountancy_code,note"; +$tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,accountancy_code,note"; $tabfieldvalue[11]= "element,source,code,libelle"; $tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage"; $tabfieldvalue[13]= "code,libelle,type"; @@ -239,7 +240,7 @@ $tabfieldinsert[6] = "code,libelle,type,position"; $tabfieldinsert[7] = "code,libelle,fk_pays,deductible"; $tabfieldinsert[8] = "code,libelle"; $tabfieldinsert[9] = "code_iso,label,unicode"; -$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,localtax1,localtax2,accountancy_code,note"; +$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,accountancy_code,note"; $tabfieldinsert[11]= "element,source,code,libelle"; $tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage"; $tabfieldinsert[13]= "code,libelle,type"; @@ -368,6 +369,20 @@ if ($id == 11) ); } +// Define localtax_typeList (used for dictionnary "c_tva") +$localtax_typeList = array(); +if (GETPOST("id") == 10) +{ + $localtax_typeList = array( + "1" => $langs->trans("%ageOnAllWithoutVAT"), + "2" => $langs->trans("%ageOnAllBeforeVAT"), + "3" => $langs->trans("%ageOnProductsWithoutVAT"), + "4" => $langs->trans("%ageOnProductsBeforeVAT"), + "5" => $langs->trans("%ageOnServiceWithoutVAT"), + "6" => $langs->trans("%ageOnServiceBeforeVAT"), + "7" => $langs->trans("AmountOnOrder") + ); +} $msg=''; @@ -686,9 +701,14 @@ if ($id) // dans les dictionnaires de donnees $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate + $align="left"; if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } if ($fieldlist[$field]=='taux') { $valuetoshow=$langs->trans("Rate"); } + if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("localtax1"); $align="right";} + if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("localtax2"); $align="right";} + if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("localtax_type"); $align="center";} + if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("localtax_type"); $align="center";} if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } @@ -715,7 +735,7 @@ if ($id) if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } if ($valuetoshow != '') { - print ''; + print ''; if (! empty($tabhelp[$id][$value]) && preg_match('/http:/i',$tabhelp[$id][$value])) print ''.$valuetoshow.''; else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); else print $valuetoshow; @@ -787,9 +807,14 @@ if ($id) $showfield=1; // Par defaut $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate + $align="left"; if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } if ($fieldlist[$field]=='taux') { $valuetoshow=$langs->trans("Rate"); } + if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("localtax1"); $align="right";} + if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("localtax2"); $align="right";} + if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("localtax_type"); $align="center";} + if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("localtax_type"); $align="center";} if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } @@ -814,7 +839,7 @@ if ($id) // Affiche nom du champ if ($showfield) { - print_liste_field_titre($valuetoshow,$_SERVER["PHP_SELF"],$fieldlist[$field],($page?'page='.$page.'&':'').'&id='.$id,"","",$sortfield,$sortorder); + print_liste_field_titre($valuetoshow,$_SERVER["PHP_SELF"],$fieldlist[$field],($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder); } } print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); @@ -860,6 +885,7 @@ if ($id) foreach ($fieldlist as $field => $value) { $showfield=1; + $align="left"; $valuetoshow=$obj->$fieldlist[$field]; if ($value == 'element') { @@ -976,7 +1002,30 @@ if ($id) $valuetoshow = ($obj->code && ($key != 'SizeUnit'.strtolower($obj->unit))) ? $key : $obj->$fieldlist[$field]; } - if ($showfield) print ''.$valuetoshow.''; + else if ($fieldlist[$field]=='localtax1_type') { + if ($obj->localtax1 != 0) + $valuetoshow=$localtax_typeList[$valuetoshow]; + else + $valuetoshow = ''; + } + else if ($fieldlist[$field]=='localtax2_type') { + if ($obj->localtax2 != 0) + $valuetoshow=$localtax_typeList[$valuetoshow]; + else + $valuetoshow = ''; + } + else if ($fieldlist[$field]=='localtax1') { + if ($obj->localtax1 == 0) + $valuetoshow = ''; + $align="right"; + } + else if ($fieldlist[$field]=='localtax2') { + if ($obj->localtax2 == 0) + $valuetoshow = ''; + $align="right"; + } + + if ($showfield) print ''.$valuetoshow.''; } } @@ -1096,7 +1145,7 @@ function fieldList($fieldlist,$obj='',$tabname='') global $conf,$langs,$db; global $form; global $region_id; - global $elementList,$sourceList; + global $elementList,$sourceList,$localtax_typeList; $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); @@ -1153,7 +1202,12 @@ function fieldList($fieldlist,$obj='',$tabname='') print ''; } elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) { - print ''; + $align="left"; + // Les taxes locales sont cadrées à droite + if ($fieldlist[$field] == 'localtax1' || $fieldlist[$field] == 'localtax2') + $align="right"; + print ''; + print ''; } elseif ($fieldlist[$field] == 'libelle_facture') { print ''; @@ -1174,6 +1228,13 @@ function fieldList($fieldlist,$obj='',$tabname='') ), (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), 0, 0, 0); print ''; } + // Le type de taxe locale + elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type') + { + print ''; + print $html->selectarray($fieldlist[$field], $localtax_typeList,$obj->$fieldlist[$field]); + print ''; + } else { print ''; From a9ed3bc1750edf5ec611b1efda151a8f04810db0 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Sun, 16 Sep 2012 10:12:43 +0200 Subject: [PATCH 2/2] correction for previous patch on localtax --- htdocs/admin/dict.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index e55643d1a4e..e187facc3e8 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -188,7 +188,7 @@ $tabfield[6] = "code,libelle,type,position"; $tabfield[7] = "code,libelle,pays_id,pays,deductible"; $tabfield[8] = "code,libelle"; $tabfield[9] = "code,libelle,unicode"; -$tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,accountancy_code,note"; +$tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1,localtax2,localtax1_type,localtax2,localtax2_type,accountancy_code,note"; $tabfield[11]= "element,source,code,libelle"; $tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage"; $tabfield[13]= "code,libelle,type"; @@ -214,7 +214,7 @@ $tabfieldvalue[6] = "code,libelle,type,position"; $tabfieldvalue[7] = "code,libelle,pays,deductible"; $tabfieldvalue[8] = "code,libelle"; $tabfieldvalue[9] = "code,libelle,unicode"; -$tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,accountancy_code,note"; +$tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1,localtax2,localtax1_type,localtax2,localtax2_type,accountancy_code,note"; $tabfieldvalue[11]= "element,source,code,libelle"; $tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage"; $tabfieldvalue[13]= "code,libelle,type"; @@ -240,7 +240,7 @@ $tabfieldinsert[6] = "code,libelle,type,position"; $tabfieldinsert[7] = "code,libelle,fk_pays,deductible"; $tabfieldinsert[8] = "code,libelle"; $tabfieldinsert[9] = "code_iso,label,unicode"; -$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,accountancy_code,note"; +$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,localtax1,localtax2,localtax1_type,localtax2,localtax2_type,accountancy_code,note"; $tabfieldinsert[11]= "element,source,code,libelle"; $tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage"; $tabfieldinsert[13]= "code,libelle,type";