diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index 346e75dc339..86870e08f6b 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -24,6 +24,7 @@ * \brief Fiche projet * \version $Id$ */ + require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); @@ -139,10 +140,9 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) /* * Create */ - print_titre($langs->trans("NewProject")); + print_fiche_titre($langs->trans("NewProject")); - if ($mesg) print $mesg; - print '
'; + if ($mesg) print $mesg.'
'; print '
'; //if ($_REQUEST["socid"]) print ''; diff --git a/htdocs/projet/tasks/fiche.php b/htdocs/projet/tasks/fiche.php index fff1ae38539..d7d3b384a7f 100644 --- a/htdocs/projet/tasks/fiche.php +++ b/htdocs/projet/tasks/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2007 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -39,11 +39,18 @@ $result = restrictedArea($user, 'projet', $projetid); * Actions */ -if ($_POST["action"] == 'createtask' && $user->rights->projet->creer) +if ($_POST["action"] == 'createtask' && $user->rights->projet->creer && empty($_POST["cancel"])) { $error=0; - if (empty($_POST["cancel"])) + if (empty($_POST['task_parent'])) + { + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("ChildOfTaks")); + $_GET["action"]='create'; + $error++; + } + + if (! $error) { $tmparray=split('_',$_POST['task_parent']); $projectid=$tmparray[0]; @@ -98,6 +105,7 @@ if ($_POST["action"] == 'addtime' && $user->rights->projet->creer) /* * View */ + $form=new Form($db); llxHeader("",$langs->trans("Tasks"),"Tasks"); @@ -116,7 +124,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) $tasksarray=$projet->getTasksArray(); - if ($mesg) print $mesg; + if ($mesg) print '
'.$mesg.'
'; print ''; print ''; @@ -131,6 +139,8 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) print ''; } @@ -167,8 +177,6 @@ else else print ' '; print ''; - $tasksrole=$projet->getTasksRoleForUser($user); - $tasksarray=$projet->getTasksArray(); print ''; @@ -184,7 +192,8 @@ else print ''.$langs->trans("LabelTask").''; print ''.$langs->trans("TimeSpent").''; print "\n"; - PLines($j, 0, $tasksarray, $level, $tasksrole); + $j=0; + PLines($j, 0, $tasksarray, $level, true); print ''; @@ -205,22 +214,29 @@ $db->close(); llxFooter('$Date$ - $Revision$'); -function PLines(&$inc, $parent, $lines, &$level, $tasksrole) + +// TODO Same function PLines than in fiche.php +function PLines(&$inc, $parent, $lines, &$level, $var) { global $user, $bc, $langs; + $lastprojectid=0; + $projectstatic = new Project($db); - $var=true; - for ($i = 0 ; $i < sizeof($lines) ; $i++) { - if ($parent == 0) - $level = 0; + if ($parent == 0) $level = 0; if ($lines[$i]->fk_parent == $parent) { - $var = !$var; + // Break on a new project + if ($parent == 0 && $lines[$i]->projectid != $lastprojectid) + { + $var = !$var; + $lastprojectid=$lines[$i]->projectid; + } + print "\n"; print ""; @@ -246,9 +262,11 @@ function PLines(&$inc, $parent, $lines, &$level, $tasksrole) print ''.$heure." h ".$minutes."\n"; print "\n"; + $inc++; + $level++; - if ($lines[$i]->id) PLines($inc, $lines[$i]->id, $lines, $level, $tasksrole); + if ($lines[$i]->id) PLines($inc, $lines[$i]->id, $lines, $level, $var); $level--; } else @@ -259,10 +277,20 @@ function PLines(&$inc, $parent, $lines, &$level, $tasksrole) } +/** + * Enter description here... + * + * @param unknown_type $inc + * @param unknown_type $parent + * @param unknown_type $lines + * @param unknown_type $level + */ function PLineSelect(&$inc, $parent, $lines, &$level) { global $langs; + $lastprojectid=0; + for ($i = 0 ; $i < sizeof($lines) ; $i++) { if ($parent == 0) $level = 0; @@ -270,6 +298,19 @@ function PLineSelect(&$inc, $parent, $lines, &$level) if ($lines[$i]->fk_parent == $parent) { $var = !$var; + + // Break on a new project + if ($parent == 0 && $lines[$i]->projectid != $lastprojectid) + { + print '\n"; + + $lastprojectid=$lines[$i]->projectid; + $inc++; + } + print '\n"; $inc++; + $level++; if ($lines[$i]->id) PLineSelect($inc, $lines[$i]->id, $lines, $level); $level--; } } } + ?> diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index 753123f29b5..0e2d6830ce9 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2008 Laurent Destailleur +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2006-2009 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,10 +18,10 @@ */ /** - \file htdocs/projet/tasks/index.php - \ingroup project - \brief Fiche tāches d'un projet - \version $Id$ + * \file htdocs/projet/tasks/index.php + * \ingroup project + * \brief Fiche tāches d'un projet + * \version $Id$ */ require("./pre.inc.php"); @@ -77,51 +77,21 @@ $h++; dolibarr_fiche_head($head, 'tasks', $title); -/* Liste des tāches */ +$projet = new Project($db); +$tasksarray=$projet->getTasksArray(); -$sql = "SELECT t.rowid, t.title, t.fk_task_parent, t.duration_effective"; -$sql .= " , p.rowid as prowid, p.title as ptitle"; -$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t"; -$sql .= " , ".MAIN_DB_PREFIX."projet_task_actors as a"; -$sql .= " , ".MAIN_DB_PREFIX."projet as p"; -$sql .= " WHERE p.rowid = t.fk_projet"; -$sql .= " AND a.fk_projet_task = t.rowid"; -if ($mode == 'mine') $sql.= " AND a.fk_user = ".$user->id; -$sql .= " ORDER BY p.rowid, t.fk_task_parent"; - -$resql = $db->query($sql); -if ($resql) -{ - $num = $db->num_rows($resql); - $i = 0; - $tasks = array(); - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $tasks[$i][0] = $obj->title; - $tasks[$i][1] = $obj->fk_task_parent; - $tasks[$i][2] = $obj->rowid; - $tasks[$i][3] = $obj->duration_effective; - $tasks[$i][4] = $obj->ptitle; - $tasks[$i][5] = $obj->prowid; - $i++; - } - $db->free(); -} -else -{ - dolibarr_print_error($db); -} print ''; print ''; print ''; print ''; +print ''; print ''; print "\n"; -$var=true; -PLines($j, 0, $tasks, $level, $var); +$level=0; +$j=0; +PLines($j, 0, $tasksarray, $level, true); print "
'.$langs->trans("Project").''.$langs->trans("Task").' '.$langs->trans("TimeSpent").'
"; print ''; @@ -141,52 +111,65 @@ $db->close(); llxFooter('$Date$ - $Revision$'); - -Function PLines(&$inc, $parent, $lines, &$level, &$var) +// TODO Same function PLines than in fiche.php +function PLines(&$inc, $parent, $lines, &$level, $var) { - global $db; - global $bc, $langs; + global $user, $bc, $langs; + + $lastprojectid=0; - $projectstatic=new Project($db); + $projectstatic = new Project($db); for ($i = 0 ; $i < sizeof($lines) ; $i++) { - if ($parent == 0) - { - $level = 0; - $var = !$var; - } + if ($parent == 0) $level = 0; - if ($lines[$i][1] == $parent) + if ($lines[$i]->fk_parent == $parent) { - print "\n"; - $projectstatic->id=$lines[$i][5]; - $projectstatic->ref=$lines[$i][4]; - print $projectstatic->getNomUrl(1); - print "\n"; - - for ($k = 0 ; $k < $level ; $k++) - { - print "   "; - } - - print ''.$lines[$i][0]."\n"; - - $heure = intval($lines[$i][3]); - $minutes = (($lines[$i][3] - $heure) * 60); - $minutes = substr("00"."$minutes", -2); - - print ''.$heure." h ".$minutes."\n"; - print "\n"; - $inc++; - $level++; - PLines($inc, $lines[$i][2], $lines, $level, $var); - $level--; + // Break on a new project + if ($parent == 0 && $lines[$i]->projectid != $lastprojectid) + { + $var = !$var; + $lastprojectid=$lines[$i]->projectid; + } + + print "\n"; + + print ""; + $projectstatic->id=$lines[$i]->projectid; + $projectstatic->ref=$lines[$i]->projectref; + print $projectstatic->getNomUrl(1); + print ""; + + print "".$lines[$i]->id.""; + + print ""; + for ($k = 0 ; $k < $level ; $k++) + { + print "   "; + } + + print ''.$lines[$i]->title."\n"; + + $heure = intval($lines[$i]->duration); + $minutes = round((($lines[$i]->duration - $heure) * 60),0); + $minutes = substr("00"."$minutes", -2); + + print ''.$heure." h ".$minutes."\n"; + + print "\n"; + + $inc++; + + $level++; + if ($lines[$i]->id) PLines($inc, $lines[$i]->id, $lines, $level, $var); + $level--; } else { - //$level--; + //$level--; } } } + ?>