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 >
2018-02-26 13:21:16 +01:00
* Copyright ( C ) 2006 - 2018 Laurent Destailleur < eldy @ users . sourceforge . net >
2013-10-30 21:44:04 +01:00
* Copyright ( C ) 2010 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
* Copyright ( C ) 2011 Juanjo Menent < jmenent @ 2 byte . es >
2018-04-20 10:38:16 +02:00
* Copyright ( C ) 2018 Ferran Marcet < fmarcet @ 2 byte . es >
2013-10-30 21:44:04 +01:00
*
* 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' ;
2014-09-29 16:25:18 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2018-02-26 11:57:29 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
2009-07-28 02:52:34 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2010-03-01 20:36:58 +01:00
$langs -> load ( 'projects' );
2012-04-18 11:16:15 +02:00
$id = GETPOST ( 'id' , 'int' );
2016-08-30 20:16:58 +02:00
$projectid = GETPOST ( 'projectid' , 'int' );
2012-04-18 11:16:15 +02:00
$ref = GETPOST ( 'ref' , 'alpha' );
$action = GETPOST ( 'action' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
2018-02-26 11:57:29 +01:00
$cancel = GETPOST ( 'cancel' , 'alpha' );
2012-04-18 11:16:15 +02:00
$withproject = GETPOST ( 'withproject' , 'int' );
$project_ref = GETPOST ( 'project_ref' , 'alpha' );
2012-02-15 23:08:20 +01:00
2018-01-04 00:23:08 +01:00
$search_day = GETPOST ( 'search_day' , 'int' );
$search_month = GETPOST ( 'search_month' , 'int' );
$search_year = GETPOST ( 'search_year' , 'int' );
2016-08-30 20:17:34 +02:00
$search_datehour = '' ;
$search_datewithhour = '' ;
$search_note = GETPOST ( 'search_note' , 'alpha' );
$search_duration = GETPOST ( 'search_duration' , 'int' );
$search_value = GETPOST ( 'search_value' , 'int' );
2017-04-05 14:48:24 +02:00
$search_task_ref = GETPOST ( 'search_task_ref' , 'alpha' );
$search_task_label = GETPOST ( 'search_task_label' , 'alpha' );
$search_user = GETPOST ( 'search_user' , 'int' );
2016-08-30 20:17:34 +02:00
2010-05-30 14:21:32 +02:00
// Security check
$socid = 0 ;
2017-01-12 15:23:30 +01:00
//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
2010-02-10 16:55:29 +01:00
if ( ! $user -> rights -> projet -> lire ) accessforbidden ();
2009-07-28 02:52:34 +02:00
2017-06-08 14:55:12 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2016-08-30 20:17:34 +02:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
$page = GETPOST ( " page " , 'int' );
2017-06-06 10:53:53 +02:00
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
2016-08-30 20:17:34 +02:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
if ( ! $sortfield ) $sortfield = 't.task_date,t.task_datehour,t.rowid' ;
2018-08-21 14:41:59 +02:00
if ( ! $sortorder ) $sortorder = 'DESC,DESC,DESC' ;
2016-08-30 20:17:34 +02:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2018-03-31 18:48:27 +02:00
//$object = new TaskTime($db);
2018-05-18 08:52:13 +02:00
$hookmanager -> initHooks ( array ( 'projecttasktime' , 'globalcard' ));
2016-08-30 20:16:58 +02:00
2012-04-18 11:16:15 +02:00
$object = new Task ( $db );
$projectstatic = new Project ( $db );
2016-08-30 20:16:58 +02:00
$extrafields_project = new ExtraFields ( $db );
$extrafields_task = new ExtraFields ( $db );
2018-02-26 14:09:15 +01:00
$extralabels_projet = $extrafields_project -> fetch_name_optionals_label ( $projectstatic -> table_element );
2016-08-30 20:16:58 +02:00
$extralabels_task = $extrafields_task -> fetch_name_optionals_label ( $object -> table_element );
2012-04-18 11:16:15 +02:00
2010-05-30 14:21:32 +02:00
2009-07-28 02:52:34 +02:00
/*
* Actions
2014-10-03 03:42:11 +02:00
*/
2012-04-18 12:15:14 +02:00
2018-02-26 11:57:29 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) { $action = '' ; }
2016-08-30 20:17:34 +02:00
$parameters = array ( 'socid' => $socid , 'projectid' => $projectid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
2017-07-13 00:35:10 +02:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) // All tests are required to be compatible with all browsers
2016-08-30 20:17:34 +02:00
{
2018-01-04 00:23:08 +01:00
$search_day = '' ;
$search_month = '' ;
$search_year = '' ;
$search_date = '' ;
2016-08-30 20:17:34 +02:00
$search_datehour = '' ;
$search_datewithhour = '' ;
$search_note = '' ;
$search_duration = '' ;
$search_value = '' ;
$search_date_creation = '' ;
$search_date_update = '' ;
2017-04-05 14:48:24 +02:00
$search_task_ref = '' ;
$search_task_label = '' ;
$search_user = 0 ;
2016-08-30 20:17:34 +02:00
$toselect = '' ;
$search_array_options = array ();
$action = '' ;
}
2016-06-30 14:24:03 +02:00
if ( $action == 'addtimespent' && $user -> rights -> projet -> lire )
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
{
2015-12-17 14:14:44 +01:00
setEventMessages ( $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentitiesnoconv ( " Duration " )), null , '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 " );
2015-12-17 14:14:44 +01:00
setEventMessages ( $langs -> trans ( 'ErrorUserNotAssignedToTask' ), null , '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
{
2018-02-26 11:57:29 +01:00
if ( $id || $ref )
{
$object -> fetch ( $id , $ref );
}
else
{
$object -> fetch ( GETPOST ( 'taskid' , 'int' ));
}
2014-07-17 01:28:01 +02:00
$object -> fetch_projet ();
2010-02-25 10:44:58 +01:00
2018-02-26 11:57:29 +01:00
if ( empty ( $object -> project -> statut ))
2010-02-28 02:33:12 +01:00
{
2015-12-17 14:14:44 +01:00
setEventMessages ( $langs -> trans ( " ProjectMustBeValidatedFirst " ), null , 'errors' );
2014-07-17 01:28:01 +02:00
$error ++ ;
2010-02-28 02:33:12 +01:00
}
else
{
2014-07-17 01:28:01 +02:00
$object -> timespent_note = $_POST [ " timespent_note " ];
2018-08-21 14:41:59 +02:00
if ( GETPOST ( 'progress' , 'int' ) > 0 ) $object -> progress = GETPOST ( 'progress' , 'int' ); // If progress is -1 (not defined), we do not change value
2014-07-17 01:28:01 +02:00
$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
2015-03-05 13:48:57 +01:00
if ( GETPOST ( " timehour " ) != '' && GETPOST ( " timehour " ) >= 0 ) // If hour was entered
{
$object -> timespent_date = dol_mktime ( GETPOST ( " timehour " ), GETPOST ( " timemin " ), 0 , GETPOST ( " timemonth " ), GETPOST ( " timeday " ), GETPOST ( " timeyear " ));
$object -> timespent_withhour = 1 ;
}
else
{
$object -> timespent_date = dol_mktime ( 12 , 0 , 0 , GETPOST ( " timemonth " ), GETPOST ( " timeday " ), GETPOST ( " timeyear " ));
}
2014-07-17 01:28:01 +02:00
$object -> timespent_fk_user = $_POST [ " userid " ];
$result = $object -> addTimeSpent ( $user );
if ( $result >= 0 )
{
2015-12-17 14:14:44 +01:00
setEventMessages ( $langs -> trans ( " RecordSaved " ), null , 'mesgs' );
2014-07-17 01:28:01 +02:00
}
else
{
2015-12-17 14:14:44 +01:00
setEventMessages ( $langs -> trans ( $object -> error ), null , 'errors' );
2014-07-17 01:28:01 +02:00
$error ++ ;
}
2010-02-28 02:33:12 +01:00
}
2010-02-25 10:44:58 +01:00
}
else
{
2018-02-26 11:57:29 +01:00
if ( empty ( $id )) $action = 'createtime' ;
else $action = 'createtime' ;
2010-02-25 10:44:58 +01:00
}
}
2017-01-13 13:43:09 +01:00
if ( $action == 'updateline' && ! $_POST [ " cancel " ] && $user -> rights -> projet -> lire )
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
{
2015-12-17 14:14:44 +01:00
setEventMessages ( $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentitiesnoconv ( " Duration " )), null , '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 )
{
2014-12-22 22:52:43 +01:00
$object -> fetch ( $id , $ref );
2017-01-13 13:43:09 +01:00
// TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids))
2017-06-07 10:55:39 +02:00
2012-04-18 11:16:15 +02:00
$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
2015-03-05 13:48:57 +01:00
if ( GETPOST ( " timelinehour " ) != '' && GETPOST ( " timelinehour " ) >= 0 ) // If hour was entered
{
$object -> timespent_date = dol_mktime ( GETPOST ( " timelinehour " ), GETPOST ( " timelinemin " ), 0 , GETPOST ( " timelinemonth " ), GETPOST ( " timelineday " ), GETPOST ( " timelineyear " ));
$object -> timespent_withhour = 1 ;
}
else
{
$object -> timespent_date = dol_mktime ( 12 , 0 , 0 , GETPOST ( " timelinemonth " ), GETPOST ( " timelineday " ), GETPOST ( " timelineyear " ));
}
2012-04-18 11:16:15 +02:00
$object -> timespent_fk_user = $_POST [ " userid_line " ];
$result = $object -> updateTimeSpent ( $user );
2010-03-01 17:42:02 +01:00
if ( $result >= 0 )
{
2015-12-17 14:14:44 +01:00
setEventMessages ( $langs -> trans ( " RecordSaved " ), null , 'mesgs' );
2010-03-01 17:42:02 +01:00
}
else
{
2015-12-17 14:14:44 +01:00
setEventMessages ( $langs -> trans ( $object -> error ), null , 'errors' );
2014-03-11 20:38:29 +01:00
$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
2017-01-13 13:43:09 +01:00
if ( $action == 'confirm_delete' && $confirm == " yes " && $user -> rights -> projet -> lire )
2010-02-24 11:30:26 +01:00
{
2018-02-26 13:21:16 +01:00
$object -> fetchTimeSpent ( GETPOST ( 'lineid' , 'int' ));
2017-01-13 13:43:09 +01:00
// TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids))
2012-04-18 11:16:15 +02:00
$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 " );
2015-12-17 14:14:44 +01:00
setEventMessages ( $langs -> trans ( $object -> error ), null , 'errors' );
2014-03-11 20:38:29 +01:00
$error ++ ;
2012-04-18 11:16:15 +02:00
$action = '' ;
}
2018-02-26 13:21:16 +01:00
else
{
setEventMessages ( $langs -> trans ( " RecordDeleted " ), null , 'mesgs' );
}
2012-04-18 11:16:15 +02:00
}
// 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
2016-02-28 00:00:08 +01:00
// To show all time lines for project
$projectidforalltimes = 0 ;
2018-02-26 14:09:15 +01:00
if ( GETPOST ( 'projectid' , 'none' ))
2016-02-28 00:00:08 +01:00
{
2018-02-26 14:09:15 +01:00
$projectidforalltimes = GETPOST ( 'projectid' , 'int' );
2016-02-28 00:00:08 +01:00
}
2017-06-07 10:55:39 +02:00
2009-07-28 02:52:34 +02:00
/*
* View
2014-10-03 03:42:11 +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 );
2014-09-29 16:25:18 +02:00
$formother = new FormOther ( $db );
2018-02-26 11:57:29 +01:00
$formproject = new FormProjets ( $db );
2012-08-07 14:54:56 +02:00
$userstatic = new User ( $db );
2009-07-28 02:52:34 +02:00
2016-02-28 00:00:08 +01:00
if (( $id > 0 || ! empty ( $ref )) || $projectidforalltimes > 0 )
2009-07-28 02:52:34 +02:00
{
/*
* Fiche projet en mode visu
2014-10-12 01:04:34 +02:00
*/
2016-02-28 00:00:08 +01:00
if ( $projectidforalltimes )
{
$result = $projectstatic -> fetch ( $projectidforalltimes );
if ( ! empty ( $projectstatic -> socid )) $projectstatic -> fetch_thirdparty ();
2018-02-21 14:48:25 +01:00
$res = $projectstatic -> fetch_optionals ();
2016-02-28 00:00:08 +01:00
}
elseif ( $object -> fetch ( $id , $ref ) >= 0 )
2009-07-28 02:52:34 +02:00
{
2018-05-22 16:07:32 +02:00
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_TASK ) && method_exists ( $object , 'fetchComments' ) && empty ( $object -> comments )) $object -> fetchComments ();
2012-04-18 11:16:15 +02:00
$result = $projectstatic -> fetch ( $object -> fk_project );
2018-05-22 16:07:32 +02:00
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_PROJECT ) && method_exists ( $projectstatic , 'fetchComments' ) && empty ( $projectstatic -> comments )) $projectstatic -> fetchComments ();
2014-09-20 10:14:26 +02:00
if ( ! empty ( $projectstatic -> socid )) $projectstatic -> fetch_thirdparty ();
2018-02-21 14:48:25 +01:00
$res = $projectstatic -> fetch_optionals ();
2017-06-07 10:55:39 +02:00
2015-09-24 16:32:48 +02:00
$object -> project = clone $projectstatic ;
2016-02-28 00:00:08 +01:00
}
2017-06-07 10:55:39 +02:00
2016-02-28 00:00:08 +01:00
$userWrite = $projectstatic -> restrictedProjectArea ( $user , 'write' );
2014-05-10 16:43:47 +02:00
2016-02-28 00:00:08 +01:00
if ( $projectstatic -> id > 0 )
{
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
2018-05-04 11:25:21 +02:00
if ( empty ( $id )) $tab = 'timespent' ;
else $tab = 'tasks' ;
2013-05-14 20:22:33 +02:00
$head = project_prepare_head ( $projectstatic );
2017-05-24 18:00:26 +02:00
dol_fiche_head ( $head , $tab , $langs -> trans ( " Project " ), - 1 , ( $projectstatic -> public ? 'projectpub' : 'project' ));
2013-05-14 20:22:33 +02:00
$param = ( $mode == 'mine' ? '&mode=mine' : '' );
2016-10-18 12:16:12 +02:00
// Project card
2017-06-07 10:55:39 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2016-10-18 12:16:12 +02:00
$morehtmlref = '<div class="refidno">' ;
// Title
$morehtmlref .= $projectstatic -> title ;
// Thirdparty
2017-06-07 10:55:39 +02:00
if ( $projectstatic -> thirdparty -> id > 0 )
2016-10-18 12:16:12 +02:00
{
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $projectstatic -> thirdparty -> getNomUrl ( 1 , 'project' );
}
$morehtmlref .= '</div>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Define a complementary filter for search of next/prev ref.
if ( ! $user -> rights -> projet -> all -> lire )
{
2017-01-04 16:35:04 +01:00
$objectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 0 );
2016-10-18 12:16:12 +02:00
$projectstatic -> next_prev_filter = " rowid in ( " . ( count ( $objectsListId ) ? join ( ',' , array_keys ( $objectsListId )) : '0' ) . " ) " ;
}
2017-06-07 10:55:39 +02:00
2017-01-20 10:27:37 +01:00
dol_banner_tab ( $projectstatic , 'project_ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
print '<div class="underbanner clearboth"></div>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '<table class="border" width="100%">' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Visibility
print '<tr><td class="titlefield">' . $langs -> trans ( " Visibility " ) . '</td><td>' ;
if ( $projectstatic -> public ) print $langs -> trans ( 'SharedProject' );
else print $langs -> trans ( 'PrivateProject' );
print '</td></tr>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Date start - end
print '<tr><td>' . $langs -> trans ( " DateStart " ) . ' - ' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
2018-02-15 02:02:32 +01:00
$start = dol_print_date ( $projectstatic -> date_start , 'day' );
print ( $start ? $start : '?' );
$end = dol_print_date ( $projectstatic -> date_end , 'day' );
print ' - ' ;
print ( $end ? $end : '?' );
if ( $projectstatic -> hasDelay ()) print img_warning ( " Late " );
2016-10-18 12:16:12 +02:00
print '</td></tr>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Budget
print '<tr><td>' . $langs -> trans ( " Budget " ) . '</td><td>' ;
if ( strcmp ( $projectstatic -> budget_amount , '' )) print price ( $projectstatic -> budget_amount , '' , $langs , 1 , 0 , 0 , $conf -> currency );
print '</td></tr>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Other attributes
$cols = 2 ;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</table>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</div>' ;
print '<div class="fichehalfright">' ;
print '<div class="ficheaddleft">' ;
print '<div class="underbanner clearboth"></div>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '<table class="border" width="100%">' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Description
print '<td class="titlefield tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
print nl2br ( $projectstatic -> description );
print '</td></tr>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Categories
if ( $conf -> categorie -> enabled ) {
print '<tr><td valign="middle">' . $langs -> trans ( " Categories " ) . '</td><td>' ;
print $form -> showCategories ( $projectstatic -> id , 'project' , 1 );
print " </td></tr> " ;
}
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</table>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</div>' ;
print '</div>' ;
print '</div>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '<div class="clearboth"></div>' ;
2013-05-14 20:22:33 +02:00
dol_fiche_end ();
2017-06-07 10:55:39 +02:00
2018-02-26 11:57:29 +01:00
print '<br>' ;
2016-08-31 01:04:33 +02:00
2018-02-26 11:57:29 +01:00
// Link to create time
2018-02-26 12:21:01 +01:00
//if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes))
//{
2016-03-29 20:06:01 +02:00
if ( $user -> rights -> projet -> all -> creer || $user -> rights -> projet -> creer )
{
2018-02-26 12:21:01 +01:00
if ( $projectstatic -> public || $userWrite > 0 )
2016-03-29 20:06:01 +02:00
{
2018-08-21 14:41:59 +02:00
if ( ! empty ( $projectidforalltimes )) // We are on tab 'Time Spent' of project
{
$backtourl = $_SERVER [ 'PHP_SELF' ] . '?projectid=' . $projectstatic -> id . ( $withproject ? '&withproject=1' : '' );
$linktocreatetime = '<a class="butActionNew" href="' . $_SERVER [ 'PHP_SELF' ] . '?withproject=1&projectid=' . $projectstatic -> id . '&action=createtime' . $param . '&backtopage=' . urlencode ( $backtourl ) . '">' . $langs -> trans ( 'AddTimeSpent' ) . '<span class="fa fa-plus-circle valignmiddle"></span></a>' ;
}
else // We are on tab 'Time Spent' of task
{
$backtourl = $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . ( $withproject ? '&withproject=1' : '' );
$linktocreatetime = '<a class="butActionNew" href="' . $_SERVER [ 'PHP_SELF' ] . '?withproject=1' . ( $object -> id > 0 ? '&id=' . $object -> id : '&projectid=' . $projectstatic -> id ) . '&action=createtime' . $param . '&backtopage=' . urlencode ( $backtourl ) . '">' . $langs -> trans ( 'AddTimeSpent' ) . '<span class="fa fa-plus-circle valignmiddle"></span></a>' ;
}
2016-03-29 20:06:01 +02:00
}
else
{
2018-04-26 10:07:27 +02:00
$linktocreatetime = '<a class="butActionNewRefused" href="#" title="' . $langs -> trans ( " NotOwnerOfProject " ) . '">' . $langs -> trans ( 'AddTime' ) . '<span class="fa fa-plus-circle valignmiddle"></span></a>' ;
2016-03-29 20:06:01 +02:00
}
}
else
{
2018-04-26 10:07:27 +02:00
$linktocreatetime = '<a class="butActionNewRefused" href="#" title="' . $langs -> trans ( " NotEnoughPermissions " ) . '">' . $langs -> trans ( 'AddTime' ) . '<span class="fa fa-plus-circle valignmiddle"></span></a>' ;
2016-03-29 20:06:01 +02:00
}
2018-02-26 12:21:01 +01:00
//}
2012-02-15 23:08:20 +01:00
}
2016-02-28 00:00:08 +01:00
}
2017-06-07 10:55:39 +02:00
2016-02-28 00:00:08 +01:00
if ( empty ( $projectidforalltimes ))
{
2012-04-18 11:16:15 +02:00
$head = task_prepare_head ( $object );
2018-03-06 21:51:43 +01:00
dol_fiche_head ( $head , 'task_time' , $langs -> trans ( " Task " ), - 1 , 'projecttask' , 0 , '' , 'reposition' );
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
{
2018-02-26 13:21:16 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ? " . ( $object -> id > 0 ? " id= " . $object -> id : 'projectid=' . $projectstatic -> id ) . '&lineid=' . GETPOST ( " lineid " , 'int' ) . ( $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
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
2012-04-18 11:16:15 +02:00
if ( ! GETPOST ( 'withproject' ) || empty ( $projectstatic -> id ))
2012-02-15 23:08:20 +01:00
{
2015-12-04 15:37:28 +01:00
$projectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 1 );
2013-05-14 20:22:33 +02:00
$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 ;
2017-06-07 10:55:39 +02:00
2017-04-05 14:48:24 +02:00
$morehtmlref = '' ;
2017-09-17 20:05:36 +02:00
2017-05-18 12:12:36 +02:00
// Project
if ( empty ( $withproject ))
{
$morehtmlref .= '<div class="refidno">' ;
$morehtmlref .= $langs -> trans ( " Project " ) . ': ' ;
$morehtmlref .= $projectstatic -> getNomUrl ( 1 );
$morehtmlref .= '<br>' ;
2017-09-17 20:05:36 +02:00
2017-05-18 12:12:36 +02:00
// Third party
2017-09-11 16:56:50 +02:00
$morehtmlref .= $langs -> trans ( " ThirdParty " ) . ': ' ;
2017-09-14 12:01:32 +02:00
if ( is_object ( $projectstatic -> thirdparty )) {
2017-09-11 16:56:50 +02:00
$morehtmlref .= $projectstatic -> thirdparty -> getNomUrl ( 1 );
}
2017-05-18 12:12:36 +02:00
$morehtmlref .= '</div>' ;
}
2017-06-07 10:55:39 +02:00
2017-04-05 14:48:24 +02:00
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref , $param );
2017-06-07 10:55:39 +02:00
2017-04-05 14:48:24 +02:00
print '<div class="fichecenter">' ;
2017-05-18 12:12:36 +02:00
print '<div class="fichehalfleft">' ;
2017-06-07 10:55:39 +02:00
2017-09-17 20:05:36 +02:00
print '<div class="underbanner clearboth"></div>' ;
2017-04-05 14:48:24 +02:00
print '<table class="border" width="100%">' ;
// Date start - Date end
2017-05-18 12:12:36 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " DateStart " ) . ' - ' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
2017-04-05 14:48:24 +02:00
$start = dol_print_date ( $object -> date_start , 'dayhour' );
print ( $start ? $start : '?' );
$end = dol_print_date ( $object -> date_end , 'dayhour' );
print ' - ' ;
print ( $end ? $end : '?' );
if ( $object -> hasDelay ()) print img_warning ( " Late " );
2014-10-03 03:42:11 +02:00
print '</td></tr>' ;
// Planned workload
2017-05-18 12:12:36 +02:00
print '<tr><td>' . $langs -> trans ( " PlannedWorkload " ) . '</td><td>' ;
2014-10-17 15:01:56 +02:00
print convertSecondToTime ( $object -> planned_workload , 'allhourmin' );
print '</td></tr>' ;
2014-10-03 03:42:11 +02:00
2017-05-18 12:12:36 +02:00
print '</table>' ;
print '</div>' ;
2017-06-07 10:55:39 +02:00
2017-05-18 12:12:36 +02:00
print '<div class="fichehalfright"><div class="ficheaddleft">' ;
2017-06-07 10:55:39 +02:00
2017-05-18 12:12:36 +02:00
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border" width="100%">' ;
2017-06-07 10:55:39 +02:00
2014-10-17 15:01:56 +02:00
// Progress declared
2017-09-17 20:05:36 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " ProgressDeclared " ) . '</td><td>' ;
2014-10-03 03:42:11 +02:00
print $object -> progress . ' %' ;
print '</td></tr>' ;
2014-10-17 15:01:56 +02:00
// Progress calculated
2017-05-18 12:12:36 +02:00
print '<tr><td>' . $langs -> trans ( " ProgressCalculated " ) . '</td><td>' ;
2014-10-12 01:04:34 +02:00
if ( $object -> planned_workload )
{
2014-10-17 15:01:56 +02:00
$tmparray = $object -> getSummaryOfTimeSpent ();
2014-10-12 01:04:34 +02:00
if ( $tmparray [ 'total_duration' ] > 0 ) print round ( $tmparray [ 'total_duration' ] / $object -> planned_workload * 100 , 2 ) . ' %' ;
else print '0 %' ;
}
2017-09-17 20:05:36 +02:00
else print '<span class="opacitymedium">' . $langs -> trans ( " WorkloadNotDefined " ) . '</span>' ;
2014-10-03 03:42:11 +02:00
print '</td></tr>' ;
2010-02-24 10:53:16 +01:00
print '</table>' ;
2017-05-18 12:12:36 +02:00
print '</div>' ;
print '</div>' ;
2017-06-07 10:55:39 +02:00
2017-05-18 12:12:36 +02:00
print '</div>' ;
print '<div class="clearboth"></div>' ;
2017-06-07 10:55:39 +02:00
2012-02-15 23:08:20 +01:00
dol_fiche_end ();
2018-02-26 12:32:26 +01:00
print '<!-- List of time spent for task -->' . " \n " ;
2010-02-28 02:33:12 +01:00
2018-02-26 12:21:01 +01:00
$title = $langs -> trans ( " ListTaskTimeForTask " );
//print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1);
print load_fiche_titre ( $title , $linktocreatetime , 'title_generic.png' );
2010-02-24 10:53:16 +01:00
/*
2018-02-26 11:57:29 +01:00
* Form to add time spent on task
2014-10-12 01:04:34 +02:00
*/
2018-02-26 11:57:29 +01:00
2018-02-26 12:21:01 +01:00
if ( $action == 'createtime' && $object -> id > 0 && $user -> rights -> projet -> lire )
2010-02-26 09:45:22 +01:00
{
2018-02-26 11:57:29 +01:00
print '<!-- form to add time spent on task -->' . " \n " ;
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
2018-03-06 21:51:43 +01:00
print '<div class="div-table-responsive-no-min">' ;
2015-06-03 21:01:50 +02:00
print '<table class="noborder nohover" width="100%">' ;
2010-02-28 02:33:12 +01:00
2010-02-26 09:45:22 +01:00
print '<tr class="liste_titre">' ;
2016-10-24 18:43:17 +02:00
print '<td>' . $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>' ;
2017-04-05 14:48:24 +02:00
print '<td>' . $langs -> trans ( " NewTimeSpent " ) . '</td>' ;
2014-10-12 01:04:34 +02:00
print '<td>' . $langs -> trans ( " ProgressDeclared " ) . '</td>' ;
2017-04-05 14:48:24 +02:00
print '<td></td>' ;
2010-02-26 09:45:22 +01:00
print " </tr> \n " ;
2010-02-28 02:33:12 +01:00
2017-04-05 14:48:24 +02:00
print '<tr class="oddeven">' ;
2010-02-28 02:33:12 +01:00
// Date
2016-10-24 18:43:17 +02:00
print '<td class="maxwidthonsmartphone">' ;
2015-03-05 13:48:57 +01:00
//$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]);
$newdate = '' ;
2016-10-24 18:43:17 +02:00
print $form -> select_date ( $newdate , 'time' , ( $conf -> browser -> layout == 'phone' ? 2 : 1 ), 1 , 2 , " timespent_date " , 1 , 0 , 1 );
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
2016-10-24 18:43:17 +02:00
print '<td class="maxwidthonsmartphone">' ;
2014-11-23 23:31:35 +01:00
print img_object ( '' , 'user' , 'class="hideonsmartphone"' );
2014-09-20 10:14:26 +02:00
$contactsoftask = $object -> getListContactId ( 'internal' );
2015-06-03 21:01:50 +02:00
if ( count ( $contactsoftask ) > 0 )
2015-04-23 13:54:49 +02:00
{
2018-05-14 15:16:07 +02:00
if ( in_array ( $user -> id , $contactsoftask )) $userid = $user -> id ;
else $userid = $contactsoftask [ 0 ];
2016-10-24 18:43:17 +02:00
print $form -> select_dolusers (( GETPOST ( 'userid' ) ? GETPOST ( 'userid' ) : $userid ), 'userid' , 0 , '' , 0 , '' , $contactsoftask , 0 , 0 , 0 , '' , 0 , $langs -> trans ( " ResourceNotAssignedToTheTask " ), 'maxwidth200' );
2015-04-23 13:54:49 +02:00
}
2015-06-03 21:01:50 +02:00
else
2015-04-23 13:54:49 +02:00
{
2014-09-20 10:14:26 +02:00
print img_error ( $langs -> trans ( 'FirstAddRessourceToAllocateTime' )) . $langs -> trans ( 'FirstAddRessourceToAllocateTime' );
2014-08-07 12:05:42 +02:00
}
2010-02-26 09:45:22 +01:00
print '</td>' ;
2010-02-28 02:33:12 +01:00
// Note
2016-10-24 18:43:17 +02:00
print '<td>' ;
print '<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 . '">' . ( $_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
2017-04-05 14:48:24 +02:00
// Duration - Time spent
print '<td>' ;
print $form -> select_duration ( 'timespent_duration' , ( $_POST [ 'timespent_duration' ] ? $_POST [ 'timespent_duration' ] : '' ), 0 , 'text' );
print '</td>' ;
2014-10-12 01:04:34 +02:00
// Progress declared
2014-09-29 16:25:18 +02:00
print '<td class="nowrap">' ;
2018-08-21 14:41:59 +02:00
print $formother -> select_percent ( GETPOST ( 'progress' ) ? GETPOST ( 'progress' ) : $object -> progress , 'progress' , 0 , 5 , 0 , 100 , 1 );
2010-02-26 09:45:22 +01:00
print '</td>' ;
2010-02-28 02:33:12 +01:00
print '<td align="center">' ;
2018-02-26 12:21:01 +01:00
print '<input type="submit" name="save" class="button" value="' . $langs -> trans ( " Add " ) . '">' ;
print ' ' ;
print '<input type="submit" name="cancel" class="button" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2010-02-26 09:45:22 +01:00
print '</td></tr>' ;
2010-02-28 02:33:12 +01:00
2018-03-06 21:51:43 +01:00
print '</table>' ;
print '</div>' ;
print '</form>' ;
2017-06-07 10:55:39 +02:00
2016-02-28 00:00:08 +01:00
print '<br>' ;
2010-02-26 09:45:22 +01:00
}
2016-02-28 00:00:08 +01:00
}
2017-06-07 10:55:39 +02:00
2016-02-28 00:00:08 +01:00
if ( $projectstatic -> id > 0 )
2017-06-07 10:55:39 +02:00
{
2018-02-26 10:33:39 +01:00
if ( $action == 'deleteline' && ! empty ( $projectidforalltimes ))
2016-08-30 20:16:58 +02:00
{
2018-02-26 13:21:16 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ? " . ( $object -> id > 0 ? " id= " . $object -> id : 'projectid=' . $projectstatic -> id ) . '&lineid=' . GETPOST ( 'lineid' , 'int' ) . ( $withproject ? '&withproject=1' : '' ), $langs -> trans ( " DeleteATimeSpent " ), $langs -> trans ( " ConfirmDeleteATimeSpent " ), " confirm_delete " , '' , '' , 1 );
2016-08-30 20:16:58 +02:00
}
2017-06-07 10:55:39 +02:00
2016-08-30 20:17:34 +02:00
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
$hookmanager -> initHooks ( array ( 'tasktimelist' ));
$extrafields = new ExtraFields ( $db );
// Definition of fields for list
2016-08-31 00:16:07 +02:00
$arrayfields = array ();
$arrayfields [ 't.task_date' ] = array ( 'label' => $langs -> trans ( " Date " ), 'checked' => 1 );
2016-08-31 01:04:33 +02:00
if (( empty ( $id ) && empty ( $ref )) || ! empty ( $projectidforalltimes )) // Not a dedicated task
2016-08-31 00:16:07 +02:00
{
2016-10-24 18:43:17 +02:00
$arrayfields [ 't.task_ref' ] = array ( 'label' => $langs -> trans ( " RefTask " ), 'checked' => 1 );
$arrayfields [ 't.task_label' ] = array ( 'label' => $langs -> trans ( " LabelTask " ), 'checked' => 1 );
2016-08-31 00:16:07 +02:00
}
$arrayfields [ 'author' ] = array ( 'label' => $langs -> trans ( " By " ), 'checked' => 1 );
$arrayfields [ 't.note' ] = array ( 'label' => $langs -> trans ( " Note " ), 'checked' => 1 );
$arrayfields [ 't.task_duration' ] = array ( 'label' => $langs -> trans ( " Duration " ), 'checked' => 1 );
2018-01-13 17:21:56 +01:00
$arrayfields [ 'value' ] = array ( 'label' => $langs -> trans ( " Value " ), 'checked' => 1 , 'enabled' => ( empty ( $conf -> salaries -> enabled ) ? 0 : 1 ));
2018-02-26 13:21:16 +01:00
$arrayfields [ 'valuebilled' ] = array ( 'label' => $langs -> trans ( " AmountInvoiced " ), 'checked' => 1 , 'enabled' => ( empty ( $conf -> global -> PROJECT_BILL_TIME_SPENT ) ? 0 : 1 ));
2016-08-30 20:17:34 +02:00
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
2017-10-29 11:00:02 +01:00
if ( ! empty ( $extrafields -> attribute_list [ $key ])) $arrayfields [ " ef. " . $key ] = array ( 'label' => $extrafields -> attribute_label [ $key ], 'checked' => (( $extrafields -> attribute_list [ $key ] < 0 ) ? 0 : 1 ), 'position' => $extrafields -> attribute_pos [ $key ], 'enabled' => ( abs ( $extrafields -> attribute_list [ $key ]) != 3 && $extrafields -> attribute_perms [ $key ]));
2016-08-30 20:17:34 +02:00
}
}
2017-06-07 10:55:39 +02:00
2010-02-03 17:57:23 +01:00
/*
2010-02-07 03:39:01 +01:00
* List of time spent
2014-10-12 01:04:34 +02:00
*/
2015-10-06 16:09:24 +02:00
$tasks = array ();
2017-06-07 10:55:39 +02:00
2016-08-30 20:16:58 +02:00
$sql = " SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm, " ;
$sql .= " pt.ref, pt.label, " ;
2018-02-26 13:21:16 +01:00
$sql .= " u.lastname, u.firstname, u.login, u.photo, " ;
$sql .= " il.fk_facture as invoice_id, il.total_ht " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " projet_task_time as t " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " facturedet as il ON il.rowid = t.invoice_line_id " ;
$sql .= " , " . MAIN_DB_PREFIX . " projet_task as pt, " . MAIN_DB_PREFIX . " user as u " ;
2016-08-30 20:16:58 +02:00
$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid " ;
2016-02-28 00:00:08 +01:00
if ( empty ( $projectidforalltimes )) $sql .= " AND t.fk_task = " . $object -> id ;
2016-08-31 00:15:09 +02:00
else $sql .= " AND pt.fk_projet IN ( " . $projectidforalltimes . " ) " ;
2016-08-30 20:17:34 +02:00
if ( $search_ref ) $sql .= natural_search ( 'c.ref' , $search_ref );
2016-08-31 01:04:33 +02:00
if ( $search_note ) $sql .= natural_search ( 't.note' , $search_note );
2017-04-05 14:48:24 +02:00
if ( $search_task_ref ) $sql .= natural_search ( 'pt.ref' , $search_task_ref );
if ( $search_task_label ) $sql .= natural_search ( 'pt.label' , $search_task_label );
if ( $search_user > 0 ) $sql .= natural_search ( 't.fk_user' , $search_user );
2018-01-04 00:23:08 +01:00
if ( $search_month > 0 )
{
if ( $search_year > 0 && empty ( $search_day ))
$sql .= " AND t.task_datehour BETWEEN ' " . $db -> idate ( dol_get_first_day ( $search_year , $search_month , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $search_year , $search_month , false )) . " ' " ;
else if ( $search_year > 0 && ! empty ( $search_day ))
$sql .= " AND t.task_datehour BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $search_month , $search_day , $search_year )) . " ' AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $search_month , $search_day , $search_year )) . " ' " ;
else
$sql .= " AND date_format(t.task_datehour, '%m') = ' " . $db -> escape ( $search_month ) . " ' " ;
}
else if ( $search_year > 0 )
{
$sql .= " AND t.task_datehour BETWEEN ' " . $db -> idate ( dol_get_first_day ( $search_year , 1 , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $search_year , 12 , false )) . " ' " ;
}
2016-08-30 20:17:34 +02:00
$sql .= $db -> order ( $sortfield , $sortorder );
2017-06-07 10:55:39 +02:00
2009-07-28 02:52:34 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
2016-02-28 00:00:08 +01:00
$totalnboflines = $num ;
if ( ! empty ( $projectidforalltimes ))
{
2018-02-26 12:32:26 +01:00
print '<!-- List of time spent for project -->' . " \n " ;
$title = $langs -> trans ( " ListTaskTimeUserProject " );
2018-05-04 11:25:21 +02:00
//$linktotasks='<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("GoToListOfTasks").'</a>';
2016-02-28 00:00:08 +01:00
//print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1);
2018-05-04 11:25:21 +02:00
print load_fiche_titre ( $title , $linktocreatetime , 'title_generic.png' );
2016-02-28 00:00:08 +01:00
}
2009-07-28 02:52:34 +02:00
$i = 0 ;
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
2017-06-07 10:55:39 +02:00
2018-02-26 11:57:29 +01:00
/*
* Form to add time spent
*/
if ( $action == 'createtime' && empty ( $id ) && $user -> rights -> projet -> lire )
{
print '<!-- form to add time spent -->' . " \n " ;
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="addtimespent">' ;
print '<input type="hidden" name="projectid" value="' . $projectstatic -> id . '">' ;
print '<input type="hidden" name="withproject" value="' . $withproject . '">' ;
print '<table class="noborder nohover" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Date " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Task " ) . '</td>' ;
print '<td>' . $langs -> trans ( " By " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Note " ) . '</td>' ;
print '<td>' . $langs -> trans ( " NewTimeSpent " ) . '</td>' ;
print '<td>' . $langs -> trans ( " ProgressDeclared " ) . '</td>' ;
print '<td></td>' ;
print " </tr> \n " ;
print '<tr class="oddeven">' ;
// Date
print '<td class="maxwidthonsmartphone">' ;
//$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]);
$newdate = '' ;
print $form -> select_date ( $newdate , 'time' , ( $conf -> browser -> layout == 'phone' ? 2 : 1 ), 1 , 2 , " timespent_date " , 1 , 0 , 1 );
print '</td>' ;
// Task
print '<td class="maxwidthonsmartphone">' ;
$formproject -> selectTasks ( - 1 , GETPOST ( 'taskid' , 'int' ), 'taskid' , 0 , 0 , 1 , 1 , 0 , 0 , 'maxwidth300' , $projectstatic -> id , '' );
print '</td>' ;
// Contributor
print '<td class="maxwidthonsmartphone">' ;
print img_object ( '' , 'user' , 'class="hideonsmartphone"' );
$contactsofproject = $projectstatic -> getListContactId ( 'internal' );
if ( count ( $contactsofproject ) > 0 )
{
if ( in_array ( $user -> id , $userid = $contactsofproject )) $userid = $user -> id ;
else $userid = $contactsofproject [ 0 ];
if ( $projectstatic -> public ) $contactsofproject = array ();
print $form -> select_dolusers (( GETPOST ( 'userid' ) ? GETPOST ( 'userid' ) : $userid ), 'userid' , 0 , '' , 0 , '' , $contactsofproject , 0 , 0 , 0 , '' , 0 , $langs -> trans ( " ResourceNotAssignedToProject " ), 'maxwidth200' );
}
else
{
print img_error ( $langs -> trans ( 'FirstAddRessourceToAllocateTime' )) . $langs -> trans ( 'FirstAddRessourceToAllocateTime' );
}
print '</td>' ;
// Note
print '<td>' ;
print '<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="' . ROWS_2 . '">' . ( $_POST [ 'timespent_note' ] ? $_POST [ 'timespent_note' ] : '' ) . '</textarea>' ;
print '</td>' ;
// Duration - Time spent
print '<td>' ;
print $form -> select_duration ( 'timespent_duration' , ( $_POST [ 'timespent_duration' ] ? $_POST [ 'timespent_duration' ] : '' ), 0 , 'text' );
print '</td>' ;
// Progress declared
print '<td class="nowrap">' ;
2018-08-21 14:41:59 +02:00
print $formother -> select_percent ( GETPOST ( 'progress' ) ? GETPOST ( 'progress' ) : $object -> progress , 'progress' , 0 , 5 , 0 , 100 , 1 );
2018-02-26 11:57:29 +01:00
print '</td>' ;
print '<td align="center">' ;
print '<input type="submit" name="save" class="button" value="' . $langs -> trans ( " Add " ) . '">' ;
print ' ' ;
print '<input type="submit" name="cancel" class="button" value="' . $langs -> trans ( " Cancel " ) . '">' ;
print '</td></tr>' ;
print '</table></form>' ;
print '<br>' ;
}
2016-08-30 20:17:34 +02:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2017-06-07 10:55:39 +02:00
2018-02-26 12:32:26 +01:00
$param = '' ;
2016-08-30 20:17:34 +02:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
2018-02-26 12:32:26 +01:00
if ( $search_month > 0 ) $param .= '&search_month=' . urlencode ( $search_month );
if ( $search_year > 0 ) $param .= '&search_year=' . urlencode ( $search_year );
if ( $search_user > 0 ) $param .= '&search_user=' . urlencode ( $search_user );
if ( $search_task_ref != '' ) $param .= '&search_task_ref=' . urlencode ( $search_task_ref );
if ( $search_task_label != '' ) $param .= '&search_task_label=' . urlencode ( $search_task_label );
if ( $search_note != '' ) $param .= '&search_note=' . urlencode ( $search_note );
if ( $search_duration != '' ) $param .= '&search_field2=' . urlencode ( $search_duration );
if ( $optioncss != '' ) $param .= '&optioncss=' . urlencode ( $optioncss );
2017-11-27 15:24:29 +01:00
/*
2016-08-30 20:17:34 +02:00
// Add $param from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
*/
2018-02-26 12:32:26 +01:00
if ( $id ) $param .= '&id=' . urlencode ( $id );
if ( $projectid ) $param .= '&projectid=' . urlencode ( $projectid );
if ( $withproject ) $param .= '&withproject=' . urlencode ( $withproject );
2017-06-07 10:55:39 +02:00
2016-08-30 20:17:34 +02:00
$arrayofmassactions = array (
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
2017-11-15 11:39:11 +01:00
//if ($user->rights->projet->creer) $arrayofmassactions['predelete']=$langs->trans("Delete");
2017-11-11 16:03:22 +01:00
if ( in_array ( $massaction , array ( 'presend' , 'predelete' ))) $arrayofmassactions = array ();
2016-08-30 20:17:34 +02:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2017-06-07 10:55:39 +02:00
2016-08-30 20:16:58 +02:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $id . '">' ;
2016-08-30 20:17:34 +02:00
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
2010-02-26 09:45:22 +01:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2016-08-30 20:17:34 +02:00
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
2016-08-31 01:04:33 +02:00
if ( $action == 'editline' ) print '<input type="hidden" name="action" value="updateline">' ;
else print '<input type="hidden" name="action" value="list">' ;
2016-08-30 20:17:34 +02:00
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
2017-05-21 02:43:51 +02:00
print '<input type="hidden" name="page" value="' . $page . '">' ;
2017-06-07 10:55:39 +02:00
2016-08-30 20:16:58 +02:00
print '<input type="hidden" name="id" value="' . $id . '">' ;
print '<input type="hidden" name="projectid" value="' . $projectidforalltimes . '">' ;
2014-12-04 11:03:48 +01:00
print '<input type="hidden" name="withproject" value="' . $withproject . '">' ;
2010-02-28 02:33:12 +01:00
2016-08-30 20:17:34 +02:00
$moreforfilter = '' ;
2017-06-07 10:55:39 +02:00
2016-08-30 20:17:34 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook )) $moreforfilter .= $hookmanager -> resPrint ;
else $moreforfilter = $hookmanager -> resPrint ;
2017-06-07 10:55:39 +02:00
2016-08-30 20:17:34 +02:00
if ( ! empty ( $moreforfilter ))
2015-07-28 12:49:29 +02:00
{
2016-08-30 20:17:34 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
2015-07-28 12:49:29 +02:00
}
2017-06-07 10:55:39 +02:00
2016-08-30 20:17:34 +02:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2017-06-07 10:55:39 +02:00
2016-11-27 11:41:10 +01:00
print '<div class="div-table-responsive">' ;
2016-08-30 20:17:34 +02:00
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2017-06-07 10:55:39 +02:00
2016-08-30 20:17:34 +02:00
// Fields title search
2017-04-05 14:48:24 +02:00
print '<tr class="liste_titre_filter">' ;
// Date
2018-01-04 20:42:57 +01:00
if ( ! empty ( $arrayfields [ 't.task_date' ][ 'checked' ]))
2018-01-04 00:23:08 +01:00
{
print '<td class="liste_titre">' ;
2018-05-04 11:25:21 +02:00
if ( ! empty ( $conf -> global -> MAIN_LIST_FILTER_ON_DAY )) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="' . $search_day . '">' ;
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month" value="' . $search_month . '">' ;
2018-01-04 00:23:08 +01:00
$formother -> select_year ( $search_year , 'search_year' , 1 , 20 , 5 );
print '</td>' ;
}
2016-08-31 01:04:33 +02:00
if (( empty ( $id ) && empty ( $ref )) || ! empty ( $projectidforalltimes )) // Not a dedicated task
2016-08-31 00:16:07 +02:00
{
2017-04-05 14:48:24 +02:00
if ( ! empty ( $arrayfields [ 't.task_ref' ][ 'checked' ])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="' . dol_escape_htmltag ( $search_task_ref ) . '"></td>' ;
if ( ! empty ( $arrayfields [ 't.task_label' ][ 'checked' ])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="' . dol_escape_htmltag ( $search_task_label ) . '"></td>' ;
2016-08-31 00:16:07 +02:00
}
2017-04-05 14:48:24 +02:00
// Author
2018-01-04 00:23:08 +01:00
if ( ! empty ( $arrayfields [ 'author' ][ 'checked' ])) print '<td class="liste_titre">' . $form -> select_dolusers (( $search_user > 0 ? $search_user : - 1 ), 'search_user' , 1 , null , 0 , '' , '' , 0 , 0 , 0 , '' , 0 , '' , 'maxwidth200' ) . '</td>' ;
2017-04-05 14:48:24 +02:00
// Note
if ( ! empty ( $arrayfields [ 't.note' ][ 'checked' ])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="' . dol_escape_htmltag ( $search_note ) . '"></td>' ;
// Duration
if ( ! empty ( $arrayfields [ 't.task_duration' ][ 'checked' ])) print '<td class="liste_titre right"></td>' ;
2018-02-26 13:21:16 +01:00
// Value in main currency
2017-04-05 14:48:24 +02:00
if ( ! empty ( $arrayfields [ 'value' ][ 'checked' ])) print '<td class="liste_titre"></td>' ;
2018-02-26 13:21:16 +01:00
// Value billed
if ( ! empty ( $arrayfields [ 'valuebilled' ][ 'checked' ])) print '<td class="liste_titre"></td>' ;
/*
2017-11-27 15:24:29 +01:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
*/
2016-08-30 20:17:34 +02:00
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
// Action column
2017-04-05 14:48:24 +02:00
print '<td class="liste_titre center">' ;
2017-05-14 21:20:35 +02:00
$searchpicto = $form -> showFilterAndCheckAddButtons ( $massactionbutton ? 1 : 0 , 'checkforselect' , 1 );
print $searchpicto ;
2016-08-30 20:17:34 +02:00
print '</td>' ;
2017-06-07 10:55:39 +02:00
print '</tr>' . " \n " ;
2017-04-05 14:48:24 +02:00
print '<tr class="liste_titre">' ;
2018-02-26 13:21:16 +01:00
if ( ! empty ( $arrayfields [ 't.task_date' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.task_date' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 't.task_date,t.task_datehour,t.rowid' , '' , $param , '' , $sortfield , $sortorder );
2017-04-05 14:48:24 +02:00
if (( empty ( $id ) && empty ( $ref )) || ! empty ( $projectidforalltimes )) // Not a dedicated task
{
2018-02-26 12:32:26 +01:00
if ( ! empty ( $arrayfields [ 't.task_ref' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.task_ref' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'pt.ref' , '' , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 't.task_label' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.task_label' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'pt.label' , '' , $param , '' , $sortfield , $sortorder );
2017-04-05 14:48:24 +02:00
}
2018-02-26 13:21:16 +01:00
if ( ! empty ( $arrayfields [ 'author' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'author' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], '' , '' , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 't.note' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.note' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 't.note' , '' , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 't.task_duration' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.task_duration' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 't.task_duration' , '' , $param , 'align="right"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'value' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'value' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], '' , '' , $param , 'align="right"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'valuebilled' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'valuebilled' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'il.total_ht' , '' , $param , 'align="right"' , $sortfield , $sortorder );
2017-04-05 14:48:24 +02:00
/*
2017-11-27 15:24:29 +01:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
*/
2017-04-05 14:48:24 +02:00
// Hook fields
2018-04-20 10:38:16 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
2017-04-05 14:48:24 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center" width="80"' , $sortfield , $sortorder , 'maxwidthsearch ' );
print " </tr> \n " ;
2016-08-31 00:16:07 +02:00
2016-08-30 20:16:58 +02:00
$tasktmp = new Task ( $db );
2017-06-07 10:55:39 +02:00
2016-08-31 01:04:33 +02:00
$i = 0 ;
2017-01-13 16:49:18 +01:00
2017-01-13 13:43:09 +01:00
$childids = $user -> getAllChildIds ();
2017-06-07 10:55:39 +02:00
2011-07-14 17:37:37 +02:00
$total = 0 ;
2015-07-28 12:49:29 +02:00
$totalvalue = 0 ;
2016-08-31 01:04:33 +02:00
$totalarray = array ();
2009-07-28 02:52:34 +02:00
foreach ( $tasks as $task_time )
{
2017-06-07 10:55:39 +02:00
2017-04-05 14:48:24 +02:00
print '<tr class="oddeven">' ;
2013-05-14 20:22:33 +02:00
2015-03-05 13:48:57 +01:00
$date1 = $db -> jdate ( $task_time -> task_date );
$date2 = $db -> jdate ( $task_time -> task_datehour );
2013-05-14 20:22:33 +02:00
// Date
2016-08-30 20:17:34 +02:00
if ( ! empty ( $arrayfields [ 't.task_date' ][ 'checked' ]))
2013-05-14 20:22:33 +02:00
{
2016-08-30 20:17:34 +02:00
print '<td class="nowrap">' ;
if ( $_GET [ 'action' ] == 'editline' && $_GET [ 'lineid' ] == $task_time -> rowid )
{
2018-04-26 10:07:27 +02:00
if ( empty ( $task_time -> task_date_withhour ))
{
print $form -> select_date (( $date2 ? $date2 : $date1 ), 'timeline' , 3 , 3 , 2 , " timespent_date " , 1 , 0 , 1 );
}
else print $form -> select_date (( $date2 ? $date2 : $date1 ), 'timeline' , 1 , 1 , 2 , " timespent_date " , 1 , 0 , 1 );
2016-08-30 20:17:34 +02:00
}
else
{
print dol_print_date (( $date2 ? $date2 : $date1 ),( $task_time -> task_date_withhour ? 'dayhour' : 'day' ));
}
print '</td>' ;
2016-08-31 01:04:33 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2013-05-14 20:22:33 +02:00
}
2016-08-31 00:16:07 +02:00
2016-10-24 18:43:17 +02:00
// Task ref
2016-08-31 00:16:07 +02:00
if ( ! empty ( $arrayfields [ 't.task_ref' ][ 'checked' ]))
{
2016-08-31 01:04:33 +02:00
if (( empty ( $id ) && empty ( $ref )) || ! empty ( $projectidforalltimes )) // Not a dedicated task
2016-08-31 00:16:07 +02:00
{
print '<td class="nowrap">' ;
$tasktmp -> id = $task_time -> fk_task ;
$tasktmp -> ref = $task_time -> ref ;
$tasktmp -> label = $task_time -> label ;
2017-06-07 10:55:39 +02:00
print $tasktmp -> getNomUrl ( 1 , 'withproject' , 'time' );
2016-08-31 00:16:07 +02:00
print '</td>' ;
2016-08-31 01:04:33 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-08-31 00:16:07 +02:00
}
}
2017-06-07 10:55:39 +02:00
2016-10-24 18:43:17 +02:00
// Task label
if ( ! empty ( $arrayfields [ 't.task_label' ][ 'checked' ]))
{
if (( empty ( $id ) && empty ( $ref )) || ! empty ( $projectidforalltimes )) // Not a dedicated task
{
print '<td class="nowrap">' ;
2017-06-07 10:55:39 +02:00
print $task_time -> label ;
2016-10-24 18:43:17 +02:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
}
2017-06-07 10:55:39 +02:00
2016-10-24 18:43:17 +02:00
// User
2017-06-07 10:55:39 +02:00
if ( ! empty ( $arrayfields [ 'author' ][ 'checked' ]))
2016-08-30 20:17:34 +02:00
{
print '<td>' ;
if ( $_GET [ 'action' ] == 'editline' && $_GET [ 'lineid' ] == $task_time -> rowid )
{
2016-08-31 00:16:07 +02:00
if ( empty ( $object -> id )) $object -> fetch ( $id );
$contactsoftask = $object -> getListContactId ( 'internal' );
2016-08-30 20:17:34 +02:00
if ( ! in_array ( $task_time -> fk_user , $contactsoftask )) {
$contactsoftask [] = $task_time -> fk_user ;
}
if ( count ( $contactsoftask ) > 0 ) {
print img_object ( '' , 'user' , 'class="hideonsmartphone"' );
print $form -> select_dolusers ( $task_time -> fk_user , 'userid_line' , 0 , '' , 0 , '' , $contactsoftask );
} else {
print img_error ( $langs -> trans ( 'FirstAddRessourceToAllocateTime' )) . $langs -> trans ( 'FirstAddRessourceToAllocateTime' );
}
}
else
{
$userstatic -> id = $task_time -> fk_user ;
$userstatic -> lastname = $task_time -> lastname ;
$userstatic -> firstname = $task_time -> firstname ;
2017-04-05 14:48:24 +02:00
$userstatic -> photo = $task_time -> photo ;
print $userstatic -> getNomUrl ( - 1 );
2016-08-30 20:17:34 +02:00
}
print '</td>' ;
2016-08-31 01:04:33 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-08-30 20:17:34 +02:00
}
2013-05-14 20:22:33 +02:00
// Note
2017-06-07 10:55:39 +02:00
if ( ! empty ( $arrayfields [ 't.note' ][ 'checked' ]))
2016-08-30 20:17:34 +02:00
{
print '<td align="left">' ;
if ( $_GET [ 'action' ] == 'editline' && $_GET [ 'lineid' ] == $task_time -> rowid )
{
print '<textarea name="timespent_note_line" width="95%" rows="' . ROWS_2 . '">' . $task_time -> note . '</textarea>' ;
}
else
{
print dol_nl2br ( $task_time -> note );
}
print '</td>' ;
2016-08-31 01:04:33 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-08-30 20:17:34 +02:00
}
2017-06-07 10:55:39 +02:00
2013-05-14 20:22:33 +02:00
// Time spent
2016-08-30 20:17:34 +02:00
if ( ! empty ( $arrayfields [ 't.task_duration' ][ 'checked' ]))
{
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 . '">' ;
print $form -> select_duration ( 'new_duration' , $task_time -> task_duration , 0 , 'text' );
}
else
{
print convertSecondToTime ( $task_time -> task_duration , 'allhourmin' );
}
print '</td>' ;
2016-08-31 01:04:33 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
if ( ! $i ) $totalarray [ 'totaldurationfield' ] = $totalarray [ 'nbfield' ];
$totalarray [ 'totalduration' ] += $task_time -> task_duration ;
2016-08-30 20:17:34 +02:00
}
2017-06-07 10:55:39 +02:00
2015-07-28 12:49:29 +02:00
// Value spent
2017-06-07 10:55:39 +02:00
if ( ! empty ( $arrayfields [ 'value' ][ 'checked' ]))
2016-08-30 20:17:34 +02:00
{
2015-07-28 12:49:29 +02:00
print '<td align="right">' ;
2016-08-31 01:04:33 +02:00
$value = price2num ( $task_time -> thm * $task_time -> task_duration / 3600 );
print price ( $value , 1 , $langs , 1 , - 1 , - 1 , $conf -> currency );
2015-07-28 12:49:29 +02:00
print '</td>' ;
2016-08-31 01:04:33 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
if ( ! $i ) $totalarray [ 'totalvaluefield' ] = $totalarray [ 'nbfield' ];
$totalarray [ 'totalvalue' ] += $value ;
}
2015-07-28 12:49:29 +02:00
2018-02-26 13:21:16 +01:00
// Value billed
if ( ! empty ( $arrayfields [ 'valuebilled' ][ 'checked' ]))
{
print '<td align="right">' ;
$valuebilled = price2num ( $task_time -> total_ht );
if ( isset ( $task_time -> total_ht )) print price ( $valuebilled , 1 , $langs , 1 , - 1 , - 1 , $conf -> currency );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
if ( ! $i ) $totalarray [ 'totalvaluefield' ] = $totalarray [ 'nbfield' ];
$totalarray [ 'totalvaluebilled' ] += $valuebilled ;
}
2017-11-27 15:24:29 +01:00
/*
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
*/
2016-08-30 20:17:34 +02:00
// Fields from hook
2017-08-06 18:35:25 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $task_time );
2016-08-30 20:17:34 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2017-06-07 10:55:39 +02:00
2016-08-30 20:17:34 +02:00
// Action column
2018-04-26 10:07:27 +02:00
print '<td class="center nowraponall">' ;
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' ) . '">' ;
}
2017-11-22 17:25:31 +01:00
else if ( $user -> rights -> projet -> lire || $user -> rights -> projet -> all -> creer ) // Read project and enter time consumed on assigned tasks
2010-02-24 10:53:16 +01:00
{
2017-11-22 17:25:31 +01:00
if ( $task_time -> fk_user == $user -> id || in_array ( $task_time -> fk_user , $childids ) || $user -> rights -> projet -> all -> creer )
{
2018-03-07 20:12:40 +01:00
//$param = ($projectidforalltimes?'projectid='.$projectidforalltimes.'&':'').'.($withproject?'&withproject=1':'');
2017-11-22 17:25:31 +01:00
print ' ' ;
2018-03-07 20:12:40 +01:00
print '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $task_time -> fk_task . '&action=editline&lineid=' . $task_time -> rowid . $param . '">' ;
2017-11-22 17:25:31 +01:00
print img_edit ();
print '</a>' ;
print ' ' ;
2018-03-07 20:12:40 +01:00
print '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $task_time -> fk_task . '&action=deleteline&lineid=' . $task_time -> rowid . $param . '">' ;
2017-11-22 17:25:31 +01:00
print img_delete ();
print '</a>' ;
2017-01-13 13:43:09 +01:00
}
2010-02-24 10:53:16 +01:00
}
2016-08-31 01:04:33 +02:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-06-07 10:55:39 +02:00
2010-02-24 10:53:16 +01:00
print " </tr> \n " ;
2017-06-07 10:55:39 +02:00
2016-08-31 01:04:33 +02:00
$i ++ ;
2009-07-28 02:52:34 +02:00
}
2017-06-07 10:55:39 +02:00
2016-08-31 01:04:33 +02:00
// Show total line
if ( isset ( $totalarray [ 'totaldurationfield' ]) || isset ( $totalarray [ 'totalvaluefield' ]))
2015-07-28 12:49:29 +02:00
{
2016-08-31 01:04:33 +02:00
print '<tr class="liste_total">' ;
$i = 0 ;
while ( $i < $totalarray [ 'nbfield' ])
{
$i ++ ;
if ( $i == 1 )
{
2017-05-10 11:57:59 +02:00
if ( $num < $limit && empty ( $offset )) print '<td align="left">' . $langs -> trans ( " Total " ) . '</td>' ;
2016-08-31 01:04:33 +02:00
else print '<td align="left">' . $langs -> trans ( " Totalforthispage " ) . '</td>' ;
}
elseif ( $totalarray [ 'totaldurationfield' ] == $i ) print '<td align="right">' . convertSecondToTime ( $totalarray [ 'totalduration' ], 'allhourmin' ) . '</td>' ;
elseif ( $totalarray [ 'totalvaluefield' ] == $i ) print '<td align="right">' . price ( $totalarray [ 'totalvalue' ]) . '</td>' ;
else print '<td></td>' ;
}
print '</tr>' ;
2015-07-28 12:49:29 +02:00
}
2016-08-31 01:04:33 +02:00
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> " ;
2016-11-27 11:41:10 +01:00
print '</div>' ;
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 ();