diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index d368e14d6e5e1..e122150571b84 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -195,7 +195,7 @@ print "\n"; $sql = "SELECT relname, seq_tup_read, idx_tup_fetch, n_tup_ins, n_tup_upd, n_tup_del"; - $sql .= " FROM pg_stat_user_tables"; + $sql .= " FROM pg_stat_user_tables ORDER BY relname"; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index b1c89d62edc88..62f51afd5955c 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2024 Alexandre Spangaro * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2023 Laurent Destailleur * Copyright (C) 2023 Joachim Kueter @@ -649,10 +649,11 @@ function setPaymentType() $editvalue = ''; if (isModEnabled('accounting')) { print ''; - print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->hasRight('banque', 'modifier')), 'string', '', 0); + print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0); print ''; - if ($action == 'editaccountancy_code') { - print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->hasRight('banque', 'modifier')), 'string', '', 0); + if ($action == 'editaccountancy_code' && (!$alreadyaccounted && $permissiontoadd)) { + //print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->hasRight('banque', 'modifier')), 'string', '', 0); + print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->accountancy_code, 'accountancy_code', 0, 1, '', 1); } else { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->accountancy_code, 1); @@ -672,7 +673,15 @@ function setPaymentType() print ''; print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0); print ''; - print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0, null, '', 1, 'lengthAccounta'); + if ($action == 'editsubledger_account' && (!$alreadyaccounted && $permissiontoadd)) { + if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) { + print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->subledger_account, 'subledger_account', 1, 1, '', 1); + } else { + print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0, null, '', 1, 'lengthAccounta'); + } + } else { + print length_accounta($object->subledger_account); + } print ''; $bankaccountnotfound = 0; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index a2448501e7d86..7687677b0733d 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -1,9 +1,9 @@ - * Copyright (C) 2013-2014 Olivier Geffroy - * Copyright (C) 2015 Ari Elbaz (elarifr) - * Copyright (C) 2016 Marcos García - * Copyright (C) 2016-2020 Alexandre Spangaro +/* Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2015 Ari Elbaz (elarifr) + * Copyright (C) 2016 Marcos García + * Copyright (C) 2016-2024 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -592,4 +592,44 @@ public function selectyear_accountancy_bookkepping($selected = '', $htmlname = ' return $out_array; } } + + /** + * Output html select to select accounting account + * + * @param string $page Page + * @param string $selected Id preselected + * @param string $htmlname Name of HTML select object + * @param int $option option (0: aggregate by general account or 1: aggregate by subaccount) + * @param int $useempty Show empty value in list + * @param string $filter optional filters criteria + * @param int $nooutput No print output. Return it only. + * @return void|string + */ + public function formAccountingAccount($page, $selected = '', $htmlname = 'none', $option = 0, $useempty = 1, $filter = '', $nooutput = 0) + { + global $langs; + + $out = ''; + if ($htmlname != "none") { + $out .= '
'; + $out .= ''; + $out .= ''; + if ($option == 0) { + $out .= $this->select_account($selected, $htmlname, $useempty, '', 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'accounts', $filter); + } else { + $out .= $this->select_auxaccount($selected, $htmlname, $useempty, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'subaccounts'); + } + $out .= ''; + //$out .= ''; + $out .= '
'; + } else { + $out .= " "; + } + + if ($nooutput) { + return $out; + } else { + print $out; + } + } }