diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 2de5834f996e86376fda1e3248306d90aa37f835..e0cc325e3bcaa18f3d89cae30e6acddb4ef120ac 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -464,6 +464,16 @@ if (GETPOST('action') == 'create') jQuery("#fullday").change(function() { setdatefields(); }); + jQuery("#selectcomplete").change(function() { + if (jQuery("#selectcomplete").val() == 100) + { + if (jQuery("#doneby").val() <= 0) jQuery("#doneby").val(\''.$user->id.'\'); + } + if (jQuery("#selectcomplete").val() == 0) + { + jQuery("#doneby").val(-1); + } + }); })'; print '</script>'."\n"; } @@ -521,8 +531,8 @@ if (GETPOST('action') == 'create') // Status print '<tr><td width="10%">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td>'; print '<td>'; - $percent=0; - if (GETPOST('percentage')) + $percent=-1; + if (isset($_GET['percentage']) || isset($_POST['percentage'])) { $percent=GETPOST('percentage'); } @@ -531,7 +541,7 @@ if (GETPOST('action') == 'create') if (GETPOST("afaire") == 1) $percent=0; if (GETPOST("afaire") == 2) $percent=100; } - print $htmlactions->form_select_status_action('formaction',$percent,1); + print $htmlactions->form_select_status_action('formaction',$percent,1,'complete'); print '</td></tr>'; // Location @@ -550,7 +560,7 @@ if (GETPOST('action') == 'create') // Realised by print '<tr><td nowrap>'.$langs->trans("ActionDoneBy").'</td><td>'; - $html->select_users(GETPOST("doneby")?GETPOST("doneby"):$actioncomm->userdone,'doneby',1); + $html->select_users(GETPOST("doneby")?GETPOST("doneby"):($percent==100?$actioncomm->userdone:0),'doneby',1); print '</td></tr>'; print '</table>'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 388d3602d7c8ab7ba54b3fd607f0cb415ca93247..e5b2e71cb613916561c2766b76373982051088da 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -779,14 +779,14 @@ class Form } /** - * \brief Return select list of users - * \param selected Id user preselected - * \param htmlname Field name in form - * \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue - * \param exclude Array list of users id to exclude - * \param disabled If select list must be disabled - * \param include Array list of users id to include - * \param enableonly Array list of users id to be enabled. All other must be disabled + * Return select list of users + * @param selected Id user preselected + * @param htmlname Field name in form + * @param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue + * @param exclude Array list of users id to exclude + * @param disabled If select list must be disabled + * @param include Array list of users id to include + * @param enableonly Array list of users id to be enabled. All other must be disabled */ function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='') { @@ -794,21 +794,21 @@ class Form } /** - * \brief Return select list of users - * \param selected User id or user object of user preselected. If -1, we use id of current user. - * \param htmlname Field name in form - * \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue - * \param exclude Array list of users id to exclude - * \param disabled If select list must be disabled - * \param include Array list of users id to include - * \param enableonly Array list of users id to be enabled. All other must be disabled + * Return select list of users + * @param selected User id or user object of user preselected. If -1, we use id of current user. + * @param htmlname Field name in form + * @param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue + * @param exclude Array list of users id to exclude + * @param disabled If select list must be disabled + * @param include Array list of users id to include + * @param enableonly Array list of users id to be enabled. All other must be disabled */ function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='') { global $conf,$user,$langs; // If no preselected user defined, we take current user - if (empty($selected) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id; + if ($selected < -1 && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id; // Permettre l'exclusion d'utilisateurs if (is_array($exclude)) $excludeUsers = implode("','",$exclude); @@ -829,7 +829,7 @@ class Form $resql=$this->db->query($sql); if ($resql) { - $out.= '<select class="flat" name="'.$htmlname.'"'.($disabled?' disabled="true"':'').'>'; + $out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled="true"':'').'>'; if ($show_empty) $out.= '<option value="-1"'.($id==-1?' selected="selected"':'').'> </option>'."\n"; $num = $this->db->num_rows($resql); $i = 0; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index b3b1cc8ec477d280c93854a7b90020cb395a411e..92afbe8f1106fc4acb2542d7a09a087ba48aee6c 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -47,42 +47,47 @@ class FormActions /** - * \brief Show list of action status - * \param formname Name of form where select in included - * \param selected Preselected value - * \param canedit 1=can edit, 0=read only + * Show list of action status + * @param formname Name of form where select in included + * @param selected Preselected value + * @param canedit 1=can edit, 0=read only + * @param htmlname Name of html prefix for html fields (selectX and valX) */ - function form_select_status_action($formname,$selected,$canedit=1) + function form_select_status_action($formname,$selected,$canedit=1,$htmlname='complete') { global $langs,$conf; - $listofstatus=array('0'=>$langs->trans("ActionRunningNotStarted"),'50'=>$langs->trans("ActionRunningShort"),'100'=>$langs->trans("ActionDoneShort")); + $listofstatus=array('-1'=>$langs->trans("ActionNotApplicable"), + '0'=>$langs->trans("ActionRunningNotStarted"), + '50'=>$langs->trans("ActionRunningShort"), + '100'=>$langs->trans("ActionDoneShort")); if ($conf->use_javascript_ajax) { print "\n"; print '<script type="text/javascript">'."\n"; print 'function select_status(mypercentage) {'."\n"; - print 'document.'.$formname.'.percentageshown.value=mypercentage;'."\n"; + print 'document.'.$formname.'.percentageshown.value=(mypercentage>=0?mypercentage:\'\');'."\n"; print 'document.'.$formname.'.percentage.value=mypercentage;'."\n"; - print 'if (mypercentage == 0) { document.'.$formname.'.percentageshown.disabled=true; }'."\n"; + print 'if (mypercentage == -1) { document.'.$formname.'.percentageshown.disabled=true; }'."\n"; + print 'else if (mypercentage == 0) { document.'.$formname.'.percentageshown.disabled=true; }'."\n"; print 'else if (mypercentage == 100) { document.'.$formname.'.percentageshown.disabled=true; }'."\n"; print 'else { document.'.$formname.'.percentageshown.disabled=false; }'."\n"; print '}'."\n"; print '</script>'."\n"; - print '<select '.($canedit?'':'disabled="true" ').'name="status" class="flat" onChange="select_status(document.'.$formname.'.status.value)">'; + print '<select '.($canedit?'':'disabled="true" ').'name="status" id="select'.$htmlname.'" class="flat" onChange="select_status(document.'.$formname.'.status.value)">'; foreach($listofstatus as $key => $val) { print '<option value="'.$key.'"'.($selected == $key?' selected="selected"':'').'>'.$val.'</option>'; } print '</select>'; if ($selected == 0 || $selected == 100) $canedit=0; - print ' <input type="text" name="percentageshown" class="flat" value="'.$selected.'" size="2"'.($canedit?'':' disabled="true"').' onChange="select_status(document.'.$formname.'.percentageshown.value)">%'; + print ' <input type="text" id="val'.$htmlname.'" name="percentageshown" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled="true"').' onChange="select_status(document.'.$formname.'.percentageshown.value)">%'; print ' <input type="hidden" name="percentage" value="'.$selected.'">'; } else { - print ' <input type="text" name="percentage" class="flat" value="'.$selected.'" size="2"'.($canedit?'':' disabled="true"').'>%'; + print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled="true"').'>%'; } } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 9ed9f71fc6f6ad899545c6ba4fce3d5a501351ad..75eb32b7535ec04d409c831b70946125e3a533c3 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -312,7 +312,8 @@ ActionsDone=Actions done ActionsToDoShort=To do ActionsRunningshort=Started ActionsDoneShort=Done -ActionRunningNotStarted=Not started +ActionNotApplicable=Not applicable +ActionRunningNotStarted=To start ActionRunningShort=Started ActionDoneShort=Finished CompanyFoundation=Company/Foundation diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 457ea750c00835609fc1e4df33723e5c5b63d193..3e6f0e30e0cb673ba83143202932edb47c09b11a 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -311,7 +311,8 @@ ActionsToDo=Événements à faire ActionsDone=Événements effectués ActionsToDoShort=À faire ActionsDoneShort=Effectuées -ActionRunningNotStarted=Non commencé +ActionNotApplicable=Non applicable +ActionRunningNotStarted=A commencé ActionRunningShort=En cours ActionDoneShort=Terminé CompanyFoundation=Société ou institution