mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
[ task #1063 ] Allow edit localtaxes rate for thirds. Works with thirds
This commit is contained in:
parent
e30649dcd2
commit
4c7eba0ee0
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
|
||||
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr>
|
||||
|
|
@ -196,7 +196,9 @@ class Societe extends CommonObject
|
|||
|
||||
// Local taxes
|
||||
var $localtax1_assuj;
|
||||
var $localtax1_value;
|
||||
var $localtax2_assuj;
|
||||
var $localtax2_value;
|
||||
|
||||
var $managers;
|
||||
var $capital;
|
||||
|
|
@ -597,6 +599,24 @@ class Societe extends CommonObject
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update localtax value of third party
|
||||
* @param int $id id societe
|
||||
* @param int $local Localtax to update
|
||||
* @param double $value value of localtax
|
||||
*/
|
||||
function update_localtax($id, $local, $value)
|
||||
{
|
||||
global $db;
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET ";
|
||||
if($local==1) $sql .= "localtax1_value = '" .$value."'";
|
||||
else $sql.="localtax2_value='".$value."'";
|
||||
$sql.="WHERE rowid=".$id;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update parameters of third party
|
||||
*
|
||||
|
|
@ -654,6 +674,9 @@ class Societe extends CommonObject
|
|||
// Local taxes
|
||||
$this->localtax1_assuj=trim($this->localtax1_assuj);
|
||||
$this->localtax2_assuj=trim($this->localtax2_assuj);
|
||||
|
||||
$this->localtax1_value=trim($this->localtax1_value);
|
||||
$this->localtax2_value=trim($this->localtax2_value);
|
||||
|
||||
$this->capital=price2num(trim($this->capital),'MT');
|
||||
if (empty($this->capital)) $this->capital = 0;
|
||||
|
|
@ -753,6 +776,27 @@ class Societe extends CommonObject
|
|||
// Local taxes
|
||||
$sql .= ",localtax1_assuj = ".($this->localtax1_assuj!=''?"'".$this->localtax1_assuj."'":"null");
|
||||
$sql .= ",localtax2_assuj = ".($this->localtax2_assuj!=''?"'".$this->localtax2_assuj."'":"null");
|
||||
if($this->localtax1_assuj==1)
|
||||
{
|
||||
if($this->localtax1_value!='')
|
||||
{
|
||||
$sql .=",localtax1_value =".$this->localtax1_value;
|
||||
}
|
||||
else $sql .=",localtax1_value =0.000";
|
||||
|
||||
}
|
||||
else $sql .=",localtax1_value =0.000";
|
||||
|
||||
if($this->localtax2_assuj==1)
|
||||
{
|
||||
if($this->localtax2_value!='')
|
||||
{
|
||||
$sql .=",localtax2_value =".$this->localtax2_value;
|
||||
}
|
||||
else $sql .=",localtax2_value =0.000";
|
||||
|
||||
}
|
||||
else $sql .=",localtax2_value =0.000";
|
||||
|
||||
$sql .= ",capital = ".$this->capital;
|
||||
|
||||
|
|
@ -933,7 +977,7 @@ class Societe extends CommonObject
|
|||
$sql .= ', s.fk_forme_juridique as forme_juridique_code';
|
||||
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
|
||||
$sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj';
|
||||
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax2_assuj, s.fk_prospectlevel, s.default_lang, s.logo';
|
||||
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo';
|
||||
$sql .= ', s.outstanding_limit, s.import_key, s.canvas';
|
||||
$sql .= ', fj.libelle as forme_juridique';
|
||||
$sql .= ', e.libelle as effectif';
|
||||
|
|
@ -1034,7 +1078,9 @@ class Societe extends CommonObject
|
|||
// Local Taxes
|
||||
$this->localtax1_assuj = $obj->localtax1_assuj;
|
||||
$this->localtax2_assuj = $obj->localtax2_assuj;
|
||||
|
||||
|
||||
$this->localtax1_value = $obj->localtax1_value;
|
||||
$this->localtax2_value = $obj->localtax2_value;
|
||||
|
||||
$this->typent_id = $obj->typent_id;
|
||||
$this->typent_code = $obj->typent_code;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
|
||||
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2013 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -32,6 +32,7 @@ require '../main.inc.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
|
|
@ -100,6 +101,23 @@ if (empty($reshook))
|
|||
// We defined value code_fournisseur
|
||||
$_POST["code_fournisseur"]="Acompleter";
|
||||
}
|
||||
|
||||
if($action=='set_localtax1')
|
||||
{
|
||||
//obtidre selected del combobox
|
||||
$value=GETPOST('lt1');
|
||||
$object = new Societe($db);
|
||||
$res=$object->update_localtax($socid, 1, $value);
|
||||
|
||||
}
|
||||
if($action=='set_localtax2')
|
||||
{
|
||||
//obtidre selected del combobox
|
||||
$value=GETPOST('lt2');
|
||||
$object = new Societe($db);
|
||||
$res=$object->update_localtax($socid, 2, $value);
|
||||
|
||||
}
|
||||
|
||||
// Add new third party
|
||||
if ((! GETPOST('getcustomercode') && ! GETPOST('getsuppliercode'))
|
||||
|
|
@ -157,6 +175,9 @@ if (empty($reshook))
|
|||
// Local Taxes
|
||||
$object->localtax1_assuj = GETPOST('localtax1assuj_value');
|
||||
$object->localtax2_assuj = GETPOST('localtax2assuj_value');
|
||||
|
||||
$object->localtax1_value = GETPOST('lt1');
|
||||
$object->localtax2_value = GETPOST('lt2');
|
||||
|
||||
$object->forme_juridique_code = GETPOST('forme_juridique_code');
|
||||
$object->effectif_id = GETPOST('effectif_id');
|
||||
|
|
@ -659,6 +680,9 @@ else
|
|||
//Local Taxes
|
||||
$object->localtax1_assuj = GETPOST('localtax1assuj_value');
|
||||
$object->localtax2_assuj = GETPOST('localtax2assuj_value');
|
||||
|
||||
$object->localtax1_value =GETPOST('lt1');
|
||||
$object->localtax2_value =GETPOST('lt2');
|
||||
|
||||
$object->tva_intra = GETPOST('tva_intra');
|
||||
|
||||
|
|
@ -1004,13 +1028,14 @@ else
|
|||
print $form->selectyesno('localtax2assuj_value',0,1);
|
||||
print '</td><tr>';
|
||||
}
|
||||
|
||||
/*
|
||||
if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || GETPOST("type")=='') )
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print $form->selectyesno('localtax2assuj_value',0,1);
|
||||
print '</td><tr>';
|
||||
}
|
||||
*/
|
||||
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("DefaultLang").'</td><td colspan="3" class="maxwidthonsmartphone">'."\n";
|
||||
|
|
@ -1150,6 +1175,9 @@ else
|
|||
//Local Taxes
|
||||
$object->localtax1_assuj = GETPOST('localtax1assuj_value');
|
||||
$object->localtax2_assuj = GETPOST('localtax2assuj_value');
|
||||
|
||||
$object->localtax1_value =GETPOST('lt1');
|
||||
$object->localtax2_value =GETPOST('lt2');
|
||||
|
||||
// We set country_id, and country_code label of the chosen country
|
||||
if ($object->country_id > 0)
|
||||
|
|
@ -1162,6 +1190,53 @@ else
|
|||
|
||||
dol_htmloutput_errors($error,$errors);
|
||||
|
||||
if($object->localtax1_assuj==0){
|
||||
$sub=0;
|
||||
}else{$sub=1;}
|
||||
if($object->localtax2_assuj==0){
|
||||
$sub2=0;
|
||||
}else{$sub2=1;}
|
||||
|
||||
|
||||
print "\n".'<script type="text/javascript">';
|
||||
print '$(document).ready(function () {
|
||||
var val='.$sub.';
|
||||
var val2='.$sub2.';
|
||||
if("#localtax1assuj_value".value==undefined){
|
||||
if(val==1){
|
||||
$(".cblt1").show();
|
||||
}else{
|
||||
$(".cblt1").hide();
|
||||
}
|
||||
}
|
||||
if("#localtax2assuj_value".value==undefined){
|
||||
if(val2==1){
|
||||
$(".cblt2").show();
|
||||
}else{
|
||||
$(".cblt2").hide();
|
||||
}
|
||||
}
|
||||
$("#localtax1assuj_value").change(function() {
|
||||
var value=document.getElementById("localtax1assuj_value").value;
|
||||
if(value==1){
|
||||
$(".cblt1").show();
|
||||
}else{
|
||||
$(".cblt1").hide();
|
||||
}
|
||||
});
|
||||
$("#localtax2assuj_value").change(function() {
|
||||
var value=document.getElementById("localtax2assuj_value").value;
|
||||
if(value==1){
|
||||
$(".cblt2").show();
|
||||
}else{
|
||||
$(".cblt2").hide();
|
||||
}
|
||||
});
|
||||
|
||||
});';
|
||||
print '</script>'."\n";
|
||||
|
||||
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
print "\n".'<script type="text/javascript" language="javascript">';
|
||||
|
|
@ -1381,36 +1456,54 @@ else
|
|||
|
||||
// Local Taxes
|
||||
//TODO: Place into a function to control showing by country or study better option
|
||||
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
|
||||
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
|
||||
print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1);
|
||||
if(! isOnlyOneLocalTax(1))
|
||||
{
|
||||
print '<span class="cblt1"> '.$langs->transcountry("Type",$mysoc->country_code).': ';
|
||||
$formcompany->select_localtax(1,$object->localtax1_value, "lt1");
|
||||
print '</span>';
|
||||
}
|
||||
|
||||
print '</td><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
|
||||
print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1);
|
||||
if (! isOnlyOneLocalTax(2))
|
||||
{
|
||||
print '<span class="cblt2"> '.$langs->transcountry("Type",$mysoc->country_code).': ';
|
||||
$formcompany->select_localtax(2,$object->localtax2_value, "lt2");
|
||||
print '</span>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
elseif($mysoc->localtax1_assuj=="1")
|
||||
elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1);
|
||||
if(! isOnlyOneLocalTax(1))
|
||||
{
|
||||
print '<span class="cblt1"> '.$langs->transcountry("Type",$mysoc->country_code).': ';
|
||||
$formcompany->select_localtax(1,$object->localtax1_value, "lt1");
|
||||
print '</span>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
elseif($mysoc->localtax2_assuj=="1")
|
||||
elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1);
|
||||
if(! isOnlyOneLocalTax(2))
|
||||
{
|
||||
print '<span class="cblt2"> '.$langs->transcountry("Type",$mysoc->country_code).': ';
|
||||
$formcompany->select_localtax(2,$object->localtax2_value, "lt2");
|
||||
print '</span>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && $object->fournisseur==1)
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print $form->selectyesno('localtax2assuj_value',0,1);
|
||||
print '</td><tr>';
|
||||
}
|
||||
|
||||
// Type - Size
|
||||
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>';
|
||||
print $form->selectarray("typent_id",$formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
|
||||
|
|
@ -1715,27 +1808,93 @@ else
|
|||
print yn($object->localtax2_assuj);
|
||||
print '</td></tr>';
|
||||
|
||||
if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1)))
|
||||
{
|
||||
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
|
||||
print '<input type="hidden" name="action" value="set_localtax1">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<tr><td>'.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).' <a href="'.$_SERVER["PHP_SELF"].'?action=editRE&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
|
||||
if($action == 'editRE')
|
||||
{
|
||||
print '<td align="left">';
|
||||
$formcompany->select_localtax(1,$object->localtax1_value, "lt1");
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>'.$object->localtax1_value.'</td>';
|
||||
}
|
||||
print '</tr></form>';
|
||||
}
|
||||
if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2)))
|
||||
{
|
||||
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
|
||||
print '<input type="hidden" name="action" value="set_localtax2">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<tr><td>'.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).'<a href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
|
||||
if($action == 'editIRPF'){
|
||||
print '<td align="left">';
|
||||
$formcompany->select_localtax(2,$object->localtax2_value, "lt2");
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||
}else{
|
||||
print '<td>'.$object->localtax2_value.'</td>';
|
||||
}
|
||||
print '</tr></form>';
|
||||
}
|
||||
}
|
||||
elseif($mysoc->localtax1_assuj=="1")
|
||||
elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print yn($object->localtax1_assuj);
|
||||
print '</td><tr>';
|
||||
if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1)))
|
||||
{
|
||||
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
|
||||
print '<input type="hidden" name="action" value="set_localtax1">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<tr><td> '.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).'<a href="'.$_SERVER["PHP_SELF"].'?action=editRE&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
|
||||
if($action == 'editRE'){
|
||||
print '<td align="left">';
|
||||
$formcompany->select_localtax(1,$object->localtax1_value, "lt1");
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||
}else{
|
||||
print '<td>'.$object->localtax1_value.'</td>';
|
||||
}
|
||||
print '</tr></form>';
|
||||
|
||||
}
|
||||
}
|
||||
elseif($mysoc->localtax2_assuj=="1")
|
||||
elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1")
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print yn($object->localtax2_assuj);
|
||||
print '</td><tr>';
|
||||
if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2)))
|
||||
{
|
||||
|
||||
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
|
||||
print '<input type="hidden" name="action" value="set_localtax2">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<tr><td> '.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).' <a href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
|
||||
if($action == 'editIRPF'){
|
||||
print '<td align="left">';
|
||||
$formcompany->select_localtax(2,$object->localtax2_value, "lt2");
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||
}else{
|
||||
print '<td>'.$object->localtax2_value.'</td>';
|
||||
}
|
||||
print '</tr></form>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && $object->fournisseur==1)
|
||||
{
|
||||
print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
||||
print yn($object->localtax2_assuj);
|
||||
print '</td><tr>';
|
||||
}
|
||||
|
||||
*/
|
||||
// Type + Staff
|
||||
$arr = $formcompany->typent_array(1);
|
||||
$object->typent= $arr[$object->typent_code];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user