Fix: Add hidden option so we can restore old behaviour (duration is

free) for people that can't work with new one.
This commit is contained in:
Laurent Destailleur 2014-06-21 16:06:59 +02:00
parent 5c0813e865
commit dce0c38533
2 changed files with 20 additions and 17 deletions

View File

@ -3733,13 +3733,14 @@ class Form
/** /**
* Function to show a form to select a duration on a page * Function to show a form to select a duration on a page
* *
* @param string $prefix prefix * @param string $prefix Prefix
* @param int $iSecond Default preselected duration (number of seconds) * @param int $iSecond Default preselected duration (number of seconds)
* @param int $disabled Disable the combo box * @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 combo * @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 combo
* @param string $minunderhours If 1, show minutes selection under the hours
* @return void * @return void
*/ */
function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select') function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select', $minunderhours=0)
{ {
global $langs; global $langs;
@ -3770,7 +3771,11 @@ class Form
{ {
print '<input type="text" size="3" name="'.$prefix.'hour" class="flat" value="'.((int) $hourSelected).'">'; print '<input type="text" size="3" name="'.$prefix.'hour" class="flat" value="'.((int) $hourSelected).'">';
} }
print $langs->trans('Hours'). "&nbsp;"; print $langs->trans('Hours');
if ($minunderhours) print '<br>';
else print "&nbsp;";
print '<select class="flat" name="'.$prefix.'min"'.($disabled?' disabled="disabled"':'').'>'; print '<select class="flat" name="'.$prefix.'min"'.($disabled?' disabled="disabled"':'').'>';
for ($min = 0; $min <= 55; $min=$min+5) for ($min = 0; $min <= 55; $min=$min+5)
{ {

View File

@ -1332,9 +1332,7 @@ else if ($id > 0 || ! empty($ref))
print '<input type="hidden" name="action" value="addline">'; print '<input type="hidden" name="action" value="addline">';
} }
/* // Intervention lines
* Lignes d'intervention
*/
$sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,'; $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,';
$sql.= ' ft.date as date_intervention'; $sql.= ' ft.date as date_intervention';
$sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft';
@ -1419,7 +1417,7 @@ else if ($id > 0 || ! empty($ref))
print '</tr>'; print '</tr>';
} }
// Ligne en mode update // Line in update mode
if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id','int') == $objp->rowid) if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id','int') == $objp->rowid)
{ {
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
@ -1452,9 +1450,7 @@ else if ($id > 0 || ! empty($ref))
$db->free($resql); $db->free($resql);
/* // Add new line
* Add line
*/
if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline') if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline')
{ {
if (! $num) print '<br><table class="noborder" width="100%">'; if (! $num) print '<br><table class="noborder" width="100%">';
@ -1490,7 +1486,9 @@ else if ($id > 0 || ! empty($ref))
// Duration // Duration
print '<td align="right">'; print '<td align="right">';
$form->select_duration('duration',(!GETPOST('durationhour','int') && !GETPOST('durationmin','int'))?3600:(60*60*GETPOST('durationhour','int')+60*GETPOST('durationmin','int'))); $selectmode='select';
if (! empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION)) $selectmode='text';
$form->select_duration('duration', (!GETPOST('durationhour','int') && !GETPOST('durationmin','int'))?3600:(60*60*GETPOST('durationhour','int')+60*GETPOST('durationmin','int')), 0, $selectmode, 1);
print '</td>'; print '</td>';
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addline"></td>'; print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addline"></td>';
@ -1513,7 +1511,7 @@ else if ($id > 0 || ! empty($ref))
/* /*
* Barre d'actions * Actions buttons
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';