2005-08-21 14:39:11 +02:00
< ? php
2012-04-18 11:16:15 +02:00
/* Copyright ( C ) 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2017-04-11 02:48:16 +02:00
* Copyright ( C ) 2006 - 2017 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2010 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2018-09-09 11:25:59 +02:00
* Copyright ( C ) 2018 Frédéric France < frederic . france @ netlogic . fr >
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:39:11 +02:00
/**
2008-09-10 22:49:21 +02:00
* \file htdocs / projet / tasks / task . php
2012-04-18 11:16:15 +02:00
* \ingroup project
2011-09-14 14:47:51 +02:00
* \brief Page of a project task
2008-09-10 13:14:45 +02:00
*/
2005-08-21 14:39:11 +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/class/html.formother.class.php' ;
2013-04-12 11:09:53 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2013-05-15 14:19:16 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2013-07-18 10:24:45 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/modules/project/task/modules_task.php' ;
2005-08-21 14:39:11 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
$langs -> loadlangs ( array ( 'projects' , 'companies' ));
2013-07-17 18:45:58 +02:00
2020-04-10 10:59:32 +02:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( " ref " , 'alpha' , 1 ); // task ref
$taskref = GETPOST ( " taskref " , 'alpha' ); // task ref
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2020-04-10 10:59:32 +02:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
$withproject = GETPOST ( 'withproject' , 'int' );
$project_ref = GETPOST ( 'project_ref' , 'alpha' );
$planned_workload = (( GETPOST ( 'planned_workloadhour' , 'int' ) != '' || GETPOST ( 'planned_workloadmin' , 'int' ) != '' ) ? ( GETPOST ( 'planned_workloadhour' , 'int' ) > 0 ? GETPOST ( 'planned_workloadhour' , 'int' ) * 3600 : 0 ) + ( GETPOST ( 'planned_workloadmin' , 'int' ) > 0 ? GETPOST ( 'planned_workloadmin' , 'int' ) * 60 : 0 ) : '' );
2010-01-29 10:55:00 +01:00
2010-05-30 14:21:32 +02:00
// Security check
2020-04-10 10:59:32 +02:00
$socid = 0 ;
2019-10-31 20:46:31 +01:00
//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
2021-02-26 18:49:22 +01:00
if ( ! $user -> rights -> projet -> lire ) {
accessforbidden ();
}
2012-04-18 11:16:15 +02:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2020-04-10 10:59:32 +02:00
$hookmanager -> initHooks ( array ( 'projecttaskcard' , '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
2012-04-18 11:16:15 +02:00
$object = new Task ( $db );
2013-04-12 11:09:53 +02:00
$extrafields = new ExtraFields ( $db );
2012-04-18 11:16:15 +02:00
$projectstatic = new Project ( $db );
2005-08-21 14:39:11 +02:00
2013-04-12 11:09:53 +02:00
// fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2014-10-08 15:35:39 +02:00
2019-11-13 19:35:39 +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' );
}
2014-10-08 15:35:39 +02:00
2009-01-12 10:53:45 +01:00
/*
* Actions
2014-10-08 15:35:39 +02:00
*/
2009-01-12 10:53:45 +01:00
2021-03-24 19:06:44 +01:00
if ( $action == 'update' && ! GETPOST ( " cancel " ) && $user -> rights -> projet -> creer ) {
2019-11-13 19:35:39 +01:00
$error = 0 ;
2010-01-29 10:55:00 +01:00
2021-02-26 18:49:22 +01:00
if ( empty ( $taskref )) {
2016-07-09 13:58:46 +02:00
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Ref " )), null , 'errors' );
}
2021-03-24 19:53:31 +01:00
if ( ! GETPOST ( " label " )) {
2010-01-29 10:55:00 +01:00
$error ++ ;
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Label " )), null , 'errors' );
2010-01-29 10:55:00 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! $error ) {
2019-01-27 11:55:16 +01:00
$object -> fetch ( $id , $ref );
2020-10-07 15:01:28 +02:00
$object -> oldcopy = clone $object ;
2010-02-07 03:39:01 +01:00
2019-11-13 19:35:39 +01:00
$tmparray = explode ( '_' , $_POST [ 'task_parent' ]);
$task_parent = $tmparray [ 1 ];
2021-02-26 18:49:22 +01:00
if ( empty ( $task_parent )) {
$task_parent = 0 ; // If task_parent is ''
}
2010-01-29 10:55:00 +01:00
2019-11-13 19:35:39 +01:00
$object -> ref = $taskref ? $taskref : GETPOST ( " ref " , 'alpha' , 2 );
2020-11-05 14:33:41 +01:00
$object -> label = GETPOST ( " label " , " alphanohtml " );
$object -> description = GETPOST ( 'description' , " alphanohtml " );
2012-04-18 11:16:15 +02:00
$object -> fk_task_parent = $task_parent ;
2013-10-30 21:44:04 +01:00
$object -> planned_workload = $planned_workload ;
2020-11-05 14:33:41 +01:00
$object -> date_start = dol_mktime ( GETPOST ( 'dateohour' , 'int' ), GETPOST ( 'dateomin' , 'int' ), 0 , GETPOST ( 'dateomonth' , 'int' ), GETPOST ( 'dateoday' , 'int' ), GETPOST ( 'dateoyear' , 'int' ));
$object -> date_end = dol_mktime ( GETPOST ( 'dateehour' , 'int' ), GETPOST ( 'dateemin' , 'int' ), 0 , GETPOST ( 'dateemonth' , 'int' ), GETPOST ( 'dateeday' , 'int' ), GETPOST ( 'dateeyear' , 'int' ));
$object -> progress = price2num ( GETPOST ( 'progress' , 'alphanohtml' ));
2010-01-29 10:55:00 +01:00
2013-04-12 11:09:53 +02:00
// Fill array 'array_options' with data from add form
2019-10-06 14:41:52 +02:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object );
2021-02-26 18:49:22 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2013-04-12 11:09:53 +02:00
2021-02-26 18:49:22 +01:00
if ( ! $error ) {
2019-11-13 19:35:39 +01:00
$result = $object -> update ( $user );
2021-02-26 18:49:22 +01:00
if ( $result < 0 ) {
2020-10-07 15:01:28 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-02-26 14:25:30 +01:00
}
2014-07-03 17:15:42 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:35:39 +01:00
$action = 'edit' ;
2010-01-29 10:55:00 +01:00
}
}
2021-02-26 18:49:22 +01:00
if ( $action == 'confirm_delete' && $confirm == " yes " && $user -> rights -> projet -> supprimer ) {
if ( $object -> fetch ( $id , $ref ) >= 0 ) {
2019-11-13 19:35:39 +01:00
$result = $projectstatic -> fetch ( $object -> fk_project );
2015-03-14 11:56:28 +01:00
$projectstatic -> fetch_thirdparty ();
2009-01-12 10:53:45 +01:00
2021-02-26 18:49:22 +01:00
if ( $object -> delete ( $user ) > 0 ) {
2019-11-13 19:35:39 +01:00
header ( 'Location: ' . DOL_URL_ROOT . '/projet/tasks.php?restore_lastsearch_values=1&id=' . $projectstatic -> id . ( $withproject ? '&withproject=1' : '' ));
2009-01-12 10:53:45 +01:00
exit ;
2020-05-21 15:05:19 +02:00
} else {
2020-10-07 15:01:28 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2019-11-13 19:35:39 +01:00
$action = '' ;
2009-01-12 10:53:45 +01:00
}
}
}
2020-10-23 20:08:35 +02:00
// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
2021-02-26 18:49:22 +01:00
if ( ! empty ( $project_ref ) && ! empty ( $withproject )) {
if ( $projectstatic -> fetch ( '' , $project_ref ) > 0 ) {
2019-11-13 19:35:39 +01:00
$tasksarray = $object -> getTasksArray ( 0 , 0 , $projectstatic -> id , $socid , 0 );
2021-02-26 18:49:22 +01:00
if ( count ( $tasksarray ) > 0 ) {
2019-11-13 19:35:39 +01:00
$id = $tasksarray [ 0 ] -> id ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:35:39 +01:00
header ( " Location: " . DOL_URL_ROOT . '/projet/tasks.php?id=' . $projectstatic -> id . ( empty ( $mode ) ? '' : '&mode=' . $mode ));
2012-04-18 11:16:15 +02:00
}
}
}
2008-09-10 22:49:21 +02:00
2013-07-17 18:45:58 +02:00
// Build doc
2021-02-26 18:49:22 +01:00
if ( $action == 'builddoc' && $user -> rights -> projet -> creer ) {
2019-01-27 11:55:16 +01:00
$object -> fetch ( $id , $ref );
2013-10-30 21:44:04 +01:00
2013-09-06 13:25:45 +02:00
// Save last template used to generate document
2021-02-26 18:49:22 +01:00
if ( GETPOST ( 'model' )) {
$object -> setDocModel ( $user , GETPOST ( 'model' , 'alpha' ));
}
2013-07-17 18:45:58 +02:00
2013-09-06 13:25:45 +02:00
$outputlangs = $langs ;
2021-02-26 18:49:22 +01:00
if ( GETPOST ( 'lang_id' , 'aZ09' )) {
2019-01-27 11:55:16 +01:00
$outputlangs = new Translate ( " " , $conf );
$outputlangs -> setDefaultLang ( GETPOST ( 'lang_id' , 'aZ09' ));
2013-09-06 13:25:45 +02:00
}
2020-09-10 01:49:09 +02:00
$result = $object -> generateDocument ( $object -> model_pdf , $outputlangs );
2021-02-26 18:49:22 +01:00
if ( $result <= 0 ) {
2015-05-19 00:01:30 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-10-07 15:01:28 +02:00
$action = '' ;
2013-07-17 18:45:58 +02:00
}
}
// Delete file in doc form
2021-02-26 18:49:22 +01:00
if ( $action == 'remove_file' && $user -> rights -> projet -> creer ) {
2013-07-17 18:45:58 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2021-02-26 18:49:22 +01:00
if ( $object -> fetch ( $id , $ref ) >= 0 ) {
2013-07-17 18:45:58 +02:00
$langs -> load ( " other " );
2019-11-13 19:35:39 +01:00
$upload_dir = $conf -> projet -> dir_output ;
2020-11-05 14:33:41 +01:00
$file = $upload_dir . '/' . dol_sanitizeFileName ( GETPOST ( 'file' ));
2013-07-17 18:45:58 +02:00
2019-11-13 19:35:39 +01:00
$ret = dol_delete_file ( $file );
2021-02-26 18:49:22 +01:00
if ( $ret ) {
setEventMessages ( $langs -> trans ( " FileWasRemoved " , GETPOST ( 'urlfile' )), null , 'mesgs' );
} else {
setEventMessages ( $langs -> trans ( " ErrorFailToDeleteFile " , GETPOST ( 'urlfile' )), null , 'errors' );
}
2013-07-17 18:45:58 +02:00
}
}
2020-11-05 14:33:41 +01:00
2008-08-26 00:14:58 +02:00
/*
* View
2017-11-16 23:11:49 +01:00
*/
2005-08-21 14:39:11 +02:00
2012-07-28 17:34:21 +02:00
llxHeader ( '' , $langs -> trans ( " Task " ));
2005-08-21 14:39:11 +02:00
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2010-01-28 12:08:11 +01:00
$formother = new FormOther ( $db );
2013-07-17 18:45:58 +02:00
$formfile = new FormFile ( $db );
2009-01-12 10:53:45 +01:00
2021-02-26 18:49:22 +01:00
if ( $id > 0 || ! empty ( $ref )) {
if ( $object -> fetch ( $id , $ref ) > 0 ) {
2019-11-13 19:35:39 +01:00
$res = $object -> fetch_optionals ();
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_TASK ) && method_exists ( $object , 'fetchComments' ) && empty ( $object -> comments )) {
$object -> fetchComments ();
}
2013-04-12 11:09:53 +02:00
2019-11-13 19:35:39 +01:00
$result = $projectstatic -> fetch ( $object -> fk_project );
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_PROJECT ) && method_exists ( $projectstatic , 'fetchComments' ) && empty ( $projectstatic -> comments )) {
$projectstatic -> fetchComments ();
}
if ( ! empty ( $projectstatic -> socid )) {
$projectstatic -> fetch_thirdparty ();
}
2012-02-15 23:08:20 +01:00
2015-09-24 16:32:48 +02:00
$object -> project = clone $projectstatic ;
2014-05-10 16:43:47 +02:00
2020-11-05 14:33:41 +01:00
//$userWrite = $projectstatic->restrictedProjectArea($user, 'write');
2012-02-15 23:08:20 +01:00
2021-02-26 18:49:22 +01:00
if ( ! empty ( $withproject )) {
2013-04-12 11:09:53 +02:00
// Tabs for project
2019-11-13 19:35:39 +01:00
$tab = 'tasks' ;
$head = project_prepare_head ( $projectstatic );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , $tab , $langs -> trans ( " Project " ), - 1 , ( $projectstatic -> public ? 'projectpub' : 'project' ), 0 , '' , '' );
2013-04-12 11:09:53 +02:00
2019-11-13 19:35:39 +01:00
$param = ( $mode == 'mine' ? '&mode=mine' : '' );
2013-04-12 11:09:53 +02:00
2016-10-18 12:16:12 +02:00
// Project card
2017-06-07 10:55:39 +02:00
2020-10-07 15:01:28 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
$morehtmlref = '<div class="refidno">' ;
// Title
$morehtmlref .= $projectstatic -> title ;
// Thirdparty
2021-02-26 18:49:22 +01:00
if ( $projectstatic -> thirdparty -> id > 0 ) {
2020-10-07 15:01:28 +02:00
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $projectstatic -> thirdparty -> getNomUrl ( 1 , 'project' );
}
$morehtmlref .= '</div>' ;
// Define a complementary filter for search of next/prev ref.
2021-02-26 18:49:22 +01:00
if ( ! $user -> rights -> projet -> all -> lire ) {
2020-10-07 15:01:28 +02:00
$objectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 0 );
2021-03-22 12:47:23 +01:00
$projectstatic -> next_prev_filter = " rowid IN ( " . $db -> sanitize ( count ( $objectsListId ) ? join ( ',' , array_keys ( $objectsListId )) : '0' ) . " ) " ;
2020-10-07 15:01:28 +02:00
}
dol_banner_tab ( $projectstatic , 'project_ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border tableforfield centpercent">' ;
// 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-20 12:18:40 +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-20 12:18:40 +01:00
print '<input type="checkbox" disabled name="usage_opportunity"' . ( GETPOSTISSET ( 'usage_opportunity' ) ? ( GETPOST ( 'usage_opportunity' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $projectstatic -> 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-20 12:18:40 +01:00
print '<input type="checkbox" disabled name="usage_task"' . ( GETPOSTISSET ( 'usage_task' ) ? ( GETPOST ( 'usage_task' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $projectstatic -> 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-20 12:18:40 +01:00
print '<input type="checkbox" disabled name="usage_bill_time"' . ( GETPOSTISSET ( 'usage_bill_time' ) ? ( GETPOST ( 'usage_bill_time' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $projectstatic -> 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-20 12:18:40 +01:00
print '</td></tr>' ;
2020-10-07 15:01:28 +02:00
}
// Visibility
print '<tr><td class="titlefield">' . $langs -> trans ( " Visibility " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( $projectstatic -> public ) {
print $langs -> trans ( 'SharedProject' );
} else {
print $langs -> trans ( 'PrivateProject' );
}
2020-10-07 15:01:28 +02:00
print '</td></tr>' ;
// Date start - end
print '<tr><td>' . $langs -> trans ( " DateStart " ) . ' - ' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
$start = dol_print_date ( $projectstatic -> date_start , 'day' );
print ( $start ? $start : '?' );
$end = dol_print_date ( $projectstatic -> date_end , 'day' );
print ' - ' ;
print ( $end ? $end : '?' );
2021-02-26 18:49:22 +01:00
if ( $projectstatic -> hasDelay ()) {
print img_warning ( " Late " );
}
2020-10-07 15:01:28 +02:00
print '</td></tr>' ;
// Budget
print '<tr><td>' . $langs -> trans ( " Budget " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( strcmp ( $projectstatic -> budget_amount , '' )) {
print price ( $projectstatic -> budget_amount , '' , $langs , 1 , 0 , 0 , $conf -> currency );
}
2020-10-07 15:01:28 +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="ficheaddleft">' ;
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border centpercent">' ;
// Description
print '<td class="titlefield tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
print nl2br ( $projectstatic -> description );
print '</td></tr>' ;
// Categories
if ( $conf -> categorie -> enabled ) {
print '<tr><td class="valignmiddle">' . $langs -> trans ( " Categories " ) . '</td><td>' ;
print $form -> showCategories ( $projectstatic -> id , 'project' , 1 );
print " </td></tr> " ;
}
print '</table>' ;
print '</div>' ;
print '</div>' ;
print '</div>' ;
print '<div class="clearboth"></div>' ;
2017-06-07 10:55:39 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2017-04-05 14:48:24 +02:00
print '<br>' ;
2012-02-15 23:08:20 +01:00
}
/*
2013-04-12 11:09:53 +02:00
* Actions
2012-02-15 23:08:20 +01:00
*/
/* print '<div class="tabsAction">' ;
if ( $user -> rights -> projet -> all -> creer || $user -> rights -> projet -> creer )
{
2013-04-12 11:09:53 +02:00
if ( $projectstatic -> public || $userWrite > 0 )
{
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=create' . $param . '">' . $langs -> trans ( 'AddTask' ) . '</a>' ;
2012-02-15 23:08:20 +01:00
}
else
{
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " NotOwnerOfProject " ) . '">' . $langs -> trans ( 'AddTask' ) . '</a>' ;
2013-04-12 11:09:53 +02:00
}
}
else
{
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " NotEnoughPermissions " ) . '">' . $langs -> trans ( 'AddTask' ) . '</a>' ;
2012-02-15 23:08:20 +01:00
}
print '</div>' ;
*/
2010-05-30 14:21:32 +02:00
2010-03-02 08:52:31 +01:00
// To verify role of users
2012-04-18 11:16:15 +02:00
//$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
//$arrayofuseridoftask=$object->getListContactId('internal');
2010-02-07 03:39:01 +01:00
2019-11-13 19:35:39 +01:00
$head = task_prepare_head ( $object );
2013-04-12 11:09:53 +02:00
2021-02-26 18:49:22 +01:00
if ( $action == 'edit' && $user -> rights -> projet -> creer ) {
2010-01-29 10:55:00 +01:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2010-01-29 10:55:00 +01:00
print '<input type="hidden" name="action" value="update">' ;
2012-02-15 23:08:20 +01:00
print '<input type="hidden" name="withproject" value="' . $withproject . '">' ;
2012-04-18 11:16:15 +02:00
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
2010-02-07 03:39:01 +01:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'task_task' , $langs -> trans ( " Task " ), 0 , 'projecttask' , 0 , '' , '' );
2014-12-04 14:52:34 +01:00
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">' ;
2010-02-07 03:39:01 +01:00
2010-01-28 12:08:11 +01:00
// Ref
2016-07-09 13:58:46 +02:00
print '<tr><td class="titlefield fieldrequired">' . $langs -> trans ( " Ref " ) . '</td>' ;
2017-11-22 21:19:40 +01:00
print '<td><input class="minwidth100" name="taskref" value="' . $object -> ref . '"></td></tr>' ;
2010-02-07 03:39:01 +01:00
2010-01-28 12:08:11 +01:00
// Label
2016-07-09 13:58:46 +02:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Label " ) . '</td>' ;
2017-11-22 21:19:40 +01:00
print '<td><input class="minwidth500" name="label" value="' . $object -> label . '"></td></tr>' ;
2010-02-07 03:39:01 +01:00
2010-02-03 17:57:23 +01:00
// Project
2021-02-26 18:49:22 +01:00
if ( empty ( $withproject )) {
2013-04-12 11:09:53 +02:00
print '<tr><td>' . $langs -> trans ( " Project " ) . '</td><td colspan="3">' ;
print $projectstatic -> getNomUrl ( 1 );
print '</td></tr>' ;
// Third party
2014-05-09 13:39:10 +02:00
print '<td>' . $langs -> trans ( " ThirdParty " ) . '</td><td colspan="3">' ;
2021-02-26 18:49:22 +01:00
if ( $projectstatic -> societe -> id ) {
print $projectstatic -> societe -> getNomUrl ( 1 );
} else {
print ' ' ;
}
2013-04-12 11:09:53 +02:00
print '</td></tr>' ;
2012-02-15 23:27:03 +01:00
}
2010-02-07 03:39:01 +01:00
2010-02-03 17:57:23 +01:00
// Task parent
2017-11-16 23:11:49 +01:00
print '<tr><td>' . $langs -> trans ( " ChildOfProjectTask " ) . '</td><td>' ;
2019-11-13 19:35:39 +01:00
print $formother -> selectProjectTasks ( $object -> fk_task_parent , $projectstatic -> id , 'task_parent' , ( $user -> admin ? 0 : 1 ), 0 , 0 , 0 , $object -> id );
2010-02-01 10:21:52 +01:00
print '</td></tr>' ;
2010-02-07 03:39:01 +01:00
2010-01-28 12:08:11 +01:00
// Date start
2010-01-29 10:55:00 +01:00
print '<tr><td>' . $langs -> trans ( " DateStart " ) . '</td><td>' ;
2018-09-09 11:25:59 +02:00
print $form -> selectDate ( $object -> date_start , 'dateo' , 1 , 1 , 0 , '' , 1 , 0 );
2010-01-28 12:08:11 +01:00
print '</td></tr>' ;
2010-02-07 03:39:01 +01:00
2010-01-28 12:08:11 +01:00
// Date end
2020-11-28 01:14:45 +01:00
print '<tr><td>' . $langs -> trans ( " Deadline " ) . '</td><td>' ;
2019-11-13 19:35:39 +01:00
print $form -> selectDate ( $object -> date_end ? $object -> date_end : - 1 , 'datee' , 1 , 1 , 0 , '' , 1 , 0 );
2010-01-28 12:08:11 +01:00
print '</td></tr>' ;
2010-02-07 03:39:01 +01:00
2013-10-30 21:44:04 +01:00
// Planned workload
2013-05-14 20:22:33 +02:00
print '<tr><td>' . $langs -> trans ( " PlannedWorkload " ) . '</td><td>' ;
2017-05-18 11:35:12 +02:00
print $form -> select_duration ( 'planned_workload' , $object -> planned_workload , 0 , 'text' );
2013-05-13 17:08:36 +02:00
print '</td></tr>' ;
2014-10-12 01:04:34 +02:00
// Progress declared
2017-05-18 11:35:12 +02:00
print '<tr><td>' . $langs -> trans ( " ProgressDeclared " ) . '</td><td>' ;
2019-01-27 11:55:16 +01:00
print $formother -> select_percent ( $object -> progress , 'progress' , 0 , 5 , 0 , 100 , 1 );
2010-01-28 12:08:11 +01:00
print '</td></tr>' ;
2010-02-07 03:39:01 +01:00
2010-01-28 12:08:11 +01:00
// Description
2017-01-22 12:13:32 +01:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td>' ;
2010-01-29 10:55:00 +01:00
print '<td>' ;
2017-03-14 14:06:55 +01:00
print '<textarea name="description" class="quatrevingtpercent" rows="' . ROWS_4 . '">' . $object -> description . '</textarea>' ;
2010-01-28 12:08:11 +01:00
print '</td></tr>' ;
2010-02-07 03:39:01 +01:00
2013-04-12 11:09:53 +02:00
// Other options
2019-11-13 19:35:39 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2020-10-07 15:01:28 +02:00
print $hookmanager -> resPrint ;
2021-02-26 18:49:22 +01:00
if ( empty ( $reshook )) {
2019-01-27 11:55:16 +01:00
print $object -> showOptionals ( $extrafields , 'edit' );
2013-04-12 11:09:53 +02:00
}
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
2010-01-29 10:55:00 +01:00
print '</table>' ;
2012-02-15 23:08:20 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2014-12-04 14:52:34 +01:00
2019-02-23 22:24:26 +01:00
print '<div class="center">' ;
2011-09-14 14:47:51 +02:00
print '<input type="submit" class="button" name="update" value="' . $langs -> trans ( " Modify " ) . '"> ' ;
2020-11-23 15:12:52 +01:00
print '<input type="submit" class="button button-cancel" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2014-11-24 06:43:15 +01:00
print '</div>' ;
2011-09-14 14:47:51 +02:00
2010-01-29 10:55:00 +01:00
print '</form>' ;
2020-05-21 15:05:19 +02:00
} else {
2010-01-28 12:08:11 +01:00
/*
* Fiche tache en mode visu
2014-10-12 01:04:34 +02:00
*/
2019-11-13 19:35:39 +01:00
$param = ( $withproject ? '&withproject=1' : '' );
$linkback = $withproject ? '<a href="' . DOL_URL_ROOT . '/projet/tasks.php?id=' . $projectstatic -> id . '&restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' : '' ;
2010-02-07 03:39:01 +01:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'task_task' , $langs -> trans ( " Task " ), - 1 , 'projecttask' , 0 , '' , 'reposition' );
2014-12-04 14:52:34 +01:00
2021-02-26 18:49:22 +01:00
if ( $action == 'delete' ) {
2021-03-30 03:55:17 +02:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . GETPOST ( " id " , 'int' ) . '&withproject=' . $withproject , $langs -> trans ( " DeleteATask " ), $langs -> trans ( " ConfirmDeleteATask " ), " confirm_delete " );
2010-01-28 12:08:11 +01:00
}
2009-01-15 00:36:51 +01:00
2021-02-26 18:49:22 +01:00
if ( ! GETPOST ( 'withproject' ) || empty ( $projectstatic -> id )) {
2020-10-07 15:01:28 +02:00
$projectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 1 );
2021-03-22 12:47:23 +01:00
$object -> next_prev_filter = " fk_projet IN ( " . $db -> sanitize ( $projectsListId ) . " ) " ;
2021-02-26 18:49:22 +01:00
} else {
2021-03-30 03:55:17 +02:00
$object -> next_prev_filter = " fk_projet = " . (( int ) $projectstatic -> id );
2021-02-26 18:49:22 +01:00
}
2017-06-07 10:55:39 +02:00
2019-11-13 19:35:39 +01:00
$morehtmlref = '' ;
2017-06-07 10:55:39 +02:00
2017-05-18 12:12:36 +02:00
// Project
2021-02-26 18:49:22 +01:00
if ( empty ( $withproject )) {
2020-10-07 15:01:28 +02:00
$morehtmlref .= '<div class="refidno">' ;
$morehtmlref .= $langs -> trans ( " Project " ) . ': ' ;
$morehtmlref .= $projectstatic -> getNomUrl ( 1 );
$morehtmlref .= '<br>' ;
// Third party
$morehtmlref .= $langs -> trans ( " ThirdParty " ) . ': ' ;
if ( ! empty ( $projectstatic -> thirdparty )) {
$morehtmlref .= $projectstatic -> thirdparty -> getNomUrl ( 1 );
}
$morehtmlref .= '</div>' ;
2017-05-18 12:12:36 +02:00
}
2017-06-07 10:55:39 +02:00
2017-04-05 14:48:24 +02:00
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref , $param );
2017-06-07 10:55:39 +02:00
2017-03-23 16:10:38 +01:00
print '<div class="fichecenter">' ;
2017-09-17 20:05:36 +02:00
print '<div class="fichehalfleft">' ;
2017-06-07 10:55:39 +02:00
print '<div class="underbanner clearboth"></div>' ;
2020-01-15 13:33:11 +01:00
print '<table class="border centpercent tableforfield">' ;
2010-02-07 03:39:01 +01:00
2017-11-16 19:41:31 +01:00
// Task parent
print '<tr><td>' . $langs -> trans ( " ChildOfTask " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( $object -> fk_task_parent > 0 ) {
2019-11-13 19:35:39 +01:00
$tasktmp = new Task ( $db );
2017-11-16 19:41:31 +01:00
$tasktmp -> fetch ( $object -> fk_task_parent );
print $tasktmp -> getNomUrl ( 1 );
}
print '</td></tr>' ;
2017-04-05 14:48:24 +02:00
// Date start - Date end
2020-11-28 01:14:45 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " DateStart " ) . ' - ' . $langs -> trans ( " Deadline " ) . '</td><td colspan="3">' ;
2019-01-27 11:55:16 +01:00
$start = dol_print_date ( $object -> date_start , 'dayhour' );
2020-10-07 15:01:28 +02:00
print ( $start ? $start : '?' );
2019-01-27 11:55:16 +01:00
$end = dol_print_date ( $object -> date_end , 'dayhour' );
2020-10-07 15:01:28 +02:00
print ' - ' ;
print ( $end ? $end : '?' );
2021-02-26 18:49:22 +01:00
if ( $object -> hasDelay ()) {
print img_warning ( " Late " );
}
2010-01-28 12:08:11 +01:00
print '</td></tr>' ;
2010-02-07 03:39:01 +01:00
2013-10-30 21:44:04 +01:00
// Planned workload
2013-05-14 20:22:33 +02:00
print '<tr><td>' . $langs -> trans ( " PlannedWorkload " ) . '</td><td colspan="3">' ;
2021-02-26 18:49:22 +01:00
if ( $object -> planned_workload != '' ) {
2019-01-27 11:55:16 +01:00
print convertSecondToTime ( $object -> planned_workload , 'allhourmin' );
2015-02-28 19:02:03 +01:00
}
2013-05-13 17:08:36 +02:00
print '</td></tr>' ;
2017-09-17 20:05:36 +02:00
// Description
print '<td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td colspan="3">' ;
print nl2br ( $object -> description );
print '</td></tr>' ;
print '</table>' ;
print '</div>' ;
print '<div class="fichehalfright"><div class="ficheaddleft">' ;
print '<div class="underbanner clearboth"></div>' ;
2020-01-15 13:33:11 +01:00
print '<table class="border centpercent tableforfield">' ;
2017-09-17 20:05:36 +02:00
2014-10-12 01:04:34 +02:00
// Progress declared
2017-09-17 20:05:36 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " ProgressDeclared " ) . '</td><td colspan="3">' ;
2021-02-26 18:49:22 +01:00
if ( $object -> progress != '' ) {
2015-02-28 19:02:03 +01:00
print $object -> progress . ' %' ;
}
2014-03-15 23:12:00 +01:00
print '</td></tr>' ;
2014-10-12 01:04:34 +02:00
// Progress calculated
2014-03-15 23:12:00 +01:00
print '<tr><td>' . $langs -> trans ( " ProgressCalculated " ) . '</td><td colspan="3">' ;
2021-02-26 18:49:22 +01:00
if ( $object -> planned_workload != '' ) {
2019-11-13 19:35:39 +01:00
$tmparray = $object -> getSummaryOfTimeSpent ();
2021-02-26 18:49:22 +01:00
if ( $tmparray [ 'total_duration' ] > 0 && ! empty ( $object -> planned_workload )) {
print round ( $tmparray [ 'total_duration' ] / $object -> planned_workload * 100 , 2 ) . ' %' ;
} else {
print '0 %' ;
}
} else {
print '<span class="opacitymedium">' . $langs -> trans ( " WorkloadNotDefined " ) . '</span>' ;
}
2010-01-28 12:08:11 +01:00
print '</td></tr>' ;
2010-02-07 03:39:01 +01:00
2017-06-07 16:44:04 +02:00
// Other attributes
$cols = 3 ;
2019-11-13 19:35:39 +01:00
$parameters = array ( 'socid' => $socid );
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2013-10-30 21:44:04 +01:00
2011-09-14 14:47:51 +02:00
print '</table>' ;
2017-06-07 10:55:39 +02:00
2017-04-05 14:48:24 +02:00
print '</div>' ;
2017-09-17 20:05:36 +02:00
print '</div>' ;
print '</div>' ;
print '<div class="clearboth"></div>' ;
2017-06-07 10:55:39 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2011-09-14 14:47:51 +02:00
}
2010-02-07 03:39:01 +01:00
2016-04-30 01:01:32 +02:00
2021-02-26 18:49:22 +01:00
if ( $action != 'edit' ) {
2016-05-05 21:38:29 +02:00
/*
* Actions
2021-02-26 18:49:22 +01:00
*/
2017-06-07 10:55:39 +02:00
2020-10-07 15:01:28 +02:00
print '<div class="tabsAction">' ;
2016-05-05 21:38:29 +02:00
2020-10-07 15:01:28 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been
// modified by hook
2021-02-26 18:49:22 +01:00
if ( empty ( $reshook )) {
2016-04-27 22:19:38 +02:00
// Modify
2021-02-26 18:49:22 +01:00
if ( $user -> rights -> projet -> creer ) {
2016-04-27 22:19:38 +02:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=edit&withproject=' . $withproject . '">' . $langs -> trans ( 'Modify' ) . '</a>' ;
2020-05-21 15:05:19 +02:00
} else {
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " NotAllowed " ) . '">' . $langs -> trans ( 'Modify' ) . '</a>' ;
2016-04-27 22:19:38 +02:00
}
2017-06-07 10:55:39 +02:00
2016-04-27 22:19:38 +02:00
// Delete
2021-02-26 18:49:22 +01:00
if ( $user -> rights -> projet -> supprimer ) {
if ( ! $object -> hasChildren () && ! $object -> hasTimeSpent ()) {
2020-10-01 10:50:54 +02:00
print '<a class="butActionDelete" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=delete&token=' . newToken () . '&withproject=' . $withproject . '">' . $langs -> trans ( 'Delete' ) . '</a>' ;
2020-10-07 15:01:28 +02:00
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " TaskHasChild " ) . '">' . $langs -> trans ( 'Delete' ) . '</a>' ;
}
2020-05-21 15:05:19 +02:00
} else {
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " NotAllowed " ) . '">' . $langs -> trans ( 'Delete' ) . '</a>' ;
2016-04-27 22:19:38 +02:00
}
2017-06-07 10:55:39 +02:00
2016-04-27 22:19:38 +02:00
print '</div>' ;
2020-10-07 15:01:28 +02:00
}
2017-06-07 10:55:39 +02:00
2020-10-07 15:01:28 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
print '<a name="builddoc"></a>' ; // ancre
2017-06-07 10:55:39 +02:00
2016-05-05 21:38:29 +02:00
/*
2021-03-16 04:04:18 +01:00
* Generated documents
2016-05-05 21:38:29 +02:00
*/
2019-11-13 19:35:39 +01:00
$filename = dol_sanitizeFileName ( $projectstatic -> ref ) . " / " . dol_sanitizeFileName ( $object -> ref );
$filedir = $conf -> projet -> dir_output . " / " . dol_sanitizeFileName ( $projectstatic -> ref ) . " / " . dol_sanitizeFileName ( $object -> ref );
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id ;
$genallowed = ( $user -> rights -> projet -> lire );
$delallowed = ( $user -> rights -> projet -> creer );
2016-05-05 21:38:29 +02:00
2020-09-10 01:49:09 +02:00
print $formfile -> showdocuments ( 'project_task' , $filename , $filedir , $urlsource , $genallowed , $delallowed , $object -> model_pdf );
2016-05-05 21:38:29 +02:00
2016-10-24 11:27:39 +02:00
print '</div><div class="fichehalfright"><div class="ficheaddleft">' ;
2017-06-07 10:55:39 +02:00
2017-09-13 15:12:54 +02:00
// List of actions on element
2019-11-13 19:35:39 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
2017-09-13 15:12:54 +02:00
$formactions = new FormActions ( $db );
2021-02-04 13:03:05 +01:00
$defaultthirdpartyid = $socid > 0 ? $socid : $object -> project -> socid ;
$formactions -> showactions ( $object , 'task' , $defaultthirdpartyid , 1 , '' , 10 , 'withproject=' . $withproject );
2017-09-13 15:12:54 +02:00
2016-10-24 11:27:39 +02:00
print '</div></div></div>' ;
2009-07-28 15:37:28 +02:00
}
2005-08-21 14:39:11 +02:00
}
}
2018-08-15 12:48:13 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-02-15 23:08:20 +01:00
$db -> close ();