2009-07-28 02:52:34 +02:00
< ? php
2012-04-18 11:16:15 +02:00
/* Copyright ( C ) 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2013-10-30 21:44:04 +01:00
* Copyright ( C ) 2006 - 2013 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2010 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
* Copyright ( C ) 2011 Juanjo Menent < jmenent @ 2 byte . es >
*
* 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 < http :// www . gnu . org / licenses />.
*/
2009-07-28 02:52:34 +02:00
/**
2010-02-28 02:33:12 +01:00
* \file htdocs / projet / tasks / time . php
2012-04-18 11:16:15 +02:00
* \ingroup project
2010-02-28 02:33:12 +01:00
* \brief Page to add new time spent on a task
2013-10-30 21:44:04 +01:00
*/
2009-07-28 02:52:34 +02:00
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2012-08-22 23:11:24 +02:00
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' ;
2009-07-28 02:52:34 +02:00
2010-03-01 20:36:58 +01:00
$langs -> load ( 'projects' );
2012-04-18 11:16:15 +02:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
$action = GETPOST ( 'action' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$withproject = GETPOST ( 'withproject' , 'int' );
$project_ref = GETPOST ( 'project_ref' , 'alpha' );
2012-02-15 23:08:20 +01:00
2010-05-30 14:21:32 +02:00
// Security check
$socid = 0 ;
if ( $user -> societe_id > 0 ) $socid = $user -> societe_id ;
2010-02-10 16:55:29 +01:00
if ( ! $user -> rights -> projet -> lire ) accessforbidden ();
2009-07-28 02:52:34 +02:00
2012-04-18 11:16:15 +02:00
$object = new Task ( $db );
$projectstatic = new Project ( $db );
2010-05-30 14:21:32 +02:00
2009-07-28 02:52:34 +02:00
/*
* Actions
2014-07-17 01:28:01 +02:00
*/
2012-04-18 12:15:14 +02:00
2012-02-15 23:08:20 +01:00
if ( $action == 'addtimespent' && $user -> rights -> projet -> creer )
2010-02-25 10:44:58 +01:00
{
2010-02-28 02:33:12 +01:00
$error = 0 ;
2013-05-15 14:19:16 +02:00
$timespent_durationhour = GETPOST ( 'timespent_durationhour' , 'int' );
$timespent_durationmin = GETPOST ( 'timespent_durationmin' , 'int' );
if ( empty ( $timespent_durationhour ) && empty ( $timespent_durationmin ))
2010-02-28 02:33:12 +01:00
{
2014-03-11 20:38:29 +01:00
setEventMessage ( $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentitiesnoconv ( " Duration " )), 'errors' );
2010-02-28 02:33:12 +01:00
$error ++ ;
}
2010-05-30 22:25:08 +02:00
if ( empty ( $_POST [ " userid " ]))
{
2014-08-07 12:05:42 +02:00
$langs -> load ( " errors " );
setEventMessage ( $langs -> trans ( 'ErrorUserNotAssignedToTask' ), 'errors' );
2010-05-30 22:25:08 +02:00
$error ++ ;
}
2010-02-28 02:33:12 +01:00
if ( ! $error )
2010-02-25 10:44:58 +01:00
{
2012-04-18 11:16:15 +02:00
$object -> fetch ( $id );
2014-07-17 01:28:01 +02:00
$object -> fetch_projet ();
2010-02-25 10:44:58 +01:00
2014-07-17 01:28:01 +02:00
if ( empty ( $object -> projet -> statut ))
2010-02-28 02:33:12 +01:00
{
2014-07-17 01:28:01 +02:00
setEventMessage ( $langs -> trans ( " ProjectMustBeValidatedFirst " ), 'errors' );
$error ++ ;
2010-02-28 02:33:12 +01:00
}
else
{
2014-07-17 01:28:01 +02:00
$object -> timespent_note = $_POST [ " timespent_note " ];
$object -> timespent_duration = $_POST [ " timespent_durationhour " ] * 60 * 60 ; // We store duration in seconds
$object -> timespent_duration += $_POST [ " timespent_durationmin " ] * 60 ; // We store duration in seconds
$object -> timespent_date = dol_mktime ( 12 , 0 , 0 , $_POST [ " timemonth " ], $_POST [ " timeday " ], $_POST [ " timeyear " ]);
$object -> timespent_fk_user = $_POST [ " userid " ];
$result = $object -> addTimeSpent ( $user );
if ( $result >= 0 )
{
setEventMessage ( $langs -> trans ( " RecordSaved " ));
}
else
{
setEventMessage ( $langs -> trans ( $object -> error ), 'errors' );
$error ++ ;
}
2010-02-28 02:33:12 +01:00
}
2010-02-25 10:44:58 +01:00
}
else
{
2012-04-18 11:16:15 +02:00
$action = '' ;
2010-02-25 10:44:58 +01:00
}
}
2012-02-15 23:08:20 +01:00
if ( $action == 'updateline' && ! $_POST [ " cancel " ] && $user -> rights -> projet -> creer )
2010-02-24 11:30:26 +01:00
{
2010-03-01 17:42:02 +01:00
$error = 0 ;
2010-03-02 08:28:59 +01:00
if ( empty ( $_POST [ " new_durationhour " ]) && empty ( $_POST [ " new_durationmin " ]))
2010-03-01 17:42:02 +01:00
{
2014-03-11 20:38:29 +01:00
setEventMessage ( $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentitiesnoconv ( " Duration " )), 'errors' );
2010-03-01 17:42:02 +01:00
$error ++ ;
}
2010-02-28 02:33:12 +01:00
2010-03-01 17:42:02 +01:00
if ( ! $error )
{
2012-04-18 11:16:15 +02:00
$object -> fetch ( $id );
$object -> timespent_id = $_POST [ " lineid " ];
$object -> timespent_note = $_POST [ " timespent_note_line " ];
$object -> timespent_old_duration = $_POST [ " old_duration " ];
$object -> timespent_duration = $_POST [ " new_durationhour " ] * 60 * 60 ; // We store duration in seconds
$object -> timespent_duration += $_POST [ " new_durationmin " ] * 60 ; // We store duration in seconds
$object -> timespent_date = dol_mktime ( 12 , 0 , 0 , $_POST [ " timelinemonth " ], $_POST [ " timelineday " ], $_POST [ " timelineyear " ]);
$object -> timespent_fk_user = $_POST [ " userid_line " ];
$result = $object -> updateTimeSpent ( $user );
2010-03-01 17:42:02 +01:00
if ( $result >= 0 )
{
2014-03-11 20:38:29 +01:00
setEventMessage ( $langs -> trans ( " RecordSaved " ));
2010-03-01 17:42:02 +01:00
}
else
{
2014-03-11 20:38:29 +01:00
setEventMessage ( $langs -> trans ( $object -> error ), 'errors' );
$error ++ ;
2010-03-01 17:42:02 +01:00
}
}
else
{
2012-04-18 11:16:15 +02:00
$action = '' ;
2010-03-01 17:42:02 +01:00
}
2010-02-24 11:30:26 +01:00
}
2009-07-28 02:52:34 +02:00
2012-04-18 11:16:15 +02:00
if ( $action == 'confirm_delete' && $confirm == " yes " && $user -> rights -> projet -> creer )
2010-02-24 11:30:26 +01:00
{
2012-04-18 11:16:15 +02:00
$object -> fetchTimeSpent ( $_GET [ 'lineid' ]);
$result = $object -> delTimeSpent ( $user );
2010-02-24 15:54:55 +01:00
2014-07-03 17:15:42 +02:00
if ( $result < 0 )
2010-02-24 15:54:55 +01:00
{
$langs -> load ( " errors " );
2014-03-11 20:38:29 +01:00
setEventMessage ( $langs -> trans ( $object -> error ), 'errors' );
$error ++ ;
2012-04-18 11:16:15 +02:00
$action = '' ;
}
}
// Retreive First Task ID of Project if withprojet is on to allow project prev next to work
if ( ! empty ( $project_ref ) && ! empty ( $withproject ))
{
if ( $projectstatic -> fetch ( 0 , $project_ref ) > 0 )
{
$tasksarray = $object -> getTasksArray ( 0 , 0 , $projectstatic -> id , $socid , 0 );
if ( count ( $tasksarray ) > 0 )
{
$id = $tasksarray [ 0 ] -> id ;
}
else
{
2012-08-31 05:58:38 +02:00
header ( " Location: " . DOL_URL_ROOT . '/projet/tasks.php?id=' . $projectstatic -> id . ( $withproject ? '&withproject=1' : '' ) . ( empty ( $mode ) ? '' : '&mode=' . $mode ));
2012-04-18 12:15:14 +02:00
exit ;
2012-04-18 11:16:15 +02:00
}
2010-02-24 15:54:55 +01:00
}
2010-02-24 11:30:26 +01:00
}
2009-07-28 02:52:34 +02:00
/*
* View
2013-05-14 20:22:33 +02:00
*/
2009-07-28 02:52:34 +02:00
llxHeader ( " " , $langs -> trans ( " Task " ));
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2012-08-07 14:54:56 +02:00
$userstatic = new User ( $db );
2009-07-28 02:52:34 +02:00
2012-02-15 23:08:20 +01:00
if ( $id > 0 || ! empty ( $ref ))
2009-07-28 02:52:34 +02:00
{
/*
* Fiche projet en mode visu
2013-05-14 20:22:33 +02:00
*/
2012-04-18 11:16:15 +02:00
if ( $object -> fetch ( $id ) >= 0 )
2009-07-28 02:52:34 +02:00
{
2012-04-18 11:16:15 +02:00
$result = $projectstatic -> fetch ( $object -> fk_project );
if ( ! empty ( $projectstatic -> socid )) $projectstatic -> societe -> fetch ( $projectstatic -> socid );
2010-02-28 02:33:12 +01:00
2014-05-10 16:43:47 +02:00
$object -> project = dol_clone ( $projectstatic );
2012-04-18 11:16:15 +02:00
$userWrite = $projectstatic -> restrictedProjectArea ( $user , 'write' );
2009-07-28 02:52:34 +02:00
2012-02-15 23:27:03 +01:00
if ( $withproject )
2012-02-15 23:08:20 +01:00
{
2013-05-14 20:22:33 +02:00
// Tabs for project
$tab = 'tasks' ;
$head = project_prepare_head ( $projectstatic );
dol_fiche_head ( $head , $tab , $langs -> trans ( " Project " ), 0 ,( $projectstatic -> 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 = $projectstatic -> getProjectsAuthorizedForUser ( $user , $mine , 0 );
$projectstatic -> next_prev_filter = " rowid in ( " . ( count ( $projectsListId ) ? join ( ',' , array_keys ( $projectsListId )) : '0' ) . " ) " ;
}
print $form -> showrefnav ( $projectstatic , 'project_ref' , '' , 1 , 'ref' , 'ref' , '' , $param . '&withproject=1' );
print '</td></tr>' ;
2013-10-30 21:44:04 +01:00
// Label
2013-05-14 20:22:33 +02:00
print '<tr><td>' . $langs -> trans ( " Label " ) . '</td><td>' . $projectstatic -> title . '</td></tr>' ;
2013-10-30 21:44:04 +01:00
// Thirdparty
2014-05-09 13:39:10 +02:00
print '<tr><td>' . $langs -> trans ( " ThirdParty " ) . '</td><td>' ;
2013-05-14 20:22:33 +02:00
if ( ! empty ( $projectstatic -> societe -> id )) print $projectstatic -> societe -> getNomUrl ( 1 );
else print ' ' ;
print '</td>' ;
print '</tr>' ;
// Visibility
print '<tr><td>' . $langs -> trans ( " Visibility " ) . '</td><td>' ;
if ( $projectstatic -> public ) print $langs -> trans ( 'SharedProject' );
else print $langs -> trans ( 'PrivateProject' );
print '</td></tr>' ;
// Statut
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td>' . $projectstatic -> getLibStatut ( 4 ) . '</td></tr>' ;
2014-06-14 14:20:58 +02:00
// Date start
print '<tr><td>' . $langs -> trans ( " DateStart " ) . '</td><td>' ;
print dol_print_date ( $projectstatic -> date_start , 'day' );
print '</td></tr>' ;
// Date end
print '<tr><td>' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
print dol_print_date ( $projectstatic -> date_end , 'day' );
print '</td></tr>' ;
2013-05-14 20:22:33 +02:00
print '</table>' ;
dol_fiche_end ();
print '<br>' ;
2012-02-15 23:08:20 +01:00
}
2009-07-28 02:52:34 +02:00
2012-04-18 11:16:15 +02:00
$head = task_prepare_head ( $object );
2012-03-18 02:01:23 +01:00
dol_fiche_head ( $head , 'task_time' , $langs -> trans ( " Task " ), 0 , 'projecttask' );
2009-07-28 02:52:34 +02:00
2012-02-15 23:08:20 +01:00
if ( $action == 'deleteline' )
2010-02-24 11:30:26 +01:00
{
2013-09-06 11:51:24 +02:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id . '&lineid=' . $_GET [ " lineid " ] . ( $withproject ? '&withproject=1' : '' ), $langs -> trans ( " DeleteATimeSpent " ), $langs -> trans ( " ConfirmDeleteATimeSpent " ), " confirm_delete " , '' , '' , 1 );
2010-02-24 11:30:26 +01:00
}
2009-07-28 02:52:34 +02:00
print '<table class="border" width="100%">' ;
2012-02-15 23:27:03 +01:00
$param = ( $withproject ? '&withproject=1' : '' );
2012-04-18 11:16:15 +02:00
$linkback = $withproject ? '<a href="' . DOL_URL_ROOT . '/projet/tasks.php?id=' . $projectstatic -> id . '">' . $langs -> trans ( " BackToList " ) . '</a>' : '' ;
2012-02-15 23:08:20 +01:00
2009-07-28 15:37:28 +02:00
// Ref
print '<tr><td width="30%">' ;
print $langs -> trans ( " Ref " );
print '</td><td colspan="3">' ;
2012-04-18 11:16:15 +02:00
if ( ! GETPOST ( 'withproject' ) || empty ( $projectstatic -> id ))
2012-02-15 23:08:20 +01:00
{
2013-05-14 20:22:33 +02:00
$projectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , $mine , 1 );
$object -> next_prev_filter = " fk_projet in ( " . $projectsListId . " ) " ;
2012-02-15 23:08:20 +01:00
}
2012-04-18 11:16:15 +02:00
else $object -> next_prev_filter = " fk_projet = " . $projectstatic -> id ;
2014-07-02 04:27:18 +02:00
print $form -> showrefnav ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , '' , $param );
2009-07-28 15:37:28 +02:00
print '</td></tr>' ;
// Label
2012-04-18 11:16:15 +02:00
print '<tr><td>' . $langs -> trans ( " Label " ) . '</td><td colspan="3">' . $object -> label . '</td></tr>' ;
2009-07-28 02:52:34 +02:00
2013-10-30 21:44:04 +01:00
// Planned workload
print '<tr><td>' . $langs -> trans ( " PlannedWorkload " ) . '</td><td colspan="3">' . convertSecondToTime ( $object -> planned_workload , 'allhourmin' ) . '</td></tr>' ;
2013-05-14 20:22:33 +02:00
2010-02-03 17:57:23 +01:00
// Project
2012-02-15 23:27:03 +01:00
if ( empty ( $withproject ))
{
2013-05-14 20:22:33 +02:00
print '<tr><td>' . $langs -> trans ( " Project " ) . '</td><td>' ;
print $projectstatic -> getNomUrl ( 1 );
print '</td></tr>' ;
// Third party
2014-05-09 13:39:10 +02:00
print '<td>' . $langs -> trans ( " ThirdParty " ) . '</td><td>' ;
2013-05-14 20:22:33 +02:00
if ( $projectstatic -> societe -> id ) print $projectstatic -> societe -> getNomUrl ( 1 );
else print ' ' ;
print '</td></tr>' ;
2012-02-15 23:27:03 +01:00
}
2009-07-28 02:52:34 +02:00
2010-02-24 10:53:16 +01:00
print '</table>' ;
2010-02-28 02:33:12 +01:00
2012-02-15 23:08:20 +01:00
dol_fiche_end ();
2010-02-28 02:33:12 +01:00
2010-02-24 10:53:16 +01:00
/*
2010-02-25 10:44:58 +01:00
* Add time spent
2013-05-14 20:22:33 +02:00
*/
2010-05-30 23:07:47 +02:00
if ( $user -> rights -> projet -> creer )
2010-02-26 09:45:22 +01:00
{
2010-02-28 02:33:12 +01:00
print '<br>' ;
2012-04-18 11:16:15 +02:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '">' ;
2010-02-26 09:45:22 +01:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="addtimespent">' ;
2012-04-18 11:16:15 +02:00
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
2012-04-18 12:15:14 +02:00
print '<input type="hidden" name="withproject" value="' . $withproject . '">' ;
2010-02-28 02:33:12 +01:00
2010-02-26 09:45:22 +01:00
print '<table class="noborder" width="100%">' ;
2010-02-28 02:33:12 +01:00
2010-02-26 09:45:22 +01:00
print '<tr class="liste_titre">' ;
2010-02-28 02:33:12 +01:00
print '<td width="100">' . $langs -> trans ( " Date " ) . '</td>' ;
2010-02-26 09:45:22 +01:00
print '<td>' . $langs -> trans ( " By " ) . '</td>' ;
2010-02-28 02:33:12 +01:00
print '<td>' . $langs -> trans ( " Note " ) . '</td>' ;
print '<td align="right">' . $langs -> trans ( " Duration " ) . '</td>' ;
print '<td width="80"> </td>' ;
2010-02-26 09:45:22 +01:00
print " </tr> \n " ;
2010-02-28 02:33:12 +01:00
print '<tr ' . $bc [ false ] . '>' ;
// Date
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2010-02-28 02:33:12 +01:00
$newdate = dol_mktime ( 12 , 0 , 0 , $_POST [ " timemonth " ], $_POST [ " timeday " ], $_POST [ " timeyear " ]);
2011-11-08 10:18:45 +01:00
print $form -> select_date ( $newdate , 'time' , '' , '' , '' , " timespent_date " );
2010-02-26 09:45:22 +01:00
print '</td>' ;
2010-02-28 02:33:12 +01:00
2010-02-26 09:45:22 +01:00
// Contributor
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2014-08-07 12:05:42 +02:00
$restrictaddtimetocontactoftask = 0 ;
if ( empty ( $conf -> global -> PROJECT_TIME_ON_ALL_TASKS_MY_PROJECTS ))
{
$restrictaddtimetocontactoftask = $object -> getListContactId ( 'internal' );
}
2010-05-30 22:44:47 +02:00
print img_object ( '' , 'user' );
2014-08-07 12:05:42 +02:00
print $form -> select_dolusers ( $_POST [ " userid " ] ? $_POST [ " userid " ] : $user -> id , 'userid' , 0 , '' , 0 , '' , $restrictaddtimetocontactoftask ); // Note: If user is not allowed it will be disabled into combo list and userid not posted
2010-02-26 09:45:22 +01:00
print '</td>' ;
2010-02-28 02:33:12 +01:00
// Note
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2010-02-28 02:33:12 +01:00
print '<textarea name="timespent_note" cols="80" rows="' . ROWS_3 . '">' . ( $_POST [ 'timespent_note' ] ? $_POST [ 'timespent_note' ] : '' ) . '</textarea>' ;
2010-02-26 09:45:22 +01:00
print '</td>' ;
2010-02-28 02:33:12 +01:00
2010-02-26 09:45:22 +01:00
// Duration
2013-04-25 01:13:13 +02:00
print '<td class="nowrap" align="right">' ;
2013-05-15 14:19:16 +02:00
print $form -> select_duration ( 'timespent_duration' ,( $_POST [ 'timespent_duration' ] ? $_POST [ 'timespent_duration' ] : '' ), 0 , 'text' );
2010-02-26 09:45:22 +01:00
print '</td>' ;
2010-02-28 02:33:12 +01:00
print '<td align="center">' ;
2010-02-26 09:45:22 +01:00
print '<input type="submit" class="button" value="' . $langs -> trans ( " Add " ) . '">' ;
print '</td></tr>' ;
2010-02-28 02:33:12 +01:00
2010-02-26 09:45:22 +01:00
print '</table></form>' ;
}
2010-02-24 10:53:16 +01:00
print '<br>' ;
2010-02-28 02:33:12 +01:00
2010-02-03 17:57:23 +01:00
/*
2010-02-07 03:39:01 +01:00
* List of time spent
2013-05-14 20:22:33 +02:00
*/
2010-02-24 15:54:55 +01:00
$sql = " SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note " ;
2013-02-23 17:40:28 +01:00
$sql .= " , u.lastname, u.firstname " ;
2009-07-28 02:52:34 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " projet_task_time as t " ;
$sql .= " , " . MAIN_DB_PREFIX . " user as u " ;
2012-04-18 11:16:15 +02:00
$sql .= " WHERE t.fk_task = " . $object -> id ;
2009-07-28 02:52:34 +02:00
$sql .= " AND t.fk_user = u.rowid " ;
$sql .= " ORDER BY t.task_date DESC " ;
$var = true ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
$i = 0 ;
$tasks = array ();
while ( $i < $num )
{
$row = $db -> fetch_object ( $resql );
$tasks [ $i ] = $row ;
$i ++ ;
}
$db -> free ( $resql );
}
else
{
dol_print_error ( $db );
}
2010-02-28 02:33:12 +01:00
2012-04-18 11:16:15 +02:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '">' ;
2010-02-26 09:45:22 +01:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="updateline">' ;
2012-04-18 11:16:15 +02:00
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
2010-02-28 02:33:12 +01:00
2009-07-28 02:52:34 +02:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2010-02-28 02:33:12 +01:00
print '<td width="100">' . $langs -> trans ( " Date " ) . '</td>' ;
2010-02-24 10:53:16 +01:00
print '<td>' . $langs -> trans ( " By " ) . '</td>' ;
2010-02-28 02:33:12 +01:00
print '<td align="left">' . $langs -> trans ( " Note " ) . '</td>' ;
2010-02-25 12:21:06 +01:00
print '<td align="right">' . $langs -> trans ( " Duration " ) . '</td>' ;
2010-02-28 02:33:12 +01:00
print '<td> </td>' ;
2009-07-28 02:52:34 +02:00
print " </tr> \n " ;
2012-02-07 10:25:58 +01:00
2011-07-14 17:37:37 +02:00
$total = 0 ;
2009-07-28 02:52:34 +02:00
foreach ( $tasks as $task_time )
{
$var =! $var ;
2013-05-14 20:22:33 +02:00
print " <tr " . $bc [ $var ] . " > " ;
// Date
print '<td>' ;
if ( $_GET [ 'action' ] == 'editline' && $_GET [ 'lineid' ] == $task_time -> rowid )
{
print $form -> select_date ( $db -> jdate ( $task_time -> task_date ), 'timeline' , '' , '' , '' , " timespent_date " );
}
else
{
print dol_print_date ( $db -> jdate ( $task_time -> task_date ), 'day' );
}
print '</td>' ;
// User
2010-03-01 17:42:02 +01:00
print '<td>' ;
if ( $_GET [ 'action' ] == 'editline' && $_GET [ 'lineid' ] == $task_time -> rowid )
{
2013-07-27 14:10:57 +02:00
print $form -> select_dolusers ( $task_time -> fk_user , 'userid_line' );
2010-03-01 17:42:02 +01:00
}
else
{
2012-08-07 14:54:56 +02:00
$userstatic -> id = $task_time -> fk_user ;
2013-02-23 16:37:17 +01:00
$userstatic -> lastname = $task_time -> lastname ;
$userstatic -> firstname = $task_time -> firstname ;
2012-08-07 14:54:56 +02:00
print $userstatic -> getNomUrl ( 1 );
2010-03-01 17:42:02 +01:00
}
2013-05-14 20:22:33 +02:00
print '</td>' ;
// Note
print '<td align="left">' ;
if ( $_GET [ 'action' ] == 'editline' && $_GET [ 'lineid' ] == $task_time -> rowid )
{
print '<textarea name="timespent_note_line" cols="80" rows="' . ROWS_3 . '">' . $task_time -> note . '</textarea>' ;
}
else
{
print dol_nl2br ( $task_time -> note );
}
print '</td>' ;
// Time spent
print '<td align="right">' ;
if ( $_GET [ 'action' ] == 'editline' && $_GET [ 'lineid' ] == $task_time -> rowid )
{
print '<input type="hidden" name="old_duration" value="' . $task_time -> task_duration . '">' ;
2013-05-15 14:19:16 +02:00
print $form -> select_duration ( 'new_duration' , $task_time -> task_duration , 0 , 'text' );
2013-05-14 20:22:33 +02:00
}
else
{
2013-10-30 21:44:04 +01:00
print convertSecondToTime ( $task_time -> task_duration , 'allhourmin' );
2013-05-14 20:22:33 +02:00
}
print '</td>' ;
2010-02-28 02:33:12 +01:00
2010-02-24 11:30:26 +01:00
// Edit and delete icon
2010-02-28 02:33:12 +01:00
print '<td align="center" valign="middle" width="80">' ;
2012-04-18 11:16:15 +02:00
if ( $action == 'editline' && $_GET [ 'lineid' ] == $task_time -> rowid )
2013-05-14 20:22:33 +02:00
{
print '<input type="hidden" name="lineid" value="' . $_GET [ 'lineid' ] . '">' ;
print '<input type="submit" class="button" name="save" value="' . $langs -> trans ( " Save " ) . '">' ;
print '<br>' ;
print '<input type="submit" class="button" name="cancel" value="' . $langs -> trans ( 'Cancel' ) . '">' ;
}
else if ( $user -> rights -> projet -> creer )
2010-02-24 10:53:16 +01:00
{
2010-02-24 11:30:26 +01:00
print ' ' ;
2012-04-18 12:15:14 +02:00
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=editline&lineid=' . $task_time -> rowid . ( $withproject ? '&withproject=1' : '' ) . '">' ;
2010-02-24 11:30:26 +01:00
print img_edit ();
print '</a>' ;
2010-02-28 02:33:12 +01:00
2010-02-24 10:53:16 +01:00
print ' ' ;
2012-04-18 12:15:14 +02:00
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=deleteline&lineid=' . $task_time -> rowid . ( $withproject ? '&withproject=1' : '' ) . '">' ;
2010-02-24 10:53:16 +01:00
print img_delete ();
print '</a>' ;
}
print '</td>' ;
2010-02-28 02:33:12 +01:00
2010-02-24 10:53:16 +01:00
print " </tr> \n " ;
2011-07-14 17:37:37 +02:00
$total += $task_time -> task_duration ;
2009-07-28 02:52:34 +02:00
}
2011-07-14 17:37:37 +02:00
print '<tr class="liste_total"><td colspan="3" class="liste_total">' . $langs -> trans ( " Total " ) . '</td>' ;
2013-10-30 21:44:04 +01:00
print '<td align="right" class="nowrap liste_total">' . convertSecondToTime ( $total , 'allhourmin' ) . '</td><td> </td>' ;
2011-07-14 17:37:37 +02:00
print '</tr>' ;
2012-02-07 10:25:58 +01:00
2009-07-28 02:52:34 +02:00
print " </table> " ;
2010-02-26 09:45:22 +01:00
print " </form> " ;
2009-07-28 02:52:34 +02:00
}
}
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-04-18 11:16:15 +02:00
$db -> close ();