2009-07-28 16:23:09 +02:00
< ? php
2006-05-13 02:52:13 +02:00
/* Copyright ( C ) 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2019-08-19 10:29:59 +02:00
* Copyright ( C ) 2004 - 2019 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2017 Regis Houssin < regis . houssin @ inodbox . com >
2013-10-30 21:44:04 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2013-10-30 21:44:04 +01:00
*/
2005-08-21 14:24:33 +02:00
/**
2010-05-30 22:25:08 +02:00
* \file htdocs / projet / tasks . php
2019-03-29 14:34:55 +01:00
* \ingroup project
2010-05-30 22:25:08 +02:00
* \brief List all tasks of a project
2008-08-26 00:14:58 +02:00
*/
2005-08-21 14:24:33 +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' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2013-04-12 11:09:53 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2018-05-18 10:33:32 +02:00
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
2021-09-02 18:48:46 +02:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2021-02-26 18:49:22 +01:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
}
2005-08-21 14:24:33 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2021-03-11 19:09:42 +01:00
$langsLoad = array ( 'projects' , 'users' , 'companies' );
if ( ! empty ( $conf -> eventorganization -> enabled )) {
$langsLoad [] = 'eventorganization' ;
}
$langs -> loadLangs ( $langsLoad );
2019-03-29 14:34:55 +01:00
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' );
2019-03-29 14:34:55 +01:00
$toselect = GETPOST ( 'toselect' , 'array' );
2012-01-25 11:05:15 +01:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
2016-07-09 13:58:46 +02:00
$taskref = GETPOST ( 'taskref' , 'alpha' );
2019-03-29 14:34:55 +01:00
2021-02-09 18:30:34 +01:00
// Load variable for pagination
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-02-26 18:49:22 +01:00
if ( empty ( $page ) || $page < 0 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) {
$page = 0 ;
} // If $page is not defined, or '' or -1 or if we click on clear filters
2021-02-09 18:30:34 +01:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2019-11-12 09:46:08 +01:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
$cancel = GETPOST ( 'cancel' , 'alpha' );
2012-01-25 11:05:15 +01:00
2017-04-11 02:48:16 +02:00
$search_user_id = GETPOST ( 'search_user_id' , 'int' );
2019-11-12 09:46:08 +01:00
$search_taskref = GETPOST ( 'search_taskref' );
$search_tasklabel = GETPOST ( 'search_tasklabel' );
2020-04-10 10:59:32 +02:00
$search_taskdescription = GETPOST ( 'search_taskdescription' );
2019-11-12 09:46:08 +01:00
$search_dtstartday = GETPOST ( 'search_dtstartday' );
$search_dtstartmonth = GETPOST ( 'search_dtstartmonth' );
$search_dtstartyear = GETPOST ( 'search_dtstartyear' );
$search_dtendday = GETPOST ( 'search_dtendday' );
$search_dtendmonth = GETPOST ( 'search_dtendmonth' );
$search_dtendyear = GETPOST ( 'search_dtendyear' );
$search_planedworkload = GETPOST ( 'search_planedworkload' );
$search_timespend = GETPOST ( 'search_timespend' );
$search_progresscalc = GETPOST ( 'search_progresscalc' );
$search_progressdeclare = GETPOST ( 'search_progressdeclare' );
2021-10-15 10:24:56 +02:00
$search_task_budget_amount = GETPOST ( 'search_task_budget_amount' );
2017-06-11 10:37:58 +02:00
2021-08-25 12:46:56 +02:00
$search_date_start_startmonth = GETPOST ( 'search_date_start_startmonth' , 'int' );
$search_date_start_startyear = GETPOST ( 'search_date_start_startyear' , 'int' );
$search_date_start_startday = GETPOST ( 'search_date_start_startday' , 'int' );
$search_date_start_start = dol_mktime ( 0 , 0 , 0 , $search_date_start_startmonth , $search_date_start_startday , $search_date_start_startyear ); // Use tzserver
$search_date_start_endmonth = GETPOST ( 'search_date_start_endmonth' , 'int' );
$search_date_start_endyear = GETPOST ( 'search_date_start_endyear' , 'int' );
$search_date_start_endday = GETPOST ( 'search_date_start_endday' , 'int' );
$search_date_start_end = dol_mktime ( 23 , 59 , 59 , $search_date_start_endmonth , $search_date_start_endday , $search_date_start_endyear ); // Use tzserver
$search_date_end_startmonth = GETPOST ( 'search_date_end_startmonth' , 'int' );
$search_date_end_startyear = GETPOST ( 'search_date_end_startyear' , 'int' );
$search_date_end_startday = GETPOST ( 'search_date_end_startday' , 'int' );
$search_date_end_start = dol_mktime ( 0 , 0 , 0 , $search_date_end_startmonth , $search_date_end_startday , $search_date_end_startyear ); // Use tzserver
$search_date_end_endmonth = GETPOST ( 'search_date_end_endmonth' , 'int' );
$search_date_end_endyear = GETPOST ( 'search_date_end_endyear' , 'int' );
$search_date_end_endday = GETPOST ( 'search_date_end_endday' , 'int' );
$search_date_end_end = dol_mktime ( 23 , 59 , 59 , $search_date_end_endmonth , $search_date_end_endday , $search_date_end_endyear ); // Use tzserver
2020-03-24 19:50:01 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'projecttasklist' ;
2010-05-29 01:26:08 +02:00
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
2010-05-30 14:21:32 +02:00
2012-05-23 14:34:44 +02:00
$object = new Project ( $db );
2013-04-26 10:29:14 +02:00
$taskstatic = new Task ( $db );
2019-10-22 17:08:37 +02:00
$extrafields = new ExtraFields ( $db );
2015-03-02 17:54:35 +01:00
2019-11-12 09:46:08 +01:00
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php' ; // Must be include, not include_once
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_PROJECT ) && method_exists ( $object , 'fetchComments' ) && empty ( $object -> comments )) {
$object -> fetchComments ();
}
2015-03-02 17:54:35 +01:00
2021-02-26 18:49:22 +01:00
if ( $id > 0 || ! empty ( $ref )) {
2014-03-11 20:38:29 +01:00
// fetch optionals attributes and labels
2019-10-22 17:08:37 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2012-05-23 14:34:44 +02:00
}
2019-10-22 17:08:37 +02:00
$extrafields -> fetch_name_optionals_label ( $taskstatic -> table_element );
2020-03-24 19:50:01 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $taskstatic -> table_element , '' , 'search_' );
2012-05-23 14:34:44 +02:00
2021-02-09 18:30:34 +01:00
// Default sort order (if not yet defined by previous GETPOST)
2021-02-26 18:49:22 +01:00
if ( ! $sortfield ) {
reset ( $object -> fields ); $sortfield = " t. " . key ( $object -> fields );
} // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null.
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
2021-02-09 18:30:34 +01:00
2010-05-30 14:21:32 +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.
2017-04-11 02:48:16 +02:00
$result = restrictedArea ( $user , 'projet' , $id , 'projet&project' );
2006-03-10 18:19:14 +01:00
2019-11-12 09:46:08 +01:00
$diroutputmassaction = $conf -> projet -> dir_output . '/tasks/temp/massgeneration/' . $user -> id ;
2019-03-29 14:34:55 +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
2019-11-12 09:46:08 +01:00
$hookmanager -> initHooks ( array ( 'projecttaskscard' , 'globalcard' ));
Add: hooks and triggers for a lot of core modules (action/calendrier, deplacement, dons, tva, contact/tiers, contrat, product lines, expedition, fournisseur commandes et factures, fiche intervention, projet et taches)
Signed-off-by: Stephen L. <lrq3000@gmail.com>
2012-08-14 15:50:45 +02:00
2019-11-12 09:46:08 +01:00
$progress = GETPOST ( 'progress' , 'int' );
2021-10-15 10:24:56 +02:00
$budget_amount = GETPOST ( 'budget_amount' , 'int' );
2019-11-12 09:46:08 +01:00
$label = GETPOST ( 'label' , 'alpha' );
2020-09-17 12:30:14 +02:00
$description = GETPOST ( 'description' , 'restricthtml' );
2019-11-12 09:46:08 +01:00
$planned_workloadhour = ( GETPOST ( 'planned_workloadhour' , 'int' ) ? GETPOST ( 'planned_workloadhour' , 'int' ) : 0 );
$planned_workloadmin = ( GETPOST ( 'planned_workloadmin' , 'int' ) ? GETPOST ( 'planned_workloadmin' , 'int' ) : 0 );
$planned_workload = $planned_workloadhour * 3600 + $planned_workloadmin * 60 ;
2011-05-18 13:55:41 +02:00
2020-03-24 19:50:01 +01:00
// Definition of fields for list
2019-11-12 09:46:08 +01:00
$arrayfields = array (
2020-03-24 19:50:01 +01:00
't.ref' => array ( 'label' => $langs -> trans ( " RefTask " ), 'checked' => 1 , 'position' => 1 ),
't.label' => array ( 'label' => $langs -> trans ( " LabelTask " ), 'checked' => 1 , 'position' => 2 ),
't.description' => array ( 'label' => $langs -> trans ( " Description " ), 'checked' => 0 , 'position' => 3 ),
't.dateo' => array ( 'label' => $langs -> trans ( " DateStart " ), 'checked' => 1 , 'position' => 4 ),
2020-11-28 01:14:45 +01:00
't.datee' => array ( 'label' => $langs -> trans ( " Deadline " ), 'checked' => 1 , 'position' => 5 ),
2020-03-24 19:50:01 +01:00
't.planned_workload' => array ( 'label' => $langs -> trans ( " PlannedWorkload " ), 'checked' => 1 , 'position' => 6 ),
't.duration_effective' => array ( 'label' => $langs -> trans ( " TimeSpent " ), 'checked' => 1 , 'position' => 7 ),
't.progress_calculated' => array ( 'label' => $langs -> trans ( " ProgressCalculated " ), 'checked' => 1 , 'position' => 8 ),
't.progress' => array ( 'label' => $langs -> trans ( " ProgressDeclared " ), 'checked' => 1 , 'position' => 9 ),
't.progress_summary' => array ( 'label' => $langs -> trans ( " TaskProgressSummary " ), 'checked' => 1 , 'position' => 10 ),
2021-10-15 10:24:56 +02:00
't.budget_amount' => array ( 'label' => " Budget " , 'checked' => 1 , 'position' => 11 ),
'c.assigned' => array ( 'label' => $langs -> trans ( " TaskRessourceLinks " ), 'checked' => 1 , 'position' => 12 ),
2019-03-29 14:34:55 +01:00
);
2020-03-24 19:50:01 +01:00
if ( $object -> usage_bill_time ) {
2020-04-10 10:59:32 +02:00
$arrayfields [ 't.tobill' ] = array ( 'label' => $langs -> trans ( " TimeToBill " ), 'checked' => 0 , 'position' => 11 );
$arrayfields [ 't.billed' ] = array ( 'label' => $langs -> trans ( " TimeBilled " ), 'checked' => 0 , 'position' => 12 );
2020-03-24 19:50:01 +01:00
}
// Extra fields
2021-11-08 17:51:19 +01:00
$extrafieldsobjectkey = $taskstatic -> table_element ;
2020-12-23 19:14:47 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php' ;
2019-10-22 17:08:37 +02:00
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2019-03-29 14:34:55 +01:00
2020-03-24 19:50:01 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
2012-01-25 11:05:15 +01:00
2020-04-15 14:54:54 +02:00
2008-09-10 22:49:21 +02:00
/*
* Actions
2014-01-06 13:02:20 +01:00
*/
2006-03-10 18:19:14 +01:00
2019-11-12 09:46:08 +01:00
$parameters = array ( 'id' => $id );
$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' );
}
2018-10-26 23:27:29 +02:00
2021-02-26 18:49:22 +01:00
if ( empty ( $reshook )) {
2020-04-16 00:42:57 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
2019-03-29 14:34:55 +01:00
// 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
2020-04-16 00:42:57 +02:00
$search_user_id = " " ;
$search_taskref = '' ;
$search_tasklabel = '' ;
$search_dtstartday = '' ;
$search_dtstartmonth = '' ;
$search_dtstartyear = '' ;
$search_dtendday = '' ;
$search_dtendmonth = '' ;
$search_dtendyear = '' ;
$search_planedworkload = '' ;
$search_timespend = '' ;
$search_progresscalc = '' ;
$search_progressdeclare = '' ;
2021-10-15 10:24:56 +02:00
$search_task_budget_amount = '' ;
2020-04-16 00:42:57 +02:00
$toselect = '' ;
$search_array_options = array ();
2021-08-25 12:46:56 +02:00
$search_date_start_startmonth = " " ;
$search_date_start_startyear = " " ;
$search_date_start_startday = " " ;
$search_date_start_start = " " ;
$search_date_start_endmonth = " " ;
$search_date_start_endyear = " " ;
$search_date_start_endday = " " ;
$search_date_start_end = " " ;
$search_date_end_startmonth = " " ;
$search_date_end_startyear = " " ;
$search_date_end_startday = " " ;
$search_date_end_start = " " ;
$search_date_end_endmonth = " " ;
$search_date_end_endyear = " " ;
$search_date_end_endday = " " ;
$search_date_end_end = " " ;
2019-03-29 14:34:55 +01:00
}
// Mass actions
2019-11-12 09:46:08 +01:00
$objectclass = 'Task' ;
$objectlabel = 'Tasks' ;
2019-11-04 15:33:49 +01:00
$permissiontoread = $user -> rights -> projet -> lire ;
$permissiontodelete = $user -> rights -> projet -> supprimer ;
2019-03-29 14:34:55 +01:00
$uploaddir = $conf -> projet -> dir_output . '/tasks' ;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2017-04-11 02:48:16 +02:00
}
2019-11-12 09:46:08 +01:00
$morewherefilterarray = array ();
2018-05-18 10:33:32 +02:00
if ( ! empty ( $search_taskref )) {
2019-11-12 09:46:08 +01:00
$morewherefilterarray [] = natural_search ( 't.ref' , $search_taskref , 0 , 1 );
2018-05-18 10:33:32 +02:00
}
if ( ! empty ( $search_tasklabel )) {
2019-11-12 09:46:08 +01:00
$morewherefilterarray [] = natural_search ( 't.label' , $search_tasklabel , 0 , 1 );
2018-05-18 10:33:32 +02:00
}
2019-09-28 13:22:05 +02:00
$moresql = dolSqlDateFilter ( 't.dateo' , $search_dtstartday , $search_dtstartmonth , $search_dtstartyear , 1 );
2021-02-26 18:49:22 +01:00
if ( $moresql ) {
$morewherefilterarray [] = $moresql ;
}
2018-05-18 10:33:32 +02:00
2019-09-28 13:22:05 +02:00
$moresql = dolSqlDateFilter ( 't.datee' , $search_dtendday , $search_dtendmonth , $search_dtendyear , 1 );
2021-02-26 18:49:22 +01:00
if ( $moresql ) {
$morewherefilterarray [] = $moresql ;
}
2018-05-18 10:33:32 +02:00
2021-08-25 12:46:56 +02:00
if ( $search_date_start_start ) {
$morewherefilterarray [] = " t.dateo >= ' " . $db -> idate ( $search_date_start_start ) . " ' " ;
}
if ( $search_date_start_end ) {
$morewherefilterarray [] = " t.dateo <= ' " . $db -> idate ( $search_date_start_end ) . " ' " ;
}
if ( $search_date_end_start ) {
$morewherefilterarray [] = " t.datee >= ' " . $db -> idate ( $search_date_end_start ) . " ' " ;
}
if ( $search_date_end_end ) {
$morewherefilterarray [] = " t.datee <= ' " . $db -> idate ( $search_date_end_end ) . " ' " ;
}
2018-05-18 10:33:32 +02:00
if ( ! empty ( $search_planedworkload )) {
2019-11-12 09:46:08 +01:00
$morewherefilterarray [] = natural_search ( 't.planned_workload' , $search_planedworkload , 1 , 1 );
2018-05-18 10:33:32 +02:00
}
if ( ! empty ( $search_timespend )) {
2019-11-12 09:46:08 +01:00
$morewherefilterarray [] = natural_search ( 't.duration_effective' , $search_timespend , 1 , 1 );
2018-05-18 10:33:32 +02:00
}
if ( ! empty ( $search_progresscalc )) {
2019-11-12 09:46:08 +01:00
$filterprogresscalc = 'if ' . natural_search ( 'round(100 * $line->duration / $line->planned_workload,2)' , $search_progresscalc , 1 , 1 ) . '{return 1;} else {return 0;}' ;
2018-05-18 10:33:32 +02:00
} else {
2019-11-12 09:46:08 +01:00
$filterprogresscalc = '' ;
2018-05-18 10:33:32 +02:00
}
if ( ! empty ( $search_progressdeclare )) {
2019-11-12 09:46:08 +01:00
$morewherefilterarray [] = natural_search ( 't.progress' , $search_progressdeclare , 1 , 1 );
2018-05-18 10:33:32 +02:00
}
2021-10-15 10:24:56 +02:00
if ( $search_task_budget_amount ) {
2021-10-15 11:02:05 +02:00
$morewherefilterarray [] = natural_search ( 't.budget_amount' , $search_task_budget_amount , 1 , 1 );
2021-10-15 10:24:56 +02:00
}
2019-11-12 09:46:08 +01:00
$morewherefilter = '' ;
if ( count ( $morewherefilterarray ) > 0 ) {
$morewherefilter = ' AND ' . implode ( ' AND ' , $morewherefilterarray );
2018-05-18 10:33:32 +02:00
}
2021-02-26 18:49:22 +01:00
if ( $action == 'createtask' && $user -> rights -> projet -> creer ) {
2019-11-12 09:46:08 +01:00
$error = 0 ;
2005-08-21 14:24:33 +02:00
2020-04-16 00:42:57 +02:00
// If we use user timezone, we must change also view/list to use user timezone everywhere
2020-11-28 01:14:45 +01:00
$date_start = dol_mktime ( GETPOST ( 'dateohour' , 'int' ), GETPOST ( 'dateomin' , 'int' ), 0 , GETPOST ( 'dateomonth' , 'int' ), GETPOST ( 'dateoday' , 'int' ), GETPOST ( 'dateoyear' , 'int' ));
$date_end = dol_mktime ( GETPOST ( 'dateehour' , 'int' ), GETPOST ( 'dateemin' , 'int' ), 0 , GETPOST ( 'dateemonth' , 'int' ), GETPOST ( 'dateeday' , 'int' ), GETPOST ( 'dateeyear' , 'int' ));
2017-06-11 10:37:58 +02:00
2021-02-26 18:49:22 +01:00
if ( ! $cancel ) {
if ( empty ( $taskref )) {
2016-07-09 13:58:46 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Ref " )), null , 'errors' );
2019-11-12 09:46:08 +01:00
$action = 'create' ;
2016-07-09 13:58:46 +02:00
$error ++ ;
}
2021-02-26 18:49:22 +01:00
if ( empty ( $label )) {
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Label " )), null , 'errors' );
2019-11-12 09:46:08 +01:00
$action = 'create' ;
2009-02-04 21:38:07 +01:00
$error ++ ;
2022-02-22 23:44:56 +01:00
} elseif ( ! GETPOST ( 'task_parent' )) {
2017-11-16 23:11:49 +01:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " ChildOfProjectTask " )), null , 'errors' );
2019-11-12 09:46:08 +01:00
$action = 'create' ;
2010-02-15 02:21:47 +01:00
$error ++ ;
}
2009-01-14 17:40:45 +01:00
2021-02-26 18:49:22 +01:00
if ( ! $error ) {
2020-11-28 01:14:45 +01:00
$tmparray = explode ( '_' , GETPOST ( 'task_parent' ));
2019-11-12 09:46:08 +01:00
$projectid = $tmparray [ 0 ];
2021-02-26 18:49:22 +01:00
if ( empty ( $projectid )) {
$projectid = $id ; // If projectid is ''
}
2019-11-12 09:46:08 +01:00
$task_parent = $tmparray [ 1 ];
2021-02-26 18:49:22 +01:00
if ( empty ( $task_parent )) {
$task_parent = 0 ; // If task_parent is ''
}
2009-01-14 17:40:45 +01:00
2010-01-25 11:59:20 +01:00
$task = new Task ( $db );
2010-01-28 15:52:45 +01:00
2010-01-25 11:59:20 +01:00
$task -> fk_project = $projectid ;
2016-07-09 13:58:46 +02:00
$task -> ref = $taskref ;
2012-01-25 11:05:15 +01:00
$task -> label = $label ;
$task -> description = $description ;
2013-10-30 21:44:04 +01:00
$task -> planned_workload = $planned_workload ;
2010-01-25 11:59:20 +01:00
$task -> fk_task_parent = $task_parent ;
2010-12-08 14:13:17 +01:00
$task -> date_c = dol_now ();
2011-05-18 13:54:05 +02:00
$task -> date_start = $date_start ;
$task -> date_end = $date_end ;
2012-01-25 11:05:15 +01:00
$task -> progress = $progress ;
2021-10-15 10:24:56 +02:00
$task -> budget_amount = $budget_amount ;
2017-06-11 10:37:58 +02:00
2013-04-12 11:09:53 +02:00
// Fill array 'array_options' with data from add form
2019-10-22 17:08:37 +02:00
$ret = $extrafields -> setOptionalsFromPost ( null , $task );
2009-01-14 17:40:45 +01:00
2010-01-25 23:24:40 +01:00
$taskid = $task -> create ( $user );
2010-02-03 23:34:12 +01:00
2021-02-26 18:49:22 +01:00
if ( $taskid > 0 ) {
2021-03-24 19:53:31 +01:00
$result = $task -> add_contact ( GETPOST ( " userid " , 'int' ), 'TASKEXECUTIVE' , 'internal' );
2020-05-21 15:05:19 +02:00
} else {
2021-02-26 18:49:22 +01:00
if ( $db -> lasterrno () == 'DB_ERROR_RECORD_ALREADY_EXISTS' ) {
2018-11-15 18:20:38 +01:00
$langs -> load ( " projects " );
2019-01-27 11:55:16 +01:00
setEventMessages ( $langs -> trans ( 'NewTaskRefSuggested' ), '' , 'warnings' );
2018-11-15 18:20:38 +01:00
$duplicate_code_error = true ;
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
setEventMessages ( $task -> error , $task -> errors , 'errors' );
2018-11-15 18:20:38 +01:00
}
2018-11-15 17:55:27 +01:00
$action = 'create' ;
$error ++ ;
2010-01-25 23:24:40 +01:00
}
2009-02-04 21:38:07 +01:00
}
2010-02-03 23:34:12 +01:00
2021-02-26 18:49:22 +01:00
if ( ! $error ) {
if ( ! empty ( $backtopage )) {
2012-08-31 05:58:38 +02:00
header ( " Location: " . $backtopage );
2010-01-28 16:55:43 +01:00
exit ;
2021-02-26 18:49:22 +01:00
} elseif ( empty ( $projectid )) {
2019-11-12 09:46:08 +01:00
header ( " Location: " . DOL_URL_ROOT . '/projet/tasks/list.php' . ( empty ( $mode ) ? '' : '?mode=' . $mode ));
2010-01-28 16:55:43 +01:00
exit ;
}
2015-02-07 04:04:56 +01:00
$id = $projectid ;
2009-01-12 21:26:06 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2021-02-26 18:49:22 +01:00
if ( ! empty ( $backtopage )) {
2012-08-31 05:58:38 +02:00
header ( " Location: " . $backtopage );
2012-02-15 23:08:20 +01:00
exit ;
2021-02-26 18:49:22 +01:00
} elseif ( empty ( $id )) {
2013-04-12 11:09:53 +02:00
// We go back on task list
2019-11-12 09:46:08 +01:00
header ( " Location: " . DOL_URL_ROOT . '/projet/tasks/list.php' . ( empty ( $mode ) ? '' : '?mode=' . $mode ));
2013-04-12 11:09:53 +02:00
exit ;
}
2010-08-23 21:15:51 +02:00
}
2005-08-21 14:24:33 +02:00
}
2015-02-07 04:04:56 +01:00
2008-09-10 22:49:21 +02:00
/*
* View
2015-02-07 04:04:56 +01:00
*/
2009-01-10 04:40:06 +01:00
2019-03-29 14:34:55 +01:00
$now = dol_now ();
2019-11-12 09:46:08 +01:00
$form = new Form ( $db );
$formother = new FormOther ( $db );
$socstatic = new Societe ( $db );
2019-03-29 14:34:55 +01:00
$projectstatic = new Project ( $db );
2013-07-18 10:24:45 +02:00
$taskstatic = new Task ( $db );
2019-11-12 09:46:08 +01:00
$userstatic = new User ( $db );
2005-08-21 14:24:33 +02:00
2019-11-12 09:46:08 +01:00
$title = $langs -> trans ( " Project " ) . ' - ' . $langs -> trans ( " Tasks " ) . ' - ' . $object -> ref . ' ' . $object -> name ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> MAIN_HTML_TITLE ) && preg_match ( '/projectnameonly/' , $conf -> global -> MAIN_HTML_TITLE ) && $object -> name ) {
$title = $object -> ref . ' ' . $object -> name . ' - ' . $langs -> trans ( " Tasks " );
}
2019-11-12 09:46:08 +01:00
$help_url = " EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos " ;
2020-12-11 01:20:40 +01:00
2019-01-27 11:55:16 +01:00
llxHeader ( " " , $title , $help_url );
2005-08-21 14:24:33 +02:00
2020-03-24 19:50:01 +01:00
2021-02-26 18:49:22 +01:00
if ( $id > 0 || ! empty ( $ref )) {
2021-03-11 19:09:42 +01:00
$result = $object -> fetch ( $id , $ref );
if ( $result < 0 ) {
setEventMessages ( null , $object -> errors , 'errors' );
}
$result = $object -> fetch_thirdparty ();
if ( $result < 0 ) {
setEventMessages ( null , $object -> errors , 'errors' );
}
$result = $object -> fetch_optionals ();
if ( $result < 0 ) {
setEventMessages ( null , $object -> errors , 'errors' );
}
2010-02-03 23:34:12 +01:00
2013-04-12 11:09:53 +02:00
// To verify role of users
//$userAccess = $object->restrictedProjectArea($user,'read');
2019-11-12 09:46:08 +01:00
$userWrite = $object -> restrictedProjectArea ( $user , 'write' );
2013-04-12 11:09:53 +02:00
//$userDelete = $object->restrictedProjectArea($user,'delete');
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
2012-02-15 23:08:20 +01:00
2020-11-28 01:14:45 +01:00
$tab = ( GETPOSTISSET ( 'tab' ) ? GETPOST ( 'tab' ) : 'tasks' );
2012-02-15 23:08:20 +01:00
2019-11-12 09:46:08 +01:00
$head = project_prepare_head ( $object );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , $tab , $langs -> trans ( " Project " ), - 1 , ( $object -> public ? 'projectpub' : 'project' ));
2014-09-18 09:59:29 +02:00
2020-04-15 14:54:54 +02:00
$param = '&id=' . $object -> id ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $search_user_id ) {
$param .= '&search_user_id=' . urlencode ( $search_user_id );
}
if ( $search_taskref ) {
$param .= '&search_taskref=' . urlencode ( $search_taskref );
}
if ( $search_tasklabel ) {
$param .= '&search_tasklabel=' . urlencode ( $search_tasklabel );
}
if ( $search_taskdescription ) {
$param .= '&search_taskdescription=' . urlencode ( $search_taskdescription );
}
if ( $search_dtstartday ) {
$param .= '&search_dtstartday=' . urlencode ( $search_dtstartday );
}
if ( $search_dtstartmonth ) {
$param .= '&search_dtstartmonth=' . urlencode ( $search_dtstartmonth );
}
if ( $search_dtstartyear ) {
$param .= '&search_dtstartyear=' . urlencode ( $search_dtstartyear );
}
if ( $search_dtendday ) {
$param .= '&search_dtendday=' . urlencode ( $search_dtendday );
}
if ( $search_dtendmonth ) {
$param .= '&search_dtendmonth=' . urlencode ( $search_dtendmonth );
}
if ( $search_dtendyear ) {
$param .= '&search_dtendyear=' . urlencode ( $search_dtendyear );
}
2021-08-25 12:46:56 +02:00
if ( $search_date_start_startmonth ) {
$param .= '&search_date_start_startmonth=' . urlencode ( $search_date_start_startmonth );
}
if ( $search_date_start_startyear ) {
$param .= '&search_date_start_startyear=' . urlencode ( $search_date_start_startyear );
}
if ( $search_date_start_startday ) {
$param .= '&search_date_start_startday=' . urlencode ( $search_date_start_startday );
}
if ( $search_date_start_start ) {
$param .= '&search_date_start_start=' . urlencode ( $search_date_start_start );
}
if ( $search_date_start_endmonth ) {
$param .= '&search_date_start_endmonth=' . urlencode ( $search_date_start_endmonth );
}
if ( $search_date_start_endyear ) {
$param .= '&search_date_start_endyear=' . urlencode ( $search_date_start_endyear );
}
if ( $search_date_start_endday ) {
$param .= '&search_date_start_endday=' . urlencode ( $search_date_start_endday );
}
if ( $search_date_start_end ) {
$param .= '&search_date_start_end=' . urlencode ( $search_date_start_end );
}
if ( $search_date_end_startmonth ) {
$param .= '&search_date_end_startmonth=' . urlencode ( $search_date_end_startmonth );
}
if ( $search_date_end_startyear ) {
$param .= '&search_date_end_startyear=' . urlencode ( $search_date_end_startyear );
}
if ( $search_date_end_startday ) {
$param .= '&search_date_end_startday=' . urlencode ( $search_date_end_startday );
}
if ( $search_date_end_start ) {
$param .= '&search_date_end_start=' . urlencode ( $search_date_end_start );
}
if ( $search_date_end_endmonth ) {
$param .= '&search_date_end_endmonth=' . urlencode ( $search_date_end_endmonth );
}
if ( $search_date_end_endyear ) {
$param .= '&search_date_end_endyear=' . urlencode ( $search_date_end_endyear );
}
if ( $search_date_end_endday ) {
$param .= '&search_date_end_endday=' . urlencode ( $search_date_end_endday );
}
if ( $search_date_end_end ) {
$param .= '&search_date_end_end=' . urlencode ( $search_date_end_end );
}
2021-02-26 18:49:22 +01:00
if ( $search_planedworkload ) {
$param .= '&search_planedworkload=' . urlencode ( $search_planedworkload );
}
if ( $search_timespend ) {
$param .= '&search_timespend=' . urlencode ( $search_timespend );
}
if ( $search_progresscalc ) {
$param .= '&search_progresscalc=' . urlencode ( $search_progresscalc );
}
if ( $search_progressdeclare ) {
$param .= '&search_progressdeclare=' . urlencode ( $search_progressdeclare );
}
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 ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
2020-03-24 19:50:01 +01:00
// Add $param from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
2012-07-28 21:49:47 +02:00
2020-04-16 00:42:57 +02:00
// Project card
$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
$morehtmlref = '<div class="refidno">' ;
// Title
$morehtmlref .= $object -> title ;
// Thirdparty
2021-10-24 09:59:30 +02:00
if ( ! empty ( $object -> thirdparty -> id ) && $object -> thirdparty -> id > 0 ) {
2020-04-16 00:42:57 +02:00
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $object -> thirdparty -> getNomUrl ( 1 , 'project' );
}
$morehtmlref .= '</div>' ;
// Define a complementary filter for search of next/prev ref.
2021-10-24 09:59:30 +02:00
if ( empty ( $user -> rights -> projet -> all -> lire )) {
2020-04-16 00:42:57 +02:00
$objectsListId = $object -> getProjectsAuthorizedForUser ( $user , 0 , 0 );
2021-03-22 12:47:23 +01:00
$object -> next_prev_filter = " rowid IN ( " . $db -> sanitize ( count ( $objectsListId ) ? join ( ',' , array_keys ( $objectsListId )) : '0' ) . " ) " ;
2020-04-16 00:42:57 +02:00
}
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
print '<div class="underbanner clearboth"></div>' ;
2021-09-24 02:16:40 +02:00
print '<table class="border tableforfield centpercent">' ;
2020-04-16 00:42:57 +02:00
// Usage
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ) || empty ( $conf -> global -> PROJECT_HIDE_TASKS ) || ! empty ( $conf -> eventorganization -> enabled )) {
2021-03-18 11:07:48 +01:00
print '<tr><td class="tdtop">' ;
print $langs -> trans ( " Usage " );
print '</td>' ;
print '<td>' ;
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
2021-03-18 11:07:48 +01:00
print '<input type="checkbox" disabled name="usage_opportunity"' . ( GETPOSTISSET ( 'usage_opportunity' ) ? ( GETPOST ( 'usage_opportunity' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_opportunity ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " ProjectFollowOpportunity " );
print $form -> textwithpicto ( $langs -> trans ( " ProjectFollowOpportunity " ), $htmltext );
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS )) {
2021-03-18 11:07:48 +01:00
print '<input type="checkbox" disabled name="usage_task"' . ( GETPOSTISSET ( 'usage_task' ) ? ( GETPOST ( 'usage_task' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_task ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " ProjectFollowTasks " );
print $form -> textwithpicto ( $langs -> trans ( " ProjectFollowTasks " ), $htmltext );
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS ) && ! empty ( $conf -> global -> PROJECT_BILL_TIME_SPENT )) {
2021-03-18 11:07:48 +01:00
print '<input type="checkbox" disabled name="usage_bill_time"' . ( GETPOSTISSET ( 'usage_bill_time' ) ? ( GETPOST ( 'usage_bill_time' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_bill_time ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " ProjectBillTimeDescription " );
print $form -> textwithpicto ( $langs -> trans ( " BillTime " ), $htmltext );
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> eventorganization -> enabled )) {
print '<input type="checkbox" disabled name="usage_organize_event"' . ( GETPOSTISSET ( 'usage_organize_event' ) ? ( GETPOST ( 'usage_organize_event' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_organize_event ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " EventOrganizationDescriptionLong " );
print $form -> textwithpicto ( $langs -> trans ( " ManageOrganizeEvent " ), $htmltext );
}
2021-03-18 11:07:48 +01:00
print '</td></tr>' ;
2021-03-11 19:09:42 +01:00
}
2020-04-16 00:42:57 +02:00
// Visibility
print '<tr><td class="titlefield">' . $langs -> trans ( " Visibility " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( $object -> public ) {
print $langs -> trans ( 'SharedProject' );
} else {
print $langs -> trans ( 'PrivateProject' );
}
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Date start - end
print '<tr><td>' . $langs -> trans ( " DateStart " ) . ' - ' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
$start = dol_print_date ( $object -> date_start , 'day' );
print ( $start ? $start : '?' );
$end = dol_print_date ( $object -> date_end , 'day' );
print ' - ' ;
print ( $end ? $end : '?' );
2021-02-26 18:49:22 +01:00
if ( $object -> hasDelay ()) {
print img_warning ( " Late " );
}
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Budget
print '<tr><td>' . $langs -> trans ( " Budget " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( strcmp ( $object -> budget_amount , '' )) {
2022-01-01 18:15:22 +01:00
print '<span class="amount">' . price ( $object -> budget_amount , '' , $langs , 1 , 0 , 0 , $conf -> currency ) . '</span>' ;
2021-02-26 18:49:22 +01:00
}
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Other attributes
$cols = 2 ;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
print '</table>' ;
print '</div>' ;
print '<div class="fichehalfright">' ;
print '<div class="underbanner clearboth"></div>' ;
2021-09-24 02:16:40 +02:00
print '<table class="border tableforfield centpercent">' ;
2020-04-16 00:42:57 +02:00
// Description
print '<td class="titlefield tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
print nl2br ( $object -> description );
print '</td></tr>' ;
// Categories
if ( $conf -> categorie -> enabled ) {
2021-09-24 02:16:40 +02:00
print '<tr><td class="valignmiddle">' . $langs -> trans ( " Categories " ) . '</td><td>' ;
2020-04-16 00:42:57 +02:00
print $form -> showCategories ( $object -> id , Categorie :: TYPE_PROJECT , 1 );
print " </td></tr> " ;
}
print '</table>' ;
print '</div>' ;
print '</div>' ;
print '<div class="clearboth"></div>' ;
2012-02-15 23:08:20 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2008-09-10 22:49:21 +02:00
}
2005-08-21 14:24:33 +02:00
2012-02-15 23:08:20 +01:00
2021-02-26 18:49:22 +01:00
if ( $action == 'create' && $user -> rights -> projet -> creer && ( empty ( $object -> thirdparty -> id ) || $userWrite > 0 )) {
if ( $id > 0 || ! empty ( $ref )) {
print '<br>' ;
}
2012-02-15 23:08:20 +01:00
2020-04-25 17:18:57 +02:00
print load_fiche_titre ( $langs -> trans ( " NewTask " ), '' , 'projecttask' );
2008-09-10 22:49:21 +02:00
2020-12-08 11:58:47 +01:00
if ( $object -> id > 0 && $object -> statut == Project :: STATUS_CLOSED ) {
2018-12-10 15:06:54 +01:00
print '<div class="warning">' ;
$langs -> load ( " errors " );
print $langs -> trans ( " WarningProjectClosed " );
print '</div>' ;
2020-12-08 11:58:47 +01:00
}
2020-10-12 12:53:57 +02:00
2020-12-08 11:58:47 +01:00
if ( $object -> id > 0 && $object -> statut == Project :: STATUS_DRAFT ) {
print '<div class="warning">' ;
$langs -> load ( " errors " );
print $langs -> trans ( " WarningProjectDraft " );
print '</div>' ;
}
2017-06-11 10:37:58 +02:00
2020-12-08 11:58:47 +01:00
print '<form action="' . $_SERVER [ 'PHP_SELF' ] . '" method="POST">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="createtask">' ;
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $object -> id )) {
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
}
2015-05-14 16:47:15 +02:00
2020-12-08 11:58:47 +01:00
print dol_get_fiche_head ( '' );
2008-09-10 22:49:21 +02:00
2020-12-08 11:58:47 +01:00
print '<table class="border centpercent">' ;
2013-10-30 21:44:04 +01:00
2020-12-08 11:58:47 +01:00
$defaultref = '' ;
$obj = empty ( $conf -> global -> PROJECT_TASK_ADDON ) ? 'mod_task_simple' : $conf -> global -> PROJECT_TASK_ADDON ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_TASK_ADDON ) && is_readable ( DOL_DOCUMENT_ROOT . " /core/modules/project/task/ " . $conf -> global -> PROJECT_TASK_ADDON . " .php " )) {
2020-12-08 11:58:47 +01:00
require_once DOL_DOCUMENT_ROOT . " /core/modules/project/task/ " . $conf -> global -> PROJECT_TASK_ADDON . '.php' ;
$modTask = new $obj ;
$defaultref = $modTask -> getNextValue ( $object -> thirdparty , null );
}
2013-10-30 21:44:04 +01:00
2021-02-26 18:49:22 +01:00
if ( is_numeric ( $defaultref ) && $defaultref <= 0 ) {
$defaultref = '' ;
}
2013-07-18 10:24:45 +02:00
2020-12-08 11:58:47 +01:00
// Ref
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs -> trans ( " Ref " ) . '</span></td><td>' ;
2021-02-26 18:49:22 +01:00
if ( empty ( $duplicate_code_error )) {
2020-12-11 01:20:40 +01:00
print ( GETPOSTISSET ( " ref " ) ? GETPOST ( " ref " , 'alpha' ) : $defaultref );
2020-12-08 11:58:47 +01:00
} else {
print $defaultref ;
}
2020-12-11 01:20:40 +01:00
print '<input type="hidden" name="taskref" value="' . ( GETPOSTISSET ( " ref " ) ? GETPOST ( " ref " , 'alpha' ) : $defaultref ) . '">' ;
2020-12-08 11:58:47 +01:00
print '</td></tr>' ;
2009-01-15 00:36:51 +01:00
2021-06-26 15:39:52 +02:00
// Label
2020-12-08 11:58:47 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Label " ) . '</td><td>' ;
print '<input type="text" name="label" autofocus class="minwidth500 maxwidthonsmartphone" value="' . $label . '">' ;
print '</td></tr>' ;
2008-09-10 22:49:21 +02:00
2021-06-26 15:39:52 +02:00
// Project
2020-12-08 11:58:47 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " ChildOfProjectTask " ) . '</td><td>' ;
2020-12-11 01:20:40 +01:00
print img_picto ( '' , 'project' );
2021-09-02 18:48:46 +02:00
$formother -> selectProjectTasks ( GETPOST ( 'task_parent' ), ! empty ( $projectid ) ? $projectid : $object -> id , 'task_parent' , 0 , 0 , 1 , 1 , 0 , '0,1' , 'maxwidth500' );
2020-12-08 11:58:47 +01:00
print '</td></tr>' ;
Add: hooks and triggers for a lot of core modules (action/calendrier, deplacement, dons, tva, contact/tiers, contrat, product lines, expedition, fournisseur commandes et factures, fiche intervention, projet et taches)
Signed-off-by: Stephen L. <lrq3000@gmail.com>
2012-08-14 15:50:45 +02:00
2021-06-26 15:39:52 +02:00
// Assigned to
2020-12-08 11:58:47 +01:00
print '<tr><td>' . $langs -> trans ( " AffectedTo " ) . '</td><td>' ;
$contactsofproject = ( ! empty ( $object -> id ) ? $object -> getListContactId ( 'internal' ) : '' );
2021-02-26 18:49:22 +01:00
if ( is_array ( $contactsofproject ) && count ( $contactsofproject )) {
2020-12-08 11:58:47 +01:00
print $form -> select_dolusers ( $user -> id , 'userid' , 0 , '' , 0 , '' , $contactsofproject , 0 , 0 , 0 , '' , 0 , '' , 'maxwidth300' );
} else {
2021-06-26 15:39:52 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " NoUserAssignedToTheProject " ) . '</span>' ;
2020-12-08 11:58:47 +01:00
}
print '</td></tr>' ;
2012-02-04 18:34:52 +01:00
2020-12-08 11:58:47 +01:00
// Date start
print '<tr><td>' . $langs -> trans ( " DateStart " ) . '</td><td>' ;
2021-09-02 18:48:46 +02:00
print $form -> selectDate (( ! empty ( $date_start ) ? $date_start : '' ), 'dateo' , 1 , 1 , 0 , '' , 1 , 1 );
2020-12-08 11:58:47 +01:00
print '</td></tr>' ;
2015-05-14 16:47:15 +02:00
2020-12-08 11:58:47 +01:00
// Date end
print '<tr><td>' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
2021-09-02 18:48:46 +02:00
print $form -> selectDate (( ! empty ( $date_end ) ? $date_end : - 1 ), 'datee' , - 1 , 1 , 0 , '' , 1 , 1 );
2020-12-08 11:58:47 +01:00
print '</td></tr>' ;
2008-09-10 22:49:21 +02:00
2020-12-08 11:58:47 +01:00
// Planned workload
print '<tr><td>' . $langs -> trans ( " PlannedWorkload " ) . '</td><td>' ;
2021-09-02 18:48:46 +02:00
print $form -> select_duration ( 'planned_workload' , ! empty ( $planned_workload ) ? $planned_workload : 0 , 0 , 'text' );
2020-12-08 11:58:47 +01:00
print '</td></tr>' ;
// Progress
print '<tr><td>' . $langs -> trans ( " ProgressDeclared " ) . '</td><td colspan="3">' ;
print $formother -> select_percent ( $progress , 'progress' , 0 , 5 , 0 , 100 , 1 );
print '</td></tr>' ;
// Description
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td>' ;
print '<td>' ;
2022-03-09 14:09:22 +01:00
2022-03-09 14:15:30 +01:00
if ( empty ( $conf -> global -> FCKEDITOR_ENABLE_SOCIETE )) {
print '<textarea name="description" class="quatrevingtpercent" rows="' . ROWS_4 . '">' . $description . '</textarea>' ;
} else {
// WYSIWYG editor
include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
$cked_enabled = ( ! empty ( $conf -> global -> FCKEDITOR_ENABLE_DETAILS ) ? $conf -> global -> FCKEDITOR_ENABLE_DETAILS : 0 );
if ( ! empty ( $conf -> global -> MAIN_INPUT_DESC_HEIGHT )) {
$nbrows = $conf -> global -> MAIN_INPUT_DESC_HEIGHT ;
}
$doleditor = new DolEditor ( 'description' , $object -> description , '' , 80 , 'dolibarr_details' , '' , false , true , $cked_enabled , $nbrows );
print $doleditor -> Create ();
}
2022-03-09 14:09:22 +01:00
2020-12-08 11:58:47 +01:00
print '</td></tr>' ;
2021-10-15 10:24:56 +02:00
print '<tr><td>' . $langs -> trans ( " Budget " ) . '</td>' ;
print '<td><input size="5" type="text" name="budget_amount" value="' . dol_escape_htmltag ( GETPOSTISSET ( 'budget_amount' ) ? GETPOST ( 'budget_amount' ) : '' ) . '"></td>' ;
print '</tr>' ;
2020-12-08 11:58:47 +01:00
// Other options
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $taskstatic , $action ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2021-02-26 18:49:22 +01:00
if ( empty ( $reshook ) && ! empty ( $extrafields -> attributes [ $taskstatic -> table_element ][ 'label' ])) {
2020-12-08 11:58:47 +01:00
print $taskstatic -> showOptionals ( $extrafields , 'edit' ); // Do not use $object here that is object of project but use $taskstatic
2018-12-10 15:06:54 +01:00
}
2020-12-08 11:58:47 +01:00
print '</table>' ;
print dol_get_fiche_end ();
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ( " Add " );
2020-12-08 11:58:47 +01:00
print '</form>' ;
} elseif ( $id > 0 || ! empty ( $ref )) {
2020-03-24 19:50:01 +01:00
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2006-09-23 02:27:47 +02:00
/*
2018-01-04 20:42:57 +01:00
* Projet card in view mode
2014-03-11 20:38:29 +01:00
*/
2009-01-14 17:40:45 +01:00
2018-02-26 11:57:29 +01:00
print '<br>' ;
2018-01-04 20:42:57 +01:00
2019-10-20 11:59:21 +02:00
// Link to create task
2020-04-16 00:42:57 +02:00
$linktocreatetaskParam = array ();
$linktocreatetaskUserRight = false ;
if ( $user -> rights -> projet -> all -> creer || $user -> rights -> projet -> creer ) {
if ( $object -> public || $userWrite > 0 ) {
$linktocreatetaskUserRight = true ;
} else {
$linktocreatetaskParam [ 'attr' ][ 'title' ] = $langs -> trans ( " NotOwnerOfProject " );
}
}
$linktocreatetask = dolGetButtonTitle ( $langs -> trans ( 'AddTask' ), '' , 'fa fa-plus-circle' , DOL_URL_ROOT . '/projet/tasks.php?action=create' . $param . '&backtopage=' . urlencode ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id ), '' , $linktocreatetaskUserRight , $linktocreatetaskParam );
2009-01-14 17:40:45 +01:00
2017-04-11 02:48:16 +02:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '">' ;
2022-01-15 12:26:08 +01:00
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
2019-12-01 10:20:11 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-04-11 02:48:16 +02: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 . '">' ;
2020-04-16 00:42:57 +02:00
print '<input type="hidden" name="page" value="' . $page . '">' ;
2017-04-11 02:48:16 +02:00
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2017-06-11 10:37:58 +02:00
2019-11-12 09:46:08 +01:00
$title = $langs -> trans ( " ListOfTasks " );
2020-11-21 23:36:20 +01:00
$linktotasks = dolGetButtonTitle ( $langs -> trans ( 'ViewList' ), '' , 'fa fa-list-alt imgforviewmode' , DOL_URL_ROOT . '/projet/tasks.php?id=' . $object -> id , '' , 1 , array ( 'morecss' => 'reposition btnTitleSelected' ));
$linktotasks .= dolGetButtonTitle ( $langs -> trans ( 'ViewGantt' ), '' , 'fa fa-stream imgforviewmode' , DOL_URL_ROOT . '/projet/ganttview.php?id=' . $object -> id . '&withproject=1' , '' , 1 , array ( 'morecss' => 'reposition marginleftonly' ));
2018-02-26 11:57:29 +01:00
2019-09-30 10:14:55 +02:00
//print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1);
2020-10-12 12:53:57 +02:00
print load_fiche_titre ( $title , $linktotasks . ' ' . $linktocreatetask , 'projecttask' );
2017-06-11 10:37:58 +02:00
2009-07-28 15:37:28 +02:00
// Get list of tasks in tasksarray and taskarrayfiltered
2014-01-06 13:02:20 +01:00
// We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him).
2017-01-12 15:23:30 +01:00
$filteronthirdpartyid = $socid ;
2020-03-24 19:50:01 +01:00
$tasksarray = $taskstatic -> getTasksArray ( 0 , 0 , $object -> id , $filteronthirdpartyid , 0 , '' , - 1 , $morewherefilter , 0 , 0 , $extrafields , 1 , $search_array_options );
2020-11-05 14:33:41 +01:00
2009-07-28 15:37:28 +02:00
// We load also tasks limited to a particular user
2019-11-12 09:46:08 +01:00
$tmpuser = new User ( $db );
2021-02-26 18:49:22 +01:00
if ( $search_user_id > 0 ) {
$tmpuser -> fetch ( $search_user_id );
}
2017-06-11 10:37:58 +02:00
2019-11-12 09:46:08 +01:00
$tasksrole = ( $tmpuser -> id > 0 ? $taskstatic -> getUserRolesForProjectsOrTasks ( 0 , $tmpuser , $object -> id , 0 ) : '' );
2010-02-15 11:54:55 +01:00
//var_dump($tasksarray);
//var_dump($tasksrole);
2009-07-28 15:37:28 +02:00
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
2012-09-19 17:53:09 +02:00
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php' ;
}
2012-09-15 13:53:19 +02:00
2018-05-18 10:33:32 +02:00
// Filter on categories
2019-11-12 09:46:08 +01:00
$moreforfilter = '' ;
2021-02-26 18:49:22 +01:00
if ( count ( $tasksarray ) > 0 ) {
2019-11-12 09:46:08 +01:00
$moreforfilter .= '<div class="divsearchfield">' ;
2022-01-21 15:45:09 +01:00
$moreforfilter .= img_picto ( '' , 'user' , 'class="pictofixedwidth"' );
$moreforfilter .= $form -> select_dolusers ( $tmpuser -> id > 0 ? $tmpuser -> id : '' , 'search_user_id' , $langs -> trans ( " TasksAssignedTo " ), null , 0 , '' , '' );
2019-11-12 09:46:08 +01:00
$moreforfilter .= '</div>' ;
2018-05-18 10:33:32 +02:00
}
2021-02-26 18:49:22 +01:00
if ( $moreforfilter ) {
2018-05-18 10:33:32 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
}
2017-08-22 20:20:34 +02:00
print '<div class="div-table-responsive">' ;
2020-04-15 14:54:54 +02:00
print '<table id="tablelines" class="tagtable nobottom liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' ;
2018-05-18 10:33:32 +02:00
// Fields title search
print '<tr class="liste_titre_filter">' ;
2020-03-24 19:50:01 +01:00
if ( ! empty ( $arrayfields [ 't.ref' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
2020-04-10 10:59:32 +02:00
print '<input class="flat searchstring maxwidth50" type="text" name="search_taskref" value="' . dol_escape_htmltag ( $search_taskref ) . '">' ;
2020-03-24 19:50:01 +01:00
print '</td>' ;
}
2018-05-18 10:33:32 +02:00
2020-03-24 19:50:01 +01:00
if ( ! empty ( $arrayfields [ 't.label' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
2020-04-10 10:59:32 +02:00
print '<input class="flat searchstring maxwidth100" type="text" name="search_tasklabel" value="' . dol_escape_htmltag ( $search_tasklabel ) . '">' ;
2020-03-24 19:50:01 +01:00
print '</td>' ;
}
2018-05-18 10:33:32 +02:00
2020-03-24 19:50:01 +01:00
if ( ! empty ( $arrayfields [ 't.description' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
2020-04-10 10:59:32 +02:00
print '<input class="flat searchstring maxwidth100" type="text" name="search_taskdescription" value="' . dol_escape_htmltag ( $search_taskdescription ) . '">' ;
2020-03-24 19:50:01 +01:00
print '</td>' ;
}
2018-05-18 10:33:32 +02:00
2020-03-24 19:50:01 +01:00
if ( ! empty ( $arrayfields [ 't.dateo' ][ 'checked' ])) {
print '<td class="liste_titre center">' ;
2021-08-25 12:46:56 +02:00
/* print '<span class="nowraponall"><input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtstartday" value="' . $search_dtstartday . '">' ;
2020-10-13 10:51:51 +02:00
print '<input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtstartmonth" value="' . $search_dtstartmonth . '"></span>' ;
2021-08-25 12:46:56 +02:00
$formother -> select_year ( $search_dtstartyear ? $search_dtstartyear : - 1 , 'search_dtstartyear' , 1 , 20 , 5 ); */
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_date_start_start ? $search_date_start_start : - 1 , 'search_date_start_start' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'From' ));
print '</div>' ;
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_date_start_end ? $search_date_start_end : - 1 , 'search_date_start_end' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'to' ));
print '</div>' ;
2020-03-24 19:50:01 +01:00
print '</td>' ;
}
2018-05-18 10:33:32 +02:00
2020-03-24 19:50:01 +01:00
if ( ! empty ( $arrayfields [ 't.datee' ][ 'checked' ])) {
print '<td class="liste_titre center">' ;
2021-08-25 12:46:56 +02:00
/* print '<span class="nowraponall"><input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtendday" value="' . $search_dtendday . '">' ;
2020-10-13 10:51:51 +02:00
print '<input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtendmonth" value="' . $search_dtendmonth . '"></span>' ;
2021-08-25 12:46:56 +02:00
$formother -> select_year ( $search_dtendyear ? $search_dtendyear : - 1 , 'search_dtendyear' , 1 , 20 , 5 ); */
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_date_end_start ? $search_date_end_start : - 1 , 'search_date_end_start' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'From' ));
print '</div>' ;
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_date_end_end ? $search_date_end_end : - 1 , 'search_date_end_end' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'to' ));
print '</div>' ;
2020-03-24 19:50:01 +01:00
print '</td>' ;
}
2018-05-18 10:33:32 +02:00
2020-03-24 19:50:01 +01:00
if ( ! empty ( $arrayfields [ 't.planned_workload' ][ 'checked' ])) {
print '<td class="liste_titre right">' ;
2020-04-10 10:59:32 +02:00
print '<input class="flat" type="text" size="4" name="search_planedworkload" value="' . $search_planedworkload . '">' ;
2020-03-24 19:50:01 +01:00
print '</td>' ;
}
2018-05-18 10:33:32 +02:00
2020-03-24 19:50:01 +01:00
if ( ! empty ( $arrayfields [ 't.duration_effective' ][ 'checked' ])) {
print '<td class="liste_titre right">' ;
2020-04-10 10:59:32 +02:00
print '<input class="flat" type="text" size="4" name="search_timespend" value="' . $search_timespend . '">' ;
2020-03-24 19:50:01 +01:00
print '</td>' ;
}
2018-05-18 10:33:32 +02:00
2020-03-24 19:50:01 +01:00
if ( ! empty ( $arrayfields [ 't.progress_calculated' ][ 'checked' ])) {
print '<td class="liste_titre right">' ;
2020-04-10 10:59:32 +02:00
print '<input class="flat" type="text" size="4" name="search_progresscalc" value="' . $search_progresscalc . '">' ;
2020-03-24 19:50:01 +01:00
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 't.progress' ][ 'checked' ])) {
print '<td class="liste_titre right">' ;
2020-04-10 10:59:32 +02:00
print '<input class="flat" type="text" size="4" name="search_progressdeclare" value="' . $search_progressdeclare . '">' ;
2020-03-24 19:50:01 +01:00
print '</td>' ;
}
2019-08-10 15:41:21 +02:00
2020-04-16 00:42:57 +02:00
// progress resume not searchable
print '<td class="liste_titre right"></td>' ;
2018-05-18 10:33:32 +02:00
2021-02-26 18:49:22 +01:00
if ( $object -> usage_bill_time ) {
2020-03-24 19:50:01 +01:00
if ( ! empty ( $arrayfields [ 't.tobill' ][ 'checked' ])) {
print '<td class="liste_titre right">' ;
print '</td>' ;
}
2019-03-29 14:34:55 +01:00
2020-03-24 19:50:01 +01:00
if ( ! empty ( $arrayfields [ 't.billed' ][ 'checked' ])) {
print '<td class="liste_titre right">' ;
print '</td>' ;
}
2019-03-29 14:34:55 +01:00
}
2021-03-04 16:50:39 +01:00
// Contacts of task, disabled because available by default jsut after
/*
2021-03-04 10:33:18 +01:00
if ( ! empty ( $conf -> global -> PROJECT_SHOW_CONTACTS_IN_LIST )) {
print '<td class="liste_titre"></td>' ;
}
2021-03-04 16:50:39 +01:00
*/
2021-03-04 17:24:58 +01:00
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>' ;
}
2021-03-04 10:15:41 +01:00
if ( ! empty ( $arrayfields [ 'c.assigned' ][ 'checked' ])) {
print '<td class="liste_titre right">' ;
print '</td>' ;
2021-02-26 18:49:22 +01:00
}
2020-03-24 19:50:01 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2018-05-21 11:03:48 +02:00
2018-05-18 10:33:32 +02: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 ();
2018-05-18 10:33:32 +02:00
print $searchpicto ;
print '</td>' ;
print " </tr> \n " ;
2017-06-11 10:37:58 +02:00
2015-04-08 20:40:01 +02:00
print '<tr class="liste_titre nodrag nodrop">' ;
2012-02-04 18:34:52 +01:00
// print '<td>'.$langs->trans("Project").'</td>';
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 " ], '' , '' , $param , '' , $sortfield , $sortorder , '' );
}
if ( ! empty ( $arrayfields [ 't.label' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , '' );
}
if ( ! empty ( $arrayfields [ 't.description' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.description' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , '' );
}
if ( ! empty ( $arrayfields [ 't.dateo' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.dateo' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 't.datee' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.datee' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 't.planned_workload' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.planned_workload' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'right ' , '' , 1 );
}
if ( ! empty ( $arrayfields [ 't.duration_effective' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.duration_effective' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'right ' , '' , 1 );
}
if ( ! empty ( $arrayfields [ 't.progress_calculated' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.progress_calculated' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'right ' , '' , 1 );
}
if ( ! empty ( $arrayfields [ 't.progress' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.progress' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'right ' , '' , 1 );
}
if ( ! empty ( $arrayfields [ 't.progress_summary' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.progress_summary' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'center ' , '' , 1 );
}
if ( $object -> usage_bill_time ) {
if ( ! empty ( $arrayfields [ 't.tobill' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.tobill' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 't.billed' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.billed' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'right ' );
}
}
2021-03-04 16:50:39 +01:00
// Contacts of task, disabled because available by default jsut after
/*
2021-03-04 10:33:18 +01:00
if ( ! empty ( $conf -> global -> PROJECT_SHOW_CONTACTS_IN_LIST )) {
print_liste_field_titre ( " TaskRessourceLinks " , $_SERVER [ " PHP_SELF " ], '' , '' , $param , $sortfield , $sortorder );
}
2021-03-04 16:50:39 +01:00
*/
2021-10-15 10:24:56 +02:00
if ( ! empty ( $arrayfields [ 't.budget_amount' ][ 'checked' ])) {
2021-10-15 11:02:05 +02:00
print_liste_field_titre ( $arrayfields [ 't.budget_amount' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2021-10-15 10:24:56 +02:00
}
2021-03-04 10:15:41 +01:00
if ( ! empty ( $arrayfields [ 'c.assigned' ][ 'checked' ])) {
2021-06-30 15:00:04 +02:00
print_liste_field_titre ( $arrayfields [ 'c.assigned' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'center ' , '' );
2021-02-26 18:49:22 +01:00
}
2020-03-24 19:50:01 +01:00
// Extra fields
2020-04-10 10:59:32 +02:00
$disablesortlink = 1 ;
2020-03-24 19:50:01 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
// Hook fields
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
2009-01-12 21:26:06 +01:00
print " </tr> \n " ;
2017-06-11 10:37:58 +02:00
2021-02-26 18:49:22 +01:00
if ( count ( $tasksarray ) > 0 ) {
2020-04-16 00:42:57 +02:00
// Show all lines in taskarray (recursive function to go down on tree)
2019-11-12 09:46:08 +01:00
$j = 0 ; $level = 0 ;
2020-03-24 19:50:01 +01:00
$nboftaskshown = projectLinesa ( $j , 0 , $tasksarray , $level , true , 0 , $tasksrole , $object -> id , 1 , $object -> id , $filterprogresscalc , ( $object -> usage_bill_time ? 1 : 0 ), $arrayfields );
2020-05-21 15:05:19 +02:00
} else {
2020-04-16 00:42:57 +02:00
$colspan = 10 ;
2021-02-26 18:49:22 +01:00
if ( $object -> usage_bill_time ) {
$colspan += 2 ;
}
2019-08-21 04:02:30 +02:00
print '<tr class="oddeven nobottom"><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs -> trans ( " NoTasks " ) . '</span></td></tr>' ;
2010-05-23 22:37:28 +02:00
}
2017-06-11 10:37:58 +02:00
2009-01-12 21:26:06 +01:00
print " </table> " ;
2017-08-22 20:20:34 +02:00
print '</div>' ;
2009-07-28 15:37:28 +02:00
2017-04-11 02:48:16 +02:00
print '</form>' ;
2017-06-11 10:37:58 +02:00
2009-01-14 17:40:45 +01:00
2009-07-28 15:37:28 +02:00
// Test if database is clean. If not we clean it.
2011-09-17 21:49:50 +02:00
//print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'<br>';
2021-02-26 18:49:22 +01:00
if ( ! empty ( $user -> rights -> projet -> all -> lire )) { // We make test to clean only if user has permission to see all (test may report false positive otherwise)
if ( $search_user_id == $user -> id ) {
if ( $nboftaskshown < count ( $tasksrole )) {
2014-04-26 21:36:58 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
cleanCorruptedTree ( $db , 'projet_task' , 'fk_task_parent' );
}
2020-05-21 15:05:19 +02:00
} else {
2021-02-26 18:49:22 +01:00
if ( $nboftaskshown < count ( $tasksarray ) && ! GETPOST ( 'search_user_id' , 'int' )) {
2014-04-26 21:36:58 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
cleanCorruptedTree ( $db , 'projet_task' , 'fk_task_parent' );
}
2014-01-06 13:02:20 +01:00
}
2008-09-10 22:49:21 +02:00
}
}
2018-08-15 12:48:13 +02:00
// End of page
2012-01-25 11:05:15 +01:00
llxFooter ();
2009-01-15 00:36:51 +01:00
$db -> close ();