* Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010 François Legastelois * * 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 3 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, see . */ /** * \file htdocs/projet/activity/perweek.php * \ingroup projet * \brief List activities of tasks (per week entry) */ 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.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load('projects'); $action=GETPOST('action'); $mode=GETPOST("mode"); $id=GETPOST('id','int'); $mine=0; if ($mode == 'mine') $mine=1; $projectid=''; $projectid=isset($_GET["id"])?$_GET["id"]:$_POST["projectid"]; // Security check $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); $now=dol_now(); $year=GETPOST("year","int")?GETPOST("year","int"):date("Y"); $month=GETPOST("month","int")?GETPOST("month","int"):date("m"); $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $day=GETPOST("day","int")?GETPOST("day","int"):date("d"); /* * Actions */ if ($action == 'addtime' && $user->rights->projet->creer) { $task = new Task($db); } /* * View */ $form=new Form($db); $formother=new FormOther($db); $projectstatic=new Project($db); $project = new Project($db); $taskstatic = new Task($db); $title=$langs->trans("TimeSpent"); if ($mine) $title=$langs->trans("MyTimeSpent"); $usertoprocess=$user; //$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project if ($id) { $project->fetch($id); $project->fetch_thirdparty(); } $onlyopened=1; // or -1 $tasksarray=$taskstatic->getTasksArray(0,0,($project->id?$project->id:$projectsListId),$socid,0,'',$onlyopened); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later. $projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess,0,($project->id?$project->id:$projectsListId),0); $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$usertoprocess,($project->id?$project->id:$projectsListId),0); //var_dump($tasksarray); //var_dump($projectsrole); //var_dump($taskrole); llxHeader("",$title,"",'','','',array('/core/js/timesheet.js')); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num); $startdayarray=dol_get_first_day_week($day, $month, $year); $prev = $startdayarray; $prev_year = $prev['prev_year']; $prev_month = $prev['prev_month']; $prev_day = $prev['prev_day']; $first_day = $prev['first_day']; $first_month= $prev['first_month']; $first_year = $prev['first_year']; $week = $prev['week']; $day = (int) $day; $next = dol_get_next_week($first_day, $week, $first_month, $first_year); $next_year = $next['year']; $next_month = $next['month']; $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) $firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year); $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); $tmpday = $first_day; // Show navigation bar $nav ="".img_previous($langs->trans("Previous"))."\n"; $nav.=" ".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week; $nav.=" \n"; $nav.="".img_next($langs->trans("Next"))."\n"; $nav.="   (".$langs->trans("Today").")"; $picto='calendarweek'; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; $head=project_timesheet_prepare_head($mode); dol_fiche_head($head, 'inputperweek', '', 0, 'task'); // Show description of content if ($mine) print $langs->trans("MyTasksDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').'

'; else { if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').'

'; else print $langs->trans("ProjectsPublicTaskDesc").($onlyopened?' '.$langs->trans("AlsoOnlyOpenedProject"):'').'

'; } print "\n"; // Filter on user /* dol_fiche_head(''); print ''; print ''; print '
'.$langs->trans("User").''; if ($mine) print $user->getLoginUrl(1); print '
'; dol_fiche_end(); */ // Filter on user /* dol_fiche_head(''); print ''; print ''; print '
'.$langs->trans("User").''; if ($mine) print $user->getLoginUrl(1); print '
'; dol_fiche_end(); */ print '
'.$nav.'
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; if ($usertoprocess->id == $user->id) print ''; else print ''; $startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); for($i=0;$i<7;$i++) { print ''; } print "\n"; // By default, we can edit only tasks we are assigned to $restricteditformytask=(empty($conf->global->PROJECT_TIME_ON_ALL_TASKS_MY_PROJECTS)?1:0); if (count($tasksarray) > 0) { $j=0; projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask); print ''; } else { print ''; } print "
'.$langs->trans("Project").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.dol_print_date($startday + ($i * 3600 * 24), '%a').'
'.dol_print_date($startday + ($i * 3600 * 24), 'day').'
'.$langs->trans("Total").'
 
 
 
 
 
 
 
'.$langs->trans("NoTasks").'
"; print ''."\n"; print ''."\n"; dol_fiche_end(); print '
'; print ''; print '
'; print '
'."\n\n"; $modeinput='hours'; print ''; llxFooter(); $db->close();