NEW sort of column of custom group of account

This commit is contained in:
Laurent Destailleur 2022-12-29 17:23:56 +01:00
parent 474dd5197f
commit 13a19037dd
2 changed files with 32 additions and 15 deletions

View File

@ -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 '<br>';
/*print '<select class="flat minwidth200" size="8" name="cpt_bk[]" multiple>';
foreach ( $accountingcategory->lines_cptbk as $cpt ) {
print '<option value="' . length_accountg($cpt->numero_compte) . '">' . length_accountg($cpt->numero_compte) . ' (' . $cpt->label_compte . ' ' . $cpt->doc_ref . ')</option>';
}
print '</select><br>';
print ajax_combobox('cpt_bk');
*/
print '<input type="submit" class="button button-add small" id="" class="action-delete" value="'.$langs->trans("Add").'"> ';
}
}
@ -152,13 +164,16 @@ if (!empty($cat_id)) {
print '</form>';
if ($action == 'display' || $action == 'delete') {
if ((empty($action) || $action == 'display' || $action == 'delete') && $cat_id > 0) {
$param = 'account_category='.((int) $cat_id);
print '<br>';
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre">'.$langs->trans("AccountAccounting")."</td>";
print '<td class="liste_titre" colspan="2">'.$langs->trans("Label")."</td>";
print "</tr>\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 '</tr>'."\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 '<tr class="oddeven">';
print '<td>'.length_accountg($cpt->account_number).'</td>';

View File

@ -322,7 +322,7 @@ if ($modecompta == 'CREANCES-DETTES') {
// Year NP
print '<td class="liste_total tdoverflowmax100" title="'.dol_escape_htmltag($cat['code']).'">';
print dol_escape_htmltag($cat['code']);
print '</td><td class="tdoverflowmax150" title="'.dol_escape_htmltag($cat['label']).'">';
print '</td><td class="tdoverflowmax250" title="'.dol_escape_htmltag($cat['label']).'">';
print dol_escape_htmltag($cat['label']);
print '</td>';
@ -507,7 +507,7 @@ if ($modecompta == 'CREANCES-DETTES') {
} else {
$labeltoshow .= ' - <span class="warning">'.$langs->trans("GroupIsEmptyCheckSetup").'</span>';
}
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag(dol_string_nohtmltag($labeltoshow)).'">';
print '<td class="tdoverflowmax250" title="'.dol_escape_htmltag(dol_string_nohtmltag($labeltoshow)).'">';
print $labeltoshow;
print '</td>';
@ -537,7 +537,7 @@ if ($modecompta == 'CREANCES-DETTES') {
if ($showaccountdetail == 'all' || $resultN != 0) {
print '<tr>';
print '<td></td>';
print '<td class="tdoverflowmax200">';
print '<td class="tdoverflowmax250">';
print ' &nbsp; &nbsp; '.length_accountg($cpt['account_number']);
print ' - ';
print $cpt['account_label'];