2005-08-21 14:39:11 +02:00
|
|
|
|
<?php
|
2008-09-10 13:14:45 +02:00
|
|
|
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2009-01-12 21:26:06 +01:00
|
|
|
|
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
2008-09-10 22:49:21 +02:00
|
|
|
|
*
|
2005-08-21 14:39:11 +02:00
|
|
|
|
* 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.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-09-10 22:49:21 +02:00
|
|
|
|
* \file htdocs/projet/tasks/task.php
|
|
|
|
|
|
* \ingroup projet
|
2009-02-12 10:09:36 +01:00
|
|
|
|
* \brief Fiche t<EFBFBD>ches d'un projet
|
2008-09-10 22:49:21 +02:00
|
|
|
|
* \version $Id$
|
2008-09-10 13:14:45 +02:00
|
|
|
|
*/
|
2005-08-21 14:39:11 +02:00
|
|
|
|
|
|
|
|
|
|
require("./pre.inc.php");
|
2006-09-23 02:36:00 +02:00
|
|
|
|
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
|
2005-08-21 14:39:11 +02:00
|
|
|
|
|
|
|
|
|
|
if (!$user->rights->projet->lire) accessforbidden();
|
|
|
|
|
|
|
2009-01-12 10:53:45 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* Actions
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->projet->creer)
|
|
|
|
|
|
{
|
|
|
|
|
|
$task = new Task($db);
|
|
|
|
|
|
if ($task->fetch($_GET["id"]) >= 0 )
|
|
|
|
|
|
{
|
|
|
|
|
|
$projet = new Project($db);
|
|
|
|
|
|
$result=$projet->fetch($task->fk_projet);
|
|
|
|
|
|
if (! empty($projet->socid))
|
|
|
|
|
|
{
|
|
|
|
|
|
$projet->societe->fetch($projet->socid);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-01-12 21:26:06 +01:00
|
|
|
|
if ($task->delete($user) > 0)
|
2009-01-12 10:53:45 +01:00
|
|
|
|
{
|
|
|
|
|
|
Header("Location: index.php");
|
|
|
|
|
|
exit;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2009-01-12 21:26:06 +01:00
|
|
|
|
$langs->load("errors");
|
|
|
|
|
|
$mesg='<div class="error">'.$langs->trans($task->error).'</div>';
|
2009-01-12 10:53:45 +01:00
|
|
|
|
$_POST["action"]='';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2008-09-10 22:49:21 +02:00
|
|
|
|
|
2008-08-26 00:14:58 +02:00
|
|
|
|
/*
|
|
|
|
|
|
* View
|
|
|
|
|
|
*/
|
2005-08-21 14:39:11 +02:00
|
|
|
|
|
|
|
|
|
|
llxHeader("",$langs->trans("Task"));
|
|
|
|
|
|
|
2009-01-12 10:53:45 +01:00
|
|
|
|
$html = new Form($db);
|
|
|
|
|
|
|
2008-09-10 22:49:21 +02:00
|
|
|
|
$projectstatic = new Project($db);
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-08-21 14:39:11 +02:00
|
|
|
|
if ($_GET["id"] > 0)
|
|
|
|
|
|
{
|
2008-09-10 13:14:45 +02:00
|
|
|
|
/*
|
|
|
|
|
|
* Fiche projet en mode visu
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
$task = new Task($db);
|
|
|
|
|
|
if ($task->fetch($_GET["id"]) >= 0 )
|
2005-08-21 14:39:11 +02:00
|
|
|
|
{
|
2008-09-10 13:14:45 +02:00
|
|
|
|
$projet = new Project($db);
|
|
|
|
|
|
$result=$projet->fetch($task->fk_projet);
|
2009-01-12 21:26:06 +01:00
|
|
|
|
if (! empty($projet->socid)) $projet->societe->fetch($projet->socid);
|
2008-09-10 13:14:45 +02:00
|
|
|
|
|
2009-01-15 00:36:51 +01:00
|
|
|
|
$head=task_prepare_head($task);
|
2008-09-10 13:14:45 +02:00
|
|
|
|
|
2009-02-20 23:53:15 +01:00
|
|
|
|
dol_fiche_head($head, 'tasks', $langs->trans("Task"));
|
2008-09-10 13:14:45 +02:00
|
|
|
|
|
2009-01-12 21:26:06 +01:00
|
|
|
|
if ($mesg) print $mesg.'<br>';
|
2009-01-15 00:36:51 +01:00
|
|
|
|
|
2009-01-12 10:53:45 +01:00
|
|
|
|
if ($_GET["action"] == 'delete')
|
|
|
|
|
|
{
|
|
|
|
|
|
$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("DeleteATask"),$langs->trans("ConfirmDeleteATask"),"confirm_delete");
|
|
|
|
|
|
print "<br>";
|
|
|
|
|
|
}
|
2009-01-15 00:36:51 +01:00
|
|
|
|
|
2008-09-10 13:14:45 +02:00
|
|
|
|
print '<form method="POST" action="fiche.php?id='.$projet->id.'">';
|
|
|
|
|
|
print '<input type="hidden" name="action" value="createtask">';
|
|
|
|
|
|
print '<table class="border" width="100%">';
|
|
|
|
|
|
|
2008-09-10 22:49:21 +02:00
|
|
|
|
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'.$task->id.'</td></tr>';
|
|
|
|
|
|
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->title.'</td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
print '<tr><td>'.$langs->trans("Project").'</td><td>';
|
|
|
|
|
|
print $projet->getNomUrl(1);
|
|
|
|
|
|
print '</td></tr>';
|
2008-09-10 13:14:45 +02:00
|
|
|
|
|
2009-01-12 21:26:06 +01:00
|
|
|
|
print '<td>'.$langs->trans("Company").'</td><td>';
|
|
|
|
|
|
if ($projet->societe->id) print $projet->societe->getNomUrl(1);
|
|
|
|
|
|
else print ' ';
|
|
|
|
|
|
print '</td></tr>';
|
2008-09-10 13:14:45 +02:00
|
|
|
|
|
2009-02-12 10:09:36 +01:00
|
|
|
|
/* List of time spent */
|
2008-09-10 13:14:45 +02:00
|
|
|
|
|
2009-01-12 10:53:45 +01:00
|
|
|
|
$sql = "SELECT t.task_date, t.task_duration, t.fk_user, u.login, u.rowid";
|
2008-09-10 13:14:45 +02:00
|
|
|
|
$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)
|
|
|
|
|
|
{
|
2009-01-12 21:26:06 +01:00
|
|
|
|
$row = $db->fetch_object($resql);
|
2008-09-10 22:49:21 +02:00
|
|
|
|
$tasks[$i] = $row;
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
2009-01-12 21:26:06 +01:00
|
|
|
|
$db->free($resql);
|
2008-09-10 13:14:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2009-02-20 23:53:15 +01:00
|
|
|
|
dol_print_error($db);
|
2008-09-10 13:14:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2009-01-12 21:26:06 +01:00
|
|
|
|
print '</table></form>';
|
|
|
|
|
|
print '</div>';
|
2008-09-10 13:14:45 +02:00
|
|
|
|
|
2009-01-15 00:36:51 +01:00
|
|
|
|
|
2009-01-12 21:26:06 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* Actions
|
|
|
|
|
|
*/
|
|
|
|
|
|
print '<div class="tabsAction">';
|
2009-01-15 00:36:51 +01:00
|
|
|
|
|
2009-01-12 21:26:06 +01:00
|
|
|
|
if ($user->rights->projet->creer)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$task->id.'&action=delete">'.$langs->trans('Delete').'</a>';
|
|
|
|
|
|
}
|
2009-01-15 00:36:51 +01:00
|
|
|
|
|
|
|
|
|
|
print '</div>';
|
|
|
|
|
|
|
2009-01-12 21:26:06 +01:00
|
|
|
|
print '<br>';
|
2008-09-10 13:14:45 +02:00
|
|
|
|
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>';
|
2009-01-12 10:53:45 +01:00
|
|
|
|
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
|
2009-02-12 10:09:36 +01:00
|
|
|
|
print '<td align="right">'.$langs->trans("By").'</td>';
|
2008-09-10 13:14:45 +02:00
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($tasks as $task_time)
|
|
|
|
|
|
{
|
|
|
|
|
|
$var=!$var;
|
2008-09-10 22:49:21 +02:00
|
|
|
|
print "<tr ".$bc[$var].">";
|
2009-02-12 10:09:36 +01:00
|
|
|
|
|
|
|
|
|
|
// Date
|
2009-02-20 23:53:15 +01:00
|
|
|
|
print '<td>'.dol_print_date($db->jdate($task_time->task_date),'day').' '.dol_print_date($db->jdate($task_time->task_date),'%A').'</td>';
|
2009-02-12 10:09:36 +01:00
|
|
|
|
|
|
|
|
|
|
// Time spent
|
|
|
|
|
|
$heure = intval($task_time->task_duration);
|
|
|
|
|
|
$minutes = round((($task_time->task_duration - $heure) * 60),0);
|
|
|
|
|
|
$minutes = substr("00"."$minutes", -2);
|
|
|
|
|
|
print '<td align="right">'.$heure." h ".$minutes."</td>\n";
|
|
|
|
|
|
|
|
|
|
|
|
// User
|
|
|
|
|
|
$user->id=$task_time->rowid;
|
2009-01-12 21:26:06 +01:00
|
|
|
|
$user->nom=$task_time->login;
|
2009-01-12 10:53:45 +01:00
|
|
|
|
print '<td align="right">'.$user->getNomUrl(1).'</td>';
|
2008-09-10 22:49:21 +02:00
|
|
|
|
print "</tr>\n";
|
2008-09-10 13:14:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "</table>";
|
2009-01-15 00:36:51 +01:00
|
|
|
|
|
2005-08-21 14:39:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
|
|
|
|
|
|
llxFooter('$Date$ - $Revision$');
|
|
|
|
|
|
?>
|