Fix pagination show two times the same account on balance of accounts

This commit is contained in:
Laurent Destailleur 2018-10-14 23:47:38 +02:00
parent ab807ada07
commit 8fc73d1b1b
2 changed files with 22 additions and 10 deletions

View File

@ -42,6 +42,21 @@ $page = GETPOST("page");
$sortorder = GETPOST("sortorder", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha');
$action = GETPOST('action', 'alpha');
if (GETPOST("exportcsv",'alpha')) $action = 'export_csv';
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if (empty($page) || $page == -1 || GETPOST('button_search','alpha') || GETPOST('button_removefilter','alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
//if (! $sortfield) $sortfield="p.date_fin";
//if (! $sortorder) $sortorder="DESC";
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
@ -54,14 +69,6 @@ if ($search_accountancy_code_end == - 1) {
$search_accountancy_code_end = '';
}
if (GETPOST("exportcsv",'alpha')) $action = 'export_csv';
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):$conf->liste_limit;
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$object = new BookKeeping($db);
$formaccounting = new FormAccounting($db);

View File

@ -1016,16 +1016,21 @@ class BookKeeping extends CommonObject
}
$resql = $this->db->query($sql);
if ($resql) {
if ($resql)
{
$num = $this->db->num_rows($resql);
while ( $obj = $this->db->fetch_object($resql) ) {
$i = 0;
while ($obj = $this->db->fetch_object($resql) && $i < $num)
{
$line = new BookKeepingLine();
$line->numero_compte = $obj->numero_compte;
$line->debit = $obj->debit;
$line->credit = $obj->credit;
$this->lines[] = $line;
$i++;
}
$this->db->free($resql);