diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index d60cd2fab748e..87e35a9c8ba5d 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -30,7 +30,15 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); -$mine = $_REQUEST['mode']=='mine' ? 1 : 0; +$langs->load("users"); +$langs->load("projects"); + +$action = GETPOST('action', 'alpha'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); + +$mode = GETPOST('mode', 'alpha'); +$mine = ($mode == 'mine' ? 1 : 0); //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects // Security check @@ -39,20 +47,20 @@ //$result = restrictedArea($user, 'projet', $projectid); if (!$user->rights->projet->lire) accessforbidden(); -$langs->load("users"); -$langs->load("projects"); - -$progress=GETPOST('progress'); -$description=GETPOST('description'); +$progress=GETPOST('progress', 'int'); +$label=GETPOST('label', 'alpha'); +$description=GETPOST('description', 'alpha'); $userAccess=0; +$object = new Project($db); + /* * Actions */ -if ($_POST["action"] == 'createtask' && $user->rights->projet->creer) +if ($action == 'createtask' && $user->rights->projet->creer) { $error=0; @@ -61,16 +69,16 @@ if (empty($_POST["cancel"])) { - if (empty($_POST['label'])) + if (empty($label)) { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")); - $_GET["action"]='create'; + $action='create'; $error++; } else if (empty($_POST['task_parent'])) { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("ChildOfTask")); - $_GET["action"]='create'; + $action='create'; $error++; } @@ -78,20 +86,20 @@ { $tmparray=explode('_',$_POST['task_parent']); $projectid=$tmparray[0]; - if (empty($projectid)) $projectid = $_POST["id"]; // If projectid is '' + if (empty($projectid)) $projectid = $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->label = $label; + $task->description = $description; $task->fk_task_parent = $task_parent; $task->date_c = dol_now(); $task->date_start = $date_start; $task->date_end = $date_end; - $task->progress = $_POST['progress']; + $task->progress = $progress; $taskid = $task->create($user); @@ -105,7 +113,7 @@ { if (empty($projectid)) { - Header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($_REQUEST["mode"])?'':'?mode='.$_REQUEST["mode"])); + Header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($mode)?'':'?mode='.$mode)); exit; } else @@ -117,10 +125,10 @@ } else { - if (empty($_GET["id"]) && empty($_POST["id"])) + if (empty($id)) { // We go back on task list - Header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($_REQUEST["mode"])?'':'?mode='.$_REQUEST["mode"])); + Header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($mode)?'':'?mode='.$mode)); exit; } } @@ -132,27 +140,21 @@ $form=new Form($db); $formother=new FormOther($db); -$projectstatic = new Project($db); $taskstatic = new Task($db); $help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("",$langs->trans("Tasks"),$help_url); -$task = new Task($db); - -$id = (! empty($_GET['id']))?$_GET['id']:$_POST['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); + $object->fetch($id, $ref); + if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id); // To verify role of users - $userAccess = $project->restrictedProjectArea($user); + $userAccess = $object->restrictedProjectArea($user); } -if ($_GET["action"] == 'create' && $user->rights->projet->creer && (empty($project->societe->id) || $userAccess)) +if ($action == 'create' && $user->rights->projet->creer && (empty($object->societe->id) || $userAccess)) { print_fiche_titre($langs->trans("NewTask")); @@ -161,18 +163,18 @@ print '
'; print ''; print ''; - if ($_GET['id']) print ''; - if ($_GET['mode']) print ''; + if (! empty($object->id)) print ''; + if (! empty($mode)) print ''; print ''; print ''; // List of projects print ''; print '
'.$langs->trans("Label").''; - print ''; + print ''; print '
'.$langs->trans("ChildOfTask").''; - print $formother->selectProjectTasks('',$projectid?$projectid:$_GET["id"], 'task_parent', 0, 0, 1, 1); + print $formother->selectProjectTasks('',$projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1); print '
'.$langs->trans("AffectedTo").''; @@ -220,10 +222,10 @@ $tab='tasks'; - $head=project_prepare_head($project); - dol_fiche_head($head, $tab, $langs->trans("Project"),0,($project->public?'projectpub':'project')); + $head=project_prepare_head($object); + dol_fiche_head($head, $tab, $langs->trans("Project"),0,($object->public?'projectpub':'project')); - $param=($_REQUEST["mode"]=='mine'?'&mode=mine':''); + $param=($mode=='mine'?'&mode=mine':''); print ''; @@ -232,27 +234,27 @@ print $langs->trans("Ref"); print ''; - print ''; + print ''; print ''; print ''; // Visibility print ''; // Statut - print ''; + print ''; print '
'; // Define a complementary filter for search of next/prev ref. - $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1); - $project->next_prev_filter=" rowid in (".$projectsListId.")"; - print $form->showrefnav($project,'ref','',1,'ref','ref','',$param); + $projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,1); + $object->next_prev_filter=" rowid in (".$projectsListId.")"; + print $form->showrefnav($object,'ref','',1,'ref','ref','',$param); print '
'.$langs->trans("Label").''.$project->title.'
'.$langs->trans("Label").''.$object->title.'
'.$langs->trans("Company").''; - if (! empty($project->societe->id)) print $project->societe->getNomUrl(1); + if (! empty($object->societe->id)) print $object->societe->getNomUrl(1); else print ' '; print '
'.$langs->trans("Visibility").''; - if ($project->public) print $langs->trans('SharedProject'); + if ($object->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print '
'.$langs->trans("Status").''.$project->getLibStatut(4).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'; @@ -265,9 +267,9 @@ if ($user->rights->projet->all->creer || $user->rights->projet->creer) { - if ($project->public || $userAccess) + if ($object->public || $userAccess) { - print ''.$langs->trans('AddTask').''; + print ''.$langs->trans('AddTask').''; } else { @@ -286,9 +288,9 @@ // Link to switch in "my task" / "all task" print '
'; - if ($_REQUEST["mode"] == 'mine') + if ($mode == 'mine') { - print ''.$langs->trans("DoNotShowMyTasksOnly").''; + print ''.$langs->trans("DoNotShowMyTasksOnly").''; //print ' - '; //print $langs->trans("ShowMyTaskOnly"); } @@ -296,22 +298,22 @@ { //print $langs->trans("DoNotShowMyTaskOnly"); //print ' - '; - print ''.$langs->trans("ShowMyTasksOnly").''; + print ''.$langs->trans("ShowMyTasksOnly").''; } 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); + $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0); // We load also tasks limited to a particular user - $tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(0,$user,$project->id,0) : ''); + $tasksrole=($mode=='mine' ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$object->id,0) : ''); //var_dump($tasksarray); //var_dump($tasksrole); print ''; print ''; - if ($projectstatic->id) print ''; + if (! empty($object->id)) print ''; print ''; print ''; print ''; @@ -325,14 +327,14 @@ } else { - print ''; + print ''; } print "
'.$langs->trans("Project").''.$langs->trans("Project").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("Progress").'
'.$langs->trans("NoTasks").'
'.$langs->trans("NoTasks").'
"; // Test if database is clean. If not we clean it. //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'
'; - if ($_REQUEST["mode"]=='mine') + if ($mode=='mine') { if ($nboftaskshown < count($tasksrole)) clean_orphelins($db); } @@ -342,7 +344,8 @@ } } +llxFooter(); + $db->close(); -llxFooter(); ?>