diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 304cc9dd243..5b352dc1385 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -136,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, 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[10]= "SELECT t.rowid, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, 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, 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";
@@ -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,localtax2,localtax1_type,localtax2,localtax2_type,accountancy_code,note";
+$tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,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,localtax2,localtax1_type,localtax2,localtax2_type,accountancy_code,note";
+$tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,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,localtax2,localtax1_type,localtax2,localtax2_type,accountancy_code,note";
+$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code,note";
$tabfieldinsert[11]= "element,source,code,libelle";
$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
$tabfieldinsert[13]= "code,libelle,type";
@@ -374,13 +374,14 @@ $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")
+ "0" => $langs->trans("No"),
+ "1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"),
+ "2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"),
+ "3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"),
+ "4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"),
+ "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"),
+ "6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)", //$langs->trans("%ageOnServiceBeforeVAT"),
+ "7" => $langs->trans("Yes").' ('.$langs->trans("Type")." 7)" //$langs->trans("AmountOnOrder") // We will enable this later. For the moment, work only of invoice localtype
);
}
$msg='';
@@ -398,14 +399,13 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$ok=1;
foreach ($listfield as $f => $value)
{
- if ($value == 'pays')
- {
- if (in_array('region_id',$listfield)) { continue; } // For region page, we do not require the country input
- }
+ if ($value == 'pays' && in_array('region_id',$listfield)) continue; // For region page, we do not require the country input
+ if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue;
+ if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue;
if ((! isset($_POST[$value]) || $_POST[$value]=='')
- && $listfield[$f] != 'decalage' // Fields that are not mandatory
- && $listfield[$f] != 'module' // Fields that are not mandatory
- && $listfield[$f] != 'accountancy_code') // Fields that are not mandatory
+ // && (! in_array($listfield[$f], array('decalage','module','accountancy_code','localtax1','localtax2'))) // Fields that are not mandatory
+ && (! in_array($listfield[$f], array('decalage','module','accountancy_code'))) // Fields that are not mandatory
+ )
{
$ok=0;
$fieldnamekey=$listfield[$f];
@@ -425,7 +425,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$msg.=$langs->trans("ErrorFieldRequired",$langs->transnoentities($fieldnamekey)).'
';
}
}
- // Autres verif
+ // Other checks
if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && $_POST["type"]=='system') {
$ok=0;
$msg.="Value 'system' for type is reserved. You can use 'user' as value to add your own record.
";
@@ -438,6 +438,9 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$ok=0;
$msg.=$langs->trans("ErrorFieldRequired",$langs->trans("Country")).'
';
}
+ // Clean some parameters
+ if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0
+ if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0
// Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd'))
@@ -705,10 +708,10 @@ if ($id)
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]=='localtax1_type') { $valuetoshow=$form->textwithtooltip($langs->trans("UseLocalTax")." 2",$langs->trans("LocalTaxDesc"),2,1,img_help(1,'')); $align="center"; $sortable=0; }
+ if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $align="right"; }
+ if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$form->textwithtooltip($langs->trans("UseLocalTax")." 3",$langs->trans("LocalTaxDesc"),2,1,img_help(1,'')); $align="center"; $sortable=0; }
+ if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $align="right"; }
if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); }
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
@@ -805,21 +808,30 @@ if ($id)
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$showfield=1; // Par defaut
+ $align="left";
+ $sortable=1;
+ $valuetoshow='';
+ /*
+ $tmparray=getLabelOfField($fieldlist[$field]);
+ $showfield=$tmp['showfield'];
+ $valuetoshow=$tmp['valuetoshow'];
+ $align=$tmp['align'];
+ $sortable=$tmp['sortable'];
+ */
$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]=='localtax1_type') { $valuetoshow=$form->textwithtooltip($langs->trans("UseLocalTax")." 2",$langs->trans("LocalTaxDesc"),2,1,img_help(1,'')); $align="center"; $sortable=0; }
+ if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $align="right"; $sortable=0; }
+ if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$form->textwithtooltip($langs->trans("UseLocalTax")." 3",$langs->trans("LocalTaxDesc"),2,1,img_help(1,'')); $align="center"; $sortable=0; }
+ if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $align="right"; $sortable=0; }
if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); }
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
- if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*"; }
+ if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*"; }
if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
if ($fieldlist[$field]=='pays') { $valuetoshow=$langs->trans("Country"); }
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; }
@@ -839,10 +851,10 @@ if ($id)
// Affiche nom du champ
if ($showfield)
{
- print_liste_field_titre($valuetoshow,$_SERVER["PHP_SELF"],$fieldlist[$field],($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder);
+ print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$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);
+ print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder);
print '