Skip to content

Commit

Permalink
Fix: Debug dictionnary to add localtaxes
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Sep 16, 2012
1 parent df2bac3 commit b724a78
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 36 deletions.
80 changes: 47 additions & 33 deletions htdocs/admin/dict.php
Expand Up @@ -136,7 +136,7 @@
$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";
Expand Down Expand Up @@ -188,7 +188,7 @@
$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";
Expand All @@ -214,7 +214,7 @@
$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";
Expand All @@ -240,7 +240,7 @@
$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";
Expand Down Expand Up @@ -374,13 +374,14 @@
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='';
Expand All @@ -398,14 +399,13 @@
$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];
Expand All @@ -425,7 +425,7 @@
$msg.=$langs->trans("ErrorFieldRequired",$langs->transnoentities($fieldnamekey)).'<br>';
}
}
// 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.<br>";
Expand All @@ -438,6 +438,9 @@
$ok=0;
$msg.=$langs->trans("ErrorFieldRequired",$langs->trans("Country")).'<br>';
}
// 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'))
Expand Down Expand Up @@ -705,10 +708,10 @@
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"); }
Expand Down Expand Up @@ -805,21 +808,30 @@
// 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; }
Expand All @@ -839,10 +851,10 @@
// 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 '<td colspan="2" class="liste_titre">&nbsp;</td>';
print '</tr>';

Expand Down Expand Up @@ -1007,12 +1019,14 @@
$valuetoshow=$localtax_typeList[$valuetoshow];
else
$valuetoshow = '';
$align="center";
}
else if ($fieldlist[$field]=='localtax2_type') {
if ($obj->localtax2 != 0)
$valuetoshow=$localtax_typeList[$valuetoshow];
else
$valuetoshow = '';
$align="center";
}
else if ($fieldlist[$field]=='localtax1') {
if ($obj->localtax1 == 0)
Expand Down Expand Up @@ -1231,8 +1245,8 @@ function fieldList($fieldlist,$obj='',$tabname='')
// Le type de taxe locale
elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type')
{
print '<td>';
print $html->selectarray($fieldlist[$field], $localtax_typeList,$obj->$fieldlist[$field]);
print '<td align="center">';
print $form->selectarray($fieldlist[$field], $localtax_typeList,$obj->$fieldlist[$field]);
print '</td>';
}
else
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -1880,8 +1880,8 @@ function img_help($usehelpcursor = 1, $usealttitle = 1)

if ($usealttitle)
{
if (is_string($usealttitle)) $alt = dol_escape_htmltag($usealttitle);
else $alt = $langs->trans('Info');
if (is_string($usealttitle)) $usealttitle = dol_escape_htmltag($usealttitle);
else $usealttitle = $langs->trans('Info');
}

return img_picto($usealttitle, 'info.png', ($usehelpcursor ? 'style="cursor: help"' : ''));
Expand Down Expand Up @@ -2264,7 +2264,7 @@ function print_liste_field_titre($name, $file="", $field="", $begin="", $morepar
* @param string $name Label of field
* @param int $thead For thead format
* @param string $file Url used when we click on sort picto
* @param string $field Field to use for new sorting
* @param string $field Field to use for new sorting. Empty if this field is not sortable.
* @param string $begin ("" by defaut)
* @param string $moreparam Add more parameters on sort url links ("" by default)
* @param string $moreattrib Add more attributes on th ("" by defaut)
Expand Down
2 changes: 2 additions & 0 deletions htdocs/langs/fr_FR/main.lang
Expand Up @@ -249,6 +249,8 @@ Quadri=Trimestre
MonthOfDay=Mois du jour
HourShort=H
Rate=Taux
UseLocalTax=Inclure taxe
LocalTaxDesc=Certains pays appliquent 2 voir 3 taux sur chaque ligne de facture. Si c'est le cas, choisissez le type du deuxième et troisième taux et sa valeur. Les types possibles sont:<br>1 : local tax apply on products and services without vat (vat is not applied on local tax)<br>2 : local tax apply on products and services before vat (vat is calculated on amount + localtax)<br>3 : local tax apply on products without vat (vat is not applied on local tax)<br>4 : local tax apply on products before vat (vat is calculated on amount + localtax)<br>5 : local tax apply on services without vat (vat is not applied on local tax)<br>6 : local tax apply on services before vat (vat is calculated on amount + localtax)<br>7 : local tax is a fix amount applied on global invoice
Bytes=Octets
KiloBytes=Kilooctets
MegaBytes=Mégaoctets
Expand Down

0 comments on commit b724a78

Please sign in to comment.