New: Some enhancements in project module

This commit is contained in:
Laurent Destailleur 2008-09-10 11:14:45 +00:00
parent 6caef066c4
commit b7c5268a18
6 changed files with 554 additions and 288 deletions

View File

@ -55,8 +55,8 @@ print '<tr><td width="30%" valign="top" class="notopnoleft">';
*/
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Project"),"index.php","s.nom","","","",$sortfield,$sortorder);
print '<td align="center">'.$langs->trans("NbOpenTasks").'</td>';
print_liste_field_titre($langs->trans("Project"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder);
print '<td align="right">'.$langs->trans("NbOpenTasks").'</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, count(t.rowid)";
@ -82,7 +82,7 @@ if ( $resql )
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$row[1].'">'.$row[0].'</a></td>';
print '<td align="center">'.$row[2].'</td>';
print '<td align="right">'.$row[2].'</td>';
print "</tr>\n";
$i++;
@ -124,8 +124,8 @@ $dateendy=dolibarr_mktime(23,59,59,12,31,$info["year"]);
/* Affichage de la liste des projets du mois */
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="50%">Activité sur les projets cette semaine</td>';
print '<td width="50%" align="right">'.$langs->trans("Hours").'</td>';
print '<td >'.$langs->trans("ActivityOnProjectThisWeek").'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration) as total";
@ -169,8 +169,8 @@ print "</table><br />";
/* Affichage de la liste des projets du mois */
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="50%">'.$langs->trans("Project").' ce mois : '.strftime("%B %Y", $now).'</td>';
print '<td width="50%" align="right">'.$langs->trans("Hours").'</td>';
print '<td>'.$langs->trans("ActivityOnProjectThisMonth").': '.strftime("%B %Y", $now).'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration) as total";
@ -214,8 +214,8 @@ print "</table>";
/* Affichage de la liste des projets du mois */
print '<br /><table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="50%">'.$langs->trans("Project").' cette année : '.strftime("%Y", $now).'</td>';
print '<td width="50%" align="right">'.$langs->trans("Hours").'</td>';
print '<td>'.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration) as total";
@ -259,5 +259,6 @@ print "</table>";
print '</td></tr></table>';
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -54,8 +54,8 @@ print '<tr><td width="30%" valign="top" class="notopnoleft">';
*/
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Project"),"index.php","s.nom","","","",$sortfield,$sortorder);
print '<td align="center">'.$langs->trans("NbOpenTasks").'</td>';
print_liste_field_titre($langs->trans("Project"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder);
print '<td align="right">'.$langs->trans("NbOpenTasks").'</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, count(t.rowid)";
@ -85,7 +85,7 @@ if ( $resql )
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$row[1].'">'.$row[0].'</a></td>';
print '<td align="center">'.$row[2].'</td>';
print '<td align="right">'.$row[2].'</td>';
print "</tr>\n";
$i++;
@ -103,7 +103,7 @@ print "</table>";
print '<br /><table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="50%">'.$langs->trans('Today').'</td>';
print '<td width="50%" align="center">Temps</td>';
print '<td width="50%" align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
@ -126,7 +126,7 @@ if ( $resql )
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$row[1].'">'.$row[0].'</a></td>';
print '<td align="center">'.$row[2].'</td>';
print '<td align="right">'.$row[2].'</td>';
print "</tr>\n";
$total += $row[2];
}
@ -139,7 +139,7 @@ else
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="center">'.$total.'</td>';
print '<td align="right">'.$total.'</td>';
print "</tr>\n";
print "</table>";
@ -147,7 +147,7 @@ print "</table>";
print '<br /><table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="50%">'.$langs->trans('Yesterday').'</td>';
print '<td width="50%" align="center">Temps</td>';
print '<td width="50%" align="center">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
@ -170,7 +170,7 @@ if ( $resql )
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$row[1].'">'.$row[0].'</a></td>';
print '<td align="center">'.$row[2].'</td>';
print '<td align="right">'.$row[2].'</td>';
print "</tr>\n";
$total += $row[2];
}
@ -183,7 +183,7 @@ else
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="center">'.$total.'</td>';
print '<td align="right">'.$total.'</td>';
print "</tr>\n";
print "</table>";
@ -192,8 +192,8 @@ print '</td><td width="70%" valign="top" class="notopnoleft">';
/* Affichage de la liste des projets de la semaine */
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="50%">Activité sur les projets cette semaine</td>';
print '<td width="50%" align="center">Temps</td>';
print '<td>'.$langs->trans("ActivityOnProjectThisWeek").'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
@ -215,7 +215,7 @@ if ( $resql )
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$row[1].'">'.$row[0].'</a></td>';
print '<td align="center">'.$row[2].'</td>';
print '<td align="right">'.$row[2].'</td>';
print "</tr>\n";
$total += $row[2];
}
@ -228,15 +228,15 @@ else
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="center">'.$total.'</td>';
print '<td align="right">'.$total.'</td>';
print "</tr>\n";
print "</table><br />";
/* Affichage de la liste des projets du mois */
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="50%">'.$langs->trans("Project").' ce mois : '.strftime("%B %Y", $now).'</td>';
print '<td width="50%" align="center">Nb heures</td>';
print '<td>'.$langs->trans("ActivityOnProjectThisMonth").': '.strftime("%B %Y", $now).'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
@ -249,7 +249,7 @@ $sql .= " AND tt.fk_user = ".$user->id;
$sql .= " AND month(task_date) = ".strftime("%m",$now);
$sql .= " GROUP BY p.rowid";
$var=true;
$var=false;
$resql = $db->query($sql);
if ( $resql )
{
@ -257,7 +257,7 @@ if ( $resql )
{
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$row[1].'">'.$row[0].'</a></td>';
print '<td align="center">'.$row[2].'</td>';
print '<td align="right">'.$row[2].'</td>';
print "</tr>\n";
$var=!$var;
}
@ -272,8 +272,8 @@ print "</table>";
/* Affichage de la liste des projets de l'année */
print '<br /><table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="50%">'.$langs->trans("Project").' cette année : '.strftime("%Y", $now).'</td>';
print '<td width="50%" align="center">Nb heures</td>';
print '<td>'.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
@ -286,7 +286,7 @@ $sql .= " AND tt.fk_user = ".$user->id;
$sql .= " AND YEAR(task_date) = ".strftime("%Y",$now);
$sql .= " GROUP BY p.rowid";
$var=true;
$var=false;
$resql = $db->query($sql);
if ( $resql )
{
@ -294,7 +294,7 @@ if ( $resql )
{
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$row[1].'">'.$row[0].'</a></td>';
print '<td align="center">'.$row[2].'</td>';
print '<td align="right">'.$row[2].'</td>';
print "</tr>\n";
$var=!$var;
}
@ -310,5 +310,5 @@ print '</td></tr></table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
llxFooter('$Date$ - $Revision$');
?>

View File

@ -1,8 +1,7 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr>
*
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
@ -16,148 +15,126 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
\file htdocs/projet/tasks/index.php
\ingroup projet
\brief Page des taches du module projet
\version $Revision$
\file htdocs/projet/tasks/mytasks.php
\ingroup projet
\brief Fiche tâches d'un projet
\version $Id$
*/
require("./pre.inc.php");
if (!$user->rights->projet->lire) accessforbidden();
// Sécurité accés client
if ($user->societe_id > 0)
$langs->load('projects');
Function PLines(&$inc, $parent, $lines, &$level, &$var)
{
$action = '';
$socid = $user->societe_id;
$form = new Form($db); // $db est null ici mais inutile pour la fonction select_date()
global $bc, $langs;
for ($i = 0 ; $i < sizeof($lines) ; $i++)
{
if ($parent == 0)
{
$level = 0;
$var = !$var;
}
if ($lines[$i][1] == $parent)
{
print "<tr $bc[$var]>\n<td>";
print '<a href="fiche.php?id='.$lines[$i][5].'">'.$lines[$i][4]."</a></td><td>\n";
for ($k = 0 ; $k < $level ; $k++)
{
print "&nbsp;&nbsp;&nbsp;";
}
print '<a href="task.php?id='.$lines[$i][2].'">'.$lines[$i][0]."</a></td>\n";
$heure = intval($lines[$i][3]);
$minutes = (($lines[$i][3] - $heure) * 60);
$minutes = substr("00"."$minutes", -2);
print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n";
print "</tr>\n";
$inc++;
$level++;
PLines($inc, $lines[$i][2], $lines, $level, $var);
$level--;
}
else
{
//$level--;
}
}
}
llxHeader("",$langs->trans("Projects"),"Projet");
print_fiche_titre($langs->trans("ProjectsArea"));
print '<table border="0" width="100%" class="notopnoleftnoright">';
print '<tr><td width="30%" valign="top" class="notopnoleft">';
llxHeader("",$langs->trans("Mytasks"),"Projet");
/*
* Fiche projet en mode visu
*
* Affichage de la liste des projets
*
*/
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Project"),"index.php","s.nom","","","",$sortfield,$sortorder);
print '<td align="center">'.$langs->trans("NbOpenTasks").'</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, count(t.rowid)";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= " , ".MAIN_DB_PREFIX."projet_task as t";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE t.fk_projet = p.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/index.php';
$head[$h][1] = $langs->trans("Tasks");
$h++;
if ($socid)
{
$sql .= " AND s.rowid = ".$socid;
}
$sql .= " GROUP BY p.rowid";
dolibarr_fiche_head($head, $hselected, $langs->trans("Tasks"));
/* Liste des tâches */
$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";
$sql .= " ORDER BY p.rowid, t.fk_task_parent";
$var=true;
$resql = $db->query($sql);
if ( $resql )
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$tasks = array();
while ($i < $num)
{
$row = $db->fetch_row( $resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$row[1].'">'.$row[0].'</a></td>';
print '<td align="center">'.$row[2].'</td>';
print "</tr>\n";
$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($resql);
$db->free();
}
else
{
dolibarr_print_error($db);
}
print "</table>";
print '</td><td width="70%" valign="top" class="notopnoleft">';
/*
*
* Affichage de la liste des projets
*
*/
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","","","",$sortfield,$sortorder);
print '<td>Nb heures</td>';
print "</tr>\n";
$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= " , ".MAIN_DB_PREFIX."projet_task as t";
$sql .= " , ".MAIN_DB_PREFIX."projet_task_time as tt";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE t.fk_projet = p.rowid";
$sql .= " AND tt.fk_task = t.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
$sql .= " AND s.rowid = ".$socid;
}
$sql .= " GROUP BY p.rowid";
print '<td>'.$langs->trans("Project").'</td>';
print '<td>'.$langs->trans("Task").'</td>';
print '<td align="right">'.$langs->trans("DurationEffective").'</td>';
print "</tr>\n";
$var=true;
$resql = $db->query($sql);
if ( $resql )
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row( $resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$row[1].'">'.$row[0].'</a></td>';
print '<td>'.$row[2].'</td>';
print "</tr>\n";
$i++;
}
$db->free($resql);
}
else
{
dolibarr_print_error($db);
}
print "</table>";
PLines($j, 0, $tasks, $level, $var);
print '</td></tr></table>';
print "</table>";
print '</div>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
llxFooter('$Date$ - $Revision$');
?>

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -14,16 +15,13 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
\file htdocs/projet/tasks/mytasks.php
\ingroup projet
\brief Fiche tâches d'un projet
\version $Revision$
\version $Id$
*/
require("./pre.inc.php");

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
@ -18,11 +18,11 @@
*/
/**
\file htdocs/projet/tasks/task.php
\ingroup projet
\brief Fiche tâches d'un projet
\version $Id$
*/
\file htdocs/projet/tasks/task.php
\ingroup projet
\brief Fiche tâches d'un projet
\version $Id$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
@ -37,90 +37,92 @@ llxHeader("",$langs->trans("Task"));
if ($_GET["id"] > 0)
{
/*
* Fiche projet en mode visu
*
*/
$task = new Task($db);
if ($task->fetch($_GET["id"]) == 0 )
{
$projet = new Project($db);
$projet->fetch($task->projet_id);
$projet->societe->fetch($projet->societe->id);
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$task->id;
$head[$h][1] = $langs->trans("Tasks");
$head[$h][2] = 'tasks';
$h++;
dolibarr_fiche_head($head, 'tasks', $langs->trans("Tasks"));
print '<form method="POST" action="fiche.php?id='.$projet->id.'">';
print '<input type="hidden" name="action" value="createtask">';
print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
print '<td>'.$langs->trans("Company").'</td><td>'.$projet->societe->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("Task").'</td><td colspan="3">'.$task->title.'</td></tr>';
/* Liste des tâches */
$sql = "SELECT t.task_date, t.task_duration, t.fk_user, u.login";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
$sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE t.fk_task =".$task->id;
$sql .= " AND t.fk_user = u.rowid";
$sql .= " ORDER BY t.task_date DESC";
$var=true;
$resql = $db->query($sql);
if ($resql)
/*
* Fiche projet en mode visu
*
*/
$task = new Task($db);
if ($task->fetch($_GET["id"]) >= 0 )
{
$num = $db->num_rows($resql);
$i = 0;
$tasks = array();
while ($i < $num)
{
$row = $db->fetch_row($resql);
$tasks[$i] = $row;
$i++;
}
$db->free();
}
else
{
dolibarr_print_error($db);
}
/* Nouvelle tâche */
print '</table></form><br />';
$projet = new Project($db);
$result=$projet->fetch($task->fk_projet);
if (! empty($projet->socid))
{
$projet->societe->fetch($projet->socid);
}
print '<input type="hidden" name="action" value="addtime">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("DurationEffective").'</td>';
print '<td colspan="2">'.$langs->trans("User").'</td>';
print "</tr>\n";
foreach ($tasks as $task_time)
{
$var=!$var;
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$task->id;
$head[$h][1] = $langs->trans("Tasks");
$head[$h][2] = 'tasks';
$h++;
dolibarr_fiche_head($head, 'tasks', $langs->trans("Tasks"));
print '<form method="POST" action="fiche.php?id='.$projet->id.'">';
print '<input type="hidden" name="action" value="createtask">';
print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
print '<td>'.$langs->trans("Company").'</td><td>'.$projet->societe->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("Task").'</td><td colspan="3">'.$task->title.'</td></tr>';
/* Liste des tâches */
$sql = "SELECT t.task_date, t.task_duration, t.fk_user, u.login";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
$sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE t.fk_task =".$task->id;
$sql .= " AND t.fk_user = u.rowid";
$sql .= " ORDER BY t.task_date DESC";
$var=true;
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$tasks = array();
while ($i < $num)
{
$row = $db->fetch_row($resql);
$tasks[$i] = $row;
$i++;
}
$db->free();
}
else
{
dolibarr_print_error($db);
}
/* Nouvelle tâche */
print '</table></form><br />';
print '<input type="hidden" name="action" value="addtime">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("DurationEffective").'</td>';
print '<td colspan="2">'.$langs->trans("User").'</td>';
print "</tr>\n";
foreach ($tasks as $task_time)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>'.dolibarr_print_date($task_time[0]).'</td>';
print '<td>'.$task_time[1].'</td>';
print '<td>'.$task_time[3].'</td>';
print "</tr>\n";
}
print "</table>";
print '</div>';
}
print "</table>";
print '</div>';
}
}
$db->close();

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -14,75 +14,363 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/task.class.php
\ingroup projet
\brief Fichier de la classe de gestion des taches
\version $Revision$
\file task.class.php
\ingroup project
\brief This file is a CRUD class file for Taks (Create/Read/Update/Delete)
\version $Id$
\remarks Initialy built by build_class_from_table on 2008-09-10 12:41
*/
// Put here all includes required by your class file
//require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
//require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
//require_once(DOL_DOCUMENT_ROOT."/product.class.php");
/**
\class Task
\brief Classe permettant la gestion des taches
\class Projet_task
\brief Put here description of your class
\remarks Initialy built by build_class_from_table on 2008-09-10 12:41
*/
class Task {
var $id;
var $db;
/**
* \brief Constructeur de la classe
* \param DB handler accès base de données
*/
function Task($DB)
{
$this->db = $DB;
}
/*
* \brief Charge objet projet depuis la base
* \param rowid id du projet à charger
*/
function fetch($rowid)
{
class Task // extends CommonObject
{
var $db; //!< To store db handler
var $error; //!< To return error code (or message)
var $errors=array(); //!< To return several error codes (or messages)
//var $element='projet_task'; //!< Id that identify managed objects
//var $table_element='projet_task'; //!< Name of table without prefix where object is stored
$sql = "SELECT title, fk_projet, duration_effective, statut";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task";
$sql .= " WHERE rowid=".$rowid;
var $id;
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $rowid;
$this->title = $obj->title;
$this->statut = $obj->statut;
$this->projet_id = $obj->fk_projet;
$this->db->free($resql);
var $fk_projet;
var $fk_task_parent;
var $title;
var $duration_effective;
var $fk_user_creat;
var $statut;
var $note;
/**
* \brief Constructor
* \param DB Database handler
*/
function Task($DB)
{
$this->db = $DB;
return 1;
}
/**
* \brief Create in database
* \param user User that create
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, Id of created object if OK
*/
function create($user, $notrigger=0)
{
global $conf, $langs;
$error=0;
// Clean parameters
if (isset($this->fk_projet)) $this->fk_projet=trim($this->fk_projet);
if (isset($this->fk_task_parent)) $this->fk_task_parent=trim($this->fk_task_parent);
if (isset($this->title)) $this->title=trim($this->title);
if (isset($this->duration_effective)) $this->duration_effective=trim($this->duration_effective);
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
if (isset($this->statut)) $this->statut=trim($this->statut);
if (isset($this->note)) $this->note=trim($this->note);
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task(";
$sql.= "fk_projet,";
$sql.= "fk_task_parent,";
$sql.= "title,";
$sql.= "duration_effective,";
$sql.= "fk_user_creat,";
$sql.= "statut,";
$sql.= "note";
$sql.= ") VALUES (";
$sql.= " ".(! isset($this->fk_projet)?'NULL':"'".$this->fk_projet."'").",";
$sql.= " ".(! isset($this->fk_task_parent)?'NULL':"'".$this->fk_task_parent."'").",";
$sql.= " ".(! isset($this->title)?'NULL':"'".$this->title."'").",";
$sql.= " ".(! isset($this->duration_effective)?'NULL':"'".$this->duration_effective."'").",";
$sql.= " ".(! isset($this->fk_user_creat)?'NULL':"'".$this->fk_user_creat."'").",";
$sql.= " ".(! isset($this->statut)?'NULL':"'".$this->statut."'").",";
$sql.= " ".(! isset($this->note)?'NULL':"'".$this->note."'")."";
$sql.= ")";
$this->db->begin();
dolibarr_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task");
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dolibarr_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return $this->id;
}
}
/**
* \brief Load object in memory from database
* \param id id object
* \return int <0 if KO, >0 if OK
*/
function fetch($id)
{
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.fk_projet,";
$sql.= " t.fk_task_parent,";
$sql.= " t.title,";
$sql.= " t.duration_effective,";
$sql.= " t.fk_user_creat,";
$sql.= " t.statut,";
$sql.= " t.note";
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task as t";
$sql.= " WHERE t.rowid = ".$id;
dolibarr_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->fk_projet = $obj->fk_projet;
$this->fk_task_parent = $obj->fk_task_parent;
$this->title = $obj->title;
$this->duration_effective = $obj->duration_effective;
$this->fk_user_creat = $obj->fk_user_creat;
$this->statut = $obj->statut;
$this->note = $obj->note;
}
$this->db->free($resql);
return 1;
}
else
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1;
}
}
/**
* \brief Update database
* \param user User that modify
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, >0 if OK
*/
function update($user=0, $notrigger=0)
{
global $conf, $langs;
$error=0;
// Clean parameters
if (isset($this->fk_projet)) $this->fk_projet=trim($this->fk_projet);
if (isset($this->fk_task_parent)) $this->fk_task_parent=trim($this->fk_task_parent);
if (isset($this->title)) $this->title=trim($this->title);
if (isset($this->duration_effective)) $this->duration_effective=trim($this->duration_effective);
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
if (isset($this->statut)) $this->statut=trim($this->statut);
if (isset($this->note)) $this->note=trim($this->note);
// Check parameters
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET";
$sql.= " fk_projet=".(isset($this->fk_projet)?$this->fk_projet:"null").",";
$sql.= " fk_task_parent=".(isset($this->fk_task_parent)?$this->fk_task_parent:"null").",";
$sql.= " title=".(isset($this->title)?"'".addslashes($this->title)."'":"null").",";
$sql.= " duration_effective=".(isset($this->duration_effective)?$this->duration_effective:"null").",";
$sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").",";
$sql.= " statut=".(isset($this->statut)?$this->statut:"null").",";
$sql.= " note=".(isset($this->note)?"'".addslashes($this->note)."'":"null")."";
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
dolibarr_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dolibarr_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* \brief Delete object in database
* \param user User that delete
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger=0)
{
global $conf, $langs;
$error=0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task";
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
dolibarr_syslog(get_class($this)."::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dolibarr_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* \brief Initialise object with example values
* \remarks id must be 0 if object instance is a specimen.
*/
function initAsSpecimen()
{
$this->id=0;
$this->fk_projet='';
$this->fk_task_parent='';
$this->title='';
$this->duration_effective='';
$this->fk_user_creat='';
$this->statut='';
$this->note='';
}
return 0;
}
else
{
return -1;
}
}
else
{
print $this->db->error();
return -2;
}
}
}
?>
?>