Skip to content
Snippets Groups Projects
Commit effa56d5 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Debug on projects

parent 738a2238
Branches
Tags
No related merge requests found
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
* \brief Fiche projet * \brief Fiche projet
* \version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
...@@ -139,10 +140,9 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) ...@@ -139,10 +140,9 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
/* /*
* Create * Create
*/ */
print_titre($langs->trans("NewProject")); print_fiche_titre($langs->trans("NewProject"));
if ($mesg) print $mesg; if ($mesg) print $mesg.'<br>';
print '<br>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
//if ($_REQUEST["socid"]) print '<input type="hidden" name="socid" value="'.$_REQUEST["socid"].'">'; //if ($_REQUEST["socid"]) print '<input type="hidden" name="socid" value="'.$_REQUEST["socid"].'">';
......
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -39,11 +39,18 @@ $result = restrictedArea($user, 'projet', $projetid); ...@@ -39,11 +39,18 @@ $result = restrictedArea($user, 'projet', $projetid);
* Actions * Actions
*/ */
if ($_POST["action"] == 'createtask' && $user->rights->projet->creer) if ($_POST["action"] == 'createtask' && $user->rights->projet->creer && empty($_POST["cancel"]))
{ {
$error=0; $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']); $tmparray=split('_',$_POST['task_parent']);
$projectid=$tmparray[0]; $projectid=$tmparray[0];
...@@ -98,6 +105,7 @@ if ($_POST["action"] == 'addtime' && $user->rights->projet->creer) ...@@ -98,6 +105,7 @@ if ($_POST["action"] == 'addtime' && $user->rights->projet->creer)
/* /*
* View * View
*/ */
$form=new Form($db); $form=new Form($db);
llxHeader("",$langs->trans("Tasks"),"Tasks"); llxHeader("",$langs->trans("Tasks"),"Tasks");
...@@ -116,7 +124,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) ...@@ -116,7 +124,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
$tasksarray=$projet->getTasksArray(); $tasksarray=$projet->getTasksArray();
if ($mesg) print $mesg; if ($mesg) print '<div class="error">'.$mesg.'</div>';
print '<form action="fiche.php" method="post">'; print '<form action="fiche.php" method="post">';
print '<input type="hidden" name="action" value="createtask">'; print '<input type="hidden" name="action" value="createtask">';
...@@ -131,6 +139,8 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) ...@@ -131,6 +139,8 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
print '<select class="flat" name="task_parent">'; print '<select class="flat" name="task_parent">';
print '<option value="0" selected="true">&nbsp;</option>'; print '<option value="0" selected="true">&nbsp;</option>';
$j=0;
$level=0;
PLineSelect($j, 0, $tasksarray, $level); PLineSelect($j, 0, $tasksarray, $level);
print '</select>'; print '</select>';
} }
...@@ -167,8 +177,6 @@ else ...@@ -167,8 +177,6 @@ else
else print '&nbsp;'; else print '&nbsp;';
print '</td></tr>'; print '</td></tr>';
$tasksrole=$projet->getTasksRoleForUser($user);
$tasksarray=$projet->getTasksArray(); $tasksarray=$projet->getTasksArray();
print '</table>'; print '</table>';
...@@ -184,7 +192,8 @@ else ...@@ -184,7 +192,8 @@ else
print '<td>'.$langs->trans("LabelTask").'</td>'; print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>'; print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\n"; print "</tr>\n";
PLines($j, 0, $tasksarray, $level, $tasksrole); $j=0;
PLines($j, 0, $tasksarray, $level, true);
print '</form>'; print '</form>';
...@@ -205,22 +214,29 @@ $db->close(); ...@@ -205,22 +214,29 @@ $db->close();
llxFooter('$Date$ - $Revision$'); 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; global $user, $bc, $langs;
$projectstatic = new Project($db); $lastprojectid=0;
$var=true; $projectstatic = new Project($db);
for ($i = 0 ; $i < sizeof($lines) ; $i++) for ($i = 0 ; $i < sizeof($lines) ; $i++)
{ {
if ($parent == 0) if ($parent == 0) $level = 0;
$level = 0;
if ($lines[$i]->fk_parent == $parent) if ($lines[$i]->fk_parent == $parent)
{
// Break on a new project
if ($parent == 0 && $lines[$i]->projectid != $lastprojectid)
{ {
$var = !$var; $var = !$var;
$lastprojectid=$lines[$i]->projectid;
}
print "<tr $bc[$var]>\n"; print "<tr $bc[$var]>\n";
print "<td>"; print "<td>";
...@@ -246,9 +262,11 @@ function PLines(&$inc, $parent, $lines, &$level, $tasksrole) ...@@ -246,9 +262,11 @@ function PLines(&$inc, $parent, $lines, &$level, $tasksrole)
print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n"; print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n";
print "</tr>\n"; print "</tr>\n";
$inc++; $inc++;
$level++; $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--; $level--;
} }
else else
...@@ -259,10 +277,20 @@ function PLines(&$inc, $parent, $lines, &$level, $tasksrole) ...@@ -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) function PLineSelect(&$inc, $parent, $lines, &$level)
{ {
global $langs; global $langs;
$lastprojectid=0;
for ($i = 0 ; $i < sizeof($lines) ; $i++) for ($i = 0 ; $i < sizeof($lines) ; $i++)
{ {
if ($parent == 0) $level = 0; if ($parent == 0) $level = 0;
...@@ -270,6 +298,19 @@ function PLineSelect(&$inc, $parent, $lines, &$level) ...@@ -270,6 +298,19 @@ function PLineSelect(&$inc, $parent, $lines, &$level)
if ($lines[$i]->fk_parent == $parent) if ($lines[$i]->fk_parent == $parent)
{ {
$var = !$var; $var = !$var;
// Break on a new project
if ($parent == 0 && $lines[$i]->projectid != $lastprojectid)
{
print '<option value="'.$lines[$i]->projectid.'_0">';
print $langs->trans("Project").' '.$lines[$i]->projectref;
//print '-'.$parent.'-'.$lines[$i]->projectid.'-'.$lastprojectid;
print "</option>\n";
$lastprojectid=$lines[$i]->projectid;
$inc++;
}
print '<option value="'.$lines[$i]->projectid.'_'.$lines[$i]->id.'">'; print '<option value="'.$lines[$i]->projectid.'_'.$lines[$i]->id.'">';
print $langs->trans("Project").' '.$lines[$i]->projectref; print $langs->trans("Project").' '.$lines[$i]->projectref;
if ($lines[$i]->id) print ' > '; if ($lines[$i]->id) print ' > ';
...@@ -277,14 +318,15 @@ function PLineSelect(&$inc, $parent, $lines, &$level) ...@@ -277,14 +318,15 @@ function PLineSelect(&$inc, $parent, $lines, &$level)
{ {
print "&nbsp;&nbsp;&nbsp;"; print "&nbsp;&nbsp;&nbsp;";
} }
print $lines[$i]->title."</option>\n"; print $lines[$i]->title."</option>\n";
$inc++; $inc++;
$level++; $level++;
if ($lines[$i]->id) PLineSelect($inc, $lines[$i]->id, $lines, $level); if ($lines[$i]->id) PLineSelect($inc, $lines[$i]->id, $lines, $level);
$level--; $level--;
} }
} }
} }
?> ?>
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
*/ */
/** /**
\file htdocs/projet/tasks/index.php * \file htdocs/projet/tasks/index.php
\ingroup project * \ingroup project
\brief Fiche tches d'un projet * \brief Fiche tches d'un projet
\version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
...@@ -77,51 +77,21 @@ $h++; ...@@ -77,51 +77,21 @@ $h++;
dolibarr_fiche_head($head, 'tasks', $title); dolibarr_fiche_head($head, 'tasks', $title);
/* Liste des tches */ $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 '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Project").'</td>'; print '<td>'.$langs->trans("Project").'</td>';
print '<td>'.$langs->trans("Task").'</td>'; print '<td>'.$langs->trans("Task").'</td>';
print '<td>&nbsp;</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>'; print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\n"; print "</tr>\n";
$var=true;
PLines($j, 0, $tasks, $level, $var); $level=0;
$j=0;
PLines($j, 0, $tasksarray, $level, true);
print "</table>"; print "</table>";
print '</div>'; print '</div>';
...@@ -141,46 +111,58 @@ $db->close(); ...@@ -141,46 +111,58 @@ $db->close();
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');
// TODO Same function PLines than in fiche.php
Function PLines(&$inc, $parent, $lines, &$level, &$var) function PLines(&$inc, $parent, $lines, &$level, $var)
{ {
global $db; global $user, $bc, $langs;
global $bc, $langs;
$lastprojectid=0;
$projectstatic = new Project($db); $projectstatic = new Project($db);
for ($i = 0 ; $i < sizeof($lines) ; $i++) for ($i = 0 ; $i < sizeof($lines) ; $i++)
{ {
if ($parent == 0) if ($parent == 0) $level = 0;
if ($lines[$i]->fk_parent == $parent)
{
// Break on a new project
if ($parent == 0 && $lines[$i]->projectid != $lastprojectid)
{ {
$level = 0;
$var = !$var; $var = !$var;
$lastprojectid=$lines[$i]->projectid;
} }
if ($lines[$i][1] == $parent) print "<tr $bc[$var]>\n";
{
print "<tr ".$bc[$var].">\n<td>"; print "<td>";
$projectstatic->id=$lines[$i][5]; $projectstatic->id=$lines[$i]->projectid;
$projectstatic->ref=$lines[$i][4]; $projectstatic->ref=$lines[$i]->projectref;
print $projectstatic->getNomUrl(1); print $projectstatic->getNomUrl(1);
print "</td><td>\n"; print "</td>";
print "<td>".$lines[$i]->id."</td>";
print "<td>";
for ($k = 0 ; $k < $level ; $k++) for ($k = 0 ; $k < $level ; $k++)
{ {
print "&nbsp;&nbsp;&nbsp;"; print "&nbsp;&nbsp;&nbsp;";
} }
print '<a href="task.php?id='.$lines[$i][2].'">'.$lines[$i][0]."</a></td>\n"; print '<a href="task.php?id='.$lines[$i]->id.'">'.$lines[$i]->title."</a></td>\n";
$heure = intval($lines[$i][3]); $heure = intval($lines[$i]->duration);
$minutes = (($lines[$i][3] - $heure) * 60); $minutes = round((($lines[$i]->duration - $heure) * 60),0);
$minutes = substr("00"."$minutes", -2); $minutes = substr("00"."$minutes", -2);
print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n"; print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n";
print "</tr>\n"; print "</tr>\n";
$inc++; $inc++;
$level++; $level++;
PLines($inc, $lines[$i][2], $lines, $level, $var); if ($lines[$i]->id) PLines($inc, $lines[$i]->id, $lines, $level, $var);
$level--; $level--;
} }
else else
...@@ -189,4 +171,5 @@ Function PLines(&$inc, $parent, $lines, &$level, &$var) ...@@ -189,4 +171,5 @@ Function PLines(&$inc, $parent, $lines, &$level, &$var)
} }
} }
} }
?> ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment