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 >
2016-07-09 15:30:42 +02:00
* Copyright ( C ) 2005 - 2009 Regis Houssin < regis . houssin @ capnetworks . com >
*
* 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
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
/**
* \file htdocs / projet / info . php
* \ingroup commande
* \brief Page with info on project
*/
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 " );
2016-11-08 12:58:07 +01:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
$socid = GETPOST ( 'socid' , 'int' );
$action = GETPOST ( 'action' , 'alpha' );
2017-06-08 14:55:12 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2017-01-02 12:39:12 +01:00
$sortfield = GETPOST ( " sortfield " , " alpha " );
$sortorder = GETPOST ( " sortorder " );
$page = GETPOST ( " page " );
$page = is_numeric ( $page ) ? $page : 0 ;
$page = $page == - 1 ? 0 : $page ;
if ( ! $sortfield ) $sortfield = " a.datep,a.id " ;
2017-01-02 12:41:33 +01:00
if ( ! $sortorder ) $sortorder = " DESC " ;
2017-01-02 12:39:12 +01:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2016-10-17 17:52:58 +02:00
if ( GETPOST ( 'actioncode' , 'array' ))
{
$actioncode = GETPOST ( 'actioncode' , 'array' , 3 );
if ( ! count ( $actioncode )) $actioncode = '0' ;
}
else
{
2017-02-01 15:47:08 +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
}
2016-10-18 00:02:18 +02:00
$search_agenda_label = GETPOST ( 'search_agenda_label' );
2016-10-17 17:52:58 +02:00
2017-01-13 16:49:18 +01:00
2016-07-09 15:30:42 +02:00
// Security check
$id = GETPOST ( " id " , 'int' );
$socid = 0 ;
2017-01-12 15:23:30 +01:00
//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
2016-07-09 15:30:42 +02:00
$result = restrictedArea ( $user , 'projet' , $id , '' );
2016-10-17 17:52:58 +02:00
if ( ! $user -> rights -> projet -> lire ) accessforbidden ();
/*
* Actions
*/
$parameters = array ( 'id' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
// Purge search criteria
2017-07-13 00:35:10 +02: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
2016-10-17 17:52:58 +02:00
{
$actioncode = '' ;
2016-10-18 00:02:18 +02:00
$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
2016-11-08 12:58:07 +01:00
if ( $id > 0 || ! empty ( $ref ))
{
$object -> fetch ( $id , $ref );
$object -> fetch_thirdparty ();
2018-05-22 16:07:32 +02:00
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_PROJECT ) && method_exists ( $object , 'fetchComments' ) && empty ( $object -> comments )) $object -> fetchComments ();
2016-11-08 12:58:07 +01:00
$object -> info ( $object -> id );
}
2016-07-09 15:30:42 +02:00
2016-12-26 18:21:18 +01:00
$title = $langs -> trans ( " Project " ) . ' - ' . $object -> ref . ' ' . $object -> name ;
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 " );
$help_url = " EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos " ;
llxHeader ( " " , $title , $help_url );
2016-10-17 17:52:58 +02:00
$head = project_prepare_head ( $object );
2016-07-09 15:30:42 +02:00
2017-03-23 19:26:28 +01:00
dol_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
$morehtmlref = '<div class="refidno">' ;
// Title
$morehtmlref .= $object -> title ;
// Thirdparty
if ( $object -> thirdparty -> id > 0 )
{
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $object -> thirdparty -> getNomUrl ( 1 , 'project' );
}
$morehtmlref .= '</div>' ;
// Define a complementary filter for search of next/prev ref.
if ( ! $user -> rights -> projet -> all -> lire )
{
$objectsListId = $object -> getProjectsAuthorizedForUser ( $user , 0 , 0 );
$object -> next_prev_filter = " rowid in ( " . ( count ( $objectsListId ) ? join ( ',' , array_keys ( $objectsListId )) : '0' ) . " ) " ;
}
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
2016-10-17 17:52:58 +02:00
dol_fiche_end ();
// Actions buttons
$out = '' ;
$permok = $user -> rights -> agenda -> myactions -> create ;
if ( $permok )
{
$out .= '&projectid=' . $object -> id ;
}
2017-10-04 12:58:13 +02:00
//print '<div class="tabsAction">';
$morehtmlcenter = '' ;
2016-10-17 17:52:58 +02:00
if ( ! empty ( $conf -> agenda -> enabled ))
{
if ( ! empty ( $user -> rights -> agenda -> myactions -> create ) || ! empty ( $user -> rights -> agenda -> allactions -> create ))
{
2018-06-13 22:57:41 +02:00
$morehtmlcenter .= '<a class="butActionNew" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create' . $out . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id ) . '"><span class="valignmiddle">' . $langs -> trans ( " AddAction " ) . '</span>' ;
$morehtmlcenter .= '<span class="fa fa-plus-circle valignmiddle"></span>' ;
$morehtmlcenter .= '</a>' ;
2016-10-17 17:52:58 +02:00
}
else
{
2017-10-04 12:58:13 +02:00
$morehtmlcenter .= '<a class="butActionRefused" href="#">' . $langs -> trans ( " AddAction " ) . '</a>' ;
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
if ( ! empty ( $object -> id ))
{
2017-10-04 12:58:13 +02:00
print '<br>' ;
$param = '&id=' . $object -> id ;
2016-12-26 18:21:18 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
2017-12-04 20:17:07 +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
2016-10-17 17:52:58 +02:00
// List of all actions
2016-10-18 00:02:18 +02:00
$filters = array ();
$filters [ 'search_agenda_label' ] = $search_agenda_label ;
2017-01-02 12:39:12 +01:00
show_actions_done ( $conf , $langs , $db , $object , null , 0 , $actioncode , '' , $filters , $sortfield , $sortorder );
2016-10-17 17:52:58 +02:00
}
2016-07-09 15:30:42 +02:00
llxFooter ();
$db -> close ();