From 0b52c43e05de3e366198779c775f920b36335763 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Thu, 18 May 2017 11:35:12 +0200 Subject: [PATCH] Fix bad selection of progress when not known --- htdocs/core/class/html.formother.class.php | 6 ++++-- htdocs/projet/class/task.class.php | 6 +++--- htdocs/projet/tasks.php | 4 ++-- htdocs/projet/tasks/task.php | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 66e624e96b9..2ee6b18a44f 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -274,15 +274,17 @@ class FormOther * @param int $increment increment value * @param int $start start value * @param int $end end value + * @param int $showempty Add also an empty line * @return string HTML select string */ - function select_percent($selected=0,$htmlname='percent',$disabled=0,$increment=5,$start=0,$end=100) + function select_percent($selected=0,$htmlname='percent',$disabled=0,$increment=5,$start=0,$end=100,$showempty=0) { $return = '<select class="flat" name="'.$htmlname.'" '.($disabled?'disabled':'').'>'; + if ($showempty) $return.='<option value="-1"'.(($selected == -1 || $selected == '')?' selected':'').'> </option>'; for ($i = $start ; $i <= $end ; $i += $increment) { - if ($selected == $i) + if ($selected != '' && (int) $selected == $i) { $return.= '<option value="'.$i.'" selected>'; } diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 9a1819fc46c..dad46c96989 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -100,7 +100,7 @@ class Task extends CommonObject // Clean parameters $this->label = trim($this->label); $this->description = trim($this->description); - + // Check parameters // Put here code to add control on parameters values @@ -128,7 +128,7 @@ class Task extends CommonObject $sql.= ", ".($this->date_start!=''?"'".$this->db->idate($this->date_start)."'":'null'); $sql.= ", ".($this->date_end!=''?"'".$this->db->idate($this->date_end)."'":'null'); $sql.= ", ".($this->planned_workload!=''?$this->planned_workload:0); - $sql.= ", ".($this->progress!=''?$this->progress:0); + $sql.= ", ".(($this->progress!='' && $this->progress >= 0)?$this->progress:'null'); $sql.= ")"; $this->db->begin(); @@ -300,7 +300,7 @@ class Task extends CommonObject $sql.= " planned_workload=".((isset($this->planned_workload) && $this->planned_workload != '')?$this->planned_workload:"null").","; $sql.= " dateo=".($this->date_start!=''?"'".$this->db->idate($this->date_start)."'":'null').","; $sql.= " datee=".($this->date_end!=''?"'".$this->db->idate($this->date_end)."'":'null').","; - $sql.= " progress=".$this->progress.","; + $sql.= " progress=".(($this->progress!='' && $this->progress >= 0)?$this->progress:'null').","; $sql.= " rang=".((!empty($this->rang))?$this->rang:"0"); $sql.= " WHERE rowid=".$this->id; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 35a7812d4fa..06bd2c9c730 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -391,14 +391,14 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print $form->select_date(($date_end?$date_end:-1),'datee',1,1,0,'',1,1,1); print '</td></tr>'; - // planned workload + // Planned workload print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>'; print $form->select_duration('planned_workload', $planned_workload?$planned_workload : $object->planned_workload,0,'text'); print '</td></tr>'; // Progress print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">'; - print $formother->select_percent($progress,'progress'); + print $formother->select_percent($progress,'progress',0,5,0,100,1); print '</td></tr>'; // Description diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index f0a55517881..603a69a07b0 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -391,12 +391,12 @@ if ($id > 0 || ! empty($ref)) // Planned workload print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>'; - print $form->select_duration('planned_workload',$object->planned_workload,0,'text'); + print $form->select_duration('planned_workload', $object->planned_workload, 0, 'text'); print '</td></tr>'; // Progress declared - print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">'; - print $formother->select_percent($object->progress,'progress'); + print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td>'; + print $formother->select_percent($object->progress,'progress',0,5,0,100,1); print '</td></tr>'; // Description -- GitLab