Fix bug reported by scrutinizer

This commit is contained in:
Laurent Destailleur 2018-06-06 18:40:56 +02:00
parent a8e06abc4f
commit 6b24d81afc
2 changed files with 18 additions and 7 deletions

View File

@ -87,7 +87,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
* @param string $date Date
* @return void
*/
function pt ($db, $sql, $date)
function pt($db, $sql, $date)
{
global $conf, $bc,$langs;
@ -104,12 +104,19 @@ function pt ($db, $sql, $date)
print '<td align="right">'.$langs->trans("PaidDuringThisPeriod").'</td>';
print "</tr>\n";
$totalclaimed = 0;
$totalpaid = 0;
$amountclaimed = 0;
$amountpaid = 0;
$previousmonth = '';
$previousmode = '';
$mode = '';
while ($i < $num) {
$obj = $db->fetch_object($result);
$mode = $obj->mode;
//print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode;
if ($obj->mode == 'claimed' && ! empty($previousmode))
{
print '<tr class="oddeven">';
@ -143,27 +150,29 @@ function pt ($db, $sql, $date)
$amountclaimed = 0;
$amountpaid = 0;
$previousmode = '';
$previousmonth = '';
}
else
{
$previousmode = $obj->mode;
$previousmonth = $obj->dm;
}
$i++;
}
if ($obj->mode == 'claimed' && ! empty($previousmode))
if ($mode == 'claimed' && ! empty($previousmode))
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$obj->dm."</td>\n";
print '<td class="nowrap">'.$previousmonth."</td>\n";
print '<td class="nowrap" align="right">'.price($amountclaimed)."</td>\n";
print '<td class="nowrap" align="right">'.price($amountpaid)."</td>\n";
print "</tr>\n";
$amountclaimed = 0;
$amountpaid = 0;
}
print '<tr class="liste_total">';
print '<td align="right">'.$langs->trans("Total").'</td>';
print '<td class="nowrap" align="right">'.price($totalclaimed).'</td>';

View File

@ -87,7 +87,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
* @param string $date Date
* @return void
*/
function pt ($db, $sql, $date)
function pt($db, $sql, $date)
{
global $conf, $bc,$langs;
@ -104,6 +104,8 @@ function pt ($db, $sql, $date)
print '<td align="right">'.$langs->trans("PaidDuringThisPeriod").'</td>';
print "</tr>\n";
$totalclaimed = 0;
$totalpaid = 0;
$amountclaimed = 0;
$amountpaid = 0;
$previousmonth = '';