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

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * 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> * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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) 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 .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= " WHERE p.fk_soc = $societe->id"; $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; $num = $db->num_rows($result);
$i = 0 ;
$num = $db->num_rows();
if ($num > 0) if ($num > 0)
{ {
$tableaushown=1; require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php");
$projectstatic = new Project($db);
print '<tr class="liste_titre">'; 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>'; print '</tr>';
$var=true;
$i = 0 ;
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]>";
// 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++;
}
} }
while ($i < $num && $i < $MAXLIST) $db->free($result);
{
$obj = $db->fetch_object();
$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>";
$i++;
}
$db->free();
} }
else else
{ {

View File

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

View File

@ -141,47 +141,50 @@ if ($_GET["id"] > 0)
/* /*
* Add time spent * Add time spent
*/ */
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$task->id.'">'; if ($user->rights->projet->creer && $userAccess)
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; {
print '<input type="hidden" name="action" value="addtimespent">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$task->id.'">';
print '<input type="hidden" name="id" value="'.$task->id.'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addtimespent">';
print '<table class="noborder" width="100%">'; print '<input type="hidden" name="id" value="'.$task->id.'">';
print '<tr class="liste_titre">'; print '<table class="noborder" width="100%">';
print '<td width="50%">'.$langs->trans("Note").'</td>';
print '<td>'.$langs->trans("By").'</td>'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>'; print '<td width="50%">'.$langs->trans("Note").'</td>';
print '<td colspan="2">'.$langs->trans("Duration").'</td>'; print '<td>'.$langs->trans("By").'</td>';
print "</tr>\n"; print '<td>'.$langs->trans("Date").'</td>';
print '<td colspan="2">'.$langs->trans("Duration").'</td>';
print '<tr>'; print "</tr>\n";
// Note print '<tr>';
print '<td nowrap="nowrap" width="50%">';
print '<textarea name="timespent_note" cols="80" rows="4"></textarea>'; // Note
print '</td>'; print '<td nowrap="nowrap" width="50%">';
print '<textarea name="timespent_note" cols="80" rows="4"></textarea>';
// Contributor print '</td>';
print '<td nowrap="nowrap">';
print '&nbsp;'; // TODO ajout liste deroulante des participants // Contributor
print '</td>'; print '<td nowrap="nowrap">';
print '&nbsp;'; // TODO ajout liste deroulante des participants
// Date print '</td>';
print '<td nowrap="nowrap">';
print $html->select_date('','time','','','',"timespent_date"); // Date
print '</td>'; print '<td nowrap="nowrap">';
print $html->select_date('','time','','','',"timespent_date");
// Duration print '</td>';
print '<td nowrap="nowrap">';
print '<input size="4" type="text" class="flat" name="timespent_duration" value="">'; // Duration
print '</td>'; print '<td nowrap="nowrap">';
print '<input size="4" type="text" class="flat" name="timespent_duration" value="">';
print '<td>'; print '</td>';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td></tr>'; print '<td>';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</table></form>'; print '</td></tr>';
print '</table></form>';
}
print '<br>'; print '<br>';
@ -216,6 +219,11 @@ if ($_GET["id"] > 0)
dol_print_error($db); 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 '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width="50%">'.$langs->trans("Note").'</td>'; print '<td width="50%">'.$langs->trans("Note").'</td>';
@ -286,7 +294,7 @@ if ($_GET["id"] > 0)
} }
print "</table>"; print "</table>";
print "</form>";
} }
} }