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-04-10 10:59:32 +02:00
$action = GETPOST ( 'action' , 'alpha' );
2019-11-02 00:17:08 +01:00
$cancel = GETPOST ( 'cancel' , 'aZ09' );
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2019-01-27 11:55:16 +01:00
if ( GETPOST ( 'actioncode' , 'array' ))
2018-10-03 21:13:02 +02:00
{
2020-04-10 10:59:32 +02:00
$actioncode = GETPOST ( 'actioncode' , 'array' , 3 );
if ( ! count ( $actioncode )) $actioncode = '0' ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-10 10:59:32 +02: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 ;
2019-01-27 11:55:16 +01:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2018-10-03 21:13:02 +02:00
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2020-04-10 10:59:32 +02: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
$object = new DolResource ( $db );
$object -> fetch ( $id , $ref );
// Initialize technical objects
//$object=new MyObject($db);
$extrafields = new ExtraFields ( $db );
2018-10-03 21:13:02 +02:00
$hookmanager -> initHooks ( array ( 'agendaresource' ));
2019-11-02 00:17:08 +01:00
// Security check
2020-04-10 10:59:32 +02: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
2018-10-03 21:13:02 +02:00
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
if ( empty ( $reshook ))
{
// Cancel
2020-04-10 10:59:32 +02:00
if ( GETPOST ( 'cancel' , 'alpha' ) && ! empty ( $backtopage ))
2018-10-03 21:13:02 +02:00
{
header ( " Location: " . $backtopage );
exit ;
}
// Purge search criteria
2019-01-27 11:55:16 +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
2018-10-03 21:13:02 +02:00
{
2020-04-10 10:59:32 +02:00
$actioncode = '' ;
$search_agenda_label = '' ;
2018-10-03 21:13:02 +02:00
}
}
/*
* View
*/
$contactstatic = new Contact ( $db );
$form = new Form ( $db );
2019-11-02 00:17:08 +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 " );
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
2020-04-10 10:59:32 +02:00
if ( ! empty ( $conf -> notification -> enabled )) $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 " );
2018-10-03 21:13:02 +02:00
dol_fiche_head ( $head , 'agenda' , $titre , - 1 , $picto );
$linkback = '<a href="' . DOL_URL_ROOT . '/resource/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2020-04-10 10:59:32 +02:00
$morehtmlref = '<div class="refidno">' ;
$morehtmlref .= '</div>' ;
2019-11-02 00:17:08 +01:00
2018-10-03 21:13:02 +02:00
$shownav = 1 ;
2020-04-10 10:59:32 +02:00
if ( $user -> socid && ! in_array ( 'resource' , explode ( ',' , $conf -> global -> MAIN_MODULES_FOR_EXTERNAL ))) $shownav = 0 ;
2018-10-03 21:13:02 +02:00
2019-11-02 00:17:08 +01:00
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
2018-10-03 21:13:02 +02:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
print '</div>' ;
dol_fiche_end ();
2020-04-10 10:59:32 +02:00
if ( ! empty ( $conf -> agenda -> enabled ) && ( ! empty ( $user -> rights -> agenda -> myactions -> read ) || ! empty ( $user -> rights -> agenda -> allactions -> read )))
2018-10-03 21:13:02 +02:00
{
2020-04-10 10:59:32 +02:00
$param = '&id=' . $object -> id . '&socid=' . $socid ;
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 );
// List of all actions
2020-04-10 10:59:32 +02:00
$filters = array ();
$filters [ 'search_agenda_label' ] = $search_agenda_label ;
2018-10-03 21:13:02 +02:00
// TODO Replace this with same code than into list.php
2019-01-27 11:55:16 +01:00
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 ();