From 5dc10cfcae49b9398fa9496cf61005b6c4abd4d5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 20 Aug 2012 10:38:48 +0200 Subject: [PATCH] Fix: possibility to defined another value instead 50% --- htdocs/comm/action/fiche.php | 4 ++-- htdocs/core/class/html.formactions.class.php | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 46d9ecd5242..b41e4b2ae01 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -478,14 +478,14 @@ if ($action == 'create') print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; print ''; $percent=-1; - if (isset($_GET['percentage']) || isset($_POST['percentage'])) + if (GETPOST('percentage')) { $percent=GETPOST('percentage'); } else { if (GETPOST("afaire") == 1) $percent=0; - if (GETPOST("afaire") == 2) $percent=100; + else if (GETPOST("afaire") == 2) $percent=100; } print $htmlactions->form_select_status_action('formaction',$percent,1,'complete'); print ''; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 1e9868e050c..cf63c366792 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -84,18 +84,22 @@ class FormActions }); function select_status() { - var selected = $('#select' + htmlname).val(); + var defaultvalue = $('#select' + htmlname).val(); var percentage = $('input[name=percentage]'); - percentage.val((selected>=0?selected:'')); - if (selected == -1) { + var selected = '".(isset($selected)?$selected:'')."'; + var value = (selected>0?selected:(defaultvalue>=0?defaultvalue:'')); + + percentage.val(value); + + if (defaultvalue == -1) { percentage.attr('disabled', 'disabled'); $('.hideifna').hide(); } - else if (selected == 0) { + else if (defaultvalue == 0) { percentage.attr('disabled', 'disabled'); $('.hideifna').show(); } - else if (selected == 100) { + else if (defaultvalue == 100) { percentage.attr('disabled', 'disabled'); $('.hideifna').show(); } @@ -108,13 +112,12 @@ class FormActions print ''; if ($selected == 0 || $selected == 100) $canedit=0; print ' =0)?'':' disabled="disabled"').'>'; print '%'; - //print ' '; } else {