2018-10-03 21:13:02 +02:00
< ? php
/* Copyright ( C ) 2001 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2005 Brice Davoleau < brice . davoleau @ gmail . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2018-10-03 21:13:02 +02:00
* Copyright ( C ) 2006 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2007 Patrick Raguin < patrick . raguin @ gmail . com >
* Copyright ( C ) 2010 Juanjo Menent < jmenent @ 2 byte . es >
* Copyright ( C ) 2015 Marcos García < marcosgdf @ gmail . com >
* Copyright ( C ) 2018 Florain Henry < florian . henry @ open - concept . pro
*
* 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 />.
2018-10-03 21:13:02 +02:00
*/
/**
2018-10-04 18:01:20 +02:00
* \file htdocs / resource / agenda . php
* \ingroup resource
* \brief Page of resource events
2018-10-03 21:13:02 +02:00
*/
require '../main.inc.php' ;
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/resource.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/resource/class/dolresource.class.php' ;
// Load translation files required by the page
$langs -> load ( " companies " );
2019-11-02 00:17:08 +01:00
// Get parameters
2020-04-10 10:59:32 +02:00
$id = GETPOST ( 'id' , 'int' );
2019-11-02 00:17:08 +01:00
$ref = GETPOST ( 'ref' , 'alpha' );
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-11-02 00:17:08 +01:00
$cancel = GETPOST ( 'cancel' , 'aZ09' );
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2021-02-26 20:53:03 +01:00
if ( GETPOST ( 'actioncode' , 'array' )) {
2020-10-31 14:32:18 +01:00
$actioncode = GETPOST ( 'actioncode' , 'array' , 3 );
2021-02-26 20:53:03 +01:00
if ( ! count ( $actioncode )) {
$actioncode = '0' ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +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 ));
2018-10-03 21:13:02 +02:00
}
2020-04-10 10:59:32 +02:00
$search_agenda_label = GETPOST ( 'search_agenda_label' );
2018-10-03 21:13:02 +02:00
2020-04-10 10:59:32 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2022-01-13 11:09:37 +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' );
2021-02-26 20:53:03 +01:00
if ( empty ( $page ) || $page == - 1 ) {
$page = 0 ;
} // If $page is not defined, or '' or -1
2018-10-03 21:13:02 +02:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2021-02-26 20:53:03 +01:00
if ( ! $sortfield ) {
$sortfield = 'a.datep,a.id' ;
}
if ( ! $sortorder ) {
$sortorder = 'DESC,DESC' ;
}
2018-10-03 21:13:02 +02:00
2019-11-02 00:17:08 +01:00
// Initialize technical objects
//$object=new MyObject($db);
$extrafields = new ExtraFields ( $db );
2018-10-03 21:13:02 +02:00
$hookmanager -> initHooks ( array ( 'agendaresource' ));
2021-10-25 15:32:10 +02:00
$object = new DolResource ( $db );
// Load object
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php' ; // Must be include, not include_once.
$result = restrictedArea ( $user , 'resource' , $object -> id , 'resource' );
2019-11-02 00:17:08 +01:00
// Security check
2021-02-26 20:53:03 +01:00
if ( ! $user -> rights -> resource -> read ) {
2019-11-02 00:17:08 +01:00
accessforbidden ();
}
2018-10-03 21:13:02 +02:00
/*
* Actions
*/
2020-04-10 10:59:32 +02: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 20:53:03 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2018-10-03 21:13:02 +02:00
2021-02-26 20:53:03 +01:00
if ( empty ( $reshook )) {
2020-10-31 14:32:18 +01:00
// Cancel
2021-02-26 20:53:03 +01:00
if ( GETPOST ( 'cancel' , 'alpha' ) && ! empty ( $backtopage )) {
2020-10-31 14:32:18 +01:00
header ( " Location: " . $backtopage );
exit ;
}
// Purge search criteria
2021-02-26 20:53:03 +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-10-31 14:32:18 +01:00
$actioncode = '' ;
$search_agenda_label = '' ;
}
2018-10-03 21:13:02 +02:00
}
/*
* View
*/
$contactstatic = new Contact ( $db );
$form = new Form ( $db );
2021-02-26 20:53:03 +01:00
if ( $object -> id > 0 ) {
2018-10-03 21:13:02 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
$langs -> load ( " companies " );
2018-10-04 18:01:20 +02:00
$picto = 'resource' ;
2018-10-03 21:13:02 +02:00
2020-04-10 10:59:32 +02:00
$title = $langs -> trans ( " Agenda " );
2021-02-26 20:53:03 +01:00
if ( ! empty ( $conf -> global -> MAIN_HTML_TITLE ) && preg_match ( '/productnameonly/' , $conf -> global -> MAIN_HTML_TITLE ) && $object -> name ) {
$title = $object -> ref . " - " . $title ;
}
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $title );
2018-10-03 21:13:02 +02:00
2022-08-29 11:07:54 +02:00
if ( isModEnabled ( 'notification' )) {
2021-02-26 20:53:03 +01:00
$langs -> load ( " mails " );
}
2018-10-03 21:13:02 +02:00
$type = $langs -> trans ( 'ResourceSingular' );
$head = resource_prepare_head ( $object );
2020-04-10 10:59:32 +02:00
$titre = $langs -> trans ( " ResourceSingular " );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'agenda' , $titre , - 1 , $picto );
2018-10-03 21:13:02 +02:00
2020-10-31 14:32:18 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/resource/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2018-10-03 21:13:02 +02:00
2020-10-31 14:32:18 +01:00
$morehtmlref = '<div class="refidno">' ;
$morehtmlref .= '</div>' ;
2019-11-02 00:17:08 +01:00
2020-10-31 14:32:18 +01:00
$shownav = 1 ;
2021-02-26 20:53:03 +01:00
if ( $user -> socid && ! in_array ( 'resource' , explode ( ',' , $conf -> global -> MAIN_MODULES_FOR_EXTERNAL ))) {
$shownav = 0 ;
}
2018-10-03 21:13:02 +02:00
2020-10-31 14:32:18 +01:00
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
2018-10-03 21:13:02 +02:00
2020-10-31 14:32:18 +01:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2018-10-03 21:13:02 +02:00
print '</div>' ;
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2018-10-03 21:13:02 +02:00
2022-06-09 22:16:48 +02:00
if ( isModEnabled ( 'agenda' ) && ( ! empty ( $user -> rights -> agenda -> myactions -> read ) || ! empty ( $user -> rights -> agenda -> allactions -> read ))) {
2020-10-31 14:32:18 +01:00
$param = '&id=' . $object -> id . '&socid=' . $socid ;
2021-02-26 20:53:03 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . urlencode ( $limit );
}
2018-10-03 21:13:02 +02:00
print_barre_liste ( $langs -> trans ( " ActionsOnResource " ), 0 , $_SERVER [ " PHP_SELF " ], '' , $sortfield , $sortorder , '' , 0 , - 1 , '' , 0 , $morehtmlcenter , '' , 0 , 1 , 1 );
2020-10-31 14:32:18 +01:00
// List of all actions
2020-04-10 10:59:32 +02:00
$filters = array ();
2020-10-31 14:32:18 +01:00
$filters [ 'search_agenda_label' ] = $search_agenda_label ;
2018-10-03 21:13:02 +02:00
2020-10-31 14:32:18 +01:00
// TODO Replace this with same code than into list.php
show_actions_done ( $conf , $langs , $db , $object , null , 0 , $actioncode , '' , $filters , $sortfield , $sortorder );
}
2018-10-03 21:13:02 +02:00
}
// End of page
llxFooter ();
$db -> close ();