FIX #8192
This commit is contained in:
parent
7722f004c8
commit
13dd440fd4
@ -52,7 +52,7 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
|
|||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (! $sortfield) $sortfield="f.datef"; // Set here default search field
|
if (! $sortfield) $sortfield="f.datef,f.rowid"; // Set here default search field
|
||||||
if (! $sortorder) $sortorder="DESC";
|
if (! $sortorder) $sortorder="DESC";
|
||||||
|
|
||||||
|
|
||||||
@ -112,7 +112,6 @@ if ($id > 0)
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
$TData = array();
|
$TData = array();
|
||||||
$TDataSort = array();
|
|
||||||
|
|
||||||
$sql = "SELECT s.nom, s.rowid as socid, f.facnumber, f.amount, f.datef as df,";
|
$sql = "SELECT s.nom, s.rowid as socid, f.facnumber, f.amount, f.datef as df,";
|
||||||
$sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
|
$sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
|
||||||
@ -149,6 +148,7 @@ if ($id > 0)
|
|||||||
$values = array(
|
$values = array(
|
||||||
'fk_facture' => $objf->facid,
|
'fk_facture' => $objf->facid,
|
||||||
'date' => $fac->date,
|
'date' => $fac->date,
|
||||||
|
'datefieldforsort' => $fac->date.'-'.$fac->ref,
|
||||||
'link' => $fac->getNomUrl(1),
|
'link' => $fac->getNomUrl(1),
|
||||||
'status' => $fac->getLibStatut(2,$totalpaye),
|
'status' => $fac->getLibStatut(2,$totalpaye),
|
||||||
'amount' => $fac->total_ttc,
|
'amount' => $fac->total_ttc,
|
||||||
@ -160,7 +160,6 @@ if ($id > 0)
|
|||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
$TData[] = $values;
|
$TData[] = $values;
|
||||||
$TDataSort[] = $fac->date;
|
|
||||||
|
|
||||||
// Paiements
|
// Paiements
|
||||||
$sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
|
$sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
|
||||||
@ -171,7 +170,7 @@ if ($id > 0)
|
|||||||
$sql.= " WHERE pf.fk_paiement = p.rowid";
|
$sql.= " WHERE pf.fk_paiement = p.rowid";
|
||||||
$sql.= " AND p.entity = ".$conf->entity;
|
$sql.= " AND p.entity = ".$conf->entity;
|
||||||
$sql.= " AND pf.fk_facture = ".$fac->id;
|
$sql.= " AND pf.fk_facture = ".$fac->id;
|
||||||
$sql.= " ORDER BY p.datep ASC";
|
$sql.= " ORDER BY p.datep ASC, p.rowid ASC";
|
||||||
|
|
||||||
$resqlp = $db->query($sql);
|
$resqlp = $db->query($sql);
|
||||||
if ($resqlp)
|
if ($resqlp)
|
||||||
@ -192,6 +191,7 @@ if ($id > 0)
|
|||||||
$values = array(
|
$values = array(
|
||||||
'fk_paiement' => $objp->rowid,
|
'fk_paiement' => $objp->rowid,
|
||||||
'date' => $db->jdate($objp->dp),
|
'date' => $db->jdate($objp->dp),
|
||||||
|
'datefieldforsort' => $db->jdate($objp->dp).'-'.$fac->ref,
|
||||||
'link' => $langs->trans("Payment") .' '. $paymentstatic->getNomUrl(1),
|
'link' => $langs->trans("Payment") .' '. $paymentstatic->getNomUrl(1),
|
||||||
'status' => '',
|
'status' => '',
|
||||||
'amount' => -$objp->amount,
|
'amount' => -$objp->amount,
|
||||||
@ -203,7 +203,6 @@ if ($id > 0)
|
|||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
$TData[] = $values;
|
$TData[] = $values;
|
||||||
$TDataSort[] = $db->jdate($objp->dp);
|
|
||||||
|
|
||||||
$j++;
|
$j++;
|
||||||
}
|
}
|
||||||
@ -225,19 +224,18 @@ if ($id > 0)
|
|||||||
print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoInvoice").'</td></tr>';
|
print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoInvoice").'</td></tr>';
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Sort array by date
|
// Sort array by date ASC to calucalte balance
|
||||||
asort($TDataSort);
|
$TData = dol_sort_array($TData, 'datefieldforsort', 'ASC');
|
||||||
array_multisort($TData,$TDataSort);
|
|
||||||
|
|
||||||
// Balance calculation
|
// Balance calculation
|
||||||
|
$balance = 0;
|
||||||
foreach($TData as &$data1) {
|
foreach($TData as &$data1) {
|
||||||
$balance += $data1['amount'];
|
$balance += $data1['amount'];
|
||||||
$data1['balance'] += $balance;
|
$data1['balance'] += $balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reverse array to have last elements on top
|
// Resorte array to have elements on the required $sortorder
|
||||||
$TData = dol_sort_array($TData, 'date', $sortorder);
|
$TData = dol_sort_array($TData, 'datefieldforsort', $sortorder);
|
||||||
|
|
||||||
|
|
||||||
$totalDebit = 0;
|
$totalDebit = 0;
|
||||||
$totalCredit = 0;
|
$totalCredit = 0;
|
||||||
@ -251,7 +249,10 @@ if ($id > 0)
|
|||||||
|
|
||||||
print '<tr class="oddeven '.$html_class.'">';
|
print '<tr class="oddeven '.$html_class.'">';
|
||||||
|
|
||||||
print "<td align=\"center\">".dol_print_date($data['date'],'day')."</td>\n";
|
print "<td align=\"center\">";
|
||||||
|
if (!empty($data['fk_facture'])) print dol_print_date($data['date'],'day');
|
||||||
|
elseif (!empty($data['fk_paiement'])) print dol_print_date($data['date'],'dayhour');
|
||||||
|
print "</td>\n";
|
||||||
print '<td>'.$data['link']."</td>\n";
|
print '<td>'.$data['link']."</td>\n";
|
||||||
|
|
||||||
print '<td aling="left">'.$data['status'].'</td>';
|
print '<td aling="left">'.$data['status'].'</td>';
|
||||||
@ -259,6 +260,7 @@ if ($id > 0)
|
|||||||
$totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0;
|
$totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0;
|
||||||
print '<td align="right">'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."</td>\n";
|
print '<td align="right">'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."</td>\n";
|
||||||
$totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']);
|
$totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']);
|
||||||
|
// Balance
|
||||||
print '<td align="right">'.price($data['balance'])."</td>\n";
|
print '<td align="right">'.price($data['balance'])."</td>\n";
|
||||||
|
|
||||||
// Author
|
// Author
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user