Fix: Miscellaneous bugs on tasks management

Conflicts:
	htdocs/core/lib/project.lib.php
This commit is contained in:
Laurent Destailleur 2014-03-11 20:53:47 +01:00
parent 8d081525ae
commit 241ae7a4d1
4 changed files with 30 additions and 28 deletions

View File

@ -481,6 +481,8 @@ class FormOther
{ {
$var = !$var; $var = !$var;
//var_dump($selectedtask."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id);
// Break on a new project // Break on a new project
if ($parent == 0) if ($parent == 0)
{ {
@ -508,10 +510,10 @@ class FormOther
} }
// Print task // Print task
if ($lines[$i]->id > 0) if ($lines[$i]->id >= 0)
{ {
print '<option value="'.$lines[$i]->fk_project.'_'.$lines[$i]->id.'"'; print '<option value="'.$lines[$i]->fk_project.'_'.$lines[$i]->id.'"';
if ($lines[$i]->id == $selectedtask) print ' selected="selected"'; if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_'.$lines[$i]->id == $selectedtask)) print ' selected="selected"';
print '>'; print '>';
print $langs->trans("Project").' '.$lines[$i]->projectref; print $langs->trans("Project").' '.$lines[$i]->projectref;
if (empty($lines[$i]->public)) if (empty($lines[$i]->public))

View File

@ -285,7 +285,6 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n"; print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n";
// Project
if ($showproject) if ($showproject)
{ {
print "<td>"; print "<td>";
@ -383,7 +382,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
if (! $showlineingray) $inc++; if (! $showlineingray) $inc++;
$level++; $level++;
if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, 0, $showalsopublicproj); if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
$level--; $level--;
$total += $lines[$i]->duration; $total += $lines[$i]->duration;
} }
@ -394,7 +393,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
} }
} }
if ($total>0) if ($total>0 && $level==0)
{ {
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td class="liste_total">'.$langs->trans("Total").'</td>'; print '<td class="liste_total">'.$langs->trans("Total").'</td>';
@ -404,9 +403,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
print '<td></td>'; print '<td></td>';
print '<td></td>'; print '<td></td>';
print '<td></td>'; print '<td></td>';
if ($addordertick) print '<td class="hideonsmartphone"></td>';
print '<td align="right" class="nowrap liste_total">'.convertSecondToTime($total, 'allhourmin').'</td>'; print '<td align="right" class="nowrap liste_total">'.convertSecondToTime($total, 'allhourmin').'</td>';
print '<td></td>'; print '<td></td>';
if ($addordertick) print '<td class="hideonsmartphone"></td>';
print '</tr>'; print '</tr>';
} }

View File

@ -47,17 +47,15 @@ $object = new Project($db);
$taskstatic = new Task($db); $taskstatic = new Task($db);
$extrafields_project = new ExtraFields($db); $extrafields_project = new ExtraFields($db);
$extrafields_task = new ExtraFields($db); $extrafields_task = new ExtraFields($db);
if ($ref) if ($id > 0 || $ref)
{ {
$object->fetch(0,$ref); $object->fetch($id,$ref);
$id=$object->id; $id=$object->id;
} $ref=$object->ref;
// fetch optionals attributes and labels // fetch optionals attributes and labels
if (!empty($id)) {
$extralabels_projet=$extrafields_project->fetch_name_optionals_label($object->table_element); $extralabels_projet=$extrafields_project->fetch_name_optionals_label($object->table_element);
$extralabels_task=$extrafields_task->fetch_name_optionals_label($taskstatic->table_element); $extralabels_task=$extrafields_task->fetch_name_optionals_label($taskstatic->table_element);
} }
// Security check // Security check
@ -295,7 +293,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie
// List of projects // List of projects
print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfTask").'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfTask").'</td><td>';
print $formother->selectProjectTasks('',$projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1); print $formother->selectProjectTasks(GETPOST('task_parent'),$projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>'; print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
@ -351,11 +349,11 @@ else
{ {
/* /*
* Fiche projet en mode visu * Fiche projet en mode visu
*/ */
/* /*
* Actions * Actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($user->rights->projet->all->creer || $user->rights->projet->creer) if ($user->rights->projet->all->creer || $user->rights->projet->creer)
@ -424,12 +422,12 @@ else
if (count($tasksarray) > 0) if (count($tasksarray) > 0)
{ {
// Show all lines in taskarray (recursive function to go down on tree) // Show all lines in taskarray (recursive function to go down on tree)
$j=0; $j=0; $level=0;
$nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $id, 1); $nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $id, 1);
} }
else else
{ {
print '<tr><td colspan="'.(! empty($object->id) ? "5" : "4").'">'.$langs->trans("NoTasks").'</td></tr>'; print '<tr><td colspan="9">'.$langs->trans("NoTasks").'</td></tr>';
} }
print "</table>"; print "</table>";

View File

@ -60,12 +60,12 @@ if ($action == 'addtimespent' && $user->rights->projet->creer)
$timespent_durationmin = GETPOST('timespent_durationmin','int'); $timespent_durationmin = GETPOST('timespent_durationmin','int');
if (empty($timespent_durationhour) && empty($timespent_durationmin)) if (empty($timespent_durationhour) && empty($timespent_durationmin))
{ {
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")).'</div>'; setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")),'errors');
$error++; $error++;
} }
if (empty($_POST["userid"])) if (empty($_POST["userid"]))
{ {
$mesg='<div class="error">'.$langs->trans('ErrorUserNotAffectedToTask').'</div>'; setEventMessage($langs->trans('ErrorUserNotAffectedToTask'),'errors');
$error++; $error++;
} }
@ -82,11 +82,12 @@ if ($action == 'addtimespent' && $user->rights->projet->creer)
$result=$object->addTimeSpent($user); $result=$object->addTimeSpent($user);
if ($result >= 0) if ($result >= 0)
{ {
setEventMessage($langs->trans("RecordSaved"));
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans($object->error).'</div>'; setEventMessage($langs->trans($object->error),'errors');
$error++;
} }
} }
else else
@ -101,7 +102,7 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->cree
if (empty($_POST["new_durationhour"]) && empty($_POST["new_durationmin"])) if (empty($_POST["new_durationhour"]) && empty($_POST["new_durationmin"]))
{ {
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")).'</div>'; setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")),'errors');
$error++; $error++;
} }
@ -120,11 +121,12 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->cree
$result=$object->updateTimeSpent($user); $result=$object->updateTimeSpent($user);
if ($result >= 0) if ($result >= 0)
{ {
setEventMessage($langs->trans("RecordSaved"));
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans($object->error).'</div>'; setEventMessage($langs->trans($object->error),'errors');
$error++;
} }
} }
else else
@ -141,7 +143,8 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->c
if (!$result) if (!$result)
{ {
$langs->load("errors"); $langs->load("errors");
$mesg='<div class="error">'.$langs->trans($object->error).'</div>'; setEventMessage($langs->trans($object->error),'errors');
$error++;
$action=''; $action='';
} }
} }