Skip to content

Commit

Permalink
[ task #1063 ] Allow edit localtaxes rate for thirds. Works with company
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanjo Menent committed Jul 3, 2014
1 parent cb4c3a4 commit e30649d
Show file tree
Hide file tree
Showing 5 changed files with 292 additions and 15 deletions.
74 changes: 73 additions & 1 deletion htdocs/admin/company.php
Expand Up @@ -2,7 +2,7 @@
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -158,6 +158,31 @@
// Local taxes
dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION",$_POST["optionlocaltax1"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION",$_POST["optionlocaltax2"],'chaine',0,'',$conf->entity);

if($_POST["optionlocaltax1"]=="localtax1on")
{
if(!isset($_REQUEST['lt1']))
{
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0,'chaine',0,'',$conf->entity);
}
else
{
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", GETPOST('lt1'),'chaine',0,'',$conf->entity);
}
dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC1", $_POST["clt1"],'chaine',0,'',$conf->entity);
}
if($_POST["optionlocaltax2"]=="localtax2on")
{
if(!isset($_REQUEST['lt2']))
{
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0,'chaine',0,'',$conf->entity);
}
else
{
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", GETPOST('lt2'),'chaine',0,'',$conf->entity);
}
dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC2", $_POST["clt2"],'chaine',0,'',$conf->entity);
}

if ($action != 'updateedit' && ! $error)
{
Expand Down Expand Up @@ -570,6 +595,17 @@
print "<tr><td>".$langs->transcountry("LocalTax1IsUsedDesc",$mysoc->country_code)."</td></tr>";
$example=$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code);
print ($example!="LocalTax1IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
if(! isOnlyOneLocalTax(1))
{
print '<tr><td align="left">'.$langs->transcountry("LocalTax1Management",$mysoc->country_code).': ';
$formcompany->select_localtax(1,$conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1");
}
print '</td></tr>';

print '<tr><td align="left">'.$langs->trans("CalcLocaltax").': ';
$opcions=array($langs->transcountry("CalcLocaltax1",$mysoc->country_code),$langs->transcountry("CalcLocaltax2",$mysoc->country_code),$langs->transcountry("CalcLocaltax3",$mysoc->country_code));
print $form->selectarray("clt1", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC1);
print '</td></tr>';
print "</table>";
print "</td></tr>\n";

Expand Down Expand Up @@ -603,6 +639,16 @@
print "<tr><td>".$langs->transcountry("LocalTax2IsUsedDesc",$mysoc->country_code)."</td></tr>";
$example=$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code);
print ($example!="LocalTax2IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
print '<tr><td align="left">'.$langs->transcountry("LocalTax2Management",$mysoc->country_code).': ';
if(! isOnlyOneLocalTax(2))
{
$formcompany->select_localtax(2,$conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
print '</td></tr>';
}
print '<tr><td align="left">'.$langs->trans("CalcLocaltax").': ';
$opcions=array($langs->transcountry("CalcLocaltax1",$mysoc->country_code),$langs->transcountry("CalcLocaltax2",$mysoc->country_code),$langs->transcountry("CalcLocaltax3",$mysoc->country_code));
print $form->selectarray("clt2", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC2);
print '</td></tr>';
print "</table>";
print "</td></tr>\n";

Expand Down Expand Up @@ -954,6 +1000,19 @@
print "<tr><td>".$langs->transcountry("LocalTax1IsUsedDesc",$mysoc->country_code)."</td></tr>";
$example=$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code);
print ($example!="LocalTax1IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
if($conf->global->MAIN_INFO_VALUE_LOCALTAX1!=0){
print '<tr><td>'.$langs->transcountry("LocalTax1Management",$mysoc->country_code).': '. $conf->global->MAIN_INFO_VALUE_LOCALTAX1 .'</td></tr>';
}
print '<tr><td align="left">'.$langs->trans("CalcLocaltax").': ';
if($conf->global->MAIN_INFO_LOCALTAX_CALC1==0){
print $langs->transcountry("CalcLocaltax1",$mysoc->country_code);
}else if($conf->global->MAIN_INFO_LOCALTAX_CALC1==1){
print $langs->transcountry("CalcLocaltax2",$mysoc->country_code);
}else if($conf->global->MAIN_INFO_LOCALTAX_CALC1==2){
print $langs->transcountry("CalcLocaltax3",$mysoc->country_code);
}

print '</td></tr>';
print "</table>";
print "</td></tr>\n";

Expand Down Expand Up @@ -987,6 +1046,19 @@
print "<tr><td>".$langs->transcountry("LocalTax2IsUsedDesc",$mysoc->country_code)."</td></tr>";
$example=$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code);
print ($example!="LocalTax2IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
if($conf->global->MAIN_INFO_VALUE_LOCALTAX2!=0){
print '<tr><td>'.$langs->transcountry("LocalTax2Management",$mysoc->country_code).': '. $conf->global->MAIN_INFO_VALUE_LOCALTAX2 .'</td></tr>';
}
print '<tr><td align="left">'.$langs->trans("CalcLocaltax").': ';
if($conf->global->MAIN_INFO_LOCALTAX_CALC2==0){
print $langs->transcountry("CalcLocaltax1",$mysoc->country_code);
}else if($conf->global->MAIN_INFO_LOCALTAX_CALC2==1){
print $langs->transcountry("CalcLocaltax2",$mysoc->country_code);
}else if($conf->global->MAIN_INFO_LOCALTAX_CALC2==2){
print $langs->transcountry("CalcLocaltax3",$mysoc->country_code);
}

print '</td></tr>';
print "</table>";
print "</td></tr>\n";

Expand Down
38 changes: 38 additions & 0 deletions htdocs/core/class/html.formcompany.class.php
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
*
* 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
Expand Down Expand Up @@ -775,6 +776,43 @@ function get_input_id_prof($idprof,$htmlname,$preselected,$country_code)

return $out;
}

/**
* Return a select with localtax values for thirds
*
* @param int $local LocalTax
* @param int $selected Preselected value
* @param varchar $htmlname HTML select name
*/
function select_localtax($local, $selected, $htmlname)
{
$tax=get_localtax_by_third($local);

$num = $this->db->num_rows($tax);
$i = 0;
if ($num)
{
$valors=explode(":", $tax);

if(sizeof($valors)>1)
{
//montar select
print '<select class="flat" name="'.$htmlname.'">';
while($i <= (sizeof($valors))-1){
if ($selected == $valors[$i]){
print '<option value="'.$valors[$i].'" selected="selected">';
}else{
print '<option value="'.$valors[$i].'">';
}
print $valors[$i];
print '</option>';
$i++;
}
print'</select>';

}
}
}

}

0 comments on commit e30649d

Please sign in to comment.