Fix selection of duration type

This commit is contained in:
Laurent Destailleur 2020-12-11 02:23:43 +01:00
parent 4ec598d571
commit 697ca3e4f5
2 changed files with 19 additions and 7 deletions

View File

@ -1246,7 +1246,8 @@ if ($action == 'create')
//Reminder
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ReminderTime").'</td><td colspan="3">';
print '<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET('offsetvalue') ? GETPOST('offsetvalue', 'int') : '15').'"> '.$form->selectTypeDuration('offsetunit', 'i');
print '<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET('offsetvalue') ? GETPOST('offsetvalue', 'int') : '15').'"> ';
print $form->selectTypeDuration('offsetunit', 'i', array('y', 'm'));
print '</td></tr>';
//Reminder Type
@ -1729,7 +1730,8 @@ if ($id > 0)
// Reminder
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ReminderTime").'</td><td colspan="3">';
print '<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.'"> '.$form->selectTypeDuration('offsetunit', $actionCommReminder->offsetunit);
print '<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.'"> ';
print $form->selectTypeDuration('offsetunit', $actionCommReminder->offsetunit, array('y', 'm'));
print '</td></tr>';
// Reminder Type

View File

@ -1914,7 +1914,7 @@ class Form
$out .= '});';
$out .= '})</script>';
$out .= $this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
$out .= ' <input type="submit" disabled class="button valignmiddle" id="'.$action.'assignedtouser" name="'.$action.'assignedtouser" value="'.dol_escape_htmltag($langs->trans("Add")).'">';
$out .= ' <input type="submit" disabled class="button valignmiddle smallpaddingimp" id="'.$action.'assignedtouser" name="'.$action.'assignedtouser" value="'.dol_escape_htmltag($langs->trans("Add")).'">';
$out .= '<br>';
}
@ -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 = '<select class="flat" id="select_'.$prefix.'type_duration" name="'.$prefix.'type_duration">';
foreach ($TDurationTypes as $key=>$typeduration) {
$retstring .= '<option value="'.$key.'"';
@ -5948,6 +5956,8 @@ class Form
}
$retstring .= "</select>";
$retstring .= ajax_combobox('select_'.$prefix.'type_duration');
return $retstring;
}