mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 09:02:59 +01:00
176 lines
3.9 KiB
PHP
176 lines
3.9 KiB
PHP
<?php
|
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
* Copyright (C) 2006-2009 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
|
|
* (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/index.php
|
|
* \ingroup project
|
|
* \brief Fiche tâches d'un projet
|
|
* \version $Id$
|
|
*/
|
|
|
|
require("./pre.inc.php");
|
|
|
|
$mode=$_REQUEST["mode"];
|
|
|
|
$langs->load('projects');
|
|
|
|
// Security check
|
|
if (!$user->rights->projet->lire) accessforbidden();
|
|
$socid=0;
|
|
if ($user->societe_id > 0) $socid = $user->societe_id;
|
|
|
|
|
|
/*
|
|
* 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);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* View
|
|
*/
|
|
$form=new Form($db);
|
|
|
|
$title=$langs->trans("Tasks");
|
|
if ($mode == 'mine') $title=$langs->trans("Mytasks");
|
|
|
|
llxHeader("",$title,"Projet");
|
|
|
|
/*
|
|
* Card
|
|
*/
|
|
|
|
$h=0;
|
|
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/index.php';
|
|
$head[$h][1] = $title;
|
|
$head[$h][2] = 'tasks';
|
|
$h++;
|
|
|
|
dolibarr_fiche_head($head, 'tasks', $title);
|
|
|
|
$projet = new Project($db);
|
|
$tasksarray=$projet->getTasksArray();
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
print '<tr class="liste_titre">';
|
|
print '<td>'.$langs->trans("Project").'</td>';
|
|
print '<td>'.$langs->trans("Task").'</td>';
|
|
print '<td> </td>';
|
|
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
|
|
print "</tr>\n";
|
|
|
|
$level=0;
|
|
$j=0;
|
|
PLines($j, 0, $tasksarray, $level, true);
|
|
|
|
print "</table>";
|
|
print '</div>';
|
|
|
|
|
|
/*
|
|
* Actions
|
|
*/
|
|
print '<div class="tabsAction">';
|
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?action=create">'.$langs->trans('AddTask').'</a>';
|
|
print '</div>';
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
llxFooter('$Date$ - $Revision$');
|
|
|
|
|
|
// 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);
|
|
|
|
for ($i = 0 ; $i < sizeof($lines) ; $i++)
|
|
{
|
|
if ($parent == 0) $level = 0;
|
|
|
|
if ($lines[$i]->fk_parent == $parent)
|
|
{
|
|
// Break on a new project
|
|
if ($parent == 0 && $lines[$i]->projectid != $lastprojectid)
|
|
{
|
|
$var = !$var;
|
|
$lastprojectid=$lines[$i]->projectid;
|
|
}
|
|
|
|
print "<tr $bc[$var]>\n";
|
|
|
|
print "<td>";
|
|
$projectstatic->id=$lines[$i]->projectid;
|
|
$projectstatic->ref=$lines[$i]->projectref;
|
|
print $projectstatic->getNomUrl(1);
|
|
print "</td>";
|
|
|
|
print "<td>".$lines[$i]->id."</td>";
|
|
|
|
print "<td>";
|
|
for ($k = 0 ; $k < $level ; $k++)
|
|
{
|
|
print " ";
|
|
}
|
|
|
|
print '<a href="task.php?id='.$lines[$i]->id.'">'.$lines[$i]->title."</a></td>\n";
|
|
|
|
$heure = intval($lines[$i]->duration);
|
|
$minutes = round((($lines[$i]->duration - $heure) * 60),0);
|
|
$minutes = substr("00"."$minutes", -2);
|
|
|
|
print '<td align="right">'.$heure." h ".$minutes."</td>\n";
|
|
|
|
print "</tr>\n";
|
|
|
|
$inc++;
|
|
|
|
$level++;
|
|
if ($lines[$i]->id) PLines($inc, $lines[$i]->id, $lines, $level, $var);
|
|
$level--;
|
|
}
|
|
else
|
|
{
|
|
//$level--;
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|