diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 5893fbab0213e..307c2fe03de4f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Patrick Raguin - * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Alexandre Spangaro * Copyright (C) 2013 Peter Fontaine @@ -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 @@ function verify() 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 @@ function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmod // 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 @@ function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmod // 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 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2=' $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 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2=' // 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; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index da6c7771eb3ad..d903b4d540b93 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -5,7 +5,7 @@ * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Patrick Raguin - * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011-2013 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -32,6 +32,7 @@ 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 @@ // 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 @@ // 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 @@ //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 @@ print $form->selectyesno('localtax2assuj_value',0,1); print ''; } - +/* if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || GETPOST("type")=='') ) { print ''.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; print $form->selectyesno('localtax2assuj_value',0,1); print ''; } +*/ if (! empty($conf->global->MAIN_MULTILANGS)) { print ''.$langs->trans("DefaultLang").''."\n"; @@ -1150,6 +1175,9 @@ //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 @@ 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".''."\n"; + + if ($conf->use_javascript_ajax) { print "\n".'