diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 3a4a2249de7..1e3ea48ce6c 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -6773,8 +6773,6 @@ class Form
return $resultyesno;
}
-
-
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of export templates
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 3957e44daf5..546b57b4a5f 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;
+ }
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 80cd10afb54..22ee559f700 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.