From 697ca3e4f53726b29800b8d343c26cd5c497c5bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Dec 2020 02:23:43 +0100 Subject: [PATCH] Fix selection of duration type --- htdocs/comm/action/card.php | 6 ++++-- htdocs/core/class/html.form.class.php | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 5d284ce048a..124b8dcf1dd 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1246,7 +1246,8 @@ if ($action == 'create') //Reminder print ''.$langs->trans("ReminderTime").''; - print ' '.$form->selectTypeDuration('offsetunit', 'i'); + print ' '; + print $form->selectTypeDuration('offsetunit', 'i', array('y', 'm')); print ''; //Reminder Type @@ -1729,7 +1730,8 @@ if ($id > 0) // Reminder print ''.$langs->trans("ReminderTime").''; - print ' '.$form->selectTypeDuration('offsetunit', $actionCommReminder->offsetunit); + print ' '; + print $form->selectTypeDuration('offsetunit', $actionCommReminder->offsetunit, array('y', 'm')); print ''; // Reminder Type diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b647a7e6685..24b3a5c2bbf 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1914,7 +1914,7 @@ class Form $out .= '});'; $out .= '})'; $out .= $this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); - $out .= ' '; + $out .= ' '; $out .= '
'; } @@ -5928,16 +5928,24 @@ class Form /** * selectTypeDuration * - * @param string $prefix Prefix - * @param string $selected Selected type - * @return string HTML select string + * @param string $prefix Prefix + * @param string $selected Selected duration type + * @param array|null $ecludetypes Array of duration types to exclude. Example array('y', 'm') + * @return string HTML select string */ - public function selectTypeDuration($prefix, $selected = 'i') + public function selectTypeDuration($prefix, $selected = 'i', $excludtypes = null) { global $langs; $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes')); + // Removed undesired duration types + if (is_array($excludtypes)) { + foreach($excludtypes as $value) { + unset($TDurationTypes[$value]); + } + } + $retstring = '