Fix filter on active on list of account

This commit is contained in:
Laurent Destailleur 2022-12-22 01:42:53 +01:00
parent 36e634c67f
commit 3968161686
3 changed files with 28 additions and 22 deletions

View File

@ -329,7 +329,8 @@ if ($action == 'create') {
// Account parent // Account parent
print '<tr><td>'.$langs->trans("Accountparent").'</td>'; print '<tr><td>'.$langs->trans("Accountparent").'</td>';
print '<td>'; print '<td>';
print $formaccounting->select_account($object->account_parent, 'account_parent', 1); // Note: We accept disabled account as parent account so we can build a hierarchy and use only childs
print $formaccounting->select_account($object->account_parent, 'account_parent', 1, array(), 0, 0, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1, '');
print '</td></tr>'; print '</td></tr>';
// Chart of accounts type // Chart of accounts type

View File

@ -339,9 +339,10 @@ class FormAccounting extends Form
* @param int $select_out Set value returned by select. 0=rowid (default), 1=account_number * @param int $select_out Set value returned by select. 0=rowid (default), 1=account_number
* @param string $morecss More css non HTML object * @param string $morecss More css non HTML object
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
* @param string $active Filter on status active or not: '0', '1' or '' for no filter
* @return string String with HTML select * @return string String with HTML select
*/ */
public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss = 'minwidth100 maxwidth300 maxwidthonsmartphone', $usecache = '') public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss = 'minwidth100 maxwidth300 maxwidthonsmartphone', $usecache = '', $active = '1')
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
@ -360,14 +361,18 @@ class FormAccounting extends Form
$options = $options + $this->options_cache[$usecache]; // We use + instead of array_merge because we don't want to reindex key from 0 $options = $options + $this->options_cache[$usecache]; // We use + instead of array_merge because we don't want to reindex key from 0
$selected = $selectid; $selected = $selectid;
} else { } else {
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT) ? 50 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT; $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', 50);
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.labelshort, aa.rowid, aa.fk_pcg_version"; $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.labelshort, aa.rowid, aa.fk_pcg_version";
$sql .= " FROM ".$this->db->prefix()."accounting_account as aa"; $sql .= " FROM ".$this->db->prefix()."accounting_account as aa";
$sql .= " INNER JOIN ".$this->db->prefix()."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN ".$this->db->prefix()."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = ".((int) $conf->global->CHARTOFACCOUNTS); $sql .= " AND asy.rowid = ".((int) $conf->global->CHARTOFACCOUNTS);
if ($active === '1') {
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " AND aa.entity=".$conf->entity; } elseif ($active === '0') {
$sql .= " AND aa.active = 0";
}
$sql .= " AND aa.entity=".((int) $conf->entity);
$sql .= " ORDER BY aa.account_number"; $sql .= " ORDER BY aa.account_number";
dol_syslog(get_class($this)."::select_account", LOG_DEBUG); dol_syslog(get_class($this)."::select_account", LOG_DEBUG);

View File

@ -271,13 +271,13 @@ Reconcilable=Reconcilable
TotalVente=Total turnover before tax TotalVente=Total turnover before tax
TotalMarge=Total sales margin TotalMarge=Total sales margin
DescVentilCustomer=Consult here the list of customer invoice lines bound (or not) to a product accounting account DescVentilCustomer=Consult here the list of customer invoice lines bound (or not) to a product account from chart of account
DescVentilMore=In most cases, if you use predefined products or services and you set the account number on the product/service card, the application will be able to make all the binding between your invoice lines and the accounting account of your chart of accounts, just in one click with the button <strong>"%s"</strong>. If account was not set on product/service cards or if you still have some lines not bound to an account, you will have to make a manual binding from the menu "<strong>%s</strong>". DescVentilMore=In most cases, if you use predefined products or services and you set the account (from chart of account) on the product/service card, the application will be able to make all the binding between your invoice lines and the accounting account of your chart of accounts, just in one click with the button <strong>"%s"</strong>. If account was not set on product/service cards or if you still have some lines not bound to an account, you will have to make a manual binding from the menu "<strong>%s</strong>".
DescVentilDoneCustomer=Consult here the list of the lines of invoices customers and their product accounting account DescVentilDoneCustomer=Consult here the list of the lines of invoices customers and their product account from chart of account
DescVentilTodoCustomer=Bind invoice lines not already bound with a product accounting account DescVentilTodoCustomer=Bind invoice lines not already bound with a product account from chart of account
ChangeAccount=Change the product/service accounting account for selected lines with the following accounting account: ChangeAccount=Change the product/service account (from chart of account) for the selected lines with the following account:
Vide=- Vide=-
DescVentilSupplier=Consult here the list of vendor invoice lines bound or not yet bound to a product accounting account (only record not already transfered in accountancy are visible) DescVentilSupplier=Consult here the list of vendor invoice lines bound or not yet bound to a product account from chart of account (only record not already transfered in accountancy are visible)
DescVentilDoneSupplier=Consult here the list of the lines of vendor invoices and their accounting account DescVentilDoneSupplier=Consult here the list of the lines of vendor invoices and their accounting account
DescVentilTodoExpenseReport=Bind expense report lines not already bound with a fee accounting account DescVentilTodoExpenseReport=Bind expense report lines not already bound with a fee accounting account
DescVentilExpenseReport=Consult here the list of expense report lines bound (or not) to a fee accounting account DescVentilExpenseReport=Consult here the list of expense report lines bound (or not) to a fee accounting account
@ -295,14 +295,14 @@ DescValidateMovements=Any modification or deletion of writing, lettering and del
ValidateHistory=Bind Automatically ValidateHistory=Bind Automatically
AutomaticBindingDone=Automatic bindings done (%s) - Automatic binding not possible for some record (%s) AutomaticBindingDone=Automatic bindings done (%s) - Automatic binding not possible for some record (%s)
ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used ErrorAccountancyCodeIsAlreadyUse=Error, you cannot remove or disable this account of chart of account because it is used
MvtNotCorrectlyBalanced=Movement not correctly balanced. Debit = %s & Credit = %s MvtNotCorrectlyBalanced=Movement not correctly balanced. Debit = %s & Credit = %s
Balancing=Balancing Balancing=Balancing
FicheVentilation=Binding card FicheVentilation=Binding card
GeneralLedgerIsWritten=Transactions are written in the Ledger GeneralLedgerIsWritten=Transactions are written in the Ledger
GeneralLedgerSomeRecordWasNotRecorded=Some of the transactions could not be journalized. If there is no other error message, this is probably because they were already journalized. GeneralLedgerSomeRecordWasNotRecorded=Some of the transactions could not be journalized. If there is no other error message, this is probably because they were already journalized.
NoNewRecordSaved=No more record to transfer NoNewRecordSaved=No more record to transfer
ListOfProductsWithoutAccountingAccount=List of products not bound to any accounting account ListOfProductsWithoutAccountingAccount=List of products not bound to any account of chart of account
ChangeBinding=Change the binding ChangeBinding=Change the binding
Accounted=Accounted in ledger Accounted=Accounted in ledger
NotYetAccounted=Not yet transferred to accounting NotYetAccounted=Not yet transferred to accounting