| '.$langs->trans("Date").' | ';
- print ''.$langs->trans("AmountTTC").' | ';
print ''.$langs->trans("ReasonDiscount").' | ';
+ print ''.$langs->trans("Amount").' | ';
print ''.$langs->trans("DiscountOfferedBy").' | ';
print ' | ';
print '
';
@@ -245,8 +245,8 @@ if ($_socid > 0)
$var = !$var;
print "";
print '| '.dolibarr_print_date($obj->dc).' | ';
- print ''.price($obj->amount_ht).' | ';
print ''.$obj->description.' | ';
+ print ''.price($obj->amount_ht).' | ';
print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->code.' | ';
if ($obj->user_id == $user->id) print 'id.'&action=remove&remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).' | ';
else print ' | ';
@@ -283,8 +283,8 @@ if ($_socid > 0)
print_titre($langs->trans("Ristournes appliquées"));
print '';
print '| '.$langs->trans("Date").' | ';
- print ''.$langs->trans("AmountTTC").' | ';
print ''.$langs->trans("ReasonDiscount").' | ';
+ print ''.$langs->trans("Amount").' | ';
print ''.$langs->trans("Bill").' | ';
print ''.$langs->trans("Author").' | ';
print ' | ';
@@ -299,8 +299,8 @@ if ($_socid > 0)
$var = !$var;
print "
";
print '| '.dolibarr_print_date($obj->dc).' | ';
- print ''.price($obj->amount_ht).' | ';
print ''.$obj->description.' | ';
+ print ''.price($obj->amount_ht).' | ';
print ''.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.' | ';
print ''.$obj->code.' | ';
print ' | ';
diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php
index 2e54768db5f..5eeebcc7e1e 100644
--- a/htdocs/compta/fiche.php
+++ b/htdocs/compta/fiche.php
@@ -285,17 +285,10 @@ if ($socid > 0)
print '
';
print '';
print '';
- $sql = "SELECT rc.amount_ht,".$db->pdate("rc.datec")." as dc";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
- $sql .= " WHERE rc.fk_soc =". $societe->id;
- $sql .= " AND rc.fk_user = ".$user->id." AND fk_facture IS NULL";
- $resql=$db->query($sql);
- if ($resql)
- {
- $obj = $db->fetch_object($resql);
- if ($obj->amount_ht) print $obj->amount_ht.' '.$langs->trans("Currency".$conf->monnaie);
- else print $langs->trans("None");
- }
+ $amount_discount=$societe->getcurrentDiscount();
+ if ($amount_discount < 0) dolibarr_print_error($db,$societe->error);
+ if ($amount_discount > 0) print $amount_discount.' '.$langs->trans("Currency".$conf->monnaie);
+ else print $langs->trans("None");
print ' | ';
print '
';
}
diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php
index e93e6406b85..dfb53418e8c 100644
--- a/htdocs/societe.class.php
+++ b/htdocs/societe.class.php
@@ -897,8 +897,30 @@ class Societe
}
+ /**
+ * \brief Renvoie montant des avoirs en cours
+ * \param user Filtre sur un user auteur des l'avoir
+ * \return int <0 si ko, montant avoir sinon
+ */
+ function getCurrentDiscount($user='')
+ {
+ $sql = "SELECT SUM(rc.amount_ht) as amount";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
+ $sql.= " WHERE rc.fk_soc =". $this->id;
+ if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id.
+ $sql.= " AND rc.fk_facture IS NULL";
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $obj = $this->db->fetch_object($resql);
+ return $obj->amount;
+ }
+ return -1;
+ }
+
+
function set_price_level($price_level, $user)
- {
+ {
if ($this->id)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe ";