* Copyright (C) 2006-2009 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("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); require_once(DOL_DOCUMENT_ROOT."/html.formother.class.php"); $taskid = (isset($_GET["id"])?$_GET["id"]:(isset($_POST["id"])?$_POST["id"]:'')); $taskref = (isset($_GET["ref"])?$_GET["ref"]:''); 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"]); $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->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); } 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); $projectstatic = new Project($db); if ($taskid) { $task = new Task($db); if ($task->fetch($taskid) >= 0 ) { $projet = new Project($db); $result=$projet->fetch($task->fk_project); if (! empty($projet->socid)) $projet->societe->fetch($projet->socid); $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 ''; print ''; 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 $projet->getNomUrl(1); print '
'.$langs->trans("Company").''; if ($projet->societe->id) print $projet->societe->getNomUrl(1); else print ' '; 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 ''; print ''; print ''; // Date start print ''; // Date end print ''; // Progress print ''; // Description print ''; /* List of time spent */ $sql = "SELECT t.task_date, t.task_duration, t.fk_user, u.login, u.rowid"; $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) { $row = $db->fetch_object($resql); $tasks[$i] = $row; $i++; } $db->free($resql); } else { dol_print_error($db); } print '
'; print $langs->trans("Ref"); print ''; print $html->showrefnav($task,'id','',1,'rowid','ref','',''); print '
'.$langs->trans("Label").''.$task->label.'
'.$langs->trans("Project").''; print $projet->getNomUrl(1); print '
'.$langs->trans("Company").''; if ($projet->societe->id) print $projet->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) { print ''.$langs->trans('Delete').''; } else { print ''.$langs->trans('Delete').''; } print '
'; } } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>