NEW Can define the text on tooltip on a yesno check.

This commit is contained in:
Laurent Destailleur
2024-10-26 14:05:51 +02:00
parent 865ac03f86
commit 649adf7736
2 changed files with 13 additions and 13 deletions

View File

@@ -7735,11 +7735,11 @@ function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $id
* Return yes or no in current language
*
* @param int<0, 1>|'yes'|'true'|'no'|'false' $yesno Value to test (1, 'yes', 'true' or 0, 'no', 'false')
* @param integer $case 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No
* @param integer|string $format 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No, 4 or Text=Use picto
* @param int $color 0=texte only, 1=Text is formatted with a color font style ('ok' or 'error'), 2=Text is formatted with 'ok' color.
* @return string HTML string
*/
function yn($yesno, $case = 1, $color = 0)
function yn($yesno, $format = 1, $color = 0)
{
global $langs;
@@ -7747,33 +7747,33 @@ function yn($yesno, $case = 1, $color = 0)
$classname = '';
if ($yesno == 1 || (isset($yesno) && (strtolower($yesno) == 'yes' || strtolower($yesno) == 'true'))) { // To set to 'no' before the test because of the '== 0'
$result = $langs->trans('yes');
if ($case == 1 || $case == 3) {
if ($format == 1 || $format == 3) {
$result = $langs->trans("Yes");
}
if ($case == 2) {
if ($format == 2) {
$result = '<input type="checkbox" value="1" checked disabled>';
}
if ($case == 3) {
if ($format == 3) {
$result = '<input type="checkbox" value="1" checked disabled> '.$result;
}
if ($case == 4) {
$result = img_picto('check', 'check');
if ($format == 4 || !is_numeric($format)) {
$result = img_picto(is_numeric($format) ? '' : $format, 'check');
}
$classname = 'ok';
} elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
$result = $langs->trans("no");
if ($case == 1 || $case == 3) {
if ($format == 1 || $format == 3) {
$result = $langs->trans("No");
}
if ($case == 2) {
if ($format == 2) {
$result = '<input type="checkbox" value="0" disabled>';
}
if ($case == 3) {
if ($format == 3) {
$result = '<input type="checkbox" value="0" disabled> '.$result;
}
if ($case == 4) {
$result = img_picto('uncheck', 'uncheck');
if ($format == 4 || !is_numeric($format)) {
$result = img_picto(is_numeric($format) ? '' : $format, 'uncheck');
}
if ($color == 2) {