*
* This program is free software; you can redistribute it and/or modify
@@ -19,31 +18,39 @@
*/
/**
- \file htdocs/projet/activity/index.php
+ \file htdocs/projet/activity/myactivity.php
\ingroup projet
- \brief Page activite du module projet
+ \brief Page activite perso du module projet
\version $Id$
*/
require("./pre.inc.php");
-if (!$user->rights->projet->lire) accessforbidden();
+$mode=$_REQUEST["mode"];
-/*
- * Sécurité accés client
- */
+
+// Security check
+if (!$user->rights->projet->lire) accessforbidden();
if ($user->societe_id > 0)
{
- $action = '';
$socid = $user->societe_id;
}
-llxHeader("",$langs->trans("Activity"));
+$langs->load("projects");
+
+
+/*
+ * View
+ */
$now = time();
-print_fiche_titre($langs->trans("Activity"));
+if ($mode == 'mine') $title=$langs->trans("MyActivity");
+else $title=$langs->trans("Activity");
+llxHeader("",$title);
+
+print_fiche_titre($title);
print '';
print '| ';
@@ -61,12 +68,18 @@ print " |
\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";
+$sql .= " FROM ".MAIN_DB_PREFIX."projet as p,";
+$sql .= " ".MAIN_DB_PREFIX."projet_task as t";
+if ($mode == 'mine') $sql.= ", ".MAIN_DB_PREFIX."projet_task_actors as pta";
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;
-
+if ($socid)
+{
+ $sql .= " AND p.fk_soc = ".$socid;
+}
+if ($mode == 'mine') $sql.=" AND t.rowid = pta.fk_projet_task";
+if ($mode == 'mine') $sql.=" AND pta.fk_user = ".$user->id;
$sql .= " GROUP BY p.rowid";
$var=true;
@@ -96,66 +109,36 @@ else
}
print "
";
-print '';
-
-$var=true;
-
-// Defini les bornes date debut et fin de semaines, mois et annee pour le jour courant
-$now=mktime();
-$info=dolibarr_getdate($now);
-$daystartw=$now-(($info['wday'] - 1)*24*3600);
-$dayendw =$now+((7 - $info['wday'])*24*3600);
-$infostartw=dolibarr_getdate($daystartw);
-$infoendw =dolibarr_getdate($dayendw);
-$datestartw=dolibarr_mktime(0,0,0,$infostartw["mon"],$infostartw["mday"],$infostartw["year"]);
-$dateendw=dolibarr_mktime(23,59,59,$infoendw["mon"],$infoendw["mday"],$infoendw["year"]);
-$datestartm=dolibarr_mktime(0,0,0,$info["mon"],1,$info["year"]);
-$dateendm=dolibarr_mktime(23,59,59,$info["mon"],30,$info["year"]);
-$datestarty=dolibarr_mktime(0,0,0,1,1,$info["year"]);
-$dateendy=dolibarr_mktime(23,59,59,12,31,$info["year"]);
-//print mktime()." - ".gmmktime().' ';
-//print dolibarr_print_date(mktime(0,0,0,1,1,1970),'dayhour')." - ".dolibarr_print_date(gmmktime(0,0,0,1,1,1970),'dayhour').' ';
-//print dolibarr_print_date($datestartw,'dayhour')." - ".dolibarr_print_date($now,'dayhour')." - ".dolibarr_print_date($dateendw,'dayhour').' ';
-//print dolibarr_print_date($datestartm,'dayhour')." - ".dolibarr_print_date($now,'dayhour')." - ".dolibarr_print_date($dateendm,'dayhour').' ';
-//print dolibarr_print_date($datestarty,'dayhour')." - ".dolibarr_print_date($now,'dayhour')." - ".dolibarr_print_date($dateendy,'dayhour').' ';
-//print 'xx '.dolibarr_date('Y-m-d H:i:s',$dateendy);
-//print ' zz '.dolibarr_print_date($dateendy,'dayhour');
-
-/* Affichage de la liste des projets du mois */
-print '';
+/* Affichage de la liste des projets d'aujourd'hui */
+print '
';
print '';
-print '| '.$langs->trans("ActivityOnProjectThisWeek").' | ';
-print ''.$langs->trans("Time").' | ';
+print ''.$langs->trans('Today').' | ';
+print ''.$langs->trans("Time").' | ';
print " \n";
-$sql = "SELECT p.title, p.rowid, sum(tt.task_duration) as total";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
+$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
$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";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND tt.fk_task = t.rowid";
-$sql .= " AND task_date >= '".$db->idate($datestartw)."' AND task_date <= '".$db->idate($dateendw)."'";
+$sql .= " AND tt.fk_user = ".$user->id;
+$sql .= " AND date_format(task_date,'%d%m%y') = ".strftime("%d%m%y",time());
$sql .= " GROUP BY p.rowid";
-dolibarr_syslog("Index: sql=".$sql);
+$var=true;
+$total=0;
$resql = $db->query($sql);
if ( $resql )
{
- $num = $db->num_rows($resql);
- $i = 0;
-
- while ($i < $num)
+ while ($row = $db->fetch_row($resql))
{
- $obj = $db->fetch_object( $resql);
$var=!$var;
print "";
- print '| '.$obj->title.' | ';
- print ''.$obj->total.' | ';
- print " \n";
- $i++;
+ print ''.$row[0].' | ';
+ print ''.$row[2].' | ';
+ print "\n";
+ $total += $row[2];
}
$db->free($resql);
@@ -164,6 +147,99 @@ else
{
dolibarr_print_error($db);
}
+print '';
+print '| '.$langs->trans('Total').' | ';
+print ''.$total.' | ';
+print " \n";
+print " ";
+
+/* Affichage de la liste des projets d'hier */
+print '
';
+print '';
+print '| '.$langs->trans('Yesterday').' | ';
+print ''.$langs->trans("Time").' | ';
+print " \n";
+
+$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
+$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";
+$sql .= " WHERE t.fk_projet = p.rowid";
+$sql .= " AND tt.fk_task = t.rowid";
+$sql .= " AND tt.fk_user = ".$user->id;
+$sql .= " AND date_format(date_add(task_date, INTERVAL 1 DAY),'%d%m%y') = ".strftime("%d%m%y",time());
+$sql .= " GROUP BY p.rowid";
+
+$var=true;
+$total=0;
+$resql = $db->query($sql);
+if ( $resql )
+{
+ while ($row = $db->fetch_row($resql))
+ {
+ $var=!$var;
+ print "";
+ print '| '.$row[0].' | ';
+ print ''.$row[2].' | ';
+ print " \n";
+ $total += $row[2];
+ }
+
+ $db->free($resql);
+}
+else
+{
+ dolibarr_print_error($db);
+}
+print '';
+print '| '.$langs->trans('Total').' | ';
+print ''.$total.' | ';
+print " \n";
+print " ";
+
+print '';
+
+/* Affichage de la liste des projets de la semaine */
+print '';
+print '';
+print '| '.$langs->trans("ActivityOnProjectThisWeek").' | ';
+print ''.$langs->trans("Time").' | ';
+print " \n";
+
+$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
+$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";
+$sql .= " WHERE t.fk_projet = p.rowid";
+$sql .= " AND tt.fk_task = t.rowid";
+$sql .= " AND tt.fk_user = ".$user->id;
+$sql .= " AND week(task_date) = ".strftime("%W",time());
+$sql .= " GROUP BY p.rowid";
+$total = 0;
+$var=true;
+$resql = $db->query($sql);
+if ( $resql )
+{
+ while ($row = $db->fetch_row( $resql))
+ {
+ $var=!$var;
+ print "";
+ print '| '.$row[0].' | ';
+ print ''.$row[2].' | ';
+ print " \n";
+ $total += $row[2];
+ }
+
+ $db->free($resql);
+}
+else
+{
+ dolibarr_print_error($db);
+}
+print '';
+print '| '.$langs->trans('Total').' | ';
+print ''.$total.' | ';
+print " \n";
print " ";
/* Affichage de la liste des projets du mois */
@@ -173,36 +249,28 @@ print ' | '.$langs->trans("ActivityOnProjectThisMonth").': '.strftime("%B %Y",
print ' | '.$langs->trans("Time").' | ';
print "\n";
-$sql = "SELECT p.title, p.rowid, sum(tt.task_duration) as total";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
+$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
$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";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND tt.fk_task = t.rowid";
-$sql .= " AND task_date >= '".$db->idate($datestartm)."' AND task_date <= '".$db->idate($dateendm)."'";
+$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 )
{
- $num = $db->num_rows($resql);
- $i = 0;
-
- while ($i < $num)
+ while ($row = $db->fetch_row($resql))
{
- $obj = $db->fetch_object($resql);
- $var=!$var;
print "";
- print '| '.$obj->title.' | ';
- print ''.$obj->total.' | ';
+ print ''.$row[0].' | ';
+ print ''.$row[2].' | ';
print " \n";
- $i++;
- }
-
+ $var=!$var;
+ }
$db->free($resql);
}
else
@@ -211,43 +279,35 @@ else
}
print " ";
-/* Affichage de la liste des projets du mois */
+/* Affichage de la liste des projets de l'année */
print '
';
print '';
print '| '.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).' | ';
print ''.$langs->trans("Time").' | ';
print " \n";
-$sql = "SELECT p.title, p.rowid, sum(tt.task_duration) as total";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
+$sql = "SELECT p.title, p.rowid, sum(tt.task_duration)";
$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";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND tt.fk_task = t.rowid";
-$sql .= " AND task_date >= '".$db->idate($datestarty)."' AND task_date <= '".$db->idate($dateendy)."'";
+$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 )
{
- $num = $db->num_rows($resql);
- $i = 0;
-
- while ($i < $num)
+ while ($row = $db->fetch_row($resql))
{
- $obj = $db->fetch_object($resql);
- $var=!$var;
print "";
- print '| '.$obj->title.' | ';
- print ''.$obj->total.' | ';
+ print ''.$row[0].' | ';
+ print ''.$row[2].' | ';
print " \n";
- $i++;
- }
-
+ $var=!$var;
+ }
$db->free($resql);
}
else
diff --git a/htdocs/projet/activity/list.php b/htdocs/projet/activity/list.php
new file mode 100644
index 00000000000..637f5b63a57
--- /dev/null
+++ b/htdocs/projet/activity/list.php
@@ -0,0 +1,215 @@
+
+ * Copyright (C) 2004-2008 Laurent Destailleur
+ * Copyright (C) 2005-2007 Regis Houssin
+ *
+ * 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
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ */
+
+/**
+ * \file htdocs/projet/tasks/fiche.php
+ * \ingroup projet
+ * \brief Fiche taches d'un projet
+ * \version $Id$
+ */
+
+require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
+
+$mode=$_REQUEST["mode"];
+
+$projetid='';
+$projetid=isset($_GET["id"])?$_GET["id"]:$_POST["projetid"];
+
+// Security check
+if ($user->societe_id) $socid=$user->societe_id;
+$result = restrictedArea($user, 'projet', $projetid);
+
+/*
+ * Actions
+ */
+
+if ($_POST["action"] == 'createtask' && $user->rights->projet->creer)
+{
+ $project = new Project($db);
+
+ $result = $project->fetch($_GET["id"]);
+
+ if ($result == 0)
+ {
+ $task_parent = $_POST["task_parent"]?$_POST["task_parent"]:0;
+ $project->CreateTask($user, $_POST["task_name"], $task_parent);
+
+ Header("Location:fiche.php?id=".$project->id);
+ exit;
+ }
+}
+
+if ($_POST["action"] == 'addtime' && $user->rights->projet->creer)
+{
+ foreach ($_POST as $key => $post)
+ {
+ //$pro->CreateTask($user, $_POST["task_name"]);
+ if (substr($key,0,4) == 'task')
+ {
+ if ($post > 0)
+ {
+ $post=intval($post)+(($post-intval($post))*(1+2/3));
+ $post=price2num($post);
+
+ $id = ereg_replace("task","",$key);
+
+ $task=new Task($db);
+ $task->fetch($id);
+
+ $project = new Project($db);
+ $result = $project->fetch($task->fk_projet);
+
+ $date = dolibarr_mktime(12,0,0,$_POST["$id"."month"],$_POST["$id"."day"],$_POST["$id"."year"]);
+ $project->TaskAddTime($user, $id , $post, $date);
+ }
+ else
+ {
+ if ($post != '') $mesg=''.$langs->trans("ErrorBadValue").' ';
+ }
+ }
+ }
+}
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+
+$title=$langs->trans("TimeSpent");
+if ($mode == 'mine') $title=$langs->trans("MyTimeSpent");
+
+llxHeader("",$title,"");
+
+$projet = new Project($db);
+if ($_GET["id"])
+{
+ $projet->fetch($_GET["id"]);
+ $projet->societe->fetch($projet->societe->id);
+}
+
+
+/*
+ * Fiche projet en mode visu
+ *
+ */
+
+print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
+
+if ($mesg) print $mesg;
+
+$tasksrole=$projet->getTasksRoleForUser($user);
+$tasksarray=$projet->getTasksArray();
+
+print ' |