* Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2010 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"); require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php"); require_once(DOL_DOCUMENT_ROOT."/projet/tasks/task.class.php"); require_once(DOL_DOCUMENT_ROOT."/html.formother.class.php"); $projectid=''; $projectid=isset($_REQUEST["id"])?$_REQUEST["id"]:$_POST["id"]; // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); $userAccess=0; /* * Actions */ if ($_POST["action"] == 'createtask' && $user->rights->projet->creer) { $error=0; if (empty($_POST["cancel"])) { if (empty($_POST['label'])) { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")); $_GET["action"]='create'; $error++; } else if (empty($_POST['task_parent'])) { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("ChildOfTask")); $_GET["action"]='create'; $error++; } if (! $error) { $tmparray=explode('_',$_POST['task_parent']); $projectid=$tmparray[0]; if (empty($projectid)) $projectid = $_POST["id"]; // If projectid is '' $task_parent=$tmparray[1]; if (empty($task_parent)) $task_parent = 0; // If task_parent is '' $task = new Task($db); $task->fk_project = $projectid; $task->label = $_POST["label"]; $task->description = $_POST['description']; $task->fk_task_parent = $task_parent; $task->date_c = dol_now('tzserver'); $task->date_start = dol_mktime(12,0,0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear']); $task->date_end = dol_mktime(12,0,0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']); $task->progress = $_POST['progress']; $taskid = $task->create($user); if ($taskid > 0) { $result = $task->add_contact($_POST["userid"], 'TASKEXECUTIVE', 'internal'); } } if (! $error) { if (empty($projectid)) { Header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($_REQUEST["mode"])?'':'?mode='.$_REQUEST["mode"])); exit; } else { Header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$taskid); exit; } } } } /* * View */ $form=new Form($db); $formother=new FormOther($db); $help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("",$langs->trans("Tasks"),$help_url); $task = new Task($db); $id = $_REQUEST['id']; $ref= $_GET['ref']; if ($id > 0 || ! empty($ref)) { $project = new Project($db); $project->fetch($_REQUEST["id"],$_GET["ref"]); if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id); // To verify role of users $userAccess = $project->restrictedProjectArea($user); } if ($_GET["action"] == 'create' && $user->rights->projet->creer && (empty($project->societe->id) || $userAccess)) { print_fiche_titre($langs->trans("NewTask")); if ($mesg) print '
'.$mesg.'
'; print '
'; print ''; print ''; if ($_GET['id']) print ''; if ($_GET['mode']) print ''; print ''; print ''; print ''; print ''; // Date start print ''; // Date end print ''; // Progress print ''; // Description print ''; print ''; //$tasksarray=$task->getTasksArray(0, $user, $projectid, 0, 1); // Check print ''; print '
'.$langs->trans("Label").''; print ''; print '
'.$langs->trans("ChildOfTask").''; print $formother->selectProjectTasks('',$projectid, 'task_parent', 0, 0, 1, 1); print '
'.$langs->trans("AffectedTo").''; print $form->select_users($user->id,'userid',1); print '
'.$langs->trans("DateStart").''; print $form->select_date('','dateo'); print '
'.$langs->trans("DateEnd").''; print $form->select_date(-1,'datee'); print '
'.$langs->trans("Progress").''; print $formother->select_percent($task->progress,'progress'); print '
'.$langs->trans("Description").''; print ''; print '
'; //if (sizeof($tasksarray)) //{ print ''; print '     '; //} print ''; print '
'; print '
'; } else { /* * Fiche projet en mode visu * */ $userstatic=new User($db); $tab='tasks'; if ($_REQUEST["mode"]=='mine') $tab='mytasks'; $head=project_prepare_head($project); dol_fiche_head($head, $tab, $langs->trans("Project"),0,'project'); $param=($_REQUEST["mode"]=='mine'?'&mode=mine':''); print ''; // Ref print ''; print ''; print ''; print ''; // Visibility print ''; // Statut print ''; print '
'; print $langs->trans("Ref"); print ''; print $form->showrefnav($project,'ref','',1,'ref','ref','',$param); print '
'.$langs->trans("Label").''.$project->title.'
'.$langs->trans("Company").''; if (! empty($project->societe->id)) print $project->societe->getNomUrl(1); else print ' '; print '
'.$langs->trans("Visibility").''; if ($project->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print '
'.$langs->trans("Status").''.$project->getLibStatut(4).'
'; print ''; /* * Actions */ print '
'; if ($user->rights->projet->all->creer || $user->rights->projet->creer) { if ($project->public || $userAccess) { print ''.$langs->trans('AddTask').''; } else { print ''.$langs->trans('AddTask').''; } } else { print ''.$langs->trans('AddTask').''; } print '
'; print '
'; // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user // can have a parent that is not affected to him). $tasksarray=$task->getTasksArray(0, 0, $project->id, $socid, 0); // We load also tasks limited to a particular user $tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(0,$user,$project->id,0) : ''); //var_dump($tasksarray); //var_dump($tasksrole); print ''; print ''; if ($projectstatic->id) print ''; print ''; print ''; print ''; print "\n"; // Show all lines in taskarray (recursive function to go down on tree) $j=0; $nboftaskshown=PLines($j, 0, $tasksarray, $level, true, 0, $tasksrole); print "
'.$langs->trans("Project").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("TimeSpent").'
"; print ''; // Test if database is clean. If not we clean it. //print '$nboftaskshown='.$nboftaskshown.' sizeof($tasksarray)='.sizeof($tasksarray).' sizeof($tasksrole)='.sizeof($tasksrole).'
'; if ($_REQUEST["mode"]=='mine') { if ($nboftaskshown < sizeof($tasksrole)) clean_orphelins($db); } else { if ($nboftaskshown < sizeof($tasksarray)) clean_orphelins($db); } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>