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 >
2016-06-06 15:48:41 +02:00
* Copyright ( C ) 2006 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2006 - 2010 Regis Houssin < regis . houssin @ capnetworks . com >
2018-04-20 10:38:16 +02:00
* Copyright ( C ) 2018 Ferran Marcet < fmarcet @ 2 byte . es >
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
2011-08-01 01:19:04 +02:00
* along with this program . If not , see < http :// 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
2010-02-21 01:16:47 +01:00
* \brief List all task of a project
2008-09-10 22:49:21 +02:00
*/
2005-08-20 23:44:34 +02:00
2010-03-01 09:42:10 +01: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' ));
$action = GETPOST ( 'action' , 'alpha' );
$massaction = GETPOST ( 'massaction' , 'alpha' );
$show_files = GETPOST ( 'show_files' , 'int' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$toselect = GETPOST ( 'toselect' , 'array' );
2008-09-10 13:14:45 +02:00
2012-02-27 22:26:22 +01:00
$id = GETPOST ( 'id' , 'int' );
2015-10-17 02:41:09 +02:00
2017-05-09 19:36:10 +02:00
$search_all = GETPOST ( 'search_all' , 'alphanohtml' );
2017-03-14 13:49:04 +01:00
$search_categ = GETPOST ( " search_categ " , 'alpha' );
2013-03-01 00:56:29 +01:00
$search_project = GETPOST ( 'search_project' );
2017-06-02 13:46:30 +02:00
if ( ! isset ( $_GET [ 'search_projectstatus' ]) && ! isset ( $_POST [ 'search_projectstatus' ]))
2016-07-03 20:15:26 +02:00
{
2017-10-13 13:28:26 +02:00
if ( $search_all != '' ) $search_projectstatus =- 1 ;
else $search_projectstatus = 1 ;
2016-07-03 20:15:26 +02:00
}
2016-01-21 15:09:46 +01:00
else $search_projectstatus = GETPOST ( 'search_projectstatus' );
$search_project_ref = GETPOST ( 'search_project_ref' );
$search_project_title = GETPOST ( 'search_project_title' );
2015-04-23 15:22:50 +02:00
$search_task_ref = GETPOST ( 'search_task_ref' );
$search_task_label = GETPOST ( 'search_task_label' );
2016-01-21 15:09:46 +01:00
$search_task_description = GETPOST ( 'search_task_description' );
2015-04-23 16:20:25 +02:00
$search_project_user = GETPOST ( 'search_project_user' );
$search_task_user = GETPOST ( 'search_task_user' );
2012-03-19 14:44:27 +01:00
2015-12-04 15:37:28 +01:00
$mine = $_REQUEST [ 'mode' ] == 'mine' ? 1 : 0 ;
2016-01-21 15:09:46 +01:00
if ( $mine ) { $search_task_user = $user -> id ; $mine = 0 ; }
2017-05-16 17:49:38 +02:00
$search_sday = GETPOST ( 'search_sday' , 'int' );
$search_smonth = GETPOST ( 'search_smonth' , 'int' );
$search_syear = GETPOST ( 'search_syear' , 'int' );
$search_eday = GETPOST ( 'search_eday' , 'int' );
$search_emonth = GETPOST ( 'search_emonth' , 'int' );
$search_eyear = GETPOST ( 'search_eyear' , 'int' );
2016-01-21 15:09:46 +01:00
2016-06-07 14:06:00 +02:00
// Initialize context for list
$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
2016-04-04 16:02:29 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( 'projet_task' );
2016-01-21 15:09:46 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $extralabels , '' , 'search_' );
2015-12-04 15:37:28 +01:00
2008-09-10 22:49:21 +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-05-30 14:21:32 +02:00
if ( ! $user -> rights -> projet -> lire ) accessforbidden ();
2008-09-10 22:49:21 +02:00
2017-04-11 02:48:16 +02:00
$diroutputmassaction = $conf -> projet -> dir_output . '/tasks/temp/massgeneration/' . $user -> id ;
2017-06-08 14:55:12 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2016-01-21 15:09:46 +01: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-01-21 15:09:46 +01:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
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
);
if ( empty ( $user -> socid )) $fieldstosearchall [ 't.note_private' ] = " NotePrivate " ;
$arrayfields = array (
2017-10-13 13:28:26 +02:00
't.ref' => array ( 'label' => $langs -> trans ( " RefTask " ), 'checked' => 1 , 'position' => 80 ),
't.label' => array ( 'label' => $langs -> trans ( " LabelTask " ), 'checked' => 1 , 'position' => 80 ),
't.dateo' => array ( 'label' => $langs -> trans ( " DateStart " ), 'checked' => 1 , 'position' => 100 ),
't.datee' => array ( 'label' => $langs -> trans ( " DateEnd " ), 'checked' => 1 , 'position' => 101 ),
'p.ref' => array ( 'label' => $langs -> trans ( " ProjectRef " ), 'checked' => 1 ),
'p.title' => array ( 'label' => $langs -> trans ( " ProjectLabel " ), 'checked' => 0 ),
's.nom' => array ( 'label' => $langs -> trans ( " ThirdParty " ), 'checked' => 0 ),
'p.fk_statut' => array ( 'label' => $langs -> trans ( " ProjectStatus " ), 'checked' => 1 ),
't.planned_workload' => array ( 'label' => $langs -> trans ( " PlannedWorkload " ), 'checked' => 1 , 'position' => 102 ),
't.duration_effective' => array ( 'label' => $langs -> trans ( " TimeSpent " ), 'checked' => 1 , 'position' => 103 ),
't.progress_calculated' => array ( 'label' => $langs -> trans ( " ProgressCalculated " ), 'checked' => 1 , 'position' => 104 ),
't.progress' => array ( 'label' => $langs -> trans ( " ProgressDeclared " ), 'checked' => 1 , 'position' => 105 ),
't.datec' => array ( 'label' => $langs -> trans ( " DateCreation " ), 'checked' => 0 , 'position' => 500 ),
't.tms' => array ( 'label' => $langs -> trans ( " DateModificationShort " ), 'checked' => 0 , 'position' => 500 ),
//'t.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
2015-10-17 02:41:09 +02:00
);
2016-01-21 15:09:46 +01:00
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
2017-10-13 13:28:26 +02:00
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 ]));
2017-10-13 13:28:26 +02:00
}
2016-01-21 15:09:46 +01:00
}
2015-10-17 02:41:09 +02:00
2015-04-23 15:22:50 +02:00
/*
* Actions
*/
2017-09-15 10:50:50 +02:00
if ( GETPOST ( 'cancel' , 'alpha' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills' ) { $massaction = '' ; }
2016-11-02 12:48:50 +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
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
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
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
{
$search_all = " " ;
$search_categ = " " ;
$search_project = " " ;
$search_projectstatus =- 1 ;
$search_project_ref = " " ;
$search_project_title = " " ;
$search_task_ref = " " ;
$search_task_label = " " ;
$search_task_description = " " ;
$search_task_user =- 1 ;
$search_project_user =- 1 ;
$search_sday = '' ;
$search_smonth = '' ;
$search_syear = '' ;
$search_eday = '' ;
$search_emonth = '' ;
$search_eyear = '' ;
$toselect = '' ;
$search_array_options = array ();
}
// Mass actions
$objectclass = 'Task' ;
$objectlabel = 'Tasks' ;
$permtoread = $user -> rights -> projet -> lire ;
$permtodelete = $user -> rights -> projet -> supprimer ;
$uploaddir = $conf -> projet -> dir_output . '/tasks' ;
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
2016-01-21 15:09:46 +01:00
if ( empty ( $search_projectstatus ) && $search_projectstatus == '' ) $search_projectstatus = 1 ;
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
2017-05-24 22:48:44 +02:00
$now = dol_now ();
2012-02-15 23:08:20 +01:00
$form = new Form ( $db );
2016-01-21 15:09:46 +01:00
$formother = new FormOther ( $db );
$socstatic = new Societe ( $db );
2012-02-15 23:08:20 +01:00
$projectstatic = new Project ( $db );
2015-12-04 15:37:28 +01:00
$puser = new User ( $db );
$tuser = new User ( $db );
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
2010-05-29 01:26:08 +02: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
2012-02-15 23:08:20 +01:00
if ( $id )
2010-02-07 03:39:01 +01:00
{
2012-02-15 23:08:20 +01:00
$projectstatic -> fetch ( $id );
2010-02-07 10:49:10 +01:00
$projectstatic -> societe -> fetch ( $projectstatic -> societe -> id );
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)
2016-01-21 15:09:46 +01:00
if ( ! $user -> rights -> projet -> all -> lire ) $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)
$listofprojectcontacttype = array ();
$sql = " SELECT ctc.rowid, ctc.code FROM " . MAIN_DB_PREFIX . " c_type_contact as ctc " ;
$sql .= " WHERE ctc.element = ' " . $projectstatic -> element . " ' " ;
$sql .= " AND ctc.source = 'internal' " ;
$resql = $db -> query ( $sql );
if ( $resql )
2015-10-17 02:41:09 +02:00
{
2017-10-13 13:28:26 +02:00
while ( $obj = $db -> fetch_object ( $resql ))
{
$listofprojectcontacttype [ $obj -> rowid ] = $obj -> code ;
}
2015-10-17 02:41:09 +02:00
}
2016-01-21 15:09:46 +01:00
else dol_print_error ( $db );
if ( count ( $listofprojectcontacttype ) == 0 ) $listofprojectcontacttype [ 0 ] = '0' ; // To avoid sql syntax error if not found
// Get id of types of contacts for tasks (This list never contains a lot of elements)
$listoftaskcontacttype = array ();
$sql = " SELECT ctc.rowid, ctc.code FROM " . MAIN_DB_PREFIX . " c_type_contact as ctc " ;
2017-05-24 22:48:44 +02:00
$sql .= " WHERE ctc.element = ' " . $object -> element . " ' " ;
2016-01-21 15:09:46 +01:00
$sql .= " AND ctc.source = 'internal' " ;
$resql = $db -> query ( $sql );
if ( $resql )
2015-04-23 16:20:25 +02:00
{
2017-10-13 13:28:26 +02:00
while ( $obj = $db -> fetch_object ( $resql ))
{
$listoftaskcontacttype [ $obj -> rowid ] = $obj -> code ;
}
2015-04-23 16:20:25 +02:00
}
2016-01-21 15:09:46 +01:00
else dol_print_error ( $db );
if ( count ( $listoftaskcontacttype ) == 0 ) $listoftaskcontacttype [ 0 ] = '0' ; // To avoid sql syntax error if not found
$distinct = 'DISTINCT' ; // We add distinct until we are added a protection to be sure a contact of a project and task is only once.
2016-06-06 16:31:50 +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 " ;
2016-01-21 15:09:46 +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 " ;
$sql .= " , t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut " ;
2017-03-14 13:49:04 +01:00
// We'll need these fields in order to filter by categ
if ( $search_categ ) $sql .= " , cs.fk_categorie, cs.fk_project " ;
2016-10-11 12:27:20 +02:00
// Add fields from extrafields
foreach ( $extrafields -> attribute_label as $key => $val ) $sql .= ( $extrafields -> attribute_type [ $key ] != 'separate' ? " ,ef. " . $key . ' as options_' . $key : '' );
2016-01-21 15:09:46 +01:00
// Add fields from hooks
$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 " ;
2017-03-14 13:49:04 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s on p.fk_soc = s.rowid " ;
// We'll need this table joined to the select in order to filter by categ
if ( ! empty ( $search_categ )) $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
$sql .= " , " . MAIN_DB_PREFIX . " projet_task as t " ;
2016-04-04 16:02:29 +02:00
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " projet_task_extrafields as ef on (t.rowid = ef.fk_object) " ;
2016-10-18 12:16:12 +02:00
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 " ;
2016-01-21 15:09:46 +01:00
$sql .= " WHERE t.fk_projet = p.rowid " ;
2017-05-30 18:50:54 +02:00
$sql .= " AND p.entity IN ( " . getEntity ( 'project' ) . ')' ;
2016-07-09 13:58:46 +02:00
if ( ! $user -> rights -> projet -> all -> lire ) $sql .= " AND p.rowid IN ( " . ( $projectsListId ? $projectsListId : '0' ) . " ) " ; // public and assigned to projects, or restricted to company for external users
2016-01-21 15:09:46 +01:00
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
if ( $socid ) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . " ) " ;
2017-03-14 13:49:04 +01:00
if ( $search_categ > 0 ) $sql .= " AND cs.fk_categorie = " . $db -> escape ( $search_categ );
if ( $search_categ == - 2 ) $sql .= " AND cs.fk_categorie IS NULL " ;
2016-01-21 15:09:46 +01:00
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_societe ) $sql .= natural_search ( 's.nom' , $search_societe );
2017-05-16 17:49:38 +02:00
if ( $search_smonth > 0 )
2016-01-21 15:09:46 +01:00
{
2017-10-13 13:28:26 +02:00
if ( $search_syear > 0 && empty ( $search_sday ))
$sql .= " AND t.dateo BETWEEN ' " . $db -> idate ( dol_get_first_day ( $search_syear , $search_smonth , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $search_syear , $search_smonth , false )) . " ' " ;
else if ( $search_syear > 0 && ! empty ( $search_sday ))
$sql .= " AND t.dateo BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $search_smonth , $search_sday , $search_syear )) . " ' AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $search_smonth , $search_sday , $search_syear )) . " ' " ;
else
$sql .= " AND date_format(t.dateo, '%m') = ' " . $search_smonth . " ' " ;
2016-01-21 15:09:46 +01:00
}
2017-05-16 17:49:38 +02:00
else if ( $search_syear > 0 )
2016-01-21 15:09:46 +01:00
{
2017-10-13 13:28:26 +02:00
$sql .= " AND t.dateo BETWEEN ' " . $db -> idate ( dol_get_first_day ( $search_syear , 1 , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $search_syear , 12 , false )) . " ' " ;
2016-01-21 15:09:46 +01:00
}
2017-05-16 17:49:38 +02:00
if ( $search_emonth > 0 )
2016-01-21 15:09:46 +01:00
{
2017-10-13 13:28:26 +02:00
if ( $search_eyear > 0 && empty ( $search_eday ))
$sql .= " AND t.datee BETWEEN ' " . $db -> idate ( dol_get_first_day ( $search_eyear , $search_emonth , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $search_eyear , $search_emonth , false )) . " ' " ;
else if ( $search_eyear > 0 && ! empty ( $search_eday ))
$sql .= " AND t.datee BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $search_emonth , $search_eday , $search_eyear )) . " ' AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $search_emonth , $search_eday , $search_eyear )) . " ' " ;
else
$sql .= " AND date_format(t.datee, '%m') = ' " . $search_emonth . " ' " ;
2016-01-21 15:09:46 +01:00
}
2017-05-16 17:49:38 +02:00
else if ( $search_eyear > 0 )
2014-03-10 01:49:44 +01:00
{
2017-10-13 13:28:26 +02:00
$sql .= " AND t.datee BETWEEN ' " . $db -> idate ( dol_get_first_day ( $search_eyear , 1 , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $search_eyear , 12 , false )) . " ' " ;
2014-03-10 01:49:44 +01:00
}
2016-01-21 15:09:46 +01:00
if ( $search_all ) $sql .= natural_search ( array_keys ( $fieldstosearchall ), $search_all );
2016-10-18 12:16:12 +02:00
if ( $search_projectstatus >= 0 )
{
2017-10-13 13:28:26 +02:00
if ( $search_projectstatus == 99 ) $sql .= " AND p.fk_statut <> 2 " ;
else $sql .= " AND p.fk_statut = " . $db -> escape ( $search_projectstatus );
2016-10-18 12:16:12 +02:00
}
2016-01-21 15:09:46 +01:00
if ( $search_public != '' ) $sql .= " AND p.public = " . $db -> escape ( $search_public );
if ( $search_project_user > 0 ) $sql .= " AND ecp.fk_c_type_contact IN ( " . join ( ',' , array_keys ( $listofprojectcontacttype )) . " ) AND ecp.element_id = p.rowid AND ecp.fk_socpeople = " . $search_project_user ;
if ( $search_task_user > 0 ) $sql .= " AND ect.fk_c_type_contact IN ( " . join ( ',' , array_keys ( $listoftaskcontacttype )) . " ) AND ect.element_id = t.rowid AND ect.fk_socpeople = " . $search_task_user ;
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
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql .= $db -> order ( $sortfield , $sortorder );
2017-01-15 20:49:20 +01:00
$nbtotalofrecords = '' ;
2016-01-21 15:09:46 +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 );
2018-04-24 11:37:57 +02:00
if (( $page * $limit ) > $nbtotalofrecords ) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0 ;
$offset = 0 ;
}
2016-01-21 15:09:46 +01:00
}
$sql .= $db -> plimit ( $limit + 1 , $offset );
2016-07-09 13:58:46 +02:00
//print $sql;
2009-07-28 15:37:28 +02:00
2016-01-21 15:09:46 +01:00
dol_syslog ( " list allowed project " , LOG_DEBUG );
//print $sql;
$resql = $db -> query ( $sql );
2016-11-02 12:48:50 +01:00
if ( ! $resql )
2016-01-21 15:09:46 +01:00
{
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
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2016-11-02 12:48:50 +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 );
$id = $obj -> id ;
header ( " Location: " . DOL_URL_ROOT . '/projet/tasks/task.php?id=' . $id . '&withprojet=1' );
exit ;
2016-11-02 12:48:50 +01:00
}
2017-04-11 02:48:16 +02:00
$help_url = " EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos " ;
llxHeader ( " " , $title , $help_url );
2016-11-02 12:48:50 +01:00
$param = '' ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
2017-05-16 17:49:38 +02:00
if ( $search_sday ) $param .= '&search_sday=' . $search_sday ;
if ( $search_smonth ) $param .= '&search_smonth=' . $search_smonth ;
if ( $search_syear ) $param .= '&search_syear=' . $search_syear ;
if ( $search_eday ) $param .= '&search_eday=' . $search_eday ;
if ( $search_emonth ) $param .= '&search_emonth=' . $search_emonth ;
if ( $search_eyear ) $param .= '&search_eyear=' . $search_eyear ;
2016-11-02 12:48:50 +01:00
if ( $socid ) $param .= '&socid=' . $socid ;
if ( $search_all != '' ) $param .= '&search_all=' . $search_all ;
if ( $search_project_ref != '' ) $param .= '&search_project_ref=' . $search_project_ref ;
if ( $search_project_title != '' ) $param .= '&search_project_title=' . $search_project_title ;
if ( $search_ref != '' ) $param .= '&search_ref=' . $search_ref ;
if ( $search_label != '' ) $param .= '&search_label=' . $search_label ;
if ( $search_societe != '' ) $param .= '&search_societe=' . $search_societe ;
if ( $search_projectstatus != '' ) $param .= '&search_projectstatus=' . $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_public != '' ) $param .= '&search_public=' . $search_public ;
2017-03-14 13:49:04 +01:00
if ( $search_project_user != '' ) $param .= '&search_project_user=' . $search_project_user ;
2016-11-02 12:48:50 +01:00
if ( $search_task_user > 0 ) $param .= '&search_task_user=' . $search_task_user ;
if ( $optioncss != '' ) $param .= '&optioncss=' . $optioncss ;
// 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' ;
2017-06-02 13:46:30 +02:00
2017-04-11 02:48:16 +02:00
// List of mass actions available
$arrayofmassactions = array (
// 'presend'=>$langs->trans("SendByMail"),
// 'builddoc'=>$langs->trans("PDFMerge"),
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
2017-11-15 11:39:11 +01:00
if ( $user -> rights -> societe -> supprimer ) $arrayofmassactions [ 'predelete' ] = $langs -> trans ( " Delete " );
2017-11-11 16:03:22 +01:00
if ( in_array ( $massaction , array ( 'presend' , 'predelete' ))) $arrayofmassactions = array ();
2017-04-11 02:48:16 +02:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2018-03-30 16:54:38 +02:00
$newcardbutton = '' ;
if ( $user -> rights -> projet -> creer )
{
2018-06-13 22:57:41 +02:00
$newcardbutton = '<a class="butActionNew" href="' . DOL_URL_ROOT . '/projet/tasks.php?action=create"><span class="valignmiddle">' . $langs -> trans ( 'NewTask' ) . '</span>' ;
2018-04-18 03:26:15 +02:00
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>' ;
$newcardbutton .= '</a>' ;
2018-03-30 16:54:38 +02:00
}
2016-11-02 12:48:50 +01:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
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 . '">' ;
2017-05-21 02:43:51 +02:00
print '<input type="hidden" name="page" value="' . $page . '">' ;
2016-11-02 12:48:50 +01:00
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
2018-03-30 16:54:38 +02:00
print_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], " " , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'title_project' , 0 , $newcardbutton , '' , $limit );
2016-11-02 12:48:50 +01:00
// Show description of content
2017-12-20 21:33:45 +01:00
print '<div class="opacitymedium">' ;
2016-11-02 12:48:50 +01:00
if ( $search_task_user == $user -> id ) print $langs -> trans ( " MyTasksDesc " ) . '<br><br>' ;
else
{
2017-10-13 13:28:26 +02:00
if ( $user -> rights -> projet -> all -> lire && ! $socid ) print $langs -> trans ( " TasksOnProjectsDesc " ) . '<br><br>' ;
else print $langs -> trans ( " TasksOnProjectsPublicDesc " ) . '<br><br>' ;
2016-11-02 12:48:50 +01:00
}
2017-12-20 21:33:45 +01:00
print '</div>' ;
2016-11-02 12:48:50 +01:00
2017-11-15 11:39:11 +01:00
$topicmail = " Information " ;
$modelmail = " task " ;
$objecttmp = new Task ( $db );
$trackid = 'tas' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2016-11-02 12:48:50 +01:00
if ( $search_all )
{
2017-10-13 13:28:26 +02:00
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
2018-06-22 22:53:53 +02:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $search_all ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2016-11-02 12:48:50 +01:00
}
2017-03-14 13:49:04 +01:00
$morehtmlfilter = '' ;
// Filter on categories
if ( ! empty ( $conf -> categorie -> enabled ))
{
2017-10-13 13:28:26 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'ProjectCategories' ) . ': ' ;
$moreforfilter .= $formother -> select_categories ( 'project' , $search_categ , 'search_categ' , 1 , 'maxwidth300' );
$moreforfilter .= '</div>' ;
2017-03-14 13:49:04 +01:00
}
2016-11-02 12:48:50 +01:00
// If the user can view users
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'ProjectsWithThisUserAsContact' ) . ' ' ;
$includeonly = '' ;
if ( empty ( $user -> rights -> user -> user -> lire )) $includeonly = array ( $user -> id );
2017-06-14 11:28:42 +02:00
$moreforfilter .= $form -> select_dolusers ( $search_project_user ? $search_project_user : '' , 'search_project_user' , 1 , '' , 0 , $includeonly , '' , 0 , 0 , 0 , '' , 0 , '' , 'maxwidth200' );
2016-11-02 12:48:50 +01:00
$moreforfilter .= '</div>' ;
// If the user can view users
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'TasksWithThisUserAsContact' ) . ': ' ;
$includeonly = '' ;
if ( empty ( $user -> rights -> user -> user -> lire )) $includeonly = array ( $user -> id );
2017-06-14 11:28:42 +02:00
$moreforfilter .= $form -> select_dolusers ( $search_task_user , 'search_task_user' , 1 , '' , 0 , $includeonly , '' , 0 , 0 , 0 , '' , 0 , '' , 'maxwidth200' );
2016-11-02 12:48:50 +01:00
$moreforfilter .= '</div>' ;
if ( ! empty ( $moreforfilter ))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
$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
2016-11-02 12:48:50 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2017-04-11 02:48:16 +02: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">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '" id="tablelines3">' . " \n " ;
2016-11-02 12:48:50 +01:00
2017-03-28 18:42:23 +02:00
print '<tr class="liste_titre_filter">' ;
2016-11-02 12:48:50 +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
}
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
}
// Start date
if ( ! empty ( $arrayfields [ 't.dateo' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre center">' ;
if ( ! empty ( $conf -> global -> MAIN_LIST_FILTER_ON_DAY )) print '<input class="flat" type="text" size="1" maxlength="2" name="search_sday" value="' . $search_sday . '">' ;
print '<input class="flat" type="text" size="1" maxlength="2" name="search_smonth" value="' . $search_smonth . '">' ;
$formother -> select_year ( $search_syear ? $search_syear :- 1 , 'search_syear' , 1 , 20 , 5 );
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
// End date
if ( ! empty ( $arrayfields [ 't.datee' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre center">' ;
if ( ! empty ( $conf -> global -> MAIN_LIST_FILTER_ON_DAY )) print '<input class="flat" type="text" size="1" maxlength="2" name="search_eday" value="' . $search_eday . '">' ;
print '<input class="flat" type="text" size="1" maxlength="2" name="search_emonth" value="' . $search_emonth . '">' ;
$formother -> select_year ( $search_eyear ? $search_eyear :- 1 , 'search_eyear' , 1 , 20 , 5 );
print '</td>' ;
2016-11-02 12:48:50 +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
}
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
}
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
}
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre center">' ;
$arrayofstatus = array ();
foreach ( $projectstatic -> statuts_short as $key => $val ) $arrayofstatus [ $key ] = $langs -> trans ( $val );
$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
}
2016-12-15 23:28:18 +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' ])) 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
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
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
}
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
print '<td class="liste_titre" align="right">' ;
2017-05-14 21:20:35 +02:00
$searchpicto = $form -> showFilterButtons ();
print $searchpicto ;
2016-11-02 12:48:50 +01:00
print '</td>' ;
2016-12-16 01:12:24 +01:00
print " </tr> \n " ;
2016-11-02 12:48:50 +01:00
2017-03-28 18:42:23 +02:00
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 't.ref' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.ref " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 't.label' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.label " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 't.dateo' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.dateo' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.dateo " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 't.datee' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.datee' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.datee " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.ref " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.title' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.title' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.title " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 's.nom' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " s.nom " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.fk_statut' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.fk_statut " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 't.planned_workload' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.planned_workload' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.planned_workload " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 't.duration_effective' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.duration_effective' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.duration_effective " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 't.progress_calculated' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.progress_calculated' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , 'align="center"' );
if ( ! empty ( $arrayfields [ 't.progress' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.progress' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.progress " , " " , $param , 'align="center"' , $sortfield , $sortorder );
// 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
2018-04-20 10:38:16 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
2017-03-28 18:42:23 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 't.datec' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.datec " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 't.tms' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 't.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
2017-04-07 14:18:04 +02:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
2017-03-28 18:42:23 +02:00
print " </tr> \n " ;
2016-11-02 12:48:50 +01:00
$plannedworkloadoutputformat = 'allhourmin' ;
$timespentoutputformat = 'allhourmin' ;
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
2016-11-02 12:48:50 +01:00
$i = 0 ;
$totalarray = array ();
while ( $i < min ( $num , $limit ))
{
$obj = $db -> fetch_object ( $resql );
2017-05-24 22:48:44 +02:00
$object -> id = $obj -> id ;
$object -> ref = $obj -> ref ;
$object -> label = $obj -> label ;
$object -> fk_statut = $obj -> fk_statut ;
$object -> progress = $obj -> progress ;
$object -> datee = $db -> jdate ( $obj -> date_end ); // deprecated
$object -> date_end = $db -> jdate ( $obj -> date_end );
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
2016-11-02 12:48:50 +01:00
$userAccess = $projectstatic -> restrictedProjectArea ( $user ); // why this ?
if ( $userAccess >= 0 )
{
2017-03-29 11:03:13 +02:00
print '<tr class="oddeven">' ;
2016-11-02 12:48:50 +01:00
2017-10-13 13:28:26 +02:00
// Ref
if ( ! empty ( $arrayfields [ 't.ref' ][ 'checked' ]))
{
print '<td>' ;
print $object -> getNomUrl ( 1 , 'withproject' );
if ( $object -> hasDelay ()) print img_warning ( " Late " );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Label
if ( ! empty ( $arrayfields [ 't.label' ][ 'checked' ]))
{
print '<td>' ;
print $object -> label ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date start
if ( ! empty ( $arrayfields [ 't.dateo' ][ 'checked' ]))
{
2016-11-02 12:48:50 +01:00
print '<td class="center">' ;
2017-10-13 13:28:26 +02:00
print dol_print_date ( $db -> jdate ( $obj -> date_start ), 'day' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
// Date end
2017-10-13 13:28:26 +02:00
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' ] ++ ;
}
// Project ref
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ]))
{
print '<td class="nowrap">' ;
print $projectstatic -> getNomUrl ( 1 , 'task' );
if ( $projectstatic -> hasDelay ()) print img_warning ( " Late " );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Project title
if ( ! empty ( $arrayfields [ 'p.title' ][ 'checked' ]))
{
print '<td>' ;
print dol_trunc ( $obj -> projecttitle , 80 );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// 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' ] ++ ;
}
// Project status
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ]))
{
print '<td align="center">' ;
print $projectstatic -> getLibStatut ( 1 );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// 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 [ 'totalplannedworkloadfield' ] = $totalarray [ 'nbfield' ];
$totalarray [ 'totalplannedworkload' ] += $obj -> planned_workload ;
}
// Time spent
if ( ! empty ( $arrayfields [ 't.duration_effective' ][ 'checked' ]))
{
$showlineingray = 0 ; $showproject = 1 ;
2016-11-02 12:48:50 +01:00
print '<td class="center">' ;
if ( $showlineingray ) print '<i>' ;
2018-05-02 19:46:04 +02:00
else print '<a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $object -> id . ( $showproject ? '' : '&withproject=1' ) . '">' ;
2016-11-02 12:48:50 +01:00
if ( $obj -> duration_effective ) print convertSecondToTime ( $obj -> duration_effective , $timespentoutputformat );
else print '--:--' ;
if ( $showlineingray ) print '</i>' ;
else print '</a>' ;
2017-10-13 13:28:26 +02:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
if ( ! $i ) $totalarray [ 'totaldurationeffectivefield' ] = $totalarray [ 'nbfield' ];
$totalarray [ 'totaldurationeffective' ] += $obj -> duration_effective ;
}
// Calculated progress
if ( ! empty ( $arrayfields [ 't.progress_calculated' ][ 'checked' ]))
{
2016-11-02 12:48:50 +01:00
print '<td class="center">' ;
2017-10-13 13:28:26 +02:00
if ( $obj -> planned_workload || $obj -> duration_effective )
2016-11-02 12:48:50 +01:00
{
if ( $obj -> planned_workload ) print round ( 100 * $obj -> duration_effective / $obj -> planned_workload , 2 ) . ' %' ;
2017-03-27 00:48:50 +02:00
else print $form -> textwithpicto ( '' , $langs -> trans ( 'WorkloadNotDefined' ), 1 , 'help' );
2016-11-02 12:48:50 +01:00
}
2017-10-13 13:28:26 +02:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
if ( ! $i ) $totalarray [ 'totalprogress_calculated' ] = $totalarray [ 'nbfield' ];
}
// Declared progress
if ( ! empty ( $arrayfields [ 't.progress' ][ 'checked' ]))
{
2016-11-02 12:48:50 +01:00
print '<td class="center">' ;
2017-10-13 13:28:26 +02:00
if ( $obj -> progress != '' )
2016-11-02 12:48:50 +01:00
{
print $obj -> progress . ' %' ;
}
2017-10-13 13:28:26 +02:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
2016-11-02 12:48:50 +01:00
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj );
$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' ]))
{
2017-10-13 13:28:26 +02:00
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-11-02 12:48:50 +01:00
}
// Date modification
if ( ! empty ( $arrayfields [ 't.tms' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-11-02 12:48:50 +01:00
}
// Status
/* if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ]))
{
$projectstatic -> statut = $obj -> fk_statut ;
print '<td align="right">' . $projectstatic -> getLibStatut ( 5 ) . '</td>' ;
} */
2017-10-13 13:28:26 +02:00
// Action column
print '<td class="nowrap" align="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 ( $obj -> id , $arrayofselected )) $selected = 1 ;
print '<input id="cb' . $obj -> id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> id . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-06-02 13:46:30 +02:00
2016-11-02 12:48:50 +01:00
print " </tr> \n " ;
2017-06-02 13:46:30 +02:00
2016-11-02 12:48:50 +01:00
//print projectLinesa();
}
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
}
2016-09-19 16:42:45 +02:00
2016-11-02 12:48:50 +01:00
// Show total line
if ( isset ( $totalarray [ 'totaldurationeffectivefield' ]) || isset ( $totalarray [ 'totalplannedworkloadfield' ]))
{
2017-10-13 13:28:26 +02:00
print '<tr class="liste_total">' ;
$i = 0 ;
while ( $i < $totalarray [ 'nbfield' ])
{
$i ++ ;
if ( $i == 1 )
{
if ( $num < $limit && empty ( $offset )) print '<td align="left">' . $langs -> trans ( " Total " ) . '</td>' ;
else print '<td align="left">' . $langs -> trans ( " Totalforthispage " ) . '</td>' ;
}
elseif ( $totalarray [ 'totalplannedworkloadfield' ] == $i ) print '<td align="center">' . convertSecondToTime ( $totalarray [ 'totalplannedworkload' ], $plannedworkloadoutputformat ) . '</td>' ;
elseif ( $totalarray [ 'totaldurationeffectivefield' ] == $i ) print '<td align="center">' . convertSecondToTime ( $totalarray [ 'totaldurationeffective' ], $timespentoutputformat ) . '</td>' ;
elseif ( $totalarray [ 'totalprogress_calculated' ] == $i ) print '<td align="center">' . ( $totalarray [ 'totalplannedworkload' ] > 0 ? round ( 100 * $totalarray [ 'totaldurationeffective' ] / $totalarray [ 'totalplannedworkload' ], 2 ) . ' %' : '' ) . '</td>' ;
else print '<td></td>' ;
}
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
2016-11-02 12:48:50 +01:00
$parameters = array ( 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print " </table> " ;
2016-11-27 13:49:46 +01:00
print '</div>' ;
2012-02-15 23:08:20 +01:00
2016-11-02 12:48:50 +01:00
print '</form>' ;
llxFooter ();
2012-02-15 23:08:20 +01:00
$db -> close ();