diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php
index 3ae699709afce62c207e03816b8e609bd9cd146d..ec9e0ea0a5819d11572ed34a7135164c188dbfc8 100644
--- a/htdocs/compta/stats/cabyprodserv.php
+++ b/htdocs/compta/stats/cabyprodserv.php
@@ -173,7 +173,7 @@ $catotal=0;
if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label,";
- $sql.= " sum(DISTINCT l.total_ht) as amount, sum(DISTINCT l.total_ttc) as amount_ttc";
+ $sql.= " sum(l.total_ht) as amount, sum(l.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " JOIN ".MAIN_DB_PREFIX."facturedet as l";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON l.fk_facture = f.rowid";
diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php
index 63ca148e5c3d54cc042501451a265f44fe53cc97..214ce25e6255f3e123c00cfb2444ec797472bb95 100644
--- a/htdocs/compta/stats/casoc.php
+++ b/htdocs/compta/stats/casoc.php
@@ -177,7 +177,7 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl
$catotal=0;
if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT DISTINCT s.rowid as socid, s.nom as name,";
- $sql.= " sum(DISTINCT f.total) as amount, sum(DISTINCT f.total_ttc) as amount_ttc";
+ $sql.= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= " JOIN ".MAIN_DB_PREFIX."facture as f";
if ($selected_cat === -2) {
@@ -227,6 +227,7 @@ $sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql.= " GROUP BY s.rowid, s.nom";
$sql.= " ORDER BY s.rowid";
+echo $sql;
$result = $db->query($sql);
if ($result) {
@@ -406,13 +407,13 @@ if (count($amount)) {
print '<td align="right">';
if ($modecompta != 'CREANCES-DETTES') {
if ($key > 0) {
- print '<a href="'.DOL_URL_ROOT.'/compta/paiement/liste.php?userid='.$key.'">';
+ print '<a href="'.DOL_URL_ROOT.'/compta/paiement/liste.php?socid='.$key.'">';
} else {
- print '<a href="'.DOL_URL_ROOT.'/compta/paiement/liste.php?userid=-1">';
+ print '<a href="'.DOL_URL_ROOT.'/compta/paiement/liste.php?socid=-1">';
}
} else {
if ($key > 0) {
- print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?userid='.$key.'">';
+ print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$key.'">';
} else {
print '<a href="#">';
}
diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php
index 209cdba95637b9a303a1960b9c9d83e7dab23171..bf31220ddafc3b1aa2515df76347c6e6d65743a9 100644
--- a/htdocs/compta/stats/index.php
+++ b/htdocs/compta/stats/index.php
@@ -118,6 +118,7 @@ if ($result)
while ($i < $num)
{
$obj = $db->fetch_object($result);
+ $cum_ht[$obj->dm] = !empty($obj->amount) ? $obj->amount : 0;
$cum[$obj->dm] = $obj->amount_ttc;
if ($obj->amount_ttc)
{
@@ -180,7 +181,8 @@ print '<tr class="liste_titre"><td> </td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
- print '<td align="center" width="10%" colspan="2">';
+ if ($modecompta == 'CREANCES-DETTES') print '<td align="center" width="10%" colspan="3">';
+ else print '<td align="center" width="10%" colspan="2">';
print '<a href="casoc.php?year='.$annee.'">';
print $annee;
if ($conf->global->SOCIETE_FISCAL_MONTH_START > 1) print '-'.($annee+1);
@@ -192,6 +194,7 @@ print '</tr>';
print '<tr class="liste_titre"><td>'.$langs->trans("Month").'</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
+ if ($modecompta == 'CREANCES-DETTES') print '<td align="right">'.$langs->trans("AmountHT").'</td>';
print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
print '<td align="right">'.$langs->trans("Delta").'</td>';
if ($annee != $year_end) print '<td width="15"> </td>';
@@ -224,6 +227,22 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
$case = dol_print_date(dol_mktime(1,1,1,$mois_modulo,1,$annee_decalage),"%Y-%m");
$caseprev = dol_print_date(dol_mktime(1,1,1,$mois_modulo,1,$annee_decalage-1),"%Y-%m");
+ if ($modecompta == 'CREANCES-DETTES') {
+ // Valeur CA du mois w/o VAT
+ print '<td align="right">';
+ if ($cum_ht[$case])
+ {
+ $now_show_delta=1; // On a trouve le premier mois de la premiere annee generant du chiffre.
+ print '<a href="casoc.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price($cum_ht[$case],1).'</a>';
+ }
+ else
+ {
+ if ($minyearmonth < $case && $case <= max($maxyearmonth,$nowyearmonth)) { print '0'; }
+ else { print ' '; }
+ }
+ print "</td>";
+ }
+
// Valeur CA du mois
print '<td align="right">';
if ($cum[$case])
@@ -273,6 +292,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
print '</td>';
}
+ $total_ht[$annee]+=!empty($cum_ht[$case]) ? $cum_ht[$case] : 0;;
$total[$annee]+=$cum[$case];
if ($annee_decalage != $year_end) print '<td width="15"> </td>';
}
@@ -349,6 +369,18 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
+ if ($modecompta == 'CREANCES-DETTES') {
+ // Montant total HT
+ if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear,$maxyear)))
+ {
+ print '<td align="right" class="nowrap">'.($total_ht[$annee]?price($total_ht[$annee]):"0")."</td>";
+ }
+ else
+ {
+ print '<td> </td>';
+ }
+ }
+
// Montant total
if ($total[$annee] || ($annee >= $minyear && $annee <= max($nowyear,$maxyear)))
{
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 4ec715e0d58a9336881c0f60b2cc116792cd9f27..c77606d75bcf7b1235d203105f0c5f8192da8dc1 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -952,4 +952,4 @@ class FormFile
}
-?>
\ No newline at end of file
+?>
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index 246c32310126807c1695f9b78be5ae8bbfcf9b40..1d97c73718852f88610f0072ac3d0f960826eac9 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -617,6 +617,13 @@ class FactureFournisseur extends CommonInvoice
else {
$error++;
}
+
+ if (! $error)
+ {
+ // Delete linked object
+ $res = $this->deleteObjectLinked();
+ if ($res < 0) $error++;
+ }
if (! $error)
{