From 2c71b98d0dc6ef626acf225d631cda903c184054 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 27 Mar 2019 11:05:43 +0100 Subject: [PATCH 1/5] NEW automatic / manual selector form --- htdocs/core/lib/functions.lib.php | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0937981164b..e8547792965 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -14,6 +14,7 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2019 Thibault Foucart * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -5211,6 +5212,40 @@ function yn($yesno, $case = 1, $color = 0) return $result; } +/** + * Return automatic or manual in current language + * + * @param string $automaticmanual Value to test (1, 'automatic', 'true' or 0, 'manual', 'false') + * @param integer $case 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Automatic/Manual + * @param int $color 0=texte only, 1=Text is formated with a color font style ('ok' or 'error'), 2=Text is formated with 'ok' color. + * @return string HTML string + */ +function am($automaticmanual, $case = 1, $color = 0) +{ + global $langs; + $result='unknown'; $classname=''; + if ($automaticmanual == 1 || strtolower($automaticmanual) == 'automatic' || strtolower($automaticmanual) == 'true') // A mettre avant test sur no a cause du == 0 + { + $result=$langs->trans('automatic'); + if ($case == 1 || $case == 3) $result=$langs->trans("Automatic"); + if ($case == 2) $result=''; + if ($case == 3) $result=' '.$result; + + $classname='ok'; + } + elseif ($yesno == 0 || strtolower($automaticmanual) == 'manual' || strtolower($automaticmanual) == 'false') + { + $result=$langs->trans("manual"); + if ($case == 1 || $case == 3) $result=$langs->trans("Manual"); + if ($case == 2) $result=''; + if ($case == 3) $result=' '.$result; + + if ($color == 2) $classname='ok'; + else $classname='error'; + } + if ($color) return ''.$result.''; + return $result; +} /** * Return a path to have a the directory according to object where files are stored. From 2cc9b61a9fdc0ba48f4cdd189b9ec2b87ed833ec Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 27 Mar 2019 11:10:30 +0100 Subject: [PATCH 2/5] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4f61435f124..85a4f1922b0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -21,6 +21,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Christophe Battarel * Copyright (C) 2018 Josep Lluis Amador + * Copyright (C) 2019 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -6774,7 +6775,45 @@ class Form return $resultyesno; } + /** + * Return an html string with a select combo box to choose yes or no + * + * @param string $htmlname Name of html select field + * @param string $value Pre-selected value + * @param int $option 0 return automatic/manual, 1 return 1/0 + * @param bool $disabled true or false + * @param int $useempty 1=Add empty line + * @return string See option + */ + public function selectautomanual($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0) + { + global $langs; + $automatic="automatic"; $manual="manual"; + if ($option) + { + $automatic="1"; + $manual="0"; + } + + $disabled = ($disabled ? ' disabled' : ''); + + $resultautomanual = ''."\n"; + return $resultautomanual; + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** From 1a228ed95cc6b60876185bd0aa8b945a147d8ac8 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 31 Mar 2019 19:25:45 +0200 Subject: [PATCH 3/5] transfert to html.otherform.class.php --- htdocs/core/class/html.form.class.php | 41 --------------------------- 1 file changed, 41 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 85a4f1922b0..374fdfcfbaa 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -21,7 +21,6 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Christophe Battarel * Copyright (C) 2018 Josep Lluis Amador - * Copyright (C) 2019 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -6775,46 +6774,6 @@ class Form return $resultyesno; } - /** - * Return an html string with a select combo box to choose yes or no - * - * @param string $htmlname Name of html select field - * @param string $value Pre-selected value - * @param int $option 0 return automatic/manual, 1 return 1/0 - * @param bool $disabled true or false - * @param int $useempty 1=Add empty line - * @return string See option - */ - public function selectautomanual($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0) - { - global $langs; - - $automatic="automatic"; $manual="manual"; - if ($option) - { - $automatic="1"; - $manual="0"; - } - - $disabled = ($disabled ? ' disabled' : ''); - - $resultautomanual = ''."\n"; - return $resultautomanual; - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of export templates From 13c93ba1c280a881313d10103236e24495f5e1f0 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 31 Mar 2019 19:26:40 +0200 Subject: [PATCH 4/5] transfert from html.form.class.php --- htdocs/core/class/html.formother.class.php | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 3957e44daf5..200a0d1f9f3 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -9,6 +9,7 @@ * Copyright (C) 2006 Marc Barilley/Ocebo * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2007 Patrick Raguin + * Copyright (C) 2019 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1232,4 +1233,44 @@ class FormOther dol_print_error($this->db); } } + + /** + * Return an html string with a select combo box to choose yes or no + * + * @param string $htmlname Name of html select field + * @param string $value Pre-selected value + * @param int $option 0 return automatic/manual, 1 return 1/0 + * @param bool $disabled true or false + * @param int $useempty 1=Add empty line + * @return string See option + */ + public function selectautomanual($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0) + { + global $langs; + + $automatic="automatic"; $manual="manual"; + if ($option) + { + $automatic="1"; + $manual="0"; + } + + $disabled = ($disabled ? ' disabled' : ''); + + $resultautomanual = ''."\n"; + return $resultautomanual; + } } From 69b04e2189161fd092445816ec00ffe36e7359c0 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 31 Mar 2019 19:28:45 +0200 Subject: [PATCH 5/5] Update html.formother.class.php --- htdocs/core/class/html.formother.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 200a0d1f9f3..546b57b4a5f 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1244,7 +1244,7 @@ class FormOther * @param int $useempty 1=Add empty line * @return string See option */ - public function selectautomanual($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0) + public function selectAutoManual($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0) { global $langs;