Fix: management of time spent in task card

Fix: user rights
This commit is contained in:
Regis Houssin 2010-02-26 08:45:22 +00:00
parent f480baa65e
commit 1f52da3e99
4 changed files with 147 additions and 86 deletions

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
@ -415,7 +415,8 @@ if ($socid > 0)
}
$db->free($resql);
}
else {
else
{
dol_print_error($db);
}
print "</table>";
@ -463,7 +464,8 @@ if ($socid > 0)
}
$db->free($resql);
}
else {
else
{
dol_print_error($db);
}
print "</table>";
@ -520,7 +522,8 @@ if ($socid > 0)
}
$db->free($resql);
}
else {
else
{
dol_print_error($db);
}
print "</table>";
@ -556,15 +559,16 @@ if ($socid > 0)
{
$objp = $db->fetch_object($resql);
print "<tr $bc[$var]>";
print '<td nowrap><a href="'.DOL_URL_ROOT."/fichinter/fiche.php?id=".$objp->id."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."</a>\n";
print "</td><td align=\"right\">".dol_print_date($objp->di,'day')."</td>\n";
print '<td nowrap><a href="'.DOL_URL_ROOT.'/fichinter/fiche.php?id='.$objp->id.'">'.img_object($langs->trans("ShowPropal"),"propal").' '.$objp->ref.'</a>'."\n";
print '</td><td align="right">'.dol_print_date($objp->di,"day").'</td>'."\n";
print '</tr>';
$var=!$var;
$i++;
}
$db->free($resql);
}
else {
else
{
dol_print_error($db);
}
print "</table>";
@ -573,34 +577,57 @@ if ($socid > 0)
/*
* Last linked projects
*/
// TODO remplacer par une fonction
if ($conf->projet->enabled && $user->rights->projet->lire)
{
print '<table class="noborder" width=100%>';
$sql = "SELECT p.rowid,p.title,p.ref,".$db->pdate("p.dateo")." as do";
$sql = "SELECT p.rowid,p.title,p.ref,p.public,".$db->pdate("p.dateo")." as do";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= " WHERE p.fk_soc = $objsoc->id";
$sql .= " ORDER BY p.dateo DESC";
$result=$db->query($sql);
if ($result) {
if ($result)
{
$num = $db->num_rows($result);
if ($num > 0)
{
require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php");
$projectstatic = new Project($db);
print '<tr class="liste_titre">';
print '<td colspan="3"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastProjects",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/projet/liste.php?socid='.$objsoc->id.'">'.$langs->trans("AllProjects").' ('.$num.')</td></tr></table></td>';
print '</tr>';
$var=true;
$i = 0 ;
$num = $db->num_rows($result);
if ($num > 0) {
print '<tr class="liste_titre">';
print '<td colspan="2"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastProjects",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/projet/liste.php?socid='.$objsoc->id.'">'.$langs->trans("AllProjects").' ('.$num.')</td></tr></table></td>';
print '</tr>';
}
while ($i < $num && $i < $MAXLIST) {
while ($i < $num && $i < $MAXLIST)
{
$obj = $db->fetch_object($result);
$projectstatic->fetch($obj->rowid);
// To verify role of users
$userAccess = $projectstatic->restrictedProjectArea($user,1);
if ($user->rights->projet->lire && $userAccess > 0)
{
$var = !$var;
print "<tr $bc[$var]>";
print '<td><a href="../projet/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowProject"),"project")." ".$obj->title.'</a></td>';
print "<td align=\"right\">".$obj->ref ."</td></tr>";
// Ref
print '<td><a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowProject"),($obj->public?'projectpub':'project'))." ".$obj->ref.'</a></td>';
// Label
print '<td>'.$obj->title.'</td>';
// Date
print '<td align="right">'.dol_print_date($obj->do,"day").'</td>';
print '</tr>';
}
$i++;
}
}
$db->free($result);
}
else
@ -613,6 +640,7 @@ if ($socid > 0)
/*
* Last linked chronodocs
*/
// TODO add function to add an external module
if(!empty($conf->global->MAIN_MODULE_CHRONODOCS) && $user->rights->chronodocs->entries->read)
{
print '<table class="noborder" width=100%>';

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
@ -387,40 +388,60 @@ if ($socid > 0)
}
/*
* Last project
* Last linked projects
*/
// TODO remplacer par une fonction
if ($conf->projet->enabled && $user->rights->projet->lire)
{
print '<table class="noborder" width="100%">';
print '<table class="noborder" width=100%>';
$sql = "SELECT p.rowid,p.title,p.ref,".$db->pdate("p.dateo")." as do";
$sql = "SELECT p.rowid,p.title,p.ref,p.public,".$db->pdate("p.dateo")." as do";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= " WHERE p.fk_soc = $societe->id";
$sql .= " ORDER by p.dateo";
$sql .= " ORDER BY p.dateo DESC";
if ( $db->query($sql) )
$result=$db->query($sql);
if ($result)
{
$var=true;
$i = 0 ;
$num = $db->num_rows();
$num = $db->num_rows($result);
if ($num > 0)
{
$tableaushown=1;
require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php");
$projectstatic = new Project($db);
print '<tr class="liste_titre">';
print '<td colspan="2"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastProjects",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/projet/index.php?socid='.$societe->id.'">'.$langs->trans("AllProjects").' ('.$num.')</td></tr></table></td>';
print '<td colspan="3"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastProjects",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/projet/liste.php?socid='.$objsoc->id.'">'.$langs->trans("AllProjects").' ('.$num.')</td></tr></table></td>';
print '</tr>';
}
$var=true;
$i = 0 ;
while ($i < $num && $i < $MAXLIST)
{
$obj = $db->fetch_object();
$obj = $db->fetch_object($result);
$projectstatic->fetch($obj->rowid);
// To verify role of users
$userAccess = $projectstatic->restrictedProjectArea($user,1);
if ($user->rights->projet->lire && $userAccess > 0)
{
$var = !$var;
print "<tr $bc[$var]>";
print '<td><a href="../projet/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowProject"),"project")." ".$obj->title.'</a></td>';
print "<td align=\"right\">".dol_print_date($obj->do,"day") ."</td></tr>";
// Ref
print '<td><a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowProject"),($obj->public?'projectpub':'project'))." ".$obj->ref.'</a></td>';
// Label
print '<td>'.$obj->title.'</td>';
// Date
print '<td align="right">'.dol_print_date($obj->do,"day").'</td>';
print '</tr>';
}
$i++;
}
$db->free();
}
$db->free($result);
}
else
{

View File

@ -647,6 +647,10 @@ class Project extends CommonObject
{
$userAccess = 1;
}
else if ($this->public && $user->rights->projet->lire)
{
$userAccess = 1;
}
else
{
foreach(array('internal','external') as $source)

View File

@ -141,6 +141,8 @@ if ($_GET["id"] > 0)
/*
* Add time spent
*/
if ($user->rights->projet->creer && $userAccess)
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$task->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addtimespent">';
@ -182,6 +184,7 @@ if ($_GET["id"] > 0)
print '</td></tr>';
print '</table></form>';
}
print '<br>';
@ -216,6 +219,11 @@ if ($_GET["id"] > 0)
dol_print_error($db);
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$task->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateline">';
print '<input type="hidden" name="id" value="'.$task->id.'">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="50%">'.$langs->trans("Note").'</td>';
@ -286,7 +294,7 @@ if ($_GET["id"] > 0)
}
print "</table>";
print "</form>";
}
}