2016-07-09 15:30:42 +02:00
< ? php
2016-11-08 12:58:07 +01:00
/* Copyright ( C ) 2005 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2009 Regis Houssin < regis . houssin @ inodbox . com >
2016-07-09 15:30:42 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* 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 />.
2016-07-09 15:30:42 +02:00
*/
/**
* \file htdocs / projet / info . php
2018-12-08 16:37:41 +01:00
* \ingroup project
* \brief Page with events on project
2016-07-09 15:30:42 +02:00
*/
require '../main.inc.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php' ;
2016-10-25 10:53:25 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2016-07-09 15:30:42 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2016-07-09 15:30:42 +02:00
$langs -> load ( " projects " );
2019-01-27 11:55:16 +01:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
$socid = GETPOST ( 'socid' , 'int' );
$action = GETPOST ( 'action' , 'aZ09' );
2016-11-08 12:58:07 +01:00
2019-11-22 14:14:59 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2020-12-03 10:13:13 +01:00
$sortfield = GETPOST ( " sortfield " , " aZ09comma " );
$sortorder = GETPOST ( " sortorder " , 'aZ09comma' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2017-01-02 12:39:12 +01:00
$page = is_numeric ( $page ) ? $page : 0 ;
$page = $page == - 1 ? 0 : $page ;
2021-02-26 18:49:22 +01:00
if ( ! $sortfield ) {
$sortfield = " a.datep,a.id " ;
}
if ( ! $sortorder ) {
$sortorder = " DESC " ;
}
2019-11-22 14:14:59 +01:00
$offset = $limit * $page ;
2017-01-02 12:39:12 +01:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2021-02-26 18:49:22 +01:00
if ( GETPOST ( 'actioncode' , 'array' )) {
2019-11-22 14:14:59 +01:00
$actioncode = GETPOST ( 'actioncode' , 'array' , 3 );
2021-02-26 18:49:22 +01:00
if ( ! count ( $actioncode )) {
$actioncode = '0' ;
}
2020-05-21 15:05:19 +02:00
} else {
2019-11-22 14:14:59 +01:00
$actioncode = GETPOST ( " actioncode " , " alpha " , 3 ) ? GETPOST ( " actioncode " , " alpha " , 3 ) : ( GETPOST ( " actioncode " ) == '0' ? '0' : ( empty ( $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT ) ? '' : $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT ));
2016-10-17 17:52:58 +02:00
}
2019-11-22 14:14:59 +01:00
$search_agenda_label = GETPOST ( 'search_agenda_label' );
2016-10-17 17:52:58 +02:00
2016-07-09 15:30:42 +02:00
// Security check
2019-01-27 11:55:16 +01:00
$id = GETPOST ( " id " , 'int' );
2019-11-22 14:14:59 +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.
2020-08-07 12:09:58 +02:00
$result = restrictedArea ( $user , 'projet' , $id , 'projet&project' );
2016-07-09 15:30:42 +02:00
2021-02-26 18:49:22 +01:00
if ( ! $user -> rights -> projet -> lire ) {
accessforbidden ();
}
2016-10-17 17:52:58 +02:00
/*
2018-12-08 16:37:41 +01:00
* Actions
2016-10-17 17:52:58 +02:00
*/
2019-11-13 19:37:08 +01:00
$parameters = array ( 'id' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 18:49:22 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2016-10-17 17:52:58 +02: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 test are required to be compatible with all browsers
2019-11-13 19:37:08 +01:00
$actioncode = '' ;
$search_agenda_label = '' ;
2016-10-17 17:52:58 +02:00
}
2016-07-09 15:30:42 +02:00
/*
* View
*/
2016-10-25 10:53:25 +02:00
$form = new Form ( $db );
2016-11-08 12:58:07 +01:00
$object = new Project ( $db );
2016-10-25 10:53:25 +02:00
2021-02-26 18:49:22 +01:00
if ( $id > 0 || ! empty ( $ref )) {
2020-10-31 14:32:18 +01:00
$object -> fetch ( $id , $ref );
$object -> fetch_thirdparty ();
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 ();
}
2020-10-31 14:32:18 +01:00
$object -> info ( $object -> id );
2016-11-08 12:58:07 +01:00
}
2016-07-09 15:30:42 +02:00
2019-11-13 19:37:08 +01:00
$title = $langs -> trans ( " Project " ) . ' - ' . $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 ( " Info " );
}
2019-11-13 19:37:08 +01:00
$help_url = " EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos " ;
2019-01-27 11:55:16 +01:00
llxHeader ( " " , $title , $help_url );
2016-12-26 18:21:18 +01:00
2016-10-17 17:52:58 +02:00
$head = project_prepare_head ( $object );
2016-07-09 15:30:42 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'agenda' , $langs -> trans ( " Project " ), - 1 , ( $object -> public ? 'projectpub' : 'project' ));
2016-07-09 15:30:42 +02:00
2016-10-17 18:18:06 +02:00
// Project card
2017-05-19 00:52:13 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2016-10-17 18:18:06 +02:00
2019-11-13 19:37:08 +01:00
$morehtmlref = '<div class="refidno">' ;
2016-10-17 18:18:06 +02:00
// Title
2019-11-13 19:37:08 +01:00
$morehtmlref .= $object -> title ;
2016-10-17 18:18:06 +02:00
// Thirdparty
2021-02-26 18:49:22 +01:00
if ( $object -> thirdparty -> id > 0 ) {
2020-10-31 14:32:18 +01:00
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $object -> thirdparty -> getNomUrl ( 1 , 'project' );
2016-10-17 18:18:06 +02:00
}
2019-11-13 19:37:08 +01:00
$morehtmlref .= '</div>' ;
2016-10-17 18:18:06 +02:00
// 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-31 14:32:18 +01: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' ) . " ) " ;
2016-10-17 18:18:06 +02:00
}
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2016-10-17 17:52:58 +02:00
dol_print_object_info ( $object , 1 );
2016-10-17 18:18:06 +02:00
print '</div>' ;
print '<div class="clearboth"></div>' ;
2016-07-09 15:30:42 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2016-10-17 17:52:58 +02:00
// Actions buttons
2019-11-22 14:14:59 +01:00
$out = '' ;
$permok = $user -> rights -> agenda -> myactions -> create ;
2021-02-26 18:49:22 +01:00
if ( $permok ) {
2020-10-31 14:32:18 +01:00
$out .= '&projectid=' . $object -> id ;
2016-10-17 17:52:58 +02:00
}
2017-10-04 12:58:13 +02:00
//print '<div class="tabsAction">';
2019-11-22 14:14:59 +01:00
$morehtmlcenter = '' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> agenda -> enabled )) {
2020-10-31 14:32:18 +01:00
$addActionBtnRight = ! empty ( $user -> rights -> agenda -> myactions -> create ) || ! empty ( $user -> rights -> agenda -> allactions -> create );
2021-02-26 18:49:22 +01:00
$morehtmlcenter .= dolGetButtonTitle ( $langs -> trans ( 'AddAction' ), '' , 'fa fa-plus-circle' , DOL_URL_ROOT . '/comm/action/card.php?action=create' . $out . '&socid=' . $object -> socid . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id ), '' , $addActionBtnRight );
2016-10-17 17:52:58 +02:00
}
2017-10-04 12:58:13 +02:00
//print '</div>';
2016-10-17 17:52:58 +02:00
2021-02-26 18:49:22 +01:00
if ( ! empty ( $object -> id )) {
2017-10-04 12:58:13 +02:00
print '<br>' ;
2019-11-13 19:37:08 +01:00
$param = '&id=' . $object -> id ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . $contextpage ;
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . $limit ;
}
2016-12-26 18:21:18 +01:00
2020-10-31 14:32:18 +01:00
print_barre_liste ( $langs -> trans ( " ActionsOnProject " ), 0 , $_SERVER [ " PHP_SELF " ], '' , $sortfield , $sortorder , '' , 0 , - 1 , '' , 0 , $morehtmlcenter , '' , 0 , 1 , 1 );
2017-10-04 12:58:13 +02:00
2020-10-31 14:32:18 +01:00
// List of all actions
$filters = array ();
$filters [ 'search_agenda_label' ] = $search_agenda_label ;
show_actions_done ( $conf , $langs , $db , $object , null , 0 , $actioncode , '' , $filters , $sortfield , $sortorder );
2016-10-17 17:52:58 +02:00
}
2018-08-15 12:48:13 +02:00
// End of page
2016-07-09 15:30:42 +02:00
llxFooter ();
$db -> close ();