';
- if (! empty($arrayfields['b.rowid']['checked']))
+ if (! empty($arrayfields['b.rowid']['checked']))
{
print '| ';
print '';
@@ -884,25 +884,25 @@ if ($resql)
$balance = 0; // For balance
$balancecalculated = false;
-
+
// Loop on each record
$sign = 1;
-
+
$totalarray=array();
- while ($i < min($num,$limit))
+ 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['balance']['checked']) && $mode_balance_ok)
{
- if (! $account)
+ if (! $account)
{
dol_print_error('', 'account is not defined but $mode_balance_ok is true');
exit;
}
-
- //Loop on each record
+
+ // Loop on each record before
$sign = 1;
$i = 0;
$sqlforbalance='SELECT SUM(b.amount) as balance';
@@ -912,7 +912,8 @@ if ($resql)
$sqlforbalance.= " WHERE b.fk_account = ba.rowid";
$sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sqlforbalance.= " AND b.fk_account = ".$account;
- $sqlforbalance.= " AND b.datev < '" . $db->idate($db->jdate($objp->dv)) . "'";
+ //$sqlforbalance.= " AND (b.datev < '" . $db->idate($db->jdate($objp->dv)) . "')";
+ $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);
//print $sqlforbalance;
if ($resqlforbalance)
@@ -924,12 +925,12 @@ if ($resql)
}
}
else dol_print_error($db);
-
+
$balancecalculated=true;
}
-
+
$balance = price2num($balance + ($sign * $objp->amount),'MT');
-
+
if (empty($cachebankaccount[$objp->bankid]))
{
$bankaccounttmp = new Account($db);
@@ -941,13 +942,13 @@ if ($resql)
{
$bankaccount = $cachebankaccount[$objp->bankid];
}
-
+
$var=!$var;
print " |
";
// Ref
- if (! empty($arrayfields['b.rowid']['checked']))
+ if (! empty($arrayfields['b.rowid']['checked']))
{
print '| ';
print "rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'account', 'class="classfortooltip"').' '.$objp->rowid." ";
@@ -959,14 +960,14 @@ if ($resql)
if (! empty($arrayfields['description']['checked']))
{
print " | ";
-
+
//print "rowid."&account=".$objp->fk_account."\">";
$reg=array();
preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthee on tente recherche de traduction
if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]);
else print dol_trunc($objp->label,40);
//print " ";
-
+
// Add links after description
$links = $bankaccountstatic->get_url($objp->rowid);
$cachebankaccount=array();
@@ -1054,19 +1055,19 @@ if ($resql)
}
elseif ($links[$key]['type']=='company')
{
-
+
}
elseif ($links[$key]['type']=='user')
{
-
+
}
elseif ($links[$key]['type']=='member')
{
-
+
}
elseif ($links[$key]['type']=='sc')
{
-
+
}
else
{
@@ -1086,20 +1087,20 @@ if ($resql)
print '';
}
}
-
+
print ' | ';
if (! $i) $totalarray['nbfield']++;
}
-
+
// Date ope
- if (! empty($arrayfields['b.dateo']['checked']))
+ if (! empty($arrayfields['b.dateo']['checked']))
{
print ''.dol_print_date($db->jdate($objp->do),"day")." | \n";
if (! $i) $totalarray['nbfield']++;
}
// Date value
- if (! empty($arrayfields['b.datev']['checked']))
+ if (! empty($arrayfields['b.datev']['checked']))
{
print '';
print ''.dol_print_date($db->jdate($objp->dv),"day")."";
@@ -1115,7 +1116,7 @@ if ($resql)
}
// Payment type
- if (! empty($arrayfields['type']['checked']))
+ if (! empty($arrayfields['type']['checked']))
{
print ' | ';
$labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle');
@@ -1131,9 +1132,9 @@ if ($resql)
print ' | '.($objp->num_chq?$objp->num_chq:"")." | \n";
if (! $i) $totalarray['nbfield']++;
}
-
+
// Third party
- if (! empty($arrayfields['bu.label']['checked']))
+ if (! empty($arrayfields['bu.label']['checked']))
{
print "";
if ($objp->url_id)
@@ -1156,16 +1157,16 @@ if ($resql)
print ' | ';
if (! $i) $totalarray['nbfield']++;
}
-
+
// Bank account
- if (! empty($arrayfields['ba.ref']['checked']))
+ if (! empty($arrayfields['ba.ref']['checked']))
{
print '';
print $bankaccount->getNomUrl(1);
print " | \n";
if (! $i) $totalarray['nbfield']++;
}
-
+
// Debit
if (! empty($arrayfields['b.debit']['checked']))
{
@@ -1192,7 +1193,7 @@ if ($resql)
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield'];
}
-
+
// Balance
if (! empty($arrayfields['balance']['checked']))
{
@@ -1212,7 +1213,7 @@ if ($resql)
print '- | ';
}
}
-
+
if (! empty($arrayfields['b.num_releve']['checked']))
{
print '';
@@ -1224,7 +1225,7 @@ if ($resql)
print ''.$objp->num_releve.'';
}
else if ($action == 'reconcile')
- {
+ {
print 'rowid])?' checked':'').'>';
}
}
@@ -1239,7 +1240,7 @@ if ($resql)
print ' | ';
if (! $i) $totalarray['nbfield']++;
}
-
+
// Action edit/delete
print '';
// Transaction reconciliated or edit link
@@ -1279,8 +1280,8 @@ if ($resql)
}
}
print ' | ';
- if (! $i) $totalarray['nbfield']++;
-
+ if (! $i) $totalarray['nbfield']++;
+
// Action column
print '';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
@@ -1296,7 +1297,7 @@ if ($resql)
$i++;
}
-
+
// Show total line
if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield']))
{
@@ -1319,7 +1320,7 @@ if ($resql)
print " |