* Copyright (C) 2006-2010 Laurent Destailleur * Copyright (C) 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/task.php * \ingroup projet * \brief Fiche taches d'un projet * \version $Id$ */ require ("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); require_once(DOL_DOCUMENT_ROOT."/projet/class/task.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); $taskid = (isset($_GET["id"])?$_GET["id"]:(isset($_POST["id"])?$_POST["id"]:'')); $taskref = (isset($_GET["ref"])?$_GET["ref"]:''); // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; if (!$user->rights->projet->lire) accessforbidden(); /* * Actions */ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) { $error=0; if (empty($_POST["label"])) { $error++; $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'
'; } if (! $error) { $task = new Task($db); $task->fetch($_POST["id"]); $tmparray=explode('_',$_POST['task_parent']); $task_parent=$tmparray[1]; if (empty($task_parent)) $task_parent = 0; // If task_parent is '' $task->label = $_POST["label"]; $task->description = $_POST['description']; $task->fk_task_parent = $task_parent; $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']; $result=$task->update($user); $taskid=$task->id; // On retourne sur la fiche tache } else { $taskid=$_POST["id"]; $_GET['action']='edit'; } } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->projet->supprimer) { $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); } if ($task->delete($user) > 0) { Header("Location: index.php"); exit; } else { $langs->load("errors"); $mesg='
'.$langs->trans($task->error).'
'; $_POST["action"]=''; } } } /* * View */ llxHeader("",$langs->trans("Task")); $html = new Form($db); $formother = new FormOther($db); $project = new Project($db); if ($taskid) { $task = new Task($db); $projectstatic = new Project($db); if ($task->fetch($taskid) >= 0 ) { $result=$projectstatic->fetch($task->fk_project); if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid); // To verify role of users //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project //$arrayofuseridoftask=$task->getListContactId('internal'); if ($mesg) print $mesg; $head=task_prepare_head($task); dol_fiche_head($head, 'task', $langs->trans("Task"),0,'projecttask'); if ($_GET["action"] == 'edit' && $user->rights->projet->creer) { print '
'; print ''; print ''; print ''; print ''; if ($mesg) print $mesg.'
'; // Ref print ''; print ''; // Label print ''; print ''; // Project print ''; // Third party print ''; // Task parent print ''; // Date start print ''; // Date end print ''; // Progress print ''; // Description print ''; print ''; print ''; print '
'.$langs->trans("Ref").''.$task->ref.'
'.$langs->trans("Label").'
'.$langs->trans("Project").''; print $projectstatic->getNomUrl(1); print '
'.$langs->trans("Company").''; if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); else print ' '; print '
'.$langs->trans("ChildOfTask").''; print $formother->selectProjectTasks($task->fk_task_parent,$projectstatic->id, 'task_parent', $user->admin?0:1, 0); print '
'.$langs->trans("DateStart").''; print $html->select_date($task->date_start,'dateo'); print '
'.$langs->trans("DateEnd").''; print $html->select_date($task->date_end?$task->date_end:-1,'datee'); print '
'.$langs->trans("Progress").''; print $formother->select_percent($task->progress,'progress'); print '
'.$langs->trans("Description").''; print ''; print '
'; print '   '; print '
'; print '
'; } else { /* * Fiche tache en mode visu */ if ($_GET["action"] == 'delete') { $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("DeleteATask"),$langs->trans("ConfirmDeleteATask"),"confirm_delete"); if ($ret == 'html') print '
'; } print ''; // Ref print ''; print ''; // Label print ''; // Project print ''; // Third party print ''; // Date start print ''; // Date end print ''; // Progress print ''; // Description print ''; print '
'; print $langs->trans("Ref"); print ''; $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1); $task->next_prev_filter=" fk_projet in (".$projectsListId.")"; print $html->showrefnav($task,'id','',1,'rowid','ref','',''); print '
'.$langs->trans("Label").''.$task->label.'
'.$langs->trans("Project").''; print $projectstatic->getNomUrl(1); print '
'.$langs->trans("Company").''; if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); else print ' '; print '
'.$langs->trans("DateStart").''; print dol_print_date($task->date_start,'day'); print '
'.$langs->trans("DateEnd").''; print dol_print_date($task->date_end,'day'); print '
'.$langs->trans("Progress").''; print $task->progress.' %'; print '
'.$langs->trans("Description").''; print nl2br($task->description); print '
'; print ''; /* * Actions */ print '
'; // Modify if ($user->rights->projet->creer) { print ''.$langs->trans('Modify').''; } else { print ''.$langs->trans('Modify').''; } // Delete if ($user->rights->projet->supprimer && ! $task->hasChildren()) { print ''.$langs->trans('Delete').''; } else { print ''.$langs->trans('Delete').''; } print '
'; } } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>