diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index e9d203df1d2b6..44b0e140df34b 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -2371,7 +2371,8 @@
{
// Remise dispo de type avoir
if (! $absolute_discount) print ' ';
- $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer);
+ //$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer);
+ $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0); // We must allow credit not even if amount is higher
}
}
if (! $absolute_discount && ! $absolute_creditnote)
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 5b9d2db15d818..ae906948af04b 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -82,7 +82,7 @@ function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='st
global $conf,$langs;
$ret='';
-
+
// TODO change for compatibility
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;/',$typeofdata))
{
@@ -1961,7 +1961,7 @@ function load_PriceBaseType($selected='',$htmlname='price_base_type')
* @param string $filtre To filter list
* @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries.
* @param string $moreattrib To add more attribute on select
- * @return void
+ * @return void
*/
function select_comptes($selected='',$htmlname='accountid',$statut=0,$filtre='',$useempty=0,$moreattrib='')
{
@@ -2575,7 +2575,7 @@ function form_modes_reglement($page, $selected='', $htmlname='mode_reglement_id'
* @param string $more More string to add
* @return void
*/
- function form_remise_dispo($page, $selected='', $htmlname='remise_id',$socid, $amount, $filter='', $maxvalue=0, $more='')
+ function form_remise_dispo($page, $selected='', $htmlname='remise_id', $socid, $amount, $filter='', $maxvalue=0, $more='')
{
global $conf,$langs;
if ($htmlname != "none")
@@ -2721,7 +2721,7 @@ function select_currency($selected='',$htmlname='currency_id')
{
print $this->selectcurrency($selected,$htmlname);
}
-
+
/**
* Load into the cache all currencies
*
@@ -2730,16 +2730,16 @@ function select_currency($selected='',$htmlname='currency_id')
function load_cache_currencies()
{
global $langs;
-
+
$langs->load("dict");
-
+
if (count($this->cache_currencies)) return 0; // Cache deja charge
-
+
$sql = "SELECT code_iso, label, unicode";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
$sql.= " WHERE active = 1";
$sql.= " ORDER BY code_iso ASC";
-
+
dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
@@ -2749,14 +2749,14 @@ function load_cache_currencies()
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
-
+
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$this->cache_currencies[$obj->code_iso]['unicode'] = (array) dol_json_decode($obj->unicode, true);
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
$i++;
}
-
+
array_multisort($label, SORT_ASC, $this->cache_currencies);
return $num;
@@ -2773,14 +2773,14 @@ function load_cache_currencies()
*
* @param string $selected preselected currency code
* @param string $htmlname name of HTML select list
- * @return void
+ * @return void
*/
function selectcurrency($selected='',$htmlname='currency_id')
{
global $conf,$langs,$user;
$langs->load("dict");
-
+
$this->load_cache_currencies();
$out='';
@@ -2829,7 +2829,7 @@ function select_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='',
{
print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type);
}
-
+
/**
* Load into the cache vat rates of a country
*
@@ -2839,14 +2839,14 @@ function select_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='',
function load_cache_vatrates($country_code)
{
if (count($this->cache_vatrates)) return 0; // Cache deja charge
-
+
$sql = "SELECT DISTINCT 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";
$sql.= " AND t.active = 1";
$sql.= " AND p.code IN (".$country_code.")";
$sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC";
-
+
$resql=$this->db->query($sql);
if ($resql)
{
@@ -2860,7 +2860,7 @@ function load_cache_vatrates($country_code)
$this->cache_vatrates[$i]['libtva'] = $obj->taux.'%';
$this->cache_vatrates[$i]['nprtva'] = $obj->recuperableonly;
}
-
+
return $num;
}
else
@@ -2963,10 +2963,10 @@ function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $
}
}
}
-
+
// Now we get list
$num = $this->load_cache_vatrates($code_pays);
-
+
if ($num > 0)
{
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
@@ -2975,16 +2975,16 @@ function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $
$defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod);
$defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod);
}
-
+
// Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
{
$defaulttx = $this->cache_vatrates[$num-1]['txtva'];
}
-
+
if (! $options_only) $return.= '