diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 1ce62ce4c9e..7d7c58d756d 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -431,6 +431,19 @@ if ($action == 'create') { $(\'#fieldchqemetteur\').val(\'\'); } } + function toggleSubledger() { + var isCentral = $("#accountancy_code option:selected").data("centralized"); + console.log("the selected general ledger account is centralised?", isCentral); + if (isCentral) { + $("#subledger_account").prop("disabled", false); + } else { + $("#subledger_account").prop("disabled", true); + } + } + toggleSubledger(); + + $("#accountancy_code").on("change", toggleSubledger); + $("#accountancy_code").on("select2:select", toggleSubledger); '; print ' });'."\n"; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 93900c30ae0..3bfe4918ea3 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-2024 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-2025 Alexandre Spangaro * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; class FormAccounting extends Form { /** - * @var array> + * @var array|array>> */ private $options_cache = array(); @@ -457,7 +457,10 @@ class FormAccounting extends Form $selected = $select_value_out; } - $options[$select_value_out] = $label; + $options[$select_value_out] = array( + 'label' => $label, + 'data-centralized' => $obj->centralized ? 1 : 0 + ); } }