From 13a19037dd8f3df460bfe735a4b533df2b275c9c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Dec 2022 17:23:56 +0100 Subject: [PATCH] NEW sort of column of custom group of account --- htdocs/accountancy/admin/categories.php | 41 +++++++++++++++++-------- htdocs/compta/resultat/result.php | 6 ++-- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 3414c36cd52..2a15921243f 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -45,6 +45,26 @@ if ($cat_id == 0) { $cat_id = null; } +// Load variable for pagination +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters + $page = 0; +} +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +if (empty($sortfield)) { + $sortfield = 'account_number'; +} +if (empty($sortorder)) { + $sortorder = 'ASC'; +} + // Security check if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); @@ -137,14 +157,6 @@ if (!empty($cat_id)) { if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) { print img_picto($langs->trans("AccountingAccount"), 'accounting_account', 'class="pictofixedwith"'); print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), null, null, '', 0, "80%", '', '', $langs->transnoentitiesnoconv("AddAccountFromBookKeepingWithNoCategories")); - //print '
'; - /*print '
'; - print ajax_combobox('cpt_bk'); - */ print ' '; } } @@ -152,13 +164,16 @@ if (!empty($cat_id)) { print ''; -if ($action == 'display' || $action == 'delete') { +if ((empty($action) || $action == 'display' || $action == 'delete') && $cat_id > 0) { + $param = 'account_category='.((int) $cat_id); + print '
'; print ''."\n"; print ''; - print '"; - print '"; - print "\n"; + print getTitleFieldOfList('AccountAccounting', 0, $_SERVER['PHP_SELF'], 'account_number', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList('Label', 0, $_SERVER['PHP_SELF'], 'label', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList('', 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n"; + print ''."\n"; if (!empty($cat_id)) { $return = $accountingcategory->display($cat_id); // This load ->lines_display @@ -167,6 +182,8 @@ if ($action == 'display' || $action == 'delete') { } if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) { + $accountingcategory->lines_display = dol_sort_array($accountingcategory->lines_display, $sortfield, $sortorder, 1, 0, 1); + foreach ($accountingcategory->lines_display as $cpt) { print ''; print ''; diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index cb2158bb48b..4bbb20b18a1 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -322,7 +322,7 @@ if ($modecompta == 'CREANCES-DETTES') { // Year NP print ''; @@ -507,7 +507,7 @@ if ($modecompta == 'CREANCES-DETTES') { } else { $labeltoshow .= ' - '.$langs->trans("GroupIsEmptyCheckSetup").''; } - print ''; @@ -537,7 +537,7 @@ if ($modecompta == 'CREANCES-DETTES') { if ($showaccountdetail == 'all' || $resultN != 0) { print ''; print ''; - print '
'.$langs->trans("AccountAccounting")."'.$langs->trans("Label")."
'.length_accountg($cpt->account_number).''; print dol_escape_htmltag($cat['code']); - print ''; + print ''; print dol_escape_htmltag($cat['label']); print ''; + print ''; print $labeltoshow; print '
'; + print ''; print '     '.length_accountg($cpt['account_number']); print ' - '; print $cpt['account_label'];