diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php
index 12dff9d460a..15345584f73 100644
--- a/htdocs/compta/cashcontrol/report.php
+++ b/htdocs/compta/cashcontrol/report.php
@@ -120,9 +120,10 @@ $sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CB;
$sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE;
$sql.=")";
*/
-$sql = "SELECT f.rowid as facid, f.ref, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code";
-$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp, ".MAIN_DB_PREFIX."bank as b";
-$sql .= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement AND p.fk_bank = b.rowid";
+$sql = "SELECT f.rowid as facid, f.ref, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code, SUM(fd.qty) as qty";
+$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp, ".MAIN_DB_PREFIX."bank as b,";
+$sql .= " ".MAIN_DB_PREFIX."facturedet as fd";
+$sql .= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement AND p.fk_bank = b.rowid AND fd.fk_facture = f.rowid";
$sql .= " AND f.module_source = '".$db->escape($posmodule)."'";
$sql .= " AND f.pos_source = '".$db->escape($terminalid)."'";
$sql .= " AND f.paye = 1";
@@ -144,6 +145,7 @@ if ($syear && !$smonth) {
} else {
dol_print_error('', 'Year not defined');
}
+$sql .= " GROUP BY f.rowid, f.ref, f.datef, pf.amount, b.fk_account, cp.code";
$resql = $db->query($sql);
if ($resql) {
@@ -196,15 +198,20 @@ if ($resql) {
print "\n";
// Loop on each record
- $sign = 1;
$cash = $bank = $cheque = $other = 0;
- $totalarray = array();
+ $totalqty = 0;
$cachebankaccount = array();
+ $transactionspertype = array();
$amountpertype = array();
+
+ $totalarray = array();
while ($i < $num) {
$objp = $db->fetch_object($resql);
+ $totalqty += $objp->qty;
+
+
if (empty($cachebankaccount[$objp->bankid])) {
$bankaccounttmp = new Account($db);
$bankaccounttmp->fetch($objp->bankid);
@@ -243,25 +250,42 @@ if ($resql) {
$totalarray['nbfield']++;
}
- // Bank account
- print '
';
- print $bankaccount->getNomUrl(1);
if ($object->posmodule == "takepos") {
$var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'.$object->posnumber;
} else {
$var1 = 'CASHDESK_ID_BANKACCOUNT_CASH';
}
+
+ // Bank account
+ print ' | ';
+ print $bankaccount->getNomUrl(1);
if ($objp->code == 'CHQ') {
$cheque += $objp->amount;
+ if (empty($transactionspertype[$objp->code])) {
+ $transactionspertype[$objp->code] = 0;
+ }
+ $transactionspertype[$objp->code] += 1;
} elseif ($objp->code == 'CB') {
$bank += $objp->amount;
+ if (empty($transactionspertype[$objp->code])) {
+ $transactionspertype[$objp->code] = 0;
+ }
+ $transactionspertype[$objp->code] += 1;
} else {
if ($conf->global->$var1 == $bankaccount->id) {
$cash += $objp->amount;
// } elseif ($conf->global->$var2 == $bankaccount->id) $bank+=$objp->amount;
//elseif ($conf->global->$var3 == $bankaccount->id) $cheque+=$objp->amount;
+ if (empty($transactionspertype['CASH'])) {
+ $transactionspertype['CASH'] = 0;
+ }
+ $transactionspertype['CASH'] += 1;
} else {
$other += $objp->amount;
+ if (empty($transactionspertype['OTHER'])) {
+ $transactionspertype['OTHER'] = 0;
+ }
+ $transactionspertype['OTHER'] += 1;
}
}
print " | \n";
@@ -327,21 +351,21 @@ if ($resql) {
print '';
print '
';
- print $langs->trans("Cash").': '.price($cash).'';
+ print $langs->trans("Cash").' '.($transactionspertype['CASH']?'('.$transactionspertype['CASH'].')':'').': '.price($cash).'';
if ($object->status == $object::STATUS_VALIDATED && $cash != $object->cash) {
print ' <> '.$langs->trans("Declared").': '.price($object->cash).'';
}
print "
";
//print '
';
- print $langs->trans("PaymentTypeCHQ").': '.price($cheque).'';
+ print $langs->trans("PaymentTypeCHQ").' '.($transactionspertype['CHQ']?'('.$transactionspertype['CHQ'].')':'').': '.price($cheque).'';
if ($object->status == $object::STATUS_VALIDATED && $cheque != $object->cheque) {
print ' <> '.$langs->trans("Declared").': '.price($object->cheque).'';
}
print "
";
//print '
';
- print $langs->trans("PaymentTypeCB").': '.price($bank).'';
+ print $langs->trans("PaymentTypeCB").' '.($transactionspertype['CB']?'('.$transactionspertype['CB'].')':'').': '.price($bank).'';
if ($object->status == $object::STATUS_VALIDATED && $bank != $object->card) {
print ' <> '.$langs->trans("Declared").': '.price($object->card).'';
}
@@ -349,11 +373,11 @@ if ($resql) {
// print '
';
if ($other) {
- print ''.$langs->trans("Other").': '.price($other)."";
+ print ''.$langs->trans("Other").' '.($transactionspertype['OTHER']?'('.$transactionspertype['OTHER'].')':'').': '.price($other)."";
print '
';
}
- print $langs->trans("Total").': '.price($cash + $cheque + $bank + $other).'';
+ print $langs->trans("Total").' ('.$totalqty.' '.$langs->trans("Articles").') : '.price($cash + $cheque + $bank + $other).'';
print '
';
print '';