New: Increase usability of module project.

This commit is contained in:
Laurent Destailleur 2012-02-15 23:08:20 +01:00
parent 1de2af42b4
commit 9eb92b17ec
16 changed files with 823 additions and 449 deletions

View File

@ -49,6 +49,7 @@ For users:
- New: Default output charset are utf8 into backup tool.
- New: Extra fields support int type.
- New: Add brazilian states.
- New: Increase usability of module project.
- New: Automtic list of documents in ECM module is ok for customers,
suppliers invoice, orders, customers orders, proposals and social contributions.
- Fix: Can use POS module with several concurrent users.

View File

@ -3246,6 +3246,7 @@ class Form
$base=DOL_URL_ROOT.'/core/';
$retstring.=' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJava").'\',\''.$langs->defaultlang.'\');">'.img_object($langs->trans("SelectDate"),'calendarday','class="datecallink"').'</button>';
}
else $retstring.='<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"),'calendarday','class="datecallink"').'</button>';
$retstring.='<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n";
$retstring.='<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
@ -3628,21 +3629,21 @@ class Form
* Return a HTML area with the reference of object and a navigation bar for a business object
* To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria.
*
* @param object Object to show
* @param paramid Name of parameter to use to name the id into the URL link
* @param morehtml More html content to output just before the nav bar
* @param shownav Show Condition (navigation is shown if value is 1)
* @param fieldid Nom du champ en base a utiliser pour select next et previous
* @param fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
* @param morehtmlref Code html supplementaire a afficher apres ref
* @param moreparam More param to add in nav link url.
* @return string Portion HTML avec ref + boutons nav
* @param Object $object Object to show
* @param int $paramid Name of parameter to use to name the id into the URL link
* @param string $morehtml More html content to output just before the nav bar
* @param int $shownav Show Condition (navigation is shown if value is 1)
* @param int $fieldid Nom du champ en base a utiliser pour select next et previous
* @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
* @param string $morehtmlref Code html supplementaire a afficher apres ref
* @param string $moreparam More param to add in nav link url.
* @return tring Portion HTML avec ref + boutons nav
*/
function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='')
{
$ret='';
//print "$paramid,$morehtml,$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam";
//print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam";
$object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid);
$previous_ref = $object->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'">'.img_previous().'</a>':'';
$next_ref = $object->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'">'.img_next().'</a>':'';
@ -3653,14 +3654,17 @@ class Form
}
$ret.=$object->$fieldref;
if ($morehtmlref) {
if ($morehtmlref)
{
$ret.=' '.$morehtmlref;
}
if ($morehtml) {
if ($morehtml)
{
$ret.='</td><td class="nobordernopadding" align="right">'.$morehtml;
}
if ($shownav && ($previous_ref || $next_ref)) {
if ($shownav && ($previous_ref || $next_ref))
{
$ret.='</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td>';
$ret.='<td class="nobordernopadding" align="center" width="20">'.$next_ref;
}

View File

@ -111,17 +111,17 @@ function task_prepare_head($object)
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'task';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');;
$head[$h][1] = $langs->trans("TaskRessourceLinks");
$head[$h][2] = 'contact';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');;
$head[$h][1] = $langs->trans("TimeSpent");
$head[$h][2] = 'time';
$h++;
@ -132,7 +132,7 @@ function task_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'task');
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');;
/*$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
$listoffiles=dol_dir_list($filesdir,'files',1);
@ -141,7 +141,7 @@ function task_prepare_head($object)
$head[$h][2] = 'document';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');;
$head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note';
$h++;
@ -255,118 +255,6 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlen
}
/**
* Output a task line
*
* @param string &$inc ?
* @param string $parent ?
* @param Object $lines ?
* @param int &$level ?
* @param string &$projectsrole ?
* @param string &$tasksrole ?
* @param int $mytask 0 or 1 to enable only if task is a task i am affected to
* @return $inc
*/
function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mytask=0)
{
global $user, $bc, $langs;
global $form, $projectstatic, $taskstatic;
$lastprojectid=0;
$var=true;
$numlines=count($lines);
for ($i = 0 ; $i < $numlines ; $i++)
{
if ($parent == 0) $level = 0;
if ($lines[$i]->fk_parent == $parent)
{
// Break on a new project
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
$var = !$var;
$lastprojectid=$lines[$i]->fk_project;
}
print "<tr ".$bc[$var].">\n";
// Project
print "<td>";
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
$projectstatic->public=$lines[$i]->public;
$projectstatic->label=$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project];
print $projectstatic->getNomUrl(1);
print "</td>";
// Ref
print '<td>';
$taskstatic->id=$lines[$i]->id;
$taskstatic->ref=$lines[$i]->id;
print $taskstatic->getNomUrl(1);
print '</td>';
// Label task
print "<td>";
for ($k = 0 ; $k < $level ; $k++)
{
print "&nbsp;&nbsp;&nbsp;";
}
print $lines[$i]->label;
print "</td>\n";
// Time spent
print '<td align="right">';
if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all');
else print '--:--';
print "</td>\n";
$disabledproject=1;$disabledtask=1;
//print "x".$lines[$i]->fk_project;
//var_dump($lines[$i]);
//var_dump($projectsrole[$lines[$i]->fk_project]);
// If at least one role for project
if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
{
$disabledproject=0;
$disabledtask=0;
}
// If mytask and no role on task
if ($mytask && empty($tasksrole[$lines[$i]->id]))
{
$disabledtask=1;
}
print '<td nowrap="nowrap">';
print $form->select_date('',$lines[$i]->id,'','','',"addtime",1,0,1,$disabledtask);
print '&nbsp;&nbsp;&nbsp;';
print $form->select_duration($lines[$i]->id,'',$disabledtask);
print '&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">';
if ($disabledtask) print '('.$langs->trans("TaskIsNotAffectedToYou").')';
if ((! $lines[$i]->public) && $disabledproject) print '('.$langs->trans("YouAreNotContactOfProject").')';
print '</td>';
print "<td>&nbsp;";
print '</td>';
print "</tr>\n";
$inc++;
$level++;
if ($lines[$i]->id) projectLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mytask);
$level--;
}
else
{
//$level--;
}
}
return $inc;
}
/**
* Show task lines with a particular parent
*
@ -379,7 +267,7 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr
* @param int &$taskrole Array of roles of user for each tasks
* @param int $projectsListId List of id of project allowed to user (separated with comma)
*/
function projectLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='')
function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='')
{
global $user, $bc, $langs;
global $projectstatic, $taskstatic;
@ -463,14 +351,14 @@ function projectLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$ta
$taskstatic->id=$lines[$i]->id;
$taskstatic->ref=$lines[$i]->id;
$taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:'');
print $taskstatic->getNomUrl(1);
print $taskstatic->getNomUrl(1,($showproject?'':'withproject'));
}
print '</td>';
// Title of task
print "<td>";
if ($showlineingray) print '<i>';
else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'">';
else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">';
for ($k = 0 ; $k < $level ; $k++)
{
print "&nbsp; &nbsp; &nbsp;";
@ -480,6 +368,16 @@ function projectLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$ta
else print '</a>';
print "</td>\n";
// Date start
print '<td align="center">';
print dol_print_date($lines[$i]->date_start,'day');
print '</td>';
// Date end
print '<td align="center">';
print dol_print_date($lines[$i]->date_end,'day');
print '</td>';
// Progress
print '<td align="right">';
print $lines[$i]->progress.' %';
@ -488,7 +386,7 @@ function projectLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$ta
// Time spent
print '<td align="right">';
if ($showlineingray) print '<i>';
else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">';
if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all');
else print '--:--';
if ($showlineingray) print '</i>';
@ -500,7 +398,7 @@ function projectLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$ta
if (! $showlineingray) $inc++;
$level++;
if ($lines[$i]->id) projectLines($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId);
if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId);
$level--;
$total += $lines[$i]->duration;
}
@ -517,6 +415,8 @@ function projectLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$ta
if ($showproject) print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td align="right" nowrap="nowrap" class="liste_total">'.convertSecondToTime($total).'</td></tr>';
}
@ -524,6 +424,133 @@ function projectLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$ta
}
/**
* Output a task line
*
* @param string &$inc ?
* @param string $parent ?
* @param Object $lines ?
* @param int &$level ?
* @param string &$projectsrole ?
* @param string &$tasksrole ?
* @param int $mytask 0 or 1 to enable only if task is a task i am affected to
* @return $inc
*/
function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mytask=0)
{
global $user, $bc, $langs;
global $form, $projectstatic, $taskstatic;
$lastprojectid=0;
$var=true;
$numlines=count($lines);
for ($i = 0 ; $i < $numlines ; $i++)
{
if ($parent == 0) $level = 0;
if ($lines[$i]->fk_parent == $parent)
{
// Break on a new project
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
$var = !$var;
$lastprojectid=$lines[$i]->fk_project;
}
print "<tr ".$bc[$var].">\n";
// Project
print "<td>";
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
$projectstatic->public=$lines[$i]->public;
$projectstatic->label=$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project];
print $projectstatic->getNomUrl(1);
print "</td>";
// Ref
print '<td>';
$taskstatic->id=$lines[$i]->id;
$taskstatic->ref=$lines[$i]->id;
print $taskstatic->getNomUrl(1);
print '</td>';
// Label task
print "<td>";
for ($k = 0 ; $k < $level ; $k++)
{
print "&nbsp;&nbsp;&nbsp;";
}
print $lines[$i]->label;
print "</td>\n";
// Date start
print '<td align="center">';
print dol_print_date($lines[$i]->date_start,'day');
print '</td>';
// Date end
print '<td align="center">';
print dol_print_date($lines[$i]->date_end,'day');
print '</td>';
// Progress
print '<td align="right">';
print $lines[$i]->progress.' %';
print '</td>';
// Time spent
print '<td align="right">';
if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all');
else print '--:--';
print "</td>\n";
$disabledproject=1;$disabledtask=1;
//print "x".$lines[$i]->fk_project;
//var_dump($lines[$i]);
//var_dump($projectsrole[$lines[$i]->fk_project]);
// If at least one role for project
if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
{
$disabledproject=0;
$disabledtask=0;
}
// If mytask and no role on task
if ($mytask && empty($tasksrole[$lines[$i]->id]))
{
$disabledtask=1;
}
print '<td nowrap="nowrap">';
$s =$form->select_date('',$lines[$i]->id,'','','',"addtime",1,0,1,$disabledtask);
$s.='&nbsp;&nbsp;&nbsp;';
$s.=$form->select_duration($lines[$i]->id,'',$disabledtask);
$s.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">';
print $s;
print '</td>';
print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou"));
print '</td>';
print "</tr>\n";
$inc++;
$level++;
if ($lines[$i]->id) projectLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mytask);
$level--;
}
else
{
//$level--;
}
}
return $inc;
}
/**
* Search in task lines with a particular parent if there is a task for a particular user (in taskrole)
*

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 François Legastelois <flegastelois@teclib.com>
*
@ -32,7 +32,9 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
$langs->load('projects');
$action=GETPOST('action');
$mode=GETPOST("mode");
$id=GETPOST('id');
$mine=0;
if ($mode == 'mine') $mine=1;
@ -50,7 +52,7 @@ $result = restrictedArea($user, 'projet', $projectid);
* Actions
*/
if ($_POST["action"] == 'addtime' && $user->rights->projet->creer)
if ($action == 'addtime' && $user->rights->projet->creer)
{
$task = new Task($db);
@ -83,7 +85,7 @@ if ($_POST["action"] == 'addtime' && $user->rights->projet->creer)
$task->addTimeSpent($user);
// header to avoid submit twice on back
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$projectid);
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$projectid.($mode?'&mode='.$mode:''));
exit;
}
else
@ -110,9 +112,9 @@ llxHeader("",$title,"");
//$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,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 ($_GET["id"])
if ($id)
{
$project->fetch($_GET["id"]);
$project->fetch($id);
$project->societe->fetch($project->societe->id);
}
@ -133,21 +135,24 @@ dol_htmloutput_mesg($mesg);
print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addtime">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Project").'</td>';
print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="center">'.$langs->trans("DateStart").'</td>';
print '<td align="center">'.$langs->trans("DateEnd").'</td>';
print '<td align="right">'.$langs->trans("Progress").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print '<td colspan="2">'.$langs->trans("AddDuration").'</td>';
print "</tr>\n";
projectLinesb($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine);
print '</form>';
print "</table>";
print '</div>';
print '</form>';
llxFooter();

View File

@ -421,7 +421,7 @@ class Task extends CommonObject
$result='';
$lien = '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$this->id.($option=='withproject'?'&withproject=1':'').'">';
$lienfin='</a>';
$picto='projecttask';
@ -784,7 +784,7 @@ class Task extends CommonObject
function updateTimeSpent($user, $notrigger=0)
{
global $conf,$langs;
$error=0;
$ret = 0;

View File

@ -144,7 +144,7 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_
// Define percent
$percent = $task['task_percent_complete']?$task['task_percent_complete']:0;
// Link
$link=DOL_URL_ROOT.'/projet/tasks/task.php?id='.$task["task_id"];
$link=DOL_URL_ROOT.'/projet/tasks/task.php?withproject=1&id='.$task["task_id"];
// Name
$name=$task['task_name'];
for($i=0; $i < $level; $i++) { $name=' &nbsp; &nbsp; '.$name; }

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -40,8 +40,6 @@ $socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id;
$result = restrictedArea($user, 'projet', $id);
$userAccess=0;
$langs->load("users");
$langs->load("projects");
@ -50,11 +48,20 @@ $langs->load("projects");
* Actions
*/
// None
/*
* View
*/
$form=new Form($db);
$formother=new FormOther($db);
$userstatic=new User($db);
$companystatic=new Societe($db);
$task = new Task($db);
$object = new Project($db);
$arrayofcss=array('/includes/jsgantt/jsgantt.css');
if (! empty($conf->use_javascript_ajax))
@ -65,104 +72,95 @@ if (! empty($conf->use_javascript_ajax))
);
}
$form=new Form($db);
$formother=new FormOther($db);
$help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
llxHeader("",$langs->trans("Tasks"),$help_url,'',0,0,$arrayofjs,$arrayofcss);
$task = new Task($db);
if ($id > 0 || ! empty($ref))
{
$project = new Project($db);
$project->fetch($id,$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,'read');
//$userAccess = $object->restrictedProjectArea($user,'read');
$userWrite = $object->restrictedProjectArea($user,'write');
//$userDelete = $object->restrictedProjectArea($user,'delete');
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
$tab='gantt';
$head=project_prepare_head($object);
dol_fiche_head($head, $tab, $langs->trans("Project"),0,($object->public?'projectpub':'project'));
$param=($_REQUEST["mode"]=='mine'?'&mode=mine':'');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td>';
// Define a complementary filter for search of next/prev ref.
$objectsListId = $object->getProjectsAuthorizedForUser($user,$mine,1);
$object->next_prev_filter=" rowid in (".$objectsListId.")";
print $form->showrefnav($object,'ref','',1,'ref','ref','',$param);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
else print '&nbsp;';
print '</td>';
print '</tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($object->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
print '</table>';
print '</div>';
}
$userstatic=new User($db);
$companystatic=new Societe($db);
$tab='gantt';
$head=project_prepare_head($project);
dol_fiche_head($head, $tab, $langs->trans("Project"),0,($project->public?'projectpub':'project'));
$param=($_REQUEST["mode"]=='mine'?'&mode=mine':'');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td>';
// 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);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td>';
print '</tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($project->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
print '</table>';
print '</div>';
/*
* Actions
*/
/*
print '<div class="tabsAction">';
if ($user->rights->projet->all->creer || $user->rights->projet->creer)
{
if ($project->public || $userAccess)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$project->id.'&action=create'.$param.'">'.$langs->trans('AddTask').'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>';
}
if ($object->public || $userWrite > 0)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'&action=create'.$param.'&tab=gantt&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans('AddTask').'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>';
}
}
else
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NoPermission").'">'.$langs->trans('AddTask').'</a>';
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NoPermission").'">'.$langs->trans('AddTask').'</a>';
}
print '</div>';
print '<br>';
*/
// 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=$task->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=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(0,$user,$object->id,0) : '');
//var_dump($tasksarray);
//var_dump($tasksrole);
@ -177,7 +175,6 @@ if (count($tasksarray)>0)
$array_contacts=array();
$tasks=array();
$project_dependencies=array();
$project_id=$project->id;
$taskcursor=0;
foreach($tasksarray as $key => $val)
{
@ -221,7 +218,7 @@ if (count($tasksarray)>0)
$i++;
}
}
if ($s) $tasks[$taskcursor]['task_resources']='<a href="'.DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$val->id.'" title="'.dol_escape_htmltag($s).'">'.$langs->trans("List").'</a>';
if ($s) $tasks[$taskcursor]['task_resources']='<a href="'.DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$val->id.'&withproject=1" title="'.dol_escape_htmltag($s).'">'.$langs->trans("List").'</a>';
//print "xxx".$val->id.$tasks[$taskcursor]['task_resources'];
$taskcursor++;
}
@ -246,7 +243,8 @@ else
print $langs->trans("NoTasks");
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -27,7 +27,9 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php");
$langs->load('projects');
$id = isset($_GET["id"])?$_GET["id"]:'';
$action=GETPOST('action');
$id = GETPOST('id');
$ref= GETPOST('ref');
$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
@ -43,7 +45,7 @@ $result = restrictedArea($user, 'projet', $id);
/* Actions */
/******************************************************************************/
if ($_POST["action"] == 'update_public' && $user->rights->projet->creer)
if ($action == 'update_public' && $user->rights->projet->creer)
{
$project = new Project($db);
$project->fetch($_GET['id']);
@ -62,7 +64,7 @@ if ($_POST["action"] == 'update_public' && $user->rights->projet->creer)
}
}
if ($_POST['action'] == 'update_private' && $user->rights->projet->creer)
if ($action == 'update_private' && $user->rights->projet->creer)
{
$project = new Project($db);
$project->fetch($_GET['id']);
@ -86,22 +88,19 @@ if ($_POST['action'] == 'update_private' && $user->rights->projet->creer)
* View
*/
llxHeader();
$help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
llxHeader("",$langs->trans("Tasks"),$help_url);
$form = new Form($db);
$userstatic=new User($db);
$project = new Project($db);
$now=dol_now();
$id = $_GET['id'];
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
{
if ($mesg) print $mesg;
$now=gmmktime();
$project = new Project($db);
if ($project->fetch($id, $ref))
{

View File

@ -111,21 +111,26 @@ if ($action == 'createtask' && $user->rights->projet->creer)
if (! $error)
{
if (empty($projectid))
if (GETPOST('backtopage'))
{
Header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($mode)?'':'?mode='.$mode));
Header("Location: ".GETPOST('backtopage'));
exit;
}
else
else if (empty($projectid))
{
Header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$taskid);
Header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($mode)?'':'?mode='.$mode));
exit;
}
}
}
else
{
if (empty($id))
if (GETPOST('backtopage'))
{
Header("Location: ".GETPOST('backtopage'));
exit;
}
else if (empty($id))
{
// We go back on task list
Header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($mode)?'':'?mode='.$mode));
@ -141,6 +146,7 @@ if ($action == 'createtask' && $user->rights->projet->creer)
$form=new Form($db);
$formother=new FormOther($db);
$taskstatic = new Task($db);
$userstatic=new User($db);
$help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
llxHeader("",$langs->trans("Tasks"),$help_url);
@ -155,10 +161,57 @@ if ($id > 0 || ! empty($ref))
$userWrite = $object->restrictedProjectArea($user,'write');
//$userDelete = $object->restrictedProjectArea($user,'delete');
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
$tab=GETPOST('tab')?GETPOST('tab'):'tasks';
$head=project_prepare_head($object);
dol_fiche_head($head, $tab, $langs->trans("Project"),0,($object->public?'projectpub':'project'));
$param=($mode=='mine'?'&mode=mine':'');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
$object->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
}
print $form->showrefnav($object,'ref','',1,'ref','ref','',$param);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
else print '&nbsp;';
print '</td>';
print '</tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($object->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
print '</table>';
dol_fiche_end();
}
if ($action == 'create' && $user->rights->projet->creer && (empty($object->societe->id) || $userAccess > 0))
if ($action == 'create' && $user->rights->projet->creer && (empty($object->societe->id) || $userWrite > 0))
{
if ($id > 0 || ! empty($ref)) print '<br>';
print_fiche_titre($langs->trans("NewTask"));
dol_htmloutput_errors($mesg);
@ -166,6 +219,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="createtask">';
print '<input type="hidden" name="backtopage" value="'.GETPOST('backtopage').'">';
if (! empty($object->id)) print '<input type="hidden" name="id" value="'.$object->id.'">';
if (! empty($mode)) print '<input type="hidden" name="mode" value="'.$mode.'">';
@ -221,50 +275,6 @@ else
/*
* Fiche projet en mode visu
*/
$userstatic=new User($db);
$tab='tasks';
$head=project_prepare_head($object);
dol_fiche_head($head, $tab, $langs->trans("Project"),0,($object->public?'projectpub':'project'));
$param=($mode=='mine'?'&mode=mine':'');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
$object->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
}
print $form->showrefnav($object,'ref','',1,'ref','ref','',$param);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
else print '&nbsp;';
print '</td>';
print '</tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($object->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
print '</table>';
print '</div>';
/*
* Actions
@ -275,7 +285,7 @@ else
{
if ($object->public || $userWrite > 0)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create'.$param.'">'.$langs->trans('AddTask').'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans('AddTask').'</a>';
}
else
{
@ -322,6 +332,8 @@ else
// print '<td>'.$langs->trans("Project").'</td>';
print '<td width="80">'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="center">'.$langs->trans("DateStart").'</td>';
print '<td align="center">'.$langs->trans("DateEnd").'</td>';
print '<td align="right">'.$langs->trans("Progress").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\n";
@ -329,7 +341,7 @@ else
{
// Show all lines in taskarray (recursive function to go down on tree)
$j=0;
$nboftaskshown=projectLines($j, 0, $tasksarray, $level, true, 0, $tasksrole);
$nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole);
}
else
{

View File

@ -34,6 +34,9 @@ $langs->load("projects");
$langs->load("companies");
$taskid = isset($_GET["id"])?$_GET["id"]:'';
$id = GETPOST('id');
$ref= GETPOST('ref');
$action=GETPOST('action');
// Security check
$socid=0;
@ -47,7 +50,7 @@ if (!$user->rights->projet->lire) accessforbidden();
*/
// Add new contact
if ($_POST["action"] == 'addcontact' && $user->rights->projet->creer)
if ($action == 'addcontact' && $user->rights->projet->creer)
{
$result = 0;
@ -79,7 +82,7 @@ if ($_POST["action"] == 'addcontact' && $user->rights->projet->creer)
}
// bascule du statut d'un contact
if ($_GET["action"] == 'swapstatut' && $user->rights->projet->creer)
if ($action == 'swapstatut' && $user->rights->projet->creer)
{
$task = new Task($db);
if ($task->fetch($taskid))
@ -93,7 +96,7 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->projet->creer)
}
// Efface un contact
if ($_GET["action"] == 'deleteline' && $user->rights->projet->creer)
if ($action == 'deleteline' && $user->rights->projet->creer)
{
$task = new Task($db);
$task->fetch($taskid);
@ -122,6 +125,7 @@ $formcompany = new FormCompany($db);
$contactstatic = new Contact($db);
$userstatic = new User($db);
$project = new Project($db);
$task = new Task($db);
/* *************************************************************************** */
@ -129,23 +133,70 @@ $project = new Project($db);
/* Mode vue et edition */
/* */
/* *************************************************************************** */
dol_htmloutput_mesg($mesg);
$id = $_GET['id'];
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
{
$task = new Task($db);
if ( $task->fetch($id,$ref) > 0)
if ($task->fetch($id,$ref) > 0)
{
$result=$project->fetch($task->fk_project);
if (! empty($project->socid)) $project->societe->fetch($project->socid);
$userWrite = $project->restrictedProjectArea($user,'write');
if (GETPOST('withproject'))
{
// Tabs for project
$tab='tasks';
$head=project_prepare_head($project);
dol_fiche_head($head, $tab, $langs->trans("Project"),0,($project->public?'projectpub':'project'));
$param=($mode=='mine'?'&mode=mine':'');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,0);
$project->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
}
print $form->showrefnav($project,'ref','',1,'ref','ref','',$param);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td>';
print '</tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($project->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
print '</table>';
dol_fiche_end();
print '<br>';
}
// To verify role of users
//$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
//$userAccess = $project->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
//$arrayofuseridoftask=$task->getListContactId('internal');
dol_htmloutput_mesg($mesg);
$head = task_prepare_head($task);
dol_fiche_head($head, 'contact', $langs->trans("Task"), 0, 'projecttask');
@ -155,20 +206,25 @@ if ($id > 0 || ! empty($ref))
*/
print '<table class="border" width="100%">';
//$linkback="<a href=\"".$_SERVER["PHP_SELF"]."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder\">".$langs->trans("BackToList")."</a>";
$param=(GETPOST('withproject')?'&withproject=1':'');
$linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$project->id.'">'.$langs->trans("BackToList").'</a>':'';
// Ref
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">';
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
print $form->showrefnav($task,'id','',1,'rowid','ref','','');
if (! GETPOST('withproject') || empty($project->id))
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
}
else $task->next_prev_filter=" fk_projet = ".$project->id;
print $form->showrefnav($task,'id',$linkback,1,'rowid','ref','',$param);
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$task->label.'</td></tr>';
// Project
print '<tr><td>'.$langs->trans("Project").'</td><td>';
/*print '<tr><td>'.$langs->trans("Project").'</td><td>';
print $project->getNomUrl(1);
print '</td></tr>';
@ -178,10 +234,11 @@ if ($id > 0 || ! empty($ref))
if ($project->societe->id > 0) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
*/
print "</table>";
print '</div>';
dol_fiche_end();
/*
* Lignes de contacts
@ -192,7 +249,7 @@ if ($id > 0 || ! empty($ref))
* Ajouter une ligne de contact
* Non affiche en mode modification de ligne
*/
if ($_GET["action"] != 'editline' && $user->rights->projet->creer)
if ($action != 'editline' && $user->rights->projet->creer)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>';
@ -271,8 +328,6 @@ if ($id > 0 || ! empty($ref))
print "</form>";
}
print '<tr><td colspan="6">&nbsp;</td></tr>';
}
// Liste des contacts lies
@ -376,7 +431,8 @@ if ($id > 0 || ! empty($ref))
}
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -124,81 +124,143 @@ if ($action=='delete')
$form = new Form($db);
$project = new Project($db);
$task = new Task($db);
llxHeader('',$langs->trans('Project'));
if ($id > 0 || ! empty($ref))
{
$project = new Project($db);
$project->fetch($task->fk_project);
if ($task->fetch($id,$ref) >= 0)
{
$result=$project->fetch($task->fk_project);
if (! empty($project->socid)) $project->societe->fetch($project->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');
$userWrite = $project->restrictedProjectArea($user,'write');
$head = task_prepare_head($task);
dol_fiche_head($head, 'document', $langs->trans("Task"), 0, 'projecttask');
if (GETPOST('withproject'))
{
// Tabs for project
$tab='tasks';
$head=project_prepare_head($project);
dol_fiche_head($head, $tab, $langs->trans("Project"),0,($project->public?'projectpub':'project'));
// Files list constructor
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
$param=($mode=='mine'?'&mode=mine':'');
print '<table class="border" width="100%">';
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td colspan="3">';
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
print $form->showrefnav($task,'id','',1,'rowid','ref','','');
print '</td>';
print '</tr>';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,0);
$project->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
}
print $form->showrefnav($project,'ref','',1,'ref','ref','',$param);
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->label.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
// Project
print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
print $projectstatic->getNomUrl(1);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td>';
print '</tr>';
// Third party
print '<td>'.$langs->trans("Company").'</td><td colspan="3">';
if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($project->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Files infos
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
print "</table>\n";
print "</div>\n";
print '</table>';
if ($mesg) { print $mesg."<br>"; }
dol_fiche_end();
print '<br>';
}
$head = task_prepare_head($task);
dol_fiche_head($head, 'document', $langs->trans("Task"), 0, 'projecttask');
$param=(GETPOST('withproject')?'&withproject=1':'');
$linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$project->id.'">'.$langs->trans("BackToList").'</a>':'';
// Files list constructor
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td colspan="3">';
if (! GETPOST('withproject') || empty($project->id))
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
}
else $task->next_prev_filter=" fk_projet = ".$project->id;
print $form->showrefnav($task,'id',$linkback,1,'rowid','ref','',$param);
print '</td>';
print '</tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->label.'</td></tr>';
// Project
/*print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
print $projectstatic->getNomUrl(1);
print '</td></tr>';
// Third party
print '<td>'.$langs->trans("Company").'</td><td colspan="3">';
if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
*/
// Files infos
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print "</table>\n";
dol_fiche_end();
print '<br>';
dol_htmloutput_mesg($mesg);
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/projet/tasks/document.php?id='.$task->id,'',0,0,$user->rights->projet->creer);
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/projet/tasks/document.php?id='.$task->id,'',0,0,$user->rights->projet->creer);
// List of document
$param='&id='.$task->id;
$formfile->list_of_documents($filearray,$task,'projet',$param,0,dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($task->ref).'/');
// List of document
$param='&id='.$task->id;
$formfile->list_of_documents($filearray,$task,'projet',$param,0,dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($task->ref).'/');
}
}
else
{
Header('Location: index.php');
exit;
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -32,6 +32,8 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
$langs->load('projects');
$langs->load('users');
$id=GETPOST('id');
// Security check
$socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id;
@ -50,18 +52,18 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
* View
*/
$form=new Form($db);
$projectstatic = new Project($db);
$taskstatic = new Task($db);
$title=$langs->trans("Activities");
if ($mine) $title=$langs->trans("MyActivities");
llxHeader("",$title,"Projet");
$form=new Form($db);
$projectstatic = new Project($db);
$taskstatic = new Task($db);
if ($_GET["id"])
if ($id)
{
$projectstatic->fetch($_GET["id"]);
$projectstatic->fetch($id);
$projectstatic->societe->fetch($projectstatic->societe->id);
}
@ -89,12 +91,14 @@ print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Project").'</td>';
print '<td width="80">'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="center">'.$langs->trans("DateStart").'</td>';
print '<td align="center">'.$langs->trans("DateEnd").'</td>';
print '<td align="right">'.$langs->trans("Progress").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\n";
// Show all lines in taskarray (recursive function to go down on tree)
$j=0; $level=0;
$nboftaskshown=projectLines($j, 0, $tasksarray, $level, true, 1, $tasksrole, $projectsListId);
$nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 1, $tasksrole, $projectsListId);
print "</table>";
print '</div>';
@ -109,7 +113,8 @@ if ($user->rights->projet->creer)
print '</div>';
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -28,7 +28,11 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php");
$langs->load('projects');
$id = isset($_GET["id"])?$_GET["id"]:'';
$action=GETPOST('action');
$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$id = GETPOST('id');
$ref= GETPOST('ref');
// Security check
$socid=0;
@ -42,10 +46,10 @@ if (!$user->rights->projet->lire) accessforbidden();
/* Actions */
/******************************************************************************/
if ($_POST["action"] == 'update_public' && $user->rights->projet->creer)
if ($action == 'update_public' && $user->rights->projet->creer)
{
$task = new Task($db);
$task->fetch($_GET['id']);
$task->fetch($id);
$db->begin();
@ -61,10 +65,10 @@ if ($_POST["action"] == 'update_public' && $user->rights->projet->creer)
}
}
if ($_POST['action'] == 'update_private' && $user->rights->projet->creer)
if ($action == 'update_private' && $user->rights->projet->creer)
{
$task = new Task($db);
$task->fetch($_GET['id']);
$task->fetch($id);
$db->begin();
@ -89,60 +93,108 @@ llxHeader();
$form = new Form($db);
$project = new Project($db);
$task = new Task($db);
$userstatic = new User($db);
$now=dol_now();
$id = $_GET['id'];
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
{
if ($mesg) print $mesg;
$now=gmmktime();
$task = new Task($db);
$projectstatic = new Project($db);
$userstatic = new User($db);
if ($task->fetch($id, $ref))
if ($task->fetch($id, $ref) > 0)
{
$result=$projectstatic->fetch($task->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
$result=$project->fetch($task->fk_project);
if (! empty($project->socid)) $project->societe->fetch($project->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');
$userWrite = $project->restrictedProjectArea($user,'write');
if (GETPOST('withproject'))
{
// Tabs for project
$tab='tasks';
$head=project_prepare_head($project);
dol_fiche_head($head, $tab, $langs->trans("Project"),0,($project->public?'projectpub':'project'));
$param=($mode=='mine'?'&mode=mine':'');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,0);
$project->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
}
print $form->showrefnav($project,'ref','',1,'ref','ref','',$param);
print '</td></tr>';
// Project
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
// Company
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td>';
print '</tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($project->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
print '</table>';
dol_fiche_end();
print '<br>';
}
$head = task_prepare_head($task);
dol_fiche_head($head, 'note', $langs->trans('Task'), 0, 'projecttask');
print '<table class="border" width="100%">';
//$linkback="<a href=\"".$_SERVER["PHP_SELF"]."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder\">".$langs->trans("BackToList")."</a>";
$param=(GETPOST('withproject')?'&withproject=1':'');
$linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$project->id.'">'.$langs->trans("BackToList").'</a>':'';
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
print $form->showrefnav($task,'id','',1,'rowid','ref','','');
if (! GETPOST('withproject') || empty($project->id))
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
}
else $task->next_prev_filter=" fk_projet = ".$project->id;
print $form->showrefnav($task,'id',$linkback,1,'rowid','ref','',$param);
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$task->label.'</td></tr>';
// Project
print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
print $projectstatic->getNomUrl(1);
/*print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
print $project->getNomUrl(1);
print '</td></tr>';
// Third party
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if ($projectstatic->societe->id > 0) print $projectstatic->societe->getNomUrl(1);
if ($project->societe->id > 0) print $project->societe->getNomUrl(1);
else print'&nbsp;';
print '</td></tr>';
*/
// Note publique
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
if ($action == 'edit')
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$task->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -180,7 +232,7 @@ if ($id > 0 || ! empty($ref))
print "</table>";
print '</div>';
dol_fiche_end();
/*
* Actions
@ -199,7 +251,8 @@ if ($id > 0 || ! empty($ref))
print '</div>';
}
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -31,6 +31,10 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
$taskid = GETPOST("id");
$taskref = GETPOST("ref");
$id = GETPOST('id');
$ref= GETPOST('ref');
$action=GETPOST('action');
$withproject=GETPOST('withproject');
// Security check
$socid=0;
@ -42,7 +46,7 @@ if (!$user->rights->projet->lire) accessforbidden();
* Actions
*/
if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
{
$error=0;
@ -54,7 +58,7 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->projet-
if (! $error)
{
$task = new Task($db);
$task->fetch($_POST["id"]);
$task->fetch($id);
$tmparray=explode('_',$_POST['task_parent']);
$task_parent=$tmparray[1];
@ -74,14 +78,14 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->projet-
else
{
$taskid=$_POST["id"];
$_GET['action']='edit';
$action='edit';
}
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->projet->supprimer)
if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->projet->supprimer)
{
$task = new Task($db);
if ($task->fetch($_GET["id"]) >= 0 )
if ($task->fetch($id) >= 0 )
{
$projet = new Project($db);
$result=$projet->fetch($task->fk_projet);
@ -114,32 +118,104 @@ llxHeader("",$langs->trans("Task"));
$form = new Form($db);
$formother = new FormOther($db);
$project = new Project($db);
$task = new Task($db);
if ($taskid)
{
$task = new Task($db);
$projectstatic = new Project($db);
if ($task->fetch($taskid) >= 0 )
if ($task->fetch($taskid) > 0)
{
$result=$projectstatic->fetch($task->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
$result=$project->fetch($task->fk_project);
if (! empty($project->socid)) $project->societe->fetch($project->socid);
$userWrite = $project->restrictedProjectArea($user,'write');
if (GETPOST('withproject'))
{
// Tabs for project
$tab='tasks';
$head=project_prepare_head($project);
dol_fiche_head($head, $tab, $langs->trans("Project"),0,($project->public?'projectpub':'project'));
$param=($mode=='mine'?'&mode=mine':'');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,0);
$project->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
}
print $form->showrefnav($project,'ref','',1,'ref','ref','',$param);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td>';
print '</tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($project->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
print '</table>';
dol_fiche_end();
print '<br>';
}
/*
* Actions
*/
/*print '<div class="tabsAction">';
if ($user->rights->projet->all->creer || $user->rights->projet->creer)
{
if ($project->public || $userWrite > 0)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create'.$param.'">'.$langs->trans('AddTask').'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'</a>';
}
}
else
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NoPermission").'">'.$langs->trans('AddTask').'</a>';
}
print '</div>';
*/
// To verify role of users
//$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
//$userAccess = $project->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
//$arrayofuseridoftask=$task->getListContactId('internal');
dol_htmloutput_mesg($mesg);
$head=task_prepare_head($task);
dol_fiche_head($head, 'task', $langs->trans("Task"),0,'projecttask');
if ($_GET["action"] == 'edit' && $user->rights->projet->creer)
if ($action == 'edit' && $user->rights->projet->creer)
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="withproject" value="'.$withproject.'">';
print '<input type="hidden" name="id" value="'.$task->id.'">';
print '<table class="border" width="100%">';
@ -153,19 +229,20 @@ if ($taskid)
print '<td><input size="30" name="label" value="'.$task->label.'"></td></tr>';
// Project
print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
print $projectstatic->getNomUrl(1);
/*print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
print $project->getNomUrl(1);
print '</td></tr>';
// Third party
print '<td>'.$langs->trans("Company").'</td><td colspan="3">';
if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1);
if ($project->societe->id) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
*/
// Task parent
print '<tr><td>'.$langs->trans("ChildOfTask").'</td><td>';
print $formother->selectProjectTasks($task->fk_task_parent,$projectstatic->id, 'task_parent', $user->admin?0:1, 0);
print $formother->selectProjectTasks($task->fk_task_parent,$project->id, 'task_parent', $user->admin?0:1, 0);
print '</td></tr>';
// Date start
@ -190,7 +267,7 @@ if ($taskid)
print '</td></tr>';
print '</table>';
print '<center><br>';
print '<input type="submit" class="button" name="update" value="'.$langs->trans("Modify").'"> &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
@ -203,10 +280,12 @@ if ($taskid)
/*
* Fiche tache en mode visu
*/
$param=(GETPOST('withproject')?'&withproject=1':'');
$linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$project->id.'">'.$langs->trans("BackToList").'</a>':'';
if ($_GET["action"] == 'delete')
if ($action == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("DeleteATask"),$langs->trans("ConfirmDeleteATask"),"confirm_delete");
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject,$langs->trans("DeleteATask"),$langs->trans("ConfirmDeleteATask"),"confirm_delete");
if ($ret == 'html') print '<br>';
}
@ -216,9 +295,13 @@ if ($taskid)
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td colspan="3">';
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
print $form->showrefnav($task,'id','',1,'rowid','ref','','');
if (! GETPOST('withproject') || empty($project->id))
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
}
else $task->next_prev_filter=" fk_projet = ".$project->id;
print $form->showrefnav($task,'id',$linkback,1,'rowid','ref','',$param);
print '</td>';
print '</tr>';
@ -226,15 +309,16 @@ if ($taskid)
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->label.'</td></tr>';
// Project
print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
print $projectstatic->getNomUrl(1);
/*print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
print $project->getNomUrl(1);
print '</td></tr>';
// Third party
print '<td>'.$langs->trans("Company").'</td><td colspan="3">';
if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1);
if ($project->societe->id) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
*/
// Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td colspan="3">';
@ -257,12 +341,12 @@ if ($taskid)
print '</td></tr>';
print '</table>';
}
dol_fiche_end();
if ($_GET["action"] != 'edit')
{
/*
@ -273,7 +357,7 @@ if ($taskid)
// Modify
if ($user->rights->projet->creer)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$task->id.'&amp;action=edit">'.$langs->trans('Modify').'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$task->id.'&amp;action=edit&amp;withproject='.$withproject.'">'.$langs->trans('Modify').'</a>';
}
else
{
@ -283,7 +367,7 @@ if ($taskid)
// Delete
if ($user->rights->projet->supprimer && ! $task->hasChildren())
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$task->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$task->id.'&amp;action=delete&amp;withproject='.$withproject.'">'.$langs->trans('Delete').'</a>';
}
else
{
@ -295,7 +379,8 @@ if ($taskid)
}
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
@ -32,6 +32,11 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
$langs->load('projects');
$taskid = isset($_GET["id"])?$_GET["id"]:'';
$id = GETPOST('id');
$ref= GETPOST('ref');
$action=GETPOST('action');
// Security check
$socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id;
@ -41,7 +46,7 @@ if (!$user->rights->projet->lire) accessforbidden();
/*
* Actions
*/
if ($_POST["action"] == 'addtimespent' && $user->rights->projet->creer)
if ($action == 'addtimespent' && $user->rights->projet->creer)
{
$error=0;
@ -83,7 +88,7 @@ if ($_POST["action"] == 'addtimespent' && $user->rights->projet->creer)
}
}
if ($_POST["action"] == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->creer)
if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->creer)
{
$error=0;
@ -122,7 +127,7 @@ if ($_POST["action"] == 'updateline' && ! $_POST["cancel"] && $user->rights->pro
}
}
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == "yes" && $user->rights->projet->creer)
if ($action == 'confirm_delete' && $_REQUEST["confirm"] == "yes" && $user->rights->projet->creer)
{
$task = new Task($db);
$task->fetchTimeSpent($_GET['lineid']);
@ -141,37 +146,80 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == "yes" &&
* View
*/
$project=new Project($db);
$form = new Form($db);
$project = new Project($db);
$task = new Task($db);
llxHeader("",$langs->trans("Task"));
$form = new Form($db);
if ($_GET["id"] > 0)
if ($id > 0 || ! empty($ref))
{
/*
* Fiche projet en mode visu
*/
$task = new Task($db);
$projectstatic = new Project($db);
$userstatic = new User($db);
if ($task->fetch($_GET["id"]) >= 0 )
if ($task->fetch($id,$ref) >= 0)
{
$result=$projectstatic->fetch($task->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
$result=$project->fetch($task->fk_project);
if (! empty($project->socid)) $project->societe->fetch($project->socid);
// To get role of users
//$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
//$arrayofuseridoftask=$task->getListContactId('internal');
$userWrite = $project->restrictedProjectArea($user,'write');
if (GETPOST('withproject'))
{
// Tabs for project
$tab='tasks';
$head=project_prepare_head($project);
dol_fiche_head($head, $tab, $langs->trans("Project"),0,($project->public?'projectpub':'project'));
$param=($mode=='mine'?'&mode=mine':'');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,0);
$project->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
}
print $form->showrefnav($project,'ref','',1,'ref','ref','',$param);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td>';
print '</tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($project->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
print '</table>';
dol_fiche_end();
print '<br>';
}
$head=task_prepare_head($task);
dol_fiche_head($head, 'time', $langs->trans("Task"),0,'projecttask');
if ($mesg) print $mesg.'<br>';
dol_htmloutput_mesg($mesg);
if ($_GET["action"] == 'deleteline')
if ($action == 'deleteline')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&lineid='.$_GET["lineid"],$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1);
if ($ret == 'html') print '<br>';
@ -179,32 +227,41 @@ if ($_GET["id"] > 0)
print '<table class="border" width="100%">';
$param=(GETPOST('withproject')?'&withproject=1':'');
$linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$project->id.'">'.$langs->trans("BackToList").'</a>':'';
// Ref
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td colspan="3">';
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
print $form->showrefnav($task,'id','',1,'rowid','ref','','');
if (! GETPOST('withproject') || empty($project->id))
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
}
else $task->next_prev_filter=" fk_projet = ".$project->id;
print $form->showrefnav($task,'id',$linkback,1,'rowid','ref','',$param);
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->label.'</td></tr>';
// Project
print '<tr><td>'.$langs->trans("Project").'</td><td>';
print $projectstatic->getNomUrl(1);
/*print '<tr><td>'.$langs->trans("Project").'</td><td>';
print $project->getNomUrl(1);
print '</td></tr>';
// Third party
print '<td>'.$langs->trans("Company").'</td><td>';
if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1);
if ($project->societe->id) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
*/
print '</table>';
print '</div>';
dol_fiche_end();
/*
* Add time spent

View File

@ -2285,6 +2285,16 @@ a.cke_dialog_ui_button
height: 72px !important;
}
/* ============================================================================== */
/* JSGantt */
/* ============================================================================== */
div.scroll2 {
width: 582px !important;
}
<?php
if (is_object($db)) $db->close();
?>