Skip to content

Commit

Permalink
Merge pull request #6552 from defrance/patch-91
Browse files Browse the repository at this point in the history
NEW : introducing "mixte" mode for select_duration
  • Loading branch information
eldy committed Mar 23, 2017
2 parents 3cc312d + 7999cb9 commit d1c29bf
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -4878,11 +4878,13 @@ function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_nam
* Function to show a form to select a duration on a page
*
* @param string $prefix Prefix for input fields
* @param int $iSecond Default preselected duration (number of seconds or '')
* @param int $disabled Disable the combo box
* @param string $typehour If 'select' then input hour and input min is a combo, if 'text' input hour is in text and input min is a text
* @param integer $minunderhours If 1, show minutes selection under the hours
* @param int $nooutput Do not output html string but return it
* @param int $iSecond Default preselected duration (number of seconds or '')
* @param int $disabled Disable the combo box
* @param string $typehour If 'select' then input hour and input min is a combo,
* if 'text' input hour is in text and input min is a text,
* if 'mixte' input hour is in text and input min is a combo
* @param integer $minunderhours If 1, show minutes selection under the hours
* @param int $nooutput Do not output html string but return it
* @return string|null
*/
function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select', $minunderhours=0, $nooutput=0)
Expand All @@ -4902,7 +4904,7 @@ function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select',
$minSelected = convertSecondToTime($iSecond,'min');
}

if ($typehour=='select')
if ($typehour=='select' )
{
$retstring.='<select class="flat" name="'.$prefix.'hour"'.($disabled?' disabled':'').'>';
for ($hour = 0; $hour < 25; $hour++) // For a duration, we allow 24 hours
Expand All @@ -4916,7 +4918,7 @@ function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select',
}
$retstring.="</select>";
}
elseif ($typehour=='text')
elseif ($typehour=='text' || $typehour=='mixte')
{
$retstring.='<input placeholder="'.$langs->trans('HourShort').'" type="number" min="0" size="1" name="'.$prefix.'hour"'.($disabled?' disabled':'').' class="flat" value="'.($hourSelected?((int) $hourSelected):'').'">';
}
Expand All @@ -4929,7 +4931,7 @@ function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select',
if ($minunderhours) $retstring.='<br>';
else $retstring.="&nbsp;";

if ($typehour=='select')
if ($typehour=='select' || $typehour=='mixte')
{
$retstring.='<select class="flat" name="'.$prefix.'min"'.($disabled?' disabled':'').'>';
for ($min = 0; $min <= 55; $min=$min+5)
Expand All @@ -4940,7 +4942,7 @@ function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select',
}
$retstring.="</select>";
}
elseif ($typehour=='text')
elseif ($typehour=='text' )
{
$retstring.='<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" size="1" name="'.$prefix.'min"'.($disabled?' disabled':'').' class="flat" value="'.($minSelected?((int) $minSelected):'').'">';
}
Expand Down

0 comments on commit d1c29bf

Please sign in to comment.