NEW Accountancy - Various payment - Add script to greyed out subledger_account if general ledger is not centralized (#35842)

* NEW Accountancy -  Add data-centralized in select_account()

* NEW Accountancy - Add script to greyed out subledger_account if general ledger is not centralized

* Fix phan

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Alexandre SPANGARO 2025-10-21 02:08:19 +02:00 committed by GitHub
parent cd3b74f092
commit cdd4dde166
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 7 deletions

View file

@ -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";

View file

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016-2024 Alexandre Spangaro <aspangaro@easya.solutions>
/* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
class FormAccounting extends Form
{
/**
* @var array<string,array<string,string>>
* @var array<string, array<string, string>|array<string, array<string, mixed>>>
*/
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
);
}
}