diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 9eabd378e11..97d2509b898 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -329,7 +329,8 @@ if ($action == 'create') { // Account parent print ''.$langs->trans("Accountparent").''; print ''; - 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 ''; // Chart of accounts type diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 10e23f3d2e4..19ef75c8aaa 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -331,17 +331,18 @@ class FormAccounting extends Form /** * Return list of accounts with label by chart of accounts * - * @param string $selectid Preselected id of accounting accounts (depends on $select_in) - * @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used. - * @param int|string $showempty 1=Add an empty field, 2=Add an empty field+'None' field - * @param array $event Event options - * @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.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 $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. - * @return string String with HTML select + * @param string $selectid Preselected id of accounting accounts (depends on $select_in) + * @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used. + * @param int|string $showempty 1=Add an empty field, 2=Add an empty field+'None' field + * @param array $event Event options + * @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.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 $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 */ - 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 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 $selected = $selectid; } 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 .= " 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 .= " AND asy.rowid = ".((int) $conf->global->CHARTOFACCOUNTS); - $sql .= " AND aa.active = 1"; - $sql .= " AND aa.entity=".$conf->entity; + if ($active === '1') { + $sql .= " AND aa.active = 1"; + } elseif ($active === '0') { + $sql .= " AND aa.active = 0"; + } + $sql .= " AND aa.entity=".((int) $conf->entity); $sql .= " ORDER BY aa.account_number"; dol_syslog(get_class($this)."::select_account", LOG_DEBUG); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index a3ed5f9b7b6..b6bf1b90aef 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -271,13 +271,13 @@ Reconcilable=Reconcilable TotalVente=Total turnover before tax TotalMarge=Total sales margin -DescVentilCustomer=Consult here the list of customer invoice lines bound (or not) to a product accounting 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 "%s". 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 "%s". -DescVentilDoneCustomer=Consult here the list of the lines of invoices customers and their product accounting account -DescVentilTodoCustomer=Bind invoice lines not already bound with a product accounting account -ChangeAccount=Change the product/service accounting account for selected lines with the following 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 (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 "%s". 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 "%s". +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 account from chart of account +ChangeAccount=Change the product/service account (from chart of account) for the selected lines with the following account: 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 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 @@ -295,14 +295,14 @@ DescValidateMovements=Any modification or deletion of writing, lettering and del ValidateHistory=Bind Automatically 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 Balancing=Balancing FicheVentilation=Binding card 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. 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 Accounted=Accounted in ledger NotYetAccounted=Not yet transferred to accounting