|
@@ -25,13 +25,14 @@
|
|
|
|
|
|
/**
|
|
|
* \file htdocs/compta/cashcontrol/report.php
|
|
|
- * \ingroup pos
|
|
|
+ * \ingroup cashdesk|takepos
|
|
|
* \brief List of bank transactions
|
|
|
*/
|
|
|
|
|
|
require '../../main.inc.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
|
|
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
|
|
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
|
|
|
|
|
$id = GETPOST('id','int');
|
|
|
|
|
@@ -94,9 +95,9 @@ $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.facnumber, pf.amount as total, 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";
|
|
|
-$sql.= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement";
|
|
|
+$sql = "SELECT f.rowid as facid, f.facnumber, 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.= " AND f.module_source = '".$db->escape($posmodule)."'";
|
|
|
$sql.= " AND f.pos_source = '".$db->escape($terminalid)."'";
|
|
|
$sql.= " AND f.paye = 1";
|
|
@@ -125,6 +126,12 @@ if ($resql)
|
|
|
else print $langs->trans("CashControl")." - ".$langs->trans("Draft");
|
|
|
print "<br>".$langs->trans("DateCreationShort").": ".dol_print_date($cashcontrol->date_creation, 'dayhour')."</h2></center>";
|
|
|
|
|
|
+ $invoicetmp = new Facture($db);
|
|
|
+
|
|
|
+
|
|
|
+ print "<div style='text-align: right'><h2>";
|
|
|
+ print $langs->trans("InitialBankBalance").' - '.$langs->trans("Cash")." : ".price($cashcontrol->opening);
|
|
|
+ print "</h2></div>";
|
|
|
|
|
|
print '<div class="div-table-responsive">';
|
|
|
print '<table class="tagtable liste">'."\n";
|
|
@@ -138,55 +145,17 @@ if ($resql)
|
|
|
print_liste_field_titre($arrayfields['b.credit']['label'],$_SERVER['PHP_SELF'],'b.amount','',$param,'align="right"',$sortfield,$sortorder);
|
|
|
print "</tr>\n";
|
|
|
|
|
|
- $balance = 0; // For balance
|
|
|
- $balancecalculated = false;
|
|
|
$posconciliatecol = 0;
|
|
|
|
|
|
// Loop on each record
|
|
|
$sign = 1;
|
|
|
- $first='yes';
|
|
|
+ $cash=$bank=$cheque=$other=0;
|
|
|
|
|
|
$totalarray=array();
|
|
|
while ($i < min($num,$limit))
|
|
|
{
|
|
|
$objp = $db->fetch_object($resql);
|
|
|
|
|
|
- // If we are in a situation where we need/can show balance, we calculate the start of balance
|
|
|
- if (! $balancecalculated && (! empty($arrayfields['balancebefore']['checked']) || ! empty($arrayfields['balance']['checked'])) && $mode_balance_ok)
|
|
|
- {
|
|
|
- if (! $account)
|
|
|
- {
|
|
|
- dol_print_error('', 'account is not defined but $mode_balance_ok is true');
|
|
|
- exit;
|
|
|
- }
|
|
|
-
|
|
|
- // Loop on each record before
|
|
|
- $sign = 1;
|
|
|
- $i = 0;
|
|
|
- $sqlforbalance='SELECT SUM(b.amount) as balance';
|
|
|
- $sqlforbalance.= " FROM ";
|
|
|
- $sqlforbalance.= " ".MAIN_DB_PREFIX."bank_account as ba,";
|
|
|
- $sqlforbalance.= " ".MAIN_DB_PREFIX."bank as b";
|
|
|
- $sqlforbalance.= " WHERE b.fk_account = ba.rowid";
|
|
|
- $sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account').")";
|
|
|
- $sqlforbalance.= " AND b.fk_account = ".$account;
|
|
|
- $sqlforbalance.= " AND (b.datev < '" . $db->idate($db->jdate($objp->dv)) . "' OR (b.datev = '" . $db->idate($db->jdate($objp->dv)) . "' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))";
|
|
|
- $resqlforbalance = $db->query($sqlforbalance);
|
|
|
- if ($resqlforbalance)
|
|
|
- {
|
|
|
- $objforbalance = $db->fetch_object($resqlforbalance);
|
|
|
- if ($objforbalance)
|
|
|
- {
|
|
|
- $balance = $objforbalance->balance;
|
|
|
- }
|
|
|
- }
|
|
|
- else dol_print_error($db);
|
|
|
-
|
|
|
- $balancecalculated=true;
|
|
|
- }
|
|
|
-
|
|
|
- $balance = price2num($balance + ($sign * $objp->amount),'MT');
|
|
|
-
|
|
|
if (empty($cachebankaccount[$objp->bankid]))
|
|
|
{
|
|
|
$bankaccounttmp = new Account($db);
|
|
@@ -198,22 +167,22 @@ if ($resql)
|
|
|
{
|
|
|
$bankaccount = $cachebankaccount[$objp->bankid];
|
|
|
}
|
|
|
- print '<tr class="oddeven">';
|
|
|
|
|
|
- if ($first == "yes")
|
|
|
+ /*if ($first == "yes")
|
|
|
{
|
|
|
print '<tr class="oddeven">';
|
|
|
print '<td>'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").'</td>';
|
|
|
print '<td></td><td></td><td></td><td align="right">'.price($cashcontrol->opening).'</td>';
|
|
|
print '</tr>';
|
|
|
$first = "no";
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
print '<tr class="oddeven">';
|
|
|
|
|
|
// Ref
|
|
|
print '<td align="left" class="nowrap">';
|
|
|
- print $objp->facnumber;
|
|
|
+ $invoicetmp->fetch($objp->facid);
|
|
|
+ print $invoicetmp->getNomUrl(1);
|
|
|
print '</td>';
|
|
|
if (! $i) $totalarray['nbfield']++;
|
|
|
|
|
@@ -227,9 +196,10 @@ if ($resql)
|
|
|
// Bank account
|
|
|
print '<td align="right" class="nowrap">';
|
|
|
print $bankaccount->getNomUrl(1);
|
|
|
- if ($sql.=$conf->global->CASHDESK_ID_BANKACCOUNT_CASH==$bankaccount->id) $cash+=$objp->amount;
|
|
|
- if ($sql.=$conf->global->CASHDESK_ID_BANKACCOUNT_CB==$bankaccount->id) $bank+=$objp->amount;
|
|
|
- if ($sql.=$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE==$bankaccount->id) $cheque+=$objp->amount;
|
|
|
+ if ($conf->global->CASHDESK_ID_BANKACCOUNT_CASH==$bankaccount->id) $cash+=$objp->amount;
|
|
|
+ elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CB==$bankaccount->id) $bank+=$objp->amount;
|
|
|
+ elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE==$bankaccount->id) $cheque+=$objp->amount;
|
|
|
+ else $other+=$objp->amount;
|
|
|
print "</td>\n";
|
|
|
if (! $i) $totalarray['nbfield']++;
|
|
|
|
|
@@ -287,6 +257,7 @@ if ($resql)
|
|
|
print $langs->trans("Cash").": ".price($cash)."<br><br>";
|
|
|
print $langs->trans("PaymentTypeCB").": ".price($bank)."<br><br>";
|
|
|
print $langs->trans("PaymentTypeCHQ").": ".price($cheque)."<br><br>";
|
|
|
+ if ($other) print $langs->trans("Other").": ".price($other)."<br><br>";
|
|
|
print "</h2></div>";
|
|
|
|
|
|
//save totals to DB
|