2005-08-20 23:44:34 +02:00
< ? php
2009-01-10 04:40:06 +01:00
/* Copyright ( C ) 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2019-03-29 13:18:12 +01:00
* Copyright ( C ) 2006 - 2019 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2006 - 2010 Regis Houssin < regis . houssin @ inodbox . com >
2018-04-20 10:38:16 +02:00
* Copyright ( C ) 2018 Ferran Marcet < fmarcet @ 2 byte . es >
2021-08-25 09:30:52 +02:00
* Copyright ( C ) 2021 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2008-09-10 22:49:21 +02:00
*
2005-08-20 23:44:34 +02: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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2005-08-20 23:44:34 +02:00
* ( 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2005-08-20 23:44:34 +02:00
*/
/**
2015-12-04 15:37:28 +01:00
* \file htdocs / projet / tasks / list . php
2009-01-10 04:40:06 +01:00
* \ingroup project
2019-03-29 14:34:55 +01:00
* \brief List all tasks of a project
2008-09-10 22:49:21 +02:00
*/
2005-08-20 23:44:34 +02:00
2018-07-26 11:57:25 +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' ;
2016-01-21 15:09:46 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2005-08-20 23:44:34 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2017-04-11 02:48:16 +02:00
$langs -> loadLangs ( array ( 'projects' , 'users' , 'companies' ));
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-11-12 09:46:08 +01:00
$massaction = GETPOST ( 'massaction' , 'alpha' );
$show_files = GETPOST ( 'show_files' , 'int' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
2017-04-11 02:48:16 +02:00
$toselect = GETPOST ( 'toselect' , 'array' );
2021-06-09 15:36:47 +02:00
$optioncss = GETPOST ( 'optioncss' , 'aZ09' );
2022-03-31 18:06:39 +02:00
$mode = GETPOST ( 'mode' , 'aZ' );
2008-09-10 13:14:45 +02:00
2019-11-12 09:46:08 +01:00
$id = GETPOST ( 'id' , 'int' );
2015-10-17 02:41:09 +02:00
2019-11-12 09:46:08 +01:00
$search_all = trim (( GETPOST ( 'search_all' , 'alphanohtml' ) != '' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' ));
$search_categ = GETPOST ( " search_categ " , 'alpha' );
2020-04-28 12:40:10 +02:00
$search_projectstatus = GETPOST ( 'search_projectstatus' );
2021-02-26 18:49:22 +01:00
if ( ! isset ( $search_projectstatus ) || $search_projectstatus === '' ) {
if ( $search_all != '' ) {
$search_projectstatus = - 1 ;
} else {
$search_projectstatus = 1 ;
}
2016-07-03 20:15:26 +02:00
}
2020-04-28 12:40:10 +02:00
2019-11-12 09:46:08 +01:00
$search_project_ref = GETPOST ( 'search_project_ref' );
$search_project_title = GETPOST ( 'search_project_title' );
$search_task_ref = GETPOST ( 'search_task_ref' );
$search_task_label = GETPOST ( 'search_task_label' );
$search_task_description = GETPOST ( 'search_task_description' );
2020-03-24 19:50:01 +01:00
$search_task_ref_parent = GETPOST ( 'search_task_ref_parent' );
2021-08-23 19:37:11 +02:00
$search_project_user = GETPOST ( 'search_project_user' , 'int' );
$search_task_user = GETPOST ( 'search_task_user' , 'int' );
2020-06-24 10:17:46 +02:00
$search_task_progress = GETPOST ( 'search_task_progress' );
2021-10-15 10:24:56 +02:00
$search_task_budget_amount = GETPOST ( 'search_task_budget_amount' );
2020-07-06 12:27:25 +02:00
$search_societe = GETPOST ( 'search_societe' );
2021-10-24 13:57:04 +02:00
$search_opp_status = GETPOST ( " search_opp_status " , 'alpha' );
2019-11-12 09:46:08 +01:00
2021-10-24 14:00:05 +02:00
$mine = GETPOST ( 'mode' , 'alpha' ) == 'mine' ? 1 : 0 ;
2021-02-26 18:49:22 +01:00
if ( $mine ) {
2021-10-24 14:00:05 +02:00
$search_task_user = $user -> id ;
$mine = 0 ;
2021-02-26 18:49:22 +01:00
}
2021-10-23 22:32:03 +02:00
$type = GETPOST ( 'type' );
2016-01-21 15:09:46 +01:00
2021-08-25 09:30:52 +02:00
$search_date_startday = GETPOST ( 'search_date_startday' , 'int' );
$search_date_startmonth = GETPOST ( 'search_date_startmonth' , 'int' );
$search_date_startyear = GETPOST ( 'search_date_startyear' , 'int' );
$search_date_endday = GETPOST ( 'search_date_endday' , 'int' );
$search_date_endmonth = GETPOST ( 'search_date_endmonth' , 'int' );
$search_date_endyear = GETPOST ( 'search_date_endyear' , 'int' );
$search_date_start = dol_mktime ( 0 , 0 , 0 , $search_date_startmonth , $search_date_startday , $search_date_startyear ); // Use tzserver
$search_date_end = dol_mktime ( 23 , 59 , 59 , $search_date_endmonth , $search_date_endday , $search_date_endyear );
$search_datelimit_startday = GETPOST ( 'search_datelimit_startday' , 'int' );
$search_datelimit_startmonth = GETPOST ( 'search_datelimit_startmonth' , 'int' );
$search_datelimit_startyear = GETPOST ( 'search_datelimit_startyear' , 'int' );
$search_datelimit_endday = GETPOST ( 'search_datelimit_endday' , 'int' );
$search_datelimit_endmonth = GETPOST ( 'search_datelimit_endmonth' , 'int' );
$search_datelimit_endyear = GETPOST ( 'search_datelimit_endyear' , 'int' );
$search_datelimit_start = dol_mktime ( 0 , 0 , 0 , $search_datelimit_startmonth , $search_datelimit_startday , $search_datelimit_startyear );
$search_datelimit_end = dol_mktime ( 23 , 59 , 59 , $search_datelimit_endmonth , $search_datelimit_endday , $search_datelimit_endyear );
2016-01-21 15:09:46 +01:00
2016-06-07 14:06:00 +02:00
// Initialize context for list
2019-11-12 09:46:08 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'tasklist' ;
2016-01-21 15:09:46 +01: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 Task ( $db );
$hookmanager -> initHooks ( array ( 'tasklist' ));
2016-01-21 15:09:46 +01:00
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2019-11-12 09:46:08 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2015-12-04 15:37:28 +01:00
2008-09-10 22:49:21 +02:00
// Security check
2019-11-12 09:46:08 +01:00
$socid = 0 ;
2019-10-31 20:46:31 +01:00
//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
2021-02-26 18:49:22 +01:00
if ( ! $user -> rights -> projet -> lire ) {
accessforbidden ();
}
2008-09-10 22:49:21 +02:00
2022-06-14 17:53:17 +02:00
$diroutputmassaction = $conf -> project -> dir_output . '/tasks/temp/massgeneration/' . $user -> id ;
2017-04-11 02:48:16 +02:00
2019-11-12 09:46:08 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2022-01-13 11:09:37 +01:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2022-03-31 18:06:39 +02:00
if ( empty ( $page ) || $page < 0 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) {
// If $page is not defined, or '' or -1 or if we click on clear filters
2021-02-26 18:49:22 +01:00
$page = 0 ;
2022-03-31 18:06:39 +02:00
}
2016-01-21 15:09:46 +01:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2021-02-26 18:49:22 +01:00
if ( ! $sortfield ) {
$sortfield = 'p.ref' ;
}
if ( ! $sortorder ) {
$sortorder = 'DESC' ;
}
2012-03-19 14:44:27 +01:00
2015-10-17 02:41:09 +02:00
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
't.ref' => " Ref " ,
2017-10-13 13:28:26 +02:00
't.label' => " Label " ,
't.description' => " Description " ,
't.note_public' => " NotePublic " ,
2016-01-21 15:09:46 +01:00
);
2021-02-26 18:49:22 +01:00
if ( empty ( $user -> socid )) {
$fieldstosearchall [ 't.note_private' ] = " NotePrivate " ;
}
2016-01-21 15:09:46 +01:00
2019-11-12 09:46:08 +01:00
$arrayfields = array (
2021-03-27 14:30:10 +01:00
't.fk_task_parent' => array ( 'label' => " RefTaskParent " , 'checked' => 0 , 'position' => 70 ),
't.ref' => array ( 'label' => " RefTask " , 'checked' => 1 , 'position' => 80 ),
't.label' => array ( 'label' => " LabelTask " , 'checked' => 1 , 'position' => 80 ),
't.description' => array ( 'label' => " Description " , 'checked' => 0 , 'position' => 80 ),
't.dateo' => array ( 'label' => " DateStart " , 'checked' => 1 , 'position' => 100 ),
't.datee' => array ( 'label' => " Deadline " , 'checked' => 1 , 'position' => 101 ),
'p.ref' => array ( 'label' => " ProjectRef " , 'checked' => 1 ),
'p.title' => array ( 'label' => " ProjectLabel " , 'checked' => 0 ),
's.nom' => array ( 'label' => " ThirdParty " , 'checked' => 0 ),
'p.fk_statut' => array ( 'label' => " ProjectStatus " , 'checked' => 1 ),
't.planned_workload' => array ( 'label' => " PlannedWorkload " , 'checked' => 1 , 'position' => 102 ),
't.duration_effective' => array ( 'label' => " TimeSpent " , 'checked' => 1 , 'position' => 103 ),
't.progress_calculated' => array ( 'label' => " ProgressCalculated " , 'checked' => 1 , 'position' => 104 ),
't.progress' => array ( 'label' => " ProgressDeclared " , 'checked' => 1 , 'position' => 105 ),
't.progress_summary' => array ( 'label' => " TaskProgressSummary " , 'checked' => 1 , 'position' => 106 ),
2022-07-26 10:54:03 +02:00
't.budget_amount' => array ( 'label' => " Budget " , 'checked' => 0 , 'position' => 107 ),
2021-03-27 14:30:10 +01:00
't.tobill' => array ( 'label' => " TimeToBill " , 'checked' => 0 , 'position' => 110 ),
't.billed' => array ( 'label' => " TimeBilled " , 'checked' => 0 , 'position' => 111 ),
't.datec' => array ( 'label' => " DateCreation " , 'checked' => 0 , 'position' => 500 ),
't.tms' => array ( 'label' => " DateModificationShort " , 'checked' => 0 , 'position' => 500 ),
//'t.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
2015-10-17 02:41:09 +02:00
);
2016-01-21 15:09:46 +01:00
// Extra fields
2020-12-23 19:14:47 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php' ;
2019-09-02 03:58:00 +02:00
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2015-10-17 02:41:09 +02:00
2022-03-31 18:06:39 +02:00
$permissiontoread = $user -> rights -> projet -> lire ;
$permissiontodelete = $user -> rights -> projet -> supprimer ;
2015-04-23 15:22:50 +02:00
/*
* Actions
*/
2021-02-26 18:49:22 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
2022-03-31 18:06:39 +02:00
$action = 'list' ;
$massaction = '' ;
2021-02-26 18:49:22 +01:00
}
2022-04-25 14:28:57 +02:00
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
2021-02-26 18:49:22 +01:00
$massaction = '' ;
}
2016-11-02 12:48:50 +01:00
2019-11-12 09:46:08 +01:00
$parameters = array ( 'socid' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 18:49:22 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2016-11-02 12:48:50 +01:00
2021-02-26 18:49:22 +01:00
if ( empty ( $reshook )) {
2017-10-13 13:28:26 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
2021-02-26 18:49:22 +01: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
2019-11-12 09:46:08 +01:00
$search_all = " " ;
$search_categ = " " ;
$search_projectstatus = - 1 ;
$search_project_ref = " " ;
$search_project_title = " " ;
$search_task_ref = " " ;
$search_task_label = " " ;
$search_task_description = " " ;
2020-03-24 19:50:01 +01:00
$search_task_ref_parent = " " ;
2020-06-24 10:17:46 +02:00
$search_task_progress = " " ;
2021-10-15 10:24:56 +02:00
$search_task_budget_amount = " " ;
2019-11-12 09:46:08 +01:00
$search_task_user = - 1 ;
$search_project_user = - 1 ;
2021-08-25 09:30:52 +02:00
$search_date_startday = '' ;
$search_date_startmonth = '' ;
$search_date_startyear = '' ;
$search_date_endday = '' ;
$search_date_endmonth = '' ;
$search_date_endyear = '' ;
$search_date_start = '' ;
$search_date_end = '' ;
$search_datelimit_startday = '' ;
$search_datelimit_startmonth = '' ;
$search_datelimit_startyear = '' ;
$search_datelimit_endday = '' ;
$search_datelimit_endmonth = '' ;
$search_datelimit_endyear = '' ;
$search_datelimit_start = '' ;
$search_datelimit_end = '' ;
2022-03-31 18:06:39 +02:00
$toselect = array ();
2019-11-12 09:46:08 +01:00
$search_array_options = array ();
2017-10-13 13:28:26 +02:00
}
// Mass actions
2019-11-12 09:46:08 +01:00
$objectclass = 'Task' ;
$objectlabel = 'Tasks' ;
2022-06-14 17:53:17 +02:00
$uploaddir = $conf -> project -> dir_output . '/tasks' ;
2017-10-13 13:28:26 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2016-01-21 15:09:46 +01:00
}
2016-11-02 12:48:50 +01:00
2021-02-26 18:49:22 +01:00
if ( empty ( $search_projectstatus ) && $search_projectstatus == '' ) {
$search_projectstatus = 1 ;
}
2016-01-21 15:09:46 +01:00
2015-04-23 15:22:50 +02:00
2008-09-10 22:49:21 +02:00
/*
* View
*/
2010-05-29 01:26:08 +02:00
2019-11-12 09:46:08 +01:00
$form = new Form ( $db );
2022-03-31 18:06:39 +02:00
$now = dol_now ();
$help_url = " EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos " ;
$morejs = array ();
$morecss = array ();
2019-11-12 09:46:08 +01:00
$formother = new FormOther ( $db );
$socstatic = new Societe ( $db );
2012-02-15 23:08:20 +01:00
$projectstatic = new Project ( $db );
2019-11-12 09:46:08 +01:00
$puser = new User ( $db );
$tuser = new User ( $db );
2021-02-26 18:49:22 +01:00
if ( $search_project_user > 0 ) {
$puser -> fetch ( $search_project_user );
}
if ( $search_task_user > 0 ) {
$tuser -> fetch ( $search_task_user );
}
2012-02-15 23:08:20 +01:00
2019-03-29 13:18:12 +01:00
2019-11-12 09:46:08 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2019-03-29 13:18:12 +01:00
2019-11-12 09:46:08 +01:00
$title = $langs -> trans ( " Activities " );
2017-03-14 13:49:04 +01:00
//if ($search_task_user == $user->id) $title=$langs->trans("MyActivities");
2008-09-10 22:49:21 +02:00
2021-02-26 18:49:22 +01:00
if ( $id ) {
2012-02-15 23:08:20 +01:00
$projectstatic -> fetch ( $id );
2019-03-29 13:39:59 +01:00
$projectstatic -> fetch_thirdparty ();
2010-02-07 03:39:01 +01:00
}
2014-01-06 12:42:50 +01:00
// Get list of project id allowed to user (in a string list separated by coma)
2021-10-24 10:02:12 +02:00
if ( empty ( $user -> rights -> projet -> all -> lire )) {
2021-02-26 18:49:22 +01:00
$projectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 1 , $socid );
}
2015-12-04 15:37:28 +01:00
//var_dump($projectsListId);
2012-03-19 14:44:27 +01:00
2016-01-21 15:09:46 +01:00
// Get id of types of contacts for projects (This list never contains a lot of elements)
2019-11-12 09:46:08 +01:00
$listofprojectcontacttype = array ();
2016-01-21 15:09:46 +01:00
$sql = " SELECT ctc.rowid, ctc.code FROM " . MAIN_DB_PREFIX . " c_type_contact as ctc " ;
2020-09-20 03:32:43 +02:00
$sql .= " WHERE ctc.element = ' " . $db -> escape ( $projectstatic -> element ) . " ' " ;
2019-11-12 09:46:08 +01:00
$sql .= " AND ctc.source = 'internal' " ;
2016-01-21 15:09:46 +01:00
$resql = $db -> query ( $sql );
2021-02-26 18:49:22 +01:00
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
2019-11-12 09:46:08 +01:00
$listofprojectcontacttype [ $obj -> rowid ] = $obj -> code ;
2017-10-13 13:28:26 +02:00
}
2021-02-26 18:49:22 +01:00
} else {
dol_print_error ( $db );
}
if ( count ( $listofprojectcontacttype ) == 0 ) {
$listofprojectcontacttype [ 0 ] = '0' ; // To avoid sql syntax error if not found
}
2016-01-21 15:09:46 +01:00
// Get id of types of contacts for tasks (This list never contains a lot of elements)
2019-11-12 09:46:08 +01:00
$listoftaskcontacttype = array ();
2016-01-21 15:09:46 +01:00
$sql = " SELECT ctc.rowid, ctc.code FROM " . MAIN_DB_PREFIX . " c_type_contact as ctc " ;
2020-09-20 03:32:43 +02:00
$sql .= " WHERE ctc.element = ' " . $db -> escape ( $object -> element ) . " ' " ;
2019-11-12 09:46:08 +01:00
$sql .= " AND ctc.source = 'internal' " ;
2016-01-21 15:09:46 +01:00
$resql = $db -> query ( $sql );
2021-02-26 18:49:22 +01:00
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
2019-11-12 09:46:08 +01:00
$listoftaskcontacttype [ $obj -> rowid ] = $obj -> code ;
2017-10-13 13:28:26 +02:00
}
2021-02-26 18:49:22 +01:00
} else {
dol_print_error ( $db );
}
if ( count ( $listoftaskcontacttype ) == 0 ) {
$listoftaskcontacttype [ 0 ] = '0' ; // To avoid sql syntax error if not found
}
2016-01-21 15:09:46 +01:00
2019-11-12 09:46:08 +01:00
$distinct = 'DISTINCT' ; // We add distinct until we are added a protection to be sure a contact of a project and task is assigned only once.
2019-09-01 01:40:51 +02:00
$sql = " SELECT " . $distinct . " p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.datee as projectdatee, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate, p.usage_bill_time, " ;
2019-11-12 09:46:08 +01:00
$sql .= " s.nom as name, s.rowid as socid, " ;
$sql .= " t.datec as date_creation, t.dateo as date_start, t.datee as date_end, t.tms as date_update, " ;
2020-03-24 19:50:01 +01:00
$sql .= " t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut, " ;
$sql .= " t.description, t.fk_task_parent " ;
2021-10-15 10:24:56 +02:00
$sql .= " ,t.budget_amount " ;
2017-03-14 13:49:04 +01:00
// We'll need these fields in order to filter by categ
2022-07-21 15:59:46 +02:00
if ( $search_categ > 0 ) {
2021-02-26 18:49:22 +01:00
$sql .= " , cs.fk_categorie, cs.fk_project " ;
}
2019-03-29 13:18:12 +01:00
// Add sum fields
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.tobill' ][ 'checked' ]) || ! empty ( $arrayfields [ 't.billed' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
$sql .= " , SUM(tt.task_duration * " . $db -> ifsql ( " invoice_id IS NULL " , " 1 " , " 0 " ) . " ) as tobill, SUM(tt.task_duration * " . $db -> ifsql ( " invoice_id IS NULL " , " 0 " , " 1 " ) . " ) as billed " ;
2019-03-29 13:18:12 +01:00
}
2016-10-11 12:27:20 +02:00
// Add fields from extrafields
2019-11-12 09:46:08 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-26 18:49:22 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) {
2021-08-27 22:42:04 +02:00
$sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " , ef. " . $key . " as options_ " . $key : '' );
2021-02-26 18:49:22 +01:00
}
2019-10-16 03:34:32 +02:00
}
2016-01-21 15:09:46 +01:00
// Add fields from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql .= " FROM " . MAIN_DB_PREFIX . " projet as p " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s on p.fk_soc = s.rowid " ;
2017-03-14 13:49:04 +01:00
// We'll need this table joined to the select in order to filter by categ
2022-07-21 15:59:46 +02:00
if ( $search_categ > 0 ) {
2021-02-26 18:49:22 +01:00
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . " categorie_project as cs ON p.rowid = cs.fk_project " ; // We'll need this table joined to the select in order to filter by categ
}
2019-11-12 09:46:08 +01:00
$sql .= " , " . MAIN_DB_PREFIX . " projet_task as t " ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.tobill' ][ 'checked' ]) || ! empty ( $arrayfields [ 't.billed' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " projet_task_time as tt ON tt.fk_task = t.rowid " ;
2019-03-29 13:18:12 +01:00
}
2021-10-24 13:57:04 +02:00
if ( isset ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-26 18:49:22 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object -> table_element . " _extrafields as ef on (t.rowid = ef.fk_object) " ;
}
if ( $search_project_user > 0 ) {
$sql .= " , " . MAIN_DB_PREFIX . " element_contact as ecp " ;
}
if ( $search_task_user > 0 ) {
$sql .= " , " . MAIN_DB_PREFIX . " element_contact as ect " ;
}
2019-11-12 09:46:08 +01:00
$sql .= " WHERE t.fk_projet = p.rowid " ;
$sql .= " AND p.entity IN ( " . getEntity ( 'project' ) . ')' ;
2021-10-24 10:02:12 +02:00
if ( empty ( $user -> rights -> projet -> all -> lire )) {
2021-03-22 11:30:18 +01:00
$sql .= " AND p.rowid IN ( " . $db -> sanitize ( $projectsListId ? $projectsListId : '0' ) . " ) " ; // public and assigned to projects, or restricted to company for external users
2021-02-26 18:49:22 +01:00
}
if ( is_object ( $projectstatic ) && $projectstatic -> id > 0 ) {
2021-03-22 11:30:18 +01:00
$sql .= " AND p.rowid = " . (( int ) $projectstatic -> id );
2021-02-26 18:49:22 +01:00
}
2016-01-21 15:09:46 +01:00
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
2021-02-26 18:49:22 +01:00
if ( $socid ) {
2021-03-22 11:30:18 +01:00
$sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . (( int ) $socid ) . " ) " ;
2021-02-26 18:49:22 +01:00
}
if ( $search_categ > 0 ) {
2021-03-22 11:30:18 +01:00
$sql .= " AND cs.fk_categorie = " . (( int ) $search_categ );
2021-02-26 18:49:22 +01:00
}
if ( $search_categ == - 2 ) {
$sql .= " AND cs.fk_categorie IS NULL " ;
}
if ( $search_project_ref ) {
$sql .= natural_search ( 'p.ref' , $search_project_ref );
}
if ( $search_project_title ) {
$sql .= natural_search ( 'p.title' , $search_project_title );
}
if ( $search_task_ref ) {
$sql .= natural_search ( 't.ref' , $search_task_ref );
}
if ( $search_task_label ) {
$sql .= natural_search ( 't.label' , $search_task_label );
}
if ( $search_task_description ) {
$sql .= natural_search ( 't.description' , $search_task_description );
}
if ( $search_task_ref_parent ) {
$sql .= ' AND t.fk_task_parent IN (SELECT ipt.rowid FROM ' . MAIN_DB_PREFIX . 'projet_task as ipt WHERE ' . natural_search ( 'ipt.ref' , $search_task_ref_parent , 0 , 1 ) . ')' ;
}
if ( $search_task_progress ) {
$sql .= natural_search ( 't.progress' , $search_task_progress , 1 );
}
2021-10-15 10:24:56 +02:00
if ( $search_task_budget_amount ) {
$sql .= natural_search ( 't.budget_amount' , $search_task_budget_amount , 1 );
}
2021-02-26 18:49:22 +01:00
if ( $search_societe ) {
$sql .= natural_search ( 's.nom' , $search_societe );
}
2021-08-25 09:30:52 +02:00
if ( $search_date_start ) {
$sql .= " AND t.dateo >= ' " . $db -> idate ( $search_date_start ) . " ' " ;
}
if ( $search_date_end ) {
$sql .= " AND t.dateo <= ' " . $db -> idate ( $search_date_end ) . " ' " ;
}
if ( $search_datelimit_start ) {
$sql .= " AND t.datee >= ' " . $db -> idate ( $search_datelimit_start ) . " ' " ;
}
if ( $search_datelimit_end ) {
$sql .= " AND t.datee <= ' " . $db -> idate ( $search_datelimit_end ) . " ' " ;
}
2021-02-26 18:49:22 +01:00
if ( $search_all ) {
$sql .= natural_search ( array_keys ( $fieldstosearchall ), $search_all );
}
if ( $search_projectstatus >= 0 ) {
if ( $search_projectstatus == 99 ) {
$sql .= " AND p.fk_statut <> 2 " ;
} else {
2021-06-09 15:36:47 +02:00
$sql .= " AND p.fk_statut = " . (( int ) $search_projectstatus );
2021-02-26 18:49:22 +01:00
}
}
if ( $search_project_user > 0 ) {
2021-08-23 18:56:46 +02:00
$sql .= " AND ecp.fk_c_type_contact IN ( " . $db -> sanitize ( join ( ',' , array_keys ( $listofprojectcontacttype ))) . " ) AND ecp.element_id = p.rowid AND ecp.fk_socpeople = " . (( int ) $search_project_user );
2021-02-26 18:49:22 +01:00
}
if ( $search_task_user > 0 ) {
2021-08-23 18:56:46 +02:00
$sql .= " AND ect.fk_c_type_contact IN ( " . $db -> sanitize ( join ( ',' , array_keys ( $listoftaskcontacttype ))) . " ) AND ect.element_id = t.rowid AND ect.fk_socpeople = " . (( int ) $search_task_user );
2021-02-26 18:49:22 +01:00
}
2016-04-04 16:02:29 +02:00
// Add where from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
2016-01-21 15:09:46 +01:00
// Add where from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
2022-03-31 18:06:39 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2019-11-12 09:46:08 +01:00
$sql .= $hookmanager -> resPrint ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.tobill' ][ 'checked' ]) || ! empty ( $arrayfields [ 't.billed' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
$sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_statut, p.datee, p.fk_opp_status, p.public, p.fk_user_creat, " ;
$sql .= " s.nom, s.rowid, " ;
$sql .= " t.datec, t.dateo, t.datee, t.tms, " ;
2021-10-15 10:24:56 +02:00
$sql .= " t.rowid, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress,t.budget_amount, t.fk_statut " ;
2023-01-05 10:46:08 +01:00
if ( $search_categ > 0 ) {
2021-02-26 18:49:22 +01:00
$sql .= " , cs.fk_categorie, cs.fk_project " ;
}
2020-10-31 14:32:18 +01:00
// Add fields from extrafields
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-26 18:49:22 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) {
$sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " , ef. " . $key : '' );
}
2020-10-31 14:32:18 +01:00
}
2019-03-29 13:18:12 +01:00
}
2019-11-12 09:46:08 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2016-01-21 15:09:46 +01:00
2017-01-15 20:49:20 +01:00
$nbtotalofrecords = '' ;
2021-02-26 18:49:22 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2017-10-13 13:28:26 +02:00
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
2021-02-26 18:49:22 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) { // if total resultset is smaller then paging size (filtering), goto and load page 0
2018-04-24 11:37:57 +02:00
$page = 0 ;
$offset = 0 ;
}
2016-01-21 15:09:46 +01:00
}
2019-11-12 09:46:08 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2009-07-28 15:37:28 +02:00
2016-01-21 15:09:46 +01:00
dol_syslog ( " list allowed project " , LOG_DEBUG );
2018-11-22 11:36:30 +01:00
2016-01-21 15:09:46 +01:00
$resql = $db -> query ( $sql );
2021-02-26 18:49:22 +01:00
if ( ! $resql ) {
2017-10-13 13:28:26 +02:00
dol_print_error ( $db );
exit ;
2016-11-02 12:48:50 +01:00
}
$num = $db -> num_rows ( $resql );
2017-04-11 02:48:16 +02:00
2022-03-31 18:06:39 +02:00
// Direct jump if only one record found
2021-02-26 18:49:22 +01:00
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $search_all ) {
2017-10-13 13:28:26 +02:00
$obj = $db -> fetch_object ( $resql );
2022-03-31 18:06:39 +02:00
$id = $obj -> id ; // in select, task id has been aliases into 'id'
2020-09-10 12:32:12 +02:00
header ( " Location: " . DOL_URL_ROOT . '/projet/tasks/task.php?id=' . $id . '&withproject=1' );
2017-10-13 13:28:26 +02:00
exit ;
2016-11-02 12:48:50 +01:00
}
2022-03-31 18:06:39 +02:00
// Output page
// --------------------------------------------------------------------
llxHeader ( '' , $title , $help_url );
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2016-11-02 12:48:50 +01:00
2019-11-12 09:46:08 +01:00
$param = '' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . urlencode ( $limit );
}
2021-08-25 09:30:52 +02:00
if ( $search_date_startday ) {
$param .= '&search_date_startday=' . urlencode ( $search_date_startday );
}
if ( $search_date_startmonth ) {
$param .= '&search_date_startmonth=' . urlencode ( $search_date_startmonth );
}
if ( $search_date_startyear ) {
$param .= '&search_date_startyear=' . urlencode ( $search_date_startyear );
}
if ( $search_date_endday ) {
$param .= '&search_date_endday=' . urlencode ( $search_date_endday );
}
if ( $search_date_endmonth ) {
$param .= '&search_date_endmonth=' . urlencode ( $search_date_endmonth );
2021-02-26 18:49:22 +01:00
}
2021-08-25 09:30:52 +02:00
if ( $search_date_endyear ) {
$param .= '&search_date_endyear=' . urlencode ( $search_date_endyear );
2021-02-26 18:49:22 +01:00
}
2021-08-25 09:30:52 +02:00
if ( $search_datelimit_startday ) {
$param .= '&search_datelimit_startday=' . urlencode ( $search_datelimit_startday );
2021-02-26 18:49:22 +01:00
}
2021-08-25 09:30:52 +02:00
if ( $search_datelimit_startmonth ) {
$param .= '&search_datelimit_startmonth=' . urlencode ( $search_datelimit_startmonth );
2021-02-26 18:49:22 +01:00
}
2021-08-25 09:30:52 +02:00
if ( $search_datelimit_startyear ) {
$param .= '&search_datelimit_startyear=' . urlencode ( $search_datelimit_startyear );
2021-02-26 18:49:22 +01:00
}
2021-08-25 09:30:52 +02:00
if ( $search_datelimit_endday ) {
$param .= '&search_datelimit_endday=' . urlencode ( $search_datelimit_endday );
}
if ( $search_datelimit_endmonth ) {
$param .= '&search_datelimit_endmonth=' . urlencode ( $search_datelimit_endmonth );
}
if ( $search_datelimit_endyear ) {
$param .= '&search_datelimit_endyear=' . urlencode ( $search_datelimit_endyear );
2021-02-26 18:49:22 +01:00
}
2021-10-15 10:24:56 +02:00
if ( $search_task_budget_amount ) {
$param .= '&search_task_budget_amount=' . urlencode ( $search_task_budget_amount );
}
2021-02-26 18:49:22 +01:00
if ( $socid ) {
$param .= '&socid=' . urlencode ( $socid );
}
if ( $search_all != '' ) {
$param .= '&search_all=' . urlencode ( $search_all );
}
if ( $search_project_ref != '' ) {
$param .= '&search_project_ref=' . urlencode ( $search_project_ref );
}
if ( $search_project_title != '' ) {
$param .= '&search_project_title=' . urlencode ( $search_project_title );
}
if ( $search_task_ref != '' ) {
2021-08-23 19:37:11 +02:00
$param .= '&search_task_ref=' . urlencode ( $search_task_ref );
2021-02-26 18:49:22 +01:00
}
if ( $search_task_label != '' ) {
2021-08-23 19:37:11 +02:00
$param .= '&search_task_label=' . urlencode ( $search_task_label );
2021-02-26 18:49:22 +01:00
}
if ( $search_task_description != '' ) {
2021-08-23 19:37:11 +02:00
$param .= '&search_task_description=' . urlencode ( $search_task_description );
2021-02-26 18:49:22 +01:00
}
if ( $search_task_ref_parent != '' ) {
$param .= '&search_task_ref_parent=' . urlencode ( $search_task_ref_parent );
}
if ( $search_task_progress != '' ) {
$param .= '&search_task_progress=' . urlencode ( $search_task_progress );
}
if ( $search_societe != '' ) {
$param .= '&search_societe=' . urlencode ( $search_societe );
}
if ( $search_projectstatus != '' ) {
$param .= '&search_projectstatus=' . urlencode ( $search_projectstatus );
}
if (( is_numeric ( $search_opp_status ) && $search_opp_status >= 0 ) || in_array ( $search_opp_status , array ( 'all' , 'none' ))) {
$param .= '&search_opp_status=' . urlencode ( $search_opp_status );
}
if ( $search_project_user != '' ) {
$param .= '&search_project_user=' . urlencode ( $search_project_user );
}
if ( $search_task_user > 0 ) {
$param .= '&search_task_user=' . urlencode ( $search_task_user );
}
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
2016-11-02 12:48:50 +01: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' ;
2022-03-31 18:06:39 +02:00
// Add $param from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSearchParam' , $parameters , $object ); // Note that $action and $object may have been modified by hook
$param .= $hookmanager -> resPrint ;
2017-06-02 13:46:30 +02:00
2017-04-11 02:48:16 +02:00
// List of mass actions available
2019-11-12 09:46:08 +01:00
$arrayofmassactions = array (
2021-04-14 12:28:01 +02:00
// 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
2017-04-11 02:48:16 +02:00
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
2022-03-31 18:06:39 +02:00
if ( $permissiontodelete ) {
2021-04-14 12:28:01 +02:00
$arrayofmassactions [ 'predelete' ] = img_picto ( '' , 'delete' , 'class="pictofixedwidth"' ) . $langs -> trans ( " Delete " );
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
if ( GETPOST ( 'nomassaction' , 'int' ) || in_array ( $massaction , array ( 'presend' , 'predelete' ))) {
2021-02-26 18:49:22 +01:00
$arrayofmassactions = array ();
}
2019-11-12 09:46:08 +01:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2017-04-11 02:48:16 +02:00
2020-09-18 11:48:53 +02:00
$newcardbutton = dolGetButtonTitle ( $langs -> trans ( 'NewTask' ), '' , 'fa fa-plus-circle' , DOL_URL_ROOT . '/projet/tasks.php?action=create' , '' , $user -> rights -> projet -> creer );
2018-03-30 16:54:38 +02:00
2022-03-31 18:06:39 +02:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' . " \n " ;
2021-02-26 18:49:22 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2016-11-02 12:48:50 +01:00
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
2021-10-26 18:46:51 +02:00
if ( ! empty ( $type )) {
print '<input type="hidden" name="type" value="' . $type . '">' ;
}
2017-04-11 02:48:16 +02:00
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2016-11-02 12:48:50 +01:00
// Show description of content
2019-11-12 09:46:08 +01:00
$texthelp = '' ;
2021-02-26 18:49:22 +01:00
if ( $search_task_user == $user -> id ) {
$texthelp .= $langs -> trans ( " MyTasksDesc " );
} else {
if ( $user -> rights -> projet -> all -> lire && ! $socid ) {
$texthelp .= $langs -> trans ( " TasksOnProjectsDesc " );
} else {
$texthelp .= $langs -> trans ( " TasksOnProjectsPublicDesc " );
}
2016-11-02 12:48:50 +01:00
}
2019-04-09 19:36:56 +02:00
2020-04-25 17:18:57 +02:00
print_barre_liste ( $form -> textwithpicto ( $title , $texthelp ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'projecttask' , 0 , $newcardbutton , '' , $limit , 0 , 0 , 1 );
2016-11-02 12:48:50 +01:00
2019-11-12 09:46:08 +01:00
$topicmail = " Information " ;
$modelmail = " task " ;
$objecttmp = new Task ( $db );
$trackid = 'tas' . $object -> id ;
2017-11-15 11:39:11 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2021-02-26 18:49:22 +01:00
if ( $search_all ) {
foreach ( $fieldstosearchall as $key => $val ) {
$fieldstosearchall [ $key ] = $langs -> trans ( $val );
}
2019-11-12 09:46:08 +01:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $search_all ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2016-11-02 12:48:50 +01:00
}
2021-10-23 22:32:03 +02:00
$moreforfilter = '' ;
2017-03-14 13:49:04 +01:00
// Filter on categories
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> categorie -> enabled ) && $user -> rights -> categorie -> lire ) {
2019-11-12 09:46:08 +01:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
$moreforfilter .= '<div class="divsearchfield">' ;
2021-03-29 13:00:17 +02:00
$tmptitle = $langs -> trans ( 'ProjectCategories' );
$moreforfilter .= img_picto ( $tmptitle , 'category' , 'class="pictofixedwidth"' ) . $formother -> select_categories ( 'project' , $search_categ , 'search_categ' , 0 , $tmptitle , 'maxwidth300' );
2019-11-12 09:46:08 +01:00
$moreforfilter .= '</div>' ;
2017-03-14 13:49:04 +01:00
}
2016-11-02 12:48:50 +01:00
// If the user can view users
2019-11-12 09:46:08 +01:00
$moreforfilter .= '<div class="divsearchfield">' ;
2021-03-29 13:00:17 +02:00
$tmptitle = $langs -> trans ( 'ProjectsWithThisUserAsContact' );
2019-11-12 09:46:08 +01:00
$includeonly = '' ;
2021-02-26 18:49:22 +01:00
if ( empty ( $user -> rights -> user -> user -> lire )) {
$includeonly = array ( $user -> id );
}
2021-03-29 13:00:17 +02:00
$moreforfilter .= img_picto ( $tmptitle , 'user' , 'class="pictofixedwidth"' ) . $form -> select_dolusers ( $search_project_user ? $search_project_user : '' , 'search_project_user' , $tmptitle , '' , 0 , $includeonly , '' , 0 , 0 , 0 , '' , 0 , '' , 'maxwidth250' );
2019-11-12 09:46:08 +01:00
$moreforfilter .= '</div>' ;
2016-11-02 12:48:50 +01:00
// If the user can view users
2019-11-12 09:46:08 +01:00
$moreforfilter .= '<div class="divsearchfield">' ;
2021-03-29 13:00:17 +02:00
$tmptitle = $langs -> trans ( 'TasksWithThisUserAsContact' );
2019-11-12 09:46:08 +01:00
$includeonly = '' ;
2021-02-26 18:49:22 +01:00
if ( empty ( $user -> rights -> user -> user -> lire )) {
$includeonly = array ( $user -> id );
}
2021-03-29 13:00:17 +02:00
$moreforfilter .= img_picto ( $tmptitle , 'user' , 'class="pictofixedwidth"' ) . $form -> select_dolusers ( $search_task_user , 'search_task_user' , $tmptitle , '' , 0 , $includeonly , '' , 0 , 0 , 0 , '' , 0 , '' , 'maxwidth250' );
2019-11-12 09:46:08 +01:00
$moreforfilter .= '</div>' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $moreforfilter )) {
2016-11-02 12:48:50 +01:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
2016-01-21 15:09:46 +01:00
print $hookmanager -> resPrint ;
2016-11-02 12:48:50 +01:00
print '</div>' ;
}
2016-01-21 15:09:46 +01:00
2021-02-26 18:49:22 +01:00
if ( $massactionbutton ) {
$selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
}
2016-11-02 12:48:50 +01:00
2016-11-27 13:49:46 +01:00
print '<div class="div-table-responsive">' ;
2019-11-12 09:46:08 +01:00
print '<table class="tagtable nobottomiftotal liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '" id="tablelines3">' . " \n " ;
2016-11-02 12:48:50 +01:00
2022-03-31 18:06:39 +02:00
// Fields title search
// --------------------------------------------------------------------
2017-03-28 18:42:23 +02:00
print '<tr class="liste_titre_filter">' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.fk_task_parent' ][ 'checked' ])) {
2020-03-24 19:50:01 +01:00
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_task_ref_parent" value="' . dol_escape_htmltag ( $search_task_ref_parent ) . '" size="4">' ;
print '</td>' ;
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.ref' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_task_ref" value="' . dol_escape_htmltag ( $search_task_ref ) . '" size="4">' ;
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.label' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_task_label" value="' . dol_escape_htmltag ( $search_task_label ) . '" size="8">' ;
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-01-11 20:53:18 +01:00
// Task Description
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.description' ][ 'checked' ])) {
2020-03-24 19:50:01 +01:00
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_task_description" value="' . dol_escape_htmltag ( $search_task_description ) . '" size="8">' ;
print '</td>' ;
}
2016-11-02 12:48:50 +01:00
// Start date
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.dateo' ][ 'checked' ])) {
2021-08-25 09:30:52 +02:00
print '<td class="liste_titre center">' ;
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_date_start ? $search_date_start : - 1 , 'search_date_start' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'From' ));
print '</div>' ;
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_date_end ? $search_date_end : - 1 , 'search_date_end' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'to' ));
print '</div>' ;
2017-10-13 13:28:26 +02:00
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
// End date
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.datee' ][ 'checked' ])) {
2021-08-25 09:30:52 +02:00
print '<td class="liste_titre center">' ;
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_datelimit_start ? $search_datelimit_start : - 1 , 'search_datelimit_start' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'From' ));
print '</div>' ;
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_datelimit_end ? $search_datelimit_end : - 1 , 'search_datelimit_end' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'to' ));
// TODO Add option late
//print '<br><input type="checkbox" name="search_option" value="late"'.($option == 'late' ? ' checked' : '').'> '.$langs->trans("Alert");
print '</div>' ;
2017-10-13 13:28:26 +02:00
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_project_ref" value="' . $search_project_ref . '" size="4">' ;
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.title' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_project_title" value="' . $search_project_title . '" size="6">' ;
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_societe" value="' . dol_escape_htmltag ( $search_societe ) . '" size="4">' ;
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre center">' ;
$arrayofstatus = array ();
2021-02-26 18:49:22 +01:00
foreach ( $projectstatic -> statuts_short as $key => $val ) {
$arrayofstatus [ $key ] = $langs -> trans ( $val );
}
2019-11-12 09:46:08 +01:00
$arrayofstatus [ '99' ] = $langs -> trans ( " NotClosed " ) . ' (' . $langs -> trans ( 'Draft' ) . '+' . $langs -> trans ( 'Opened' ) . ')' ;
2016-11-02 12:48:50 +01:00
print $form -> selectarray ( 'search_projectstatus' , $arrayofstatus , $search_projectstatus , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'maxwidth100' );
2017-10-13 13:28:26 +02:00
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.planned_workload' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 't.duration_effective' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 't.progress_calculated' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 't.progress' ][ 'checked' ])) {
2020-06-24 10:17:46 +02:00
print '<td class="liste_titre center">' ;
print '<input type="text" class="flat" name="search_task_progress" value="' . $search_task_progress . '" size="4">' ;
print '</td>' ;
}
2021-10-15 10:53:17 +02:00
if ( ! empty ( $arrayfields [ 't.progress_summary' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
2021-10-15 10:24:56 +02:00
if ( ! empty ( $arrayfields [ 't.budget_amount' ][ 'checked' ])) {
print '<td class="liste_titre center">' ;
print '<input type="text" class="flat" name="search_task_budget_amount" value="' . $search_task_budget_amount . '" size="4">' ;
print '</td>' ;
}
2020-06-24 10:17:46 +02:00
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.tobill' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 't.billed' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
2016-11-02 12:48:50 +01:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2016-11-02 12:48:50 +01:00
// Fields from hook
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields );
2022-03-31 18:06:39 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2016-11-02 12:48:50 +01:00
print $hookmanager -> resPrint ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.datec' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
// Date creation
print '<td class="liste_titre">' ;
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.tms' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
// Date modification
print '<td class="liste_titre">' ;
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
// Action column
2019-05-19 13:51:47 +02:00
print '<td class="liste_titre maxwidthsearch">' ;
2019-11-12 09:46:08 +01:00
$searchpicto = $form -> showFilterButtons ();
2017-05-14 21:20:35 +02:00
print $searchpicto ;
2016-11-02 12:48:50 +01:00
print '</td>' ;
2022-03-31 18:06:39 +02:00
print '</tr>' . " \n " ;
$totalarray = array (
'nbfield' => 0 ,
'val' => array (
't.planned_workload' => 0 ,
't.duration_effective' => 0 ,
't.progress' => 0 ,
't.budget_amount' => 0 ,
),
'totalplannedworkload' => 0 ,
'totaldurationeffective' => 0 ,
'totaldurationdeclared' => 0 ,
'totaltobillfield' => 0 ,
'totalbilledfield' => 0 ,
'totalbudget_amountfield' => 0 ,
'totalbudgetamount' => 0 ,
'totaltobill' => 0 ,
'totalbilled' => 0 ,
);
2016-11-02 12:48:50 +01:00
2022-03-31 18:06:39 +02:00
// Fields title label
// --------------------------------------------------------------------
2017-03-28 18:42:23 +02:00
print '<tr class="liste_titre">' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.fk_task_parent' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.fk_task_parent' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.fk_task_parent " , " " , $param , " " , $sortfield , $sortorder );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.ref' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.ref " , " " , $param , " " , $sortfield , $sortorder );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.label' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.label " , " " , $param , " " , $sortfield , $sortorder );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.description' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.description' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.description " , " " , $param , " " , $sortfield , $sortorder );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.dateo' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.dateo' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.dateo " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.datee' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.datee' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.datee " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.ref " , " " , $param , " " , $sortfield , $sortorder );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 'p.title' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.title' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.title " , " " , $param , " " , $sortfield , $sortorder );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 's.nom' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " s.nom " , " " , $param , " " , $sortfield , $sortorder );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.fk_statut' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.fk_statut " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.planned_workload' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.planned_workload' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.planned_workload " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.duration_effective' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.duration_effective' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.duration_effective " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.progress_calculated' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.progress_calculated' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , '' , '' , 'center ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.progress' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.progress' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.progress " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.progress_summary' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.progress_summary' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.progress " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
2021-10-15 10:24:56 +02:00
if ( ! empty ( $arrayfields [ 't.budget_amount' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.budget_amount' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.budget_amount " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-10-15 10:24:56 +02:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.tobill' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.tobill' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.billed' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.billed' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
2017-03-28 18:42:23 +02:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
2017-03-28 18:42:23 +02:00
// Hook fields
2021-10-24 13:57:04 +02:00
$parameters = array (
2021-10-24 14:00:05 +02:00
'arrayfields' => $arrayfields ,
'param' => $param ,
'sortfield' => $sortfield ,
'sortorder' => $sortorder ,
'totalarray' => & $totalarray ,
2021-10-24 13:57:04 +02:00
);
2019-11-12 09:46:08 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
2017-03-28 18:42:23 +02:00
print $hookmanager -> resPrint ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 't.datec' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.datec " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $arrayfields [ 't.tms' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.tms " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:49:22 +01:00
}
2019-02-23 22:24:26 +01:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
2022-03-31 18:06:39 +02:00
$totalarray [ 'nbfield' ] ++ ;
print '</tr>' . " \n " ;
2016-11-02 12:48:50 +01:00
2019-11-12 09:46:08 +01:00
$plannedworkloadoutputformat = 'allhourmin' ;
$timespentoutputformat = 'allhourmin' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_PLANNED_WORKLOAD_FORMAT )) {
$plannedworkloadoutputformat = $conf -> global -> PROJECT_PLANNED_WORKLOAD_FORMAT ;
}
if ( ! empty ( $conf -> global -> PROJECT_TIMES_SPENT_FORMAT )) {
$timespentoutputformat = $conf -> global -> PROJECT_TIME_SPENT_FORMAT ;
}
2017-05-24 22:48:44 +02:00
2022-03-31 18:06:39 +02:00
// Loop on record
// --------------------------------------------------------------------
2019-11-12 09:46:08 +01:00
$i = 0 ;
2022-03-31 18:06:39 +02:00
$savnbfield = $totalarray [ 'nbfield' ];
$totalarray [ 'nbfield' ] = 0 ;
$imaxinloop = ( $limit ? min ( $num , $limit ) : $num );
while ( $i < $imaxinloop ) {
2016-11-02 12:48:50 +01:00
$obj = $db -> fetch_object ( $resql );
2022-03-31 18:06:39 +02:00
if ( empty ( $obj )) {
break ; // Should not happen
}
2016-11-02 12:48:50 +01:00
2022-03-31 18:06:39 +02:00
// Store properties in $object
2017-05-24 22:48:44 +02:00
$object -> id = $obj -> id ;
$object -> ref = $obj -> ref ;
$object -> label = $obj -> label ;
2020-03-24 19:50:01 +01:00
$object -> description = $obj -> description ;
2017-05-24 22:48:44 +02:00
$object -> fk_statut = $obj -> fk_statut ;
$object -> progress = $obj -> progress ;
2021-10-15 10:24:56 +02:00
$object -> budget_amount = $obj -> budget_amount ;
2020-11-28 01:14:45 +01:00
$object -> date_start = $db -> jdate ( $obj -> date_start );
2017-05-24 22:48:44 +02:00
$object -> date_end = $db -> jdate ( $obj -> date_end );
2020-10-31 14:32:18 +01:00
$object -> planned_workload = $obj -> planned_workload ;
$object -> duration_effective = $obj -> duration_effective ;
$object -> fk_task_parent = $obj -> fk_task_parent ;
2019-09-08 21:19:15 +02:00
2016-11-02 12:48:50 +01:00
$projectstatic -> id = $obj -> projectid ;
$projectstatic -> ref = $obj -> projectref ;
$projectstatic -> title = $obj -> projecttitle ;
$projectstatic -> public = $obj -> public ;
$projectstatic -> statut = $obj -> projectstatus ;
$projectstatic -> datee = $db -> jdate ( $obj -> projectdatee );
2017-06-02 13:46:30 +02:00
2022-03-31 18:06:39 +02:00
if ( $mode == 'kanban' ) {
if ( $i == 0 ) {
print '<tr><td colspan="' . $savnbfield . '">' ;
print '<div class="box-flex-container">' ;
2020-03-24 19:50:01 +01:00
}
2022-03-31 18:06:39 +02:00
// Output Kanban
print $object -> getKanbanView ( '' );
if ( $i == ( $imaxinloop - 1 )) {
print '</div>' ;
print '</td></tr>' ;
2017-10-13 13:28:26 +02:00
}
2022-03-31 18:06:39 +02:00
} else {
$userAccess = $projectstatic -> restrictedProjectArea ( $user ); // why this ?
if ( $userAccess >= 0 ) {
print '<tr data-rowid="' . $object -> id . '" class="oddeven">' ;
// Ref Parent
if ( ! empty ( $arrayfields [ 't.fk_task_parent' ][ 'checked' ])) {
print '<td class="nowraponall">' ;
if ( ! empty ( $object -> fk_task_parent )) {
$object_parent = new Task ( $db );
$result = $object_parent -> fetch ( $object -> fk_task_parent );
if ( $result < 0 ) {
setEventMessage ( $object_parent -> error , 'errors' );
} else {
print $object_parent -> getNomUrl ( 1 , 'withproject' );
if ( $object_parent -> hasDelay ()) {
print img_warning ( " Late " );
}
}
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Ref
if ( ! empty ( $arrayfields [ 't.ref' ][ 'checked' ])) {
print '<td class="nowraponall">' ;
print $object -> getNomUrl ( 1 , 'withproject' );
if ( $object -> hasDelay ()) {
print img_warning ( " Late " );
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Label
if ( ! empty ( $arrayfields [ 't.label' ][ 'checked' ])) {
print '<td class="tdoverflowmax200" title="' . dol_escape_htmltag ( $object -> label ) . '">' ;
print dol_escape_htmltag ( $object -> label );
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Description
if ( ! empty ( $arrayfields [ 't.description' ][ 'checked' ])) {
print '<td>' ;
2022-09-15 18:30:42 +02:00
print dolGetFirstLineOfText ( $object -> description , 5 );
2022-03-31 18:06:39 +02:00
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Date start
if ( ! empty ( $arrayfields [ 't.dateo' ][ 'checked' ])) {
print '<td class="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_start ), 'day' );
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Date end
if ( ! empty ( $arrayfields [ 't.datee' ][ 'checked' ])) {
print '<td class="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_end ), 'day' );
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Project ref
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ])) {
print '<td class="nowraponall tdoverflowmax150">' ;
print $projectstatic -> getNomUrl ( 1 , 'task' );
if ( $projectstatic -> hasDelay ()) {
print img_warning ( " Late " );
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Project title
if ( ! empty ( $arrayfields [ 'p.title' ][ 'checked' ])) {
print '<td>' ;
print dol_trunc ( $obj -> projecttitle , 80 );
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2022-03-31 18:06:39 +02:00
// Third party
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
print '<td>' ;
if ( $obj -> socid ) {
$socstatic -> id = $obj -> socid ;
$socstatic -> name = $obj -> name ;
print $socstatic -> getNomUrl ( 1 );
} else {
print ' ' ;
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Project status
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ])) {
print '<td class="center">' ;
print $projectstatic -> getLibStatut ( 1 );
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2017-10-13 13:28:26 +02:00
2022-03-31 18:06:39 +02:00
// Planned workload
if ( ! empty ( $arrayfields [ 't.planned_workload' ][ 'checked' ])) {
print '<td class="center">' ;
$fullhour = convertSecondToTime ( $obj -> planned_workload , $plannedworkloadoutputformat );
$workingdelay = convertSecondToTime ( $obj -> planned_workload , 'all' , 86400 , 7 ); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks
if ( $obj -> planned_workload != '' ) {
print $fullhour ;
// TODO Add delay taking account of working hours per day and working day per week
//if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')';
}
//else print '--:--';
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 't.planned_workload' ;
}
$totalarray [ 'val' ][ 't.planned_workload' ] += $obj -> planned_workload ;
if ( ! $i ) {
$totalarray [ 'totalplannedworkloadfield' ] = $totalarray [ 'nbfield' ];
}
$totalarray [ 'totalplannedworkload' ] += $obj -> planned_workload ;
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Time spent
if ( ! empty ( $arrayfields [ 't.duration_effective' ][ 'checked' ])) {
$showlineingray = 0 ; $showproject = 1 ;
print '<td class="center">' ;
if ( $showlineingray ) {
print '<i>' ;
2021-02-26 18:49:22 +01:00
} else {
2022-03-31 18:06:39 +02:00
print '<a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $object -> id . ( $showproject ? '' : '&withproject=1' ) . '">' ;
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
if ( $obj -> duration_effective ) {
print convertSecondToTime ( $obj -> duration_effective , $timespentoutputformat );
} else {
print '--:--' ;
}
if ( $showlineingray ) {
print '</i>' ;
} else {
print '</a>' ;
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 't.duration_effective' ;
}
$totalarray [ 'val' ][ 't.duration_effective' ] += $obj -> duration_effective ;
if ( ! $i ) {
$totalarray [ 'totaldurationeffectivefield' ] = $totalarray [ 'nbfield' ];
}
$totalarray [ 'totaldurationeffective' ] += $obj -> duration_effective ;
2016-11-02 12:48:50 +01:00
}
2022-03-31 18:06:39 +02:00
// Calculated progress
if ( ! empty ( $arrayfields [ 't.progress_calculated' ][ 'checked' ])) {
print '<td class="center">' ;
if ( $obj -> planned_workload || $obj -> duration_effective ) {
if ( $obj -> planned_workload ) {
print round ( 100 * $obj -> duration_effective / $obj -> planned_workload , 2 ) . ' %' ;
} else {
print $form -> textwithpicto ( '' , $langs -> trans ( 'WorkloadNotDefined' ), 1 , 'help' );
}
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'totalprogress_calculatedfield' ] = $totalarray [ 'nbfield' ];
}
2020-10-31 14:32:18 +01:00
}
2022-03-31 18:06:39 +02:00
// Declared progress
if ( ! empty ( $arrayfields [ 't.progress' ][ 'checked' ])) {
print '<td class="center">' ;
if ( $obj -> progress != '' ) {
print getTaskProgressBadge ( $object );
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 't.progress' ;
}
$totalarray [ 'val' ][ 't.progress' ] += ( $obj -> planned_workload * $obj -> progress / 100 );
if ( ! $i ) {
$totalarray [ 'totalprogress_declaredfield' ] = $totalarray [ 'nbfield' ];
}
$totalarray [ 'totaldurationdeclared' ] += $obj -> planned_workload * $obj -> progress / 100 ;
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Progress summary
if ( ! empty ( $arrayfields [ 't.progress_summary' ][ 'checked' ])) {
print '<td class="center">' ;
if ( $obj -> progress != '' && $obj -> duration_effective ) {
print getTaskProgressView ( $object , false , false );
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'totalprogress_summary' ] = $totalarray [ 'nbfield' ];
}
2021-02-26 18:49:22 +01:00
}
2022-07-26 10:54:03 +02:00
// Budget for task
2022-03-31 18:06:39 +02:00
if ( ! empty ( $arrayfields [ 't.budget_amount' ][ 'checked' ])) {
print '<td class="center">' ;
2022-07-26 10:54:03 +02:00
if ( $object -> budget_amount ) {
print '<span class="amount">' . price ( $object -> budget_amount , 0 , $langs , 1 , 0 , 0 , $conf -> currency ) . '</span>' ;
}
2022-03-31 18:06:39 +02:00
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 't.budget_amount' ;
}
$totalarray [ 'val' ][ 't.budget_amount' ] += $obj -> budget_amount ;
if ( ! $i ) {
$totalarray [ 'totalbudget_amountfield' ] = $totalarray [ 'nbfield' ];
}
$totalarray [ 'totalbudgetamount' ] += $obj -> budget_amount ;
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Time not billed
if ( ! empty ( $arrayfields [ 't.tobill' ][ 'checked' ])) {
print '<td class="center">' ;
if ( $obj -> usage_bill_time ) {
print convertSecondToTime ( $obj -> tobill , 'allhourmin' );
$totalarray [ 'val' ][ 't.tobill' ] += $obj -> tobill ;
$totalarray [ 'totaltobill' ] += $obj -> tobill ;
} else {
print '<span class="opacitymedium">' . $langs -> trans ( " NA " ) . '</span>' ;
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 't.tobill' ;
}
if ( ! $i ) {
$totalarray [ 'totaltobillfield' ] = $totalarray [ 'nbfield' ];
}
2020-10-31 14:32:18 +01:00
}
2022-03-31 18:06:39 +02:00
// Time billed
if ( ! empty ( $arrayfields [ 't.billed' ][ 'checked' ])) {
print '<td class="center">' ;
if ( $obj -> usage_bill_time ) {
print convertSecondToTime ( $obj -> billed , 'allhourmin' );
$totalarray [ 'val' ][ 't.billed' ] += $obj -> billed ;
$totalarray [ 'totalbilled' ] += $obj -> billed ;
} else {
print '<span class="opacitymedium">' . $langs -> trans ( " NA " ) . '</span>' ;
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 't.billed' ;
}
if ( ! $i ) {
$totalarray [ 'totalbilledfield' ] = $totalarray [ 'nbfield' ];
}
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj , 'i' => $i , 'totalarray' =>& $totalarray );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
// Date creation
if ( ! empty ( $arrayfields [ 't.datec' ][ 'checked' ])) {
print '<td class="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Date modification
if ( ! empty ( $arrayfields [ 't.tms' ][ 'checked' ])) {
print '<td class="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2022-03-31 18:06:39 +02:00
// Status
/* if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ]))
{
$projectstatic -> statut = $obj -> fk_statut ;
print '<td class="right">' . $projectstatic -> getLibStatut ( 5 ) . '</td>' ;
} */
// Action column
print '<td class="nowrap center">' ;
if ( $massactionbutton || $massaction ) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0 ;
if ( in_array ( $object -> id , $arrayofselected )) {
$selected = 1 ;
}
print '<input id="cb' . $object -> id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object -> id . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
2021-02-26 18:49:22 +01:00
}
2017-10-13 13:28:26 +02:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-06-02 13:46:30 +02:00
2022-03-31 18:06:39 +02:00
print '</tr>' . " \n " ;
}
2016-11-02 12:48:50 +01:00
}
2016-01-21 15:09:46 +01:00
2017-06-02 13:46:30 +02:00
$i ++ ;
2016-11-02 12:48:50 +01:00
}
2022-03-31 18:06:39 +02:00
2016-11-02 12:48:50 +01:00
// Show total line
2019-03-29 13:18:12 +01:00
if ( isset ( $totalarray [ 'totaldurationeffectivefield' ]) || isset ( $totalarray [ 'totalplannedworkloadfield' ]) || isset ( $totalarray [ 'totalprogress_calculatedfield' ])
2022-03-31 18:06:39 +02:00
|| isset ( $totalarray [ 'totaltobill' ]) || isset ( $totalarray [ 'totalbilled' ]) || isset ( $totalarray [ 'totalbudget' ])) {
2017-10-13 13:28:26 +02:00
print '<tr class="liste_total">' ;
2019-11-12 09:46:08 +01:00
$i = 0 ;
2021-02-26 18:49:22 +01:00
while ( $i < $totalarray [ 'nbfield' ]) {
2017-10-13 13:28:26 +02:00
$i ++ ;
2021-02-26 18:49:22 +01:00
if ( $i == 1 ) {
if ( $num < $limit && empty ( $offset )) {
print '<td class="left">' . $langs -> trans ( " Total " ) . '</td>' ;
} else {
print '<td class="left">' . $langs -> trans ( " Totalforthispage " ) . '</td>' ;
}
} elseif ( $totalarray [ 'totalplannedworkloadfield' ] == $i ) {
print '<td class="center">' . convertSecondToTime ( $totalarray [ 'totalplannedworkload' ], $plannedworkloadoutputformat ) . '</td>' ;
} elseif ( $totalarray [ 'totaldurationeffectivefield' ] == $i ) {
print '<td class="center">' . convertSecondToTime ( $totalarray [ 'totaldurationeffective' ], $timespentoutputformat ) . '</td>' ;
} elseif ( $totalarray [ 'totalprogress_calculatedfield' ] == $i ) {
print '<td class="center">' . ( $totalarray [ 'totalplannedworkload' ] > 0 ? round ( 100 * $totalarray [ 'totaldurationeffective' ] / $totalarray [ 'totalplannedworkload' ], 2 ) . ' %' : '' ) . '</td>' ;
} elseif ( $totalarray [ 'totalprogress_declaredfield' ] == $i ) {
print '<td class="center">' . ( $totalarray [ 'totalplannedworkload' ] > 0 ? round ( 100 * $totalarray [ 'totaldurationdeclared' ] / $totalarray [ 'totalplannedworkload' ], 2 ) . ' %' : '' ) . '</td>' ;
} elseif ( $totalarray [ 'totaltobillfield' ] == $i ) {
print '<td class="center">' . convertSecondToTime ( $totalarray [ 'totaltobill' ], $plannedworkloadoutputformat ) . '</td>' ;
} elseif ( $totalarray [ 'totalbilledfield' ] == $i ) {
print '<td class="center">' . convertSecondToTime ( $totalarray [ 'totalbilled' ], $plannedworkloadoutputformat ) . '</td>' ;
2021-10-24 13:57:04 +02:00
} elseif ( $totalarray [ 'totalbudget_amountfield' ] == $i ) {
2021-10-15 10:24:56 +02:00
print '<td class="center">' . price ( $totalarray [ 'totalbudgetamount' ], 0 , $langs , 1 , 0 , 0 , $conf -> currency ) . '</td>' ;
2021-02-26 18:49:22 +01:00
} else {
print '<td></td>' ;
}
2017-10-13 13:28:26 +02:00
}
print '</tr>' ;
2016-01-21 15:09:46 +01:00
}
2012-03-19 14:44:27 +01:00
2016-11-02 12:48:50 +01:00
$db -> free ( $resql );
2005-08-20 23:44:34 +02:00
2022-03-31 18:06:39 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
2019-11-12 09:46:08 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
2016-11-02 12:48:50 +01:00
print $hookmanager -> resPrint ;
2022-03-31 18:06:39 +02:00
print '</table>' . " \n " ;
print '</div>' . " \n " ;
2012-02-15 23:08:20 +01:00
2022-03-31 18:06:39 +02:00
print '</form>' . " \n " ;
2016-11-02 12:48:50 +01:00
2018-08-15 12:48:13 +02:00
// End of page
2016-11-02 12:48:50 +01:00
llxFooter ();
2012-02-15 23:08:20 +01:00
$db -> close ();