Ajout une fonction pour charger les taux de tva
TODO Factoriser avec la fonction select_tva
This commit is contained in:
parent
88bc13862a
commit
7d4701c050
@ -48,7 +48,7 @@ class Form
|
||||
var $cache_conditions_paiements_code=array();
|
||||
var $cache_conditions_paiements_libelle=array();
|
||||
|
||||
|
||||
var $tva_taux;
|
||||
/**
|
||||
\brief Constructeur
|
||||
\param DB handler d'accès base de donnée
|
||||
@ -2051,11 +2051,63 @@ class Form
|
||||
print ' selected="true"';
|
||||
}
|
||||
print '>'.$libtva[$i].'</option>';
|
||||
|
||||
$this->tva_taux_value[$i] = $txtva[$i];
|
||||
$this->tva_taux_libelle[$i] = $libtva[$i];
|
||||
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
|
||||
|
||||
function load_tva($name='tauxtva', $defaulttx='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='')
|
||||
{
|
||||
global $langs,$conf,$mysoc;
|
||||
|
||||
if (is_object($societe_vendeuse->pays_code))
|
||||
{
|
||||
$code_pays=$societe_vendeuse->pays_code;
|
||||
}
|
||||
else
|
||||
{
|
||||
$code_pays=$mysoc->pays_code; // Pour compatibilite ascendente
|
||||
}
|
||||
|
||||
// Recherche liste des codes TVA du pays vendeur
|
||||
$sql = "SELECT t.taux,t.recuperableonly";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
||||
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'";
|
||||
$sql .= " AND t.active = 1";
|
||||
$sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$txtva[ $i ] = $obj->taux;
|
||||
$libtva[ $i ] = $obj->taux.'%'.($obj->recuperableonly ? ' *':'');
|
||||
}
|
||||
}
|
||||
|
||||
// Définition du taux à présélectionner
|
||||
if ($defaulttx == '') $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$taux_produit);
|
||||
// Si taux par defaut n'a pu etre trouvé, on prend dernier.
|
||||
// Comme ils sont triés par ordre croissant, dernier = plus élevé = taux courant
|
||||
if ($defaulttx == '') $defaulttx = $txtva[sizeof($txtva)-1];
|
||||
|
||||
$nbdetaux = sizeof($txtva);
|
||||
|
||||
for ($i = 0 ; $i < $nbdetaux ; $i++)
|
||||
{
|
||||
$this->tva_taux_value[$i] = $txtva[$i];
|
||||
$this->tva_taux_libelle[$i] = $libtva[$i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Affiche zone de selection de date
|
||||
* Liste deroulante pour les jours, mois, annee et eventuellement heurs et minutes
|
||||
|
||||
Loading…
Reference in New Issue
Block a user