Fix: Miscellaneous bugs on tasks management

This commit is contained in:
Laurent Destailleur 2014-03-11 20:38:29 +01:00
parent 6860ae84b9
commit afca98323b
4 changed files with 28 additions and 26 deletions

View File

@ -481,6 +481,8 @@ class FormOther
{
$var = !$var;
//var_dump($selectedtask."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id);
// Break on a new project
if ($parent == 0)
{
@ -508,10 +510,10 @@ class FormOther
}
// Print task
if ($lines[$i]->id > 0)
if ($lines[$i]->id >= 0)
{
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 $langs->trans("Project").' '.$lines[$i]->projectref;
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";
// Project
if ($showproject)
{
// Project ref
@ -299,7 +298,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
if ($showlineingray) print '</i>';
print "</td>";
// Status
// Project status
print '<td>';
$projectstatic->statut=$lines[$i]->projectstatus;
print $projectstatic->getLibStatut(2);
@ -389,7 +388,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
if (! $showlineingray) $inc++;
$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--;
$total += $lines[$i]->duration;
}
@ -400,7 +399,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
}
}
if ($total>0)
if ($total>0 && $level==0)
{
print '<tr class="liste_total">';
print '<td class="liste_total">'.$langs->trans("Total").'</td>';
@ -410,9 +409,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
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></td>';
if ($addordertick) print '<td class="hideonsmartphone"></td>';
print '</tr>';
}

View File

@ -47,17 +47,15 @@ $object = new Project($db);
$taskstatic = new Task($db);
$extrafields_project = 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;
}
$ref=$object->ref;
// fetch optionals attributes and labels
if (!empty($id)) {
// fetch optionals attributes and labels
$extralabels_projet=$extrafields_project->fetch_name_optionals_label($object->table_element);
$extralabels_task=$extrafields_task->fetch_name_optionals_label($taskstatic->table_element);
}
// Security check
@ -295,7 +293,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie
// List of projects
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 '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
@ -351,11 +349,11 @@ else
{
/*
* Fiche projet en mode visu
*/
*/
/*
* Actions
*/
*/
print '<div class="tabsAction">';
if ($user->rights->projet->all->creer || $user->rights->projet->creer)
@ -424,12 +422,12 @@ else
if (count($tasksarray) > 0)
{
// 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);
}
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>";

View File

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