2014-07-11 13:55:15 +02:00
< ? php
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2003 Eric Seigne < erics @ rycks . com >
* Copyright ( C ) 2004 - 2014 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2014-07-11 13:55:15 +02:00
* Copyright ( C ) 2011 Juanjo Menent < jmenent @ 2 byte . es >
2014-09-05 13:48:55 +02:00
* Copyright ( C ) 2014 Cedric GROSS < c . gross @ kreiz - it . fr >
2019-02-14 21:45:40 +01:00
* Copyright ( C ) 2018 - 2019 Frédéric France < frederic . france @ netlogic . fr >
2014-07-11 13:55:15 +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 />.
2014-07-11 13:55:15 +02:00
*/
/**
* \file htdocs / comm / action / peruser . php
* \ingroup agenda
* \brief Tab of calendar events per user
*/
require '../../main.inc.php' ;
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
2014-09-05 13:48:55 +02:00
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ;
2017-07-29 04:07:46 +02:00
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
2014-09-05 13:48:55 +02:00
require_once DOL_DOCUMENT_ROOT . '/user/class/usergroup.class.php' ;
2014-07-11 13:55:15 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/agenda.lib.php' ;
2017-07-29 04:07:46 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2014-09-05 13:48:55 +02:00
2014-07-11 13:55:15 +02:00
2021-02-23 18:59:19 +01:00
if ( ! isset ( $conf -> global -> AGENDA_MAX_EVENTS_DAY_VIEW )) {
$conf -> global -> AGENDA_MAX_EVENTS_DAY_VIEW = 3 ;
}
2014-07-11 13:55:15 +02:00
2021-12-11 13:17:31 +01:00
$action = GETPOST ( 'action' , 'aZ09' );
2022-05-19 10:31:01 +02:00
$disabledefaultvalues = GETPOST ( 'disabledefaultvalues' , 'int' );
2020-09-11 14:35:52 +02:00
$filter = GETPOST ( " search_filter " , 'alpha' , 3 ) ? GETPOST ( " search_filter " , 'alpha' , 3 ) : GETPOST ( " filter " , 'alpha' , 3 );
$filtert = GETPOST ( " search_filtert " , " int " , 3 ) ? GETPOST ( " search_filtert " , " int " , 3 ) : GETPOST ( " filtert " , " int " , 3 );
$usergroup = GETPOST ( " search_usergroup " , " int " , 3 ) ? GETPOST ( " search_usergroup " , " int " , 3 ) : GETPOST ( " usergroup " , " int " , 3 );
2014-09-05 13:48:55 +02:00
//if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id;
//$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
$showbirthday = 0 ;
2014-07-11 13:55:15 +02:00
2014-10-09 17:05:57 +02:00
// If not choice done on calendar owner, we filter on user.
2020-02-06 21:16:48 +01:00
/* if ( empty ( $filtert ) && empty ( $conf -> global -> AGENDA_ALL_CALENDARS ))
2014-10-09 17:05:57 +02:00
{
2019-12-18 15:20:36 +01:00
$filtert = $user -> id ;
2020-02-06 21:16:48 +01:00
} */
2014-07-11 13:55:15 +02:00
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-23 18:59:19 +01:00
if ( empty ( $page ) || $page == - 1 ) {
$page = 0 ;
} // If $page is not defined, or '' or -1
2019-12-18 15:20:36 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2014-07-11 13:55:15 +02:00
$offset = $limit * $page ;
2021-02-23 18:59:19 +01:00
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
if ( ! $sortfield ) {
$sortfield = " a.datec " ;
}
2014-07-11 13:55:15 +02:00
2019-12-18 15:20:36 +01:00
$socid = GETPOST ( " search_socid " , " int " ) ? GETPOST ( " search_socid " , " int " ) : GETPOST ( " socid " , " int " );
2021-02-23 18:59:19 +01:00
if ( $user -> socid ) {
$socid = $user -> socid ;
}
if ( $socid < 0 ) {
$socid = '' ;
}
2014-07-11 13:55:15 +02:00
2019-12-18 15:20:36 +01:00
$canedit = 1 ;
2021-10-23 07:04:13 +02:00
if ( empty ( $user -> rights -> agenda -> myactions -> read )) {
2021-02-23 18:59:19 +01:00
accessforbidden ();
}
2021-10-23 07:04:13 +02:00
if ( empty ( $user -> rights -> agenda -> allactions -> read )) {
2021-02-23 18:59:19 +01:00
$canedit = 0 ;
}
2021-10-23 07:04:13 +02:00
if ( empty ( $user -> rights -> agenda -> allactions -> read ) || $filter == 'mine' ) { // If no permission to see all, we show only affected to me
2020-10-31 14:32:18 +01:00
$filtert = $user -> id ;
2014-07-11 13:55:15 +02:00
}
2021-12-11 13:17:31 +01:00
$mode = 'show_peruser' ;
2019-12-18 15:20:36 +01:00
$resourceid = GETPOST ( " search_resourceid " , " int " ) ? GETPOST ( " search_resourceid " , " int " ) : GETPOST ( " resourceid " , " int " );
$year = GETPOST ( " year " , " int " ) ? GETPOST ( " year " , " int " ) : date ( " Y " );
$month = GETPOST ( " month " , " int " ) ? GETPOST ( " month " , " int " ) : date ( " m " );
$week = GETPOST ( " week " , " int " ) ? GETPOST ( " week " , " int " ) : date ( " W " );
$day = GETPOST ( " day " , " int " ) ? GETPOST ( " day " , " int " ) : date ( " d " );
2022-04-30 20:41:18 +02:00
$pid = GETPOSTISSET ( " search_projectid " ) ? GETPOST ( " search_projectid " , " int " , 3 ) : GETPOST ( " projectid " , " int " , 3 );
2022-07-25 13:18:03 +02:00
$status = GETPOSTISSET ( " search_status " ) ? GETPOST ( " search_status " , 'aZ09' ) : GETPOST ( " status " , 'aZ09' ); // status may be 0, 50, 100, 'todo', 'na' or -1
2022-04-30 20:41:18 +02:00
$type = GETPOSTISSET ( " search_type " ) ? GETPOST ( " search_type " , 'alpha' ) : GETPOST ( " type " , 'alpha' );
2019-12-18 15:20:36 +01:00
$maxprint = (( GETPOST ( " maxprint " , 'int' ) != '' ) ? GETPOST ( " maxprint " , 'int' ) : $conf -> global -> AGENDA_MAX_EVENTS_DAY_VIEW );
$optioncss = GETPOST ( 'optioncss' , 'aZ' ); // Option for the css output (always '' except when 'print')
2016-01-14 14:15:14 +01:00
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
2021-03-23 03:44:50 +01:00
if ( GETPOST ( 'search_actioncode' , 'array:aZ09' )) {
$actioncode = GETPOST ( 'search_actioncode' , 'array:aZ09' , 3 );
2021-02-23 18:59:19 +01:00
if ( ! count ( $actioncode )) {
$actioncode = '0' ;
}
2020-05-21 15:05:19 +02:00
} else {
2022-05-19 10:31:01 +02:00
$actioncode = GETPOST ( " search_actioncode " , " alpha " , 3 ) ? GETPOST ( " search_actioncode " , " alpha " , 3 ) : ( GETPOST ( " search_actioncode " , " alpha " ) == '0' ? '0' : (( empty ( $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE ) || $disabledefaultvalues ) ? '' : $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE ));
2021-02-23 18:59:19 +01:00
}
2017-07-29 04:07:46 +02:00
2019-12-18 15:20:36 +01:00
$dateselect = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dateselectmonth' , 'int' ), GETPOST ( 'dateselectday' , 'int' ), GETPOST ( 'dateselectyear' , 'int' ));
2021-02-23 18:59:19 +01:00
if ( $dateselect > 0 ) {
2019-12-18 15:20:36 +01:00
$day = GETPOST ( 'dateselectday' , 'int' );
$month = GETPOST ( 'dateselectmonth' , 'int' );
$year = GETPOST ( 'dateselectyear' , 'int' );
2014-09-06 17:55:33 +02:00
}
2019-12-18 15:20:36 +01:00
$tmp = empty ( $conf -> global -> MAIN_DEFAULT_WORKING_HOURS ) ? '9-18' : $conf -> global -> MAIN_DEFAULT_WORKING_HOURS ;
$tmp = str_replace ( ' ' , '' , $tmp ); // FIX 7533
$tmparray = explode ( '-' , $tmp );
2020-09-25 10:27:30 +02:00
$begin_h = GETPOST ( 'begin_h' , 'int' ) != '' ? GETPOST ( 'begin_h' , 'int' ) : ( $tmparray [ 0 ] != '' ? $tmparray [ 0 ] : 9 );
$end_h = GETPOST ( 'end_h' , 'int' ) ? GETPOST ( 'end_h' , 'int' ) : ( $tmparray [ 1 ] != '' ? $tmparray [ 1 ] : 18 );
2021-02-23 18:59:19 +01:00
if ( $begin_h < 0 || $begin_h > 23 ) {
$begin_h = 9 ;
}
if ( $end_h < 1 || $end_h > 24 ) {
$end_h = 18 ;
}
if ( $end_h <= $begin_h ) {
$end_h = $begin_h + 1 ;
}
2014-09-05 13:48:55 +02:00
2019-12-18 15:20:36 +01:00
$tmp = empty ( $conf -> global -> MAIN_DEFAULT_WORKING_DAYS ) ? '1-5' : $conf -> global -> MAIN_DEFAULT_WORKING_DAYS ;
$tmp = str_replace ( ' ' , '' , $tmp ); // FIX 7533
$tmparray = explode ( '-' , $tmp );
$begin_d = GETPOST ( 'begin_d' , 'int' ) ? GETPOST ( 'begin_d' , 'int' ) : ( $tmparray [ 0 ] != '' ? $tmparray [ 0 ] : 1 );
$end_d = GETPOST ( 'end_d' , 'int' ) ? GETPOST ( 'end_d' , 'int' ) : ( $tmparray [ 1 ] != '' ? $tmparray [ 1 ] : 5 );
2021-02-23 18:59:19 +01:00
if ( $begin_d < 1 || $begin_d > 7 ) {
$begin_d = 1 ;
}
if ( $end_d < 1 || $end_d > 7 ) {
$end_d = 7 ;
}
if ( $end_d < $begin_d ) {
$end_d = $begin_d + 1 ;
}
2014-09-05 13:48:55 +02:00
2022-06-07 18:13:21 +02:00
if ( $status == '' && ! GETPOSTISSET ( 'search_status' )) {
2022-05-19 10:31:01 +02:00
$status = (( empty ( $conf -> global -> AGENDA_DEFAULT_FILTER_STATUS ) || $disabledefaultvalues ) ? '' : $conf -> global -> AGENDA_DEFAULT_FILTER_STATUS );
2021-02-23 18:59:19 +01:00
}
2022-06-07 18:13:21 +02:00
2021-12-11 13:17:31 +01:00
if ( empty ( $mode ) && ! GETPOSTISSET ( 'mode' )) {
$mode = ( empty ( $conf -> global -> AGENDA_DEFAULT_VIEW ) ? 'show_month' : $conf -> global -> AGENDA_DEFAULT_VIEW );
2021-02-23 18:59:19 +01:00
}
2014-07-11 13:55:15 +02:00
2021-12-11 13:17:31 +01:00
if ( GETPOST ( 'viewcal' , 'alpha' ) && $mode != 'show_day' && $mode != 'show_week' && $mode != 'show_peruser' ) {
$mode = 'show_month' ; $day = '' ;
} // View by month
if ( GETPOST ( 'viewweek' , 'alpha' ) || $mode == 'show_week' ) {
$mode = 'show_week' ; $week = ( $week ? $week : date ( " W " )); $day = ( $day ? $day : date ( " d " ));
} // View by week
if ( GETPOST ( 'viewday' , 'alpha' ) || $mode == 'show_day' ) {
$mode = 'show_day' ; $day = ( $day ? $day : date ( " d " ));
} // View by day
2014-07-11 13:55:15 +02:00
2022-04-30 20:41:18 +02:00
$object = new ActionComm ( $db );
2018-05-26 19:03:41 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'users' , 'agenda' , 'other' , 'commercial' ));
2014-07-11 13:55: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
2014-07-11 13:55:15 +02:00
$hookmanager -> initHooks ( array ( 'agenda' ));
2021-03-29 22:43:39 +02:00
$result = restrictedArea ( $user , 'agenda' , 0 , '' , 'myactions' );
if ( $user -> socid && $socid ) {
$result = restrictedArea ( $user , 'societe' , $socid );
}
2022-04-30 20:41:18 +02:00
$search_status = $status ;
2014-07-11 13:55:15 +02:00
/*
* Actions
*/
2021-12-11 13:17:31 +01:00
/*
if ( $action == 'delete_action' && $user -> rights -> agenda -> delete ) {
2020-10-31 14:32:18 +01:00
$event = new ActionComm ( $db );
$event -> fetch ( $actionid );
$event -> fetch_optionals ();
$event -> fetch_userassigned ();
$event -> oldcopy = clone $event ;
2019-12-10 21:11:52 +01:00
2020-10-31 14:32:18 +01:00
$result = $event -> delete ();
2014-09-05 13:48:55 +02:00
}
2021-12-11 13:17:31 +01:00
*/
2014-07-11 13:55:15 +02:00
/*
* View
*/
2020-09-11 14:35:52 +02:00
2019-12-10 21:11:52 +01:00
$parameters = array (
'socid' => $socid ,
'status' => $status ,
'year' => $year ,
'month' => $month ,
'day' => $day ,
'type' => $type ,
'maxprint' => $maxprint ,
'filter' => $filter ,
'filtert' => $filtert ,
'showbirthday' => $showbirthday ,
'canedit' => $canedit ,
'optioncss' => $optioncss ,
'actioncode' => $actioncode ,
'pid' => $pid ,
'resourceid' => $resourceid ,
'usergroup' => $usergroup ,
);
$reshook = $hookmanager -> executeHooks ( 'beforeAgendaPerUser' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-23 18:59:19 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2014-07-11 13:55:15 +02:00
2019-11-13 19:37:08 +01:00
$form = new Form ( $db );
$companystatic = new Societe ( $db );
2014-07-11 13:55:15 +02:00
2019-11-13 19:37:08 +01:00
$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda' ;
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $langs -> trans ( " Agenda " ), $help_url );
2017-07-29 01:59:26 +02:00
2019-11-13 19:37:08 +01:00
$now = dol_now ();
$nowarray = dol_getdate ( $now );
$nowyear = $nowarray [ 'year' ];
$nowmonth = $nowarray [ 'mon' ];
$nowday = $nowarray [ 'mday' ];
2014-07-11 13:55:15 +02:00
2014-09-05 13:48:55 +02:00
// Define list of all external calendars (global setup)
2019-11-13 19:37:08 +01:00
$listofextcals = array ();
2014-07-11 13:55:15 +02:00
2014-09-05 13:48:55 +02:00
$prev = dol_get_first_day_week ( $day , $month , $year );
$first_day = $prev [ 'first_day' ];
$first_month = $prev [ 'first_month' ];
$first_year = $prev [ 'first_year' ];
2014-07-11 13:55:15 +02:00
2014-09-05 13:48:55 +02:00
$week = $prev [ 'week' ];
2014-07-11 13:55:15 +02:00
2014-09-05 13:48:55 +02:00
$day = ( int ) $day ;
$next = dol_get_next_week ( $day , $week , $month , $year );
$next_year = $next [ 'year' ];
$next_month = $next [ 'month' ];
$next_day = $next [ 'day' ];
2014-07-11 13:55:15 +02:00
2019-01-27 11:55:16 +01:00
$max_day_in_month = date ( " t " , dol_mktime ( 0 , 0 , 0 , $month , 1 , $year ));
2014-09-05 13:48:55 +02:00
$tmpday = $first_day ;
2014-07-11 13:55:15 +02:00
//print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day;
//print 'xx'.$next_year.'-'.$next_month.'-'.$next_day;
2019-11-13 19:37:08 +01:00
$title = $langs -> trans ( " DoneAndToDoActions " );
2021-02-23 18:59:19 +01:00
if ( $status == 'done' ) {
$title = $langs -> trans ( " DoneActions " );
}
if ( $status == 'todo' ) {
$title = $langs -> trans ( " ToDoActions " );
}
2014-07-11 13:55:15 +02:00
2019-11-13 19:37:08 +01:00
$param = '' ;
2020-11-30 14:47:07 +01:00
if ( $actioncode || GETPOSTISSET ( 'search_actioncode' )) {
2019-11-13 19:37:08 +01:00
if ( is_array ( $actioncode )) {
2021-02-23 18:59:19 +01:00
foreach ( $actioncode as $str_action ) {
$param .= " &search_actioncode[]= " . urlencode ( $str_action );
}
} else {
$param .= " &search_actioncode= " . urlencode ( $actioncode );
}
}
if ( $resourceid > 0 ) {
$param .= " &search_resourceid= " . urlencode ( $resourceid );
}
2022-04-30 20:41:18 +02:00
if ( $status || GETPOSTISSET ( 'status' ) || GETPOSTISSET ( 'search_status' )) {
2021-02-23 18:59:19 +01:00
$param .= " &search_status= " . urlencode ( $status );
}
if ( $filter ) {
$param .= " &search_filter= " . urlencode ( $filter );
}
if ( $filtert ) {
$param .= " &search_filtert= " . urlencode ( $filtert );
}
if ( $usergroup > 0 ) {
$param .= " &search_usergroup= " . urlencode ( $usergroup );
}
if ( $socid > 0 ) {
$param .= " &search_socid= " . urlencode ( $socid );
}
if ( $showbirthday ) {
$param .= " &search_showbirthday=1 " ;
}
if ( $pid ) {
$param .= " &search_projectid= " . urlencode ( $pid );
}
if ( $type ) {
$param .= " &search_type= " . urlencode ( $type );
}
2021-12-11 13:17:31 +01:00
if ( $mode != 'show_peruser' ) {
$param .= '&mode=' . urlencode ( $mode );
2021-02-23 18:59:19 +01:00
}
if ( $begin_h != '' ) {
$param .= '&begin_h=' . urlencode ( $begin_h );
}
if ( $end_h != '' ) {
$param .= '&end_h=' . urlencode ( $end_h );
}
if ( $begin_d != '' ) {
$param .= '&begin_d=' . urlencode ( $begin_d );
}
if ( $end_d != '' ) {
$param .= '&end_d=' . urlencode ( $end_d );
}
2019-11-13 19:37:08 +01:00
$param .= " &maxprint= " . urlencode ( $maxprint );
2014-07-11 13:55:15 +02:00
2021-02-18 16:35:38 +01:00
$paramnoactionodate = $param ;
2017-11-25 00:12:45 +01:00
2014-09-05 21:12:01 +02:00
$prev = dol_get_first_day_week ( $day , $month , $year );
2015-02-03 11:25:51 +01:00
//print "day=".$day." month=".$month." year=".$year;
//var_dump($prev); exit;
2014-09-05 21:12:01 +02:00
$prev_year = $prev [ 'prev_year' ];
$prev_month = $prev [ 'prev_month' ];
$prev_day = $prev [ 'prev_day' ];
$first_day = $prev [ 'first_day' ];
2019-11-13 19:37:08 +01:00
$first_month = $prev [ 'first_month' ];
2014-09-05 21:12:01 +02:00
$first_year = $prev [ 'first_year' ];
$week = $prev [ 'week' ];
$day = ( int ) $day ;
$next = dol_get_next_week ( $first_day , $week , $first_month , $first_year );
$next_year = $next [ 'year' ];
$next_month = $next [ 'month' ];
$next_day = $next [ 'day' ];
2014-09-28 15:33:13 +02:00
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
2021-01-03 18:42:45 +01:00
$firstdaytoshow = dol_mktime ( 0 , 0 , 0 , $first_month , $first_day , $first_year , 'gmt' );
2018-03-10 16:46:57 +01:00
2019-11-13 19:37:08 +01:00
$nb_weeks_to_show = ( ! empty ( $conf -> global -> AGENDA_NB_WEEKS_IN_VIEW_PER_USER )) ? (( int ) $conf -> global -> AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7 ) : 7 ;
$lastdaytoshow = dol_time_plus_duree ( $firstdaytoshow , $nb_weeks_to_show , 'd' );
2015-02-03 11:25:51 +01:00
//print $firstday.'-'.$first_month.'-'.$first_year;
2014-09-28 15:33:13 +02:00
//print dol_print_date($firstdaytoshow,'dayhour');
//print dol_print_date($lastdaytoshow,'dayhour');
2014-09-05 21:12:01 +02:00
2021-01-03 18:42:45 +01:00
$max_day_in_month = date ( " t " , dol_mktime ( 0 , 0 , 0 , $month , 1 , $year , 'gmt' ));
2014-09-05 21:12:01 +02:00
$tmpday = $first_day ;
2019-11-13 19:37:08 +01:00
$picto = 'calendarweek' ;
2014-09-05 21:12:01 +02:00
2019-11-13 19:37:08 +01:00
$nav = " <a href= \" ?year= " . $prev_year . " &month= " . $prev_month . " &day= " . $prev_day . $param . " \" ><i class= \" fa fa-chevron-left \" title= \" " . dol_escape_htmltag ( $langs -> trans ( " Previous " )) . " \" ></i></a> \n " ;
$nav .= " <span id= \" month_name \" > " . dol_print_date ( dol_mktime ( 0 , 0 , 0 , $first_month , $first_day , $first_year ), " %Y " ) . " , " . $langs -> trans ( " Week " ) . " " . $week ;
$nav .= " </span> \n " ;
$nav .= " <a href= \" ?year= " . $next_year . " &month= " . $next_month . " &day= " . $next_day . $param . " \" ><i class= \" fa fa-chevron-right \" title= \" " . dol_escape_htmltag ( $langs -> trans ( " Next " )) . " \" ></i></a> \n " ;
2020-10-13 10:05:47 +02:00
if ( empty ( $conf -> dol_optimize_smallscreen )) {
$nav .= " <a href= \" ?year= " . $nowyear . " &month= " . $nowmonth . " &day= " . $nowday . $param . " \" > " . $langs -> trans ( " Today " ) . " </a> " ;
}
2019-11-13 19:37:08 +01:00
$nav .= $form -> selectDate ( $dateselect , 'dateselect' , 0 , 0 , 1 , '' , 1 , 0 );
2020-07-08 18:06:14 +02:00
$nav .= ' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>' ;
2014-07-11 13:55:15 +02:00
// Must be after the nav definition
2019-11-13 19:37:08 +01:00
$param .= '&year=' . urlencode ( $year ) . '&month=' . urlencode ( $month ) . ( $day ? '&day=' . urlencode ( $day ) : '' );
2014-07-11 13:55:15 +02:00
//print 'x'.$param;
2019-11-13 19:37:08 +01:00
$paramnoaction = preg_replace ( '/action=[a-z_]+/' , '' , $param );
2014-07-11 13:55:15 +02:00
$head = calendars_prepare_head ( $paramnoaction );
2017-11-25 00:12:45 +01:00
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="' . $_SERVER [ " PHP_SELF " ] . '">' . " \n " ;
2019-11-13 19:37:08 +01:00
$showextcals = $listofextcals ;
2014-09-05 13:48:55 +02:00
// Legend
2021-02-23 18:59:19 +01:00
if ( $conf -> use_javascript_ajax ) {
2019-11-13 19:37:08 +01:00
$s = '' ;
$s .= '<script type="text/javascript">' . " \n " ;
$s .= 'jQuery(document).ready(function () {' . " \n " ;
$s .= 'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . " \n " ;
$s .= 'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . " \n " ;
$s .= 'jQuery(".family_birthday").toggle();' . " \n " ;
2021-12-11 13:17:31 +01:00
if ( $mode == " show_week " || $mode == " show_month " || empty ( $mode )) {
2020-10-31 14:32:18 +01:00
$s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {' ;
2014-09-05 13:48:55 +02:00
}
2021-02-23 18:59:19 +01:00
$s .= '});' . " \n " ;
2019-11-13 19:37:08 +01:00
$s .= '</script>' . " \n " ;
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
2019-11-13 19:37:08 +01:00
$s .= '<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs -> trans ( " LocalAgenda " ) . ' </div>' ;
2021-02-23 18:59:19 +01:00
if ( is_array ( $showextcals ) && count ( $showextcals ) > 0 ) {
foreach ( $showextcals as $val ) {
2015-03-05 11:46:03 +01:00
$htmlname = md5 ( $val [ 'name' ]);
2019-11-13 19:37:08 +01:00
$s .= '<script type="text/javascript">' . " \n " ;
$s .= 'jQuery(document).ready(function () {' . " \n " ;
$s .= ' jQuery("#check_ext' . $htmlname . '").click(function() {' ;
$s .= ' /* alert("' . $htmlname . '"); */' ;
$s .= ' jQuery(".family_ext' . $htmlname . '").toggle();' ;
$s .= ' });' . " \n " ;
$s .= '});' . " \n " ;
$s .= '</script>' . " \n " ;
$s .= '<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked> ' . $val [ 'name' ] . ' </div>' ;
2014-09-05 13:48:55 +02:00
}
}
2015-07-21 12:19:21 +02:00
//$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' </div>';
// Calendars from hooks
2022-04-30 20:41:18 +02:00
$parameters = array ();
2019-11-13 19:37:08 +01:00
$reshook = $hookmanager -> executeHooks ( 'addCalendarChoice' , $parameters , $object , $action );
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook )) {
2019-11-13 19:37:08 +01:00
$s .= $hookmanager -> resPrint ;
2021-02-23 18:59:19 +01:00
} elseif ( $reshook > 1 ) {
2020-10-31 14:32:18 +01:00
$s = $hookmanager -> resPrint ;
}
2014-09-05 13:48:55 +02:00
}
}
2020-07-08 18:06:14 +02:00
$massactionbutton = '' ;
$viewmode = '' ;
2021-12-11 13:17:31 +01:00
$viewmode .= '<a class="btnTitle reposition" href="' . DOL_URL_ROOT . '/comm/action/list.php?mode=show_list&restore_lastsearch_values=1' . $paramnoactionodate . '">' ;
2020-07-08 18:06:14 +02:00
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
2022-06-07 18:03:58 +02:00
$viewmode .= img_picto ( $langs -> trans ( " List " ), 'object_calendarlist' , 'class="imgforviewmode pictoactionview block"' );
2020-07-08 18:06:14 +02:00
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">' . $langs -> trans ( " ViewList " ) . '</span></a>' ;
2021-12-11 13:17:31 +01:00
$viewmode .= '<a class="btnTitle reposition" href="' . DOL_URL_ROOT . '/comm/action/index.php?mode=show_month&year=' . dol_print_date ( $object -> datep , '%Y' ) . '&month=' . dol_print_date ( $object -> datep , '%m' ) . '&day=' . dol_print_date ( $object -> datep , '%d' ) . $paramnoactionodate . '">' ;
2020-07-08 18:06:14 +02:00
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
2021-05-18 14:00:29 +02:00
$viewmode .= img_picto ( $langs -> trans ( " ViewCal " ), 'object_calendarmonth' , 'class="pictoactionview block"' );
2020-07-08 18:06:14 +02:00
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">' . $langs -> trans ( " ViewCal " ) . '</span></a>' ;
2021-12-11 13:17:31 +01:00
$viewmode .= '<a class="btnTitle reposition" href="' . DOL_URL_ROOT . '/comm/action/index.php?mode=show_week&year=' . dol_print_date ( $object -> datep , '%Y' ) . '&month=' . dol_print_date ( $object -> datep , '%m' ) . '&day=' . dol_print_date ( $object -> datep , '%d' ) . $paramnoactionodate . '">' ;
2020-07-08 18:06:14 +02:00
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto ( $langs -> trans ( " ViewWeek " ), 'object_calendarweek' , 'class="pictoactionview block"' );
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">' . $langs -> trans ( " ViewWeek " ) . '</span></a>' ;
2021-12-11 13:17:31 +01:00
$viewmode .= '<a class="btnTitle reposition" href="' . DOL_URL_ROOT . '/comm/action/index.php?mode=show_day&year=' . dol_print_date ( $object -> datep , '%Y' ) . '&month=' . dol_print_date ( $object -> datep , '%m' ) . '&day=' . dol_print_date ( $object -> datep , '%d' ) . $paramnoactionodate . '">' ;
2020-07-08 18:06:14 +02:00
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto ( $langs -> trans ( " ViewDay " ), 'object_calendarday' , 'class="pictoactionview block"' );
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">' . $langs -> trans ( " ViewDay " ) . '</span></a>' ;
2021-12-11 13:17:31 +01:00
$viewmode .= '<a class="btnTitle btnTitleSelected reposition marginrightonly" href="' . DOL_URL_ROOT . '/comm/action/peruser.php?mode=show_peruser&year=' . dol_print_date ( $object -> datep , '%Y' ) . '&month=' . dol_print_date ( $object -> datep , '%m' ) . '&day=' . dol_print_date ( $object -> datep , '%d' ) . $paramnoactionodate . '">' ;
2020-07-08 18:06:14 +02:00
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto ( $langs -> trans ( " ViewPerUser " ), 'object_calendarperuser' , 'class="pictoactionview block"' );
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">' . $langs -> trans ( " ViewPerUser " ) . '</span></a>' ;
$viewmode .= '<span class="marginrightonly"></span>' ;
2021-01-12 13:58:16 +01:00
// Add more views from hooks
$parameters = array (); $object = null ;
$reshook = $hookmanager -> executeHooks ( 'addCalendarView' , $parameters , $object , $action );
if ( empty ( $reshook )) {
$viewmode .= $hookmanager -> resPrint ;
} elseif ( $reshook > 1 ) {
$viewmode = $hookmanager -> resPrint ;
}
2014-09-05 13:48:55 +02:00
2021-08-28 17:39:23 +02:00
$newparam = '' ;
2019-12-18 15:20:36 +01:00
$newcardbutton = '' ;
2021-02-23 18:59:19 +01:00
if ( $user -> rights -> agenda -> myactions -> create || $user -> rights -> agenda -> allactions -> create ) {
2019-12-18 15:20:36 +01:00
$tmpforcreatebutton = dol_getdate ( dol_now (), true );
2018-11-23 14:05:45 +01:00
2021-02-07 19:44:22 +01:00
$newparam .= '&month=' . urlencode ( str_pad ( $month , 2 , " 0 " , STR_PAD_LEFT )) . '&year=' . urlencode ( $tmpforcreatebutton [ 'year' ]);
2021-02-23 18:59:19 +01:00
if ( $begin_h !== '' ) {
$newparam .= '&begin_h=' . urlencode ( $begin_h );
}
if ( $end_h !== '' ) {
$newparam .= '&end_h=' . urlencode ( $end_h );
}
if ( $begin_d !== '' ) {
$newparam .= '&begin_d=' . urlencode ( $begin_d );
}
if ( $end_d !== '' ) {
$newparam .= '&end_d=' . urlencode ( $end_d );
}
2018-11-23 14:05:45 +01:00
//$param='month='.$monthshown.'&year='.$year;
2019-12-18 15:20:36 +01:00
$hourminsec = '100000' ;
2020-10-31 14:32:18 +01:00
$newcardbutton .= dolGetButtonTitle ( $langs -> trans ( " AddAction " ), '' , 'fa fa-plus-circle' , DOL_URL_ROOT . '/comm/action/card.php?action=create&datep=' . sprintf ( " %04d%02d%02d " , $tmpforcreatebutton [ 'year' ], $tmpforcreatebutton [ 'mon' ], $tmpforcreatebutton [ 'mday' ]) . $hourminsec . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . ( $newparam ? '?' . $newparam : '' )));
2018-11-23 14:05:45 +01:00
}
2014-09-05 13:48:55 +02:00
2021-08-28 18:51:01 +02:00
$num = '' ;
2020-07-09 12:33:28 +02:00
print_barre_liste ( $langs -> trans ( " Agenda " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , - 1 , 'object_action' , 0 , $nav . '<span class="marginleftonly"></span>' . $newcardbutton , '' , $limit , 1 , 0 , 1 , $viewmode );
2020-07-08 18:06:14 +02:00
2019-12-18 15:20:36 +01:00
$link = '' ;
2020-07-08 18:06:14 +02:00
//print load_fiche_titre('', $link.' '.$nav.' '.$newcardbutton, '');
// Local calendar
$newtitle = '<div class="nowrap clear inline-block minheight30">' ;
$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs -> trans ( " LocalAgenda " ) . ' ' ;
$newtitle .= '</div>' ;
//$newtitle=$langs->trans($title);
$s = $newtitle ;
print $s ;
2020-07-09 11:55:16 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
2020-07-08 18:06:14 +02:00
print_actions_filter ( $form , $canedit , $search_status , $year , $month , $day , $showbirthday , 0 , $filtert , 0 , $pid , $socid , $action , - 1 , $actioncode , $usergroup , '' , $resourceid );
2020-07-09 11:55:16 +02:00
print '</div>' ;
2018-11-23 14:05:45 +01:00
2014-07-11 13:55:15 +02:00
// Get event in an array
2019-12-18 15:20:36 +01:00
$eventarray = array ();
2014-07-11 13:55:15 +02:00
2021-02-18 12:46:42 +01:00
// DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR
2015-01-15 02:06:04 +01:00
$sql = 'SELECT' ;
2021-02-23 18:59:19 +01:00
if ( $usergroup > 0 ) {
$sql .= " DISTINCT " ;
}
2019-12-18 15:20:36 +01:00
$sql .= ' a.id, a.label,' ;
$sql .= ' a.datep,' ;
$sql .= ' a.datep2,' ;
$sql .= ' a.percent,' ;
$sql .= ' a.fk_user_author,a.fk_user_action,' ;
$sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,' ;
$sql .= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,' ;
2021-02-18 12:46:42 +01:00
$sql .= ' ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto' ;
2019-12-18 15:20:36 +01:00
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_actioncomm as ca, ' . MAIN_DB_PREFIX . " actioncomm as a " ;
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) && ! $socid ) {
2021-02-23 18:59:19 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe_commerciaux as sc ON a.fk_soc = sc.fk_soc " ;
}
2016-06-06 13:05:36 +02:00
// We must filter on resource table
2021-02-23 18:59:19 +01:00
if ( $resourceid > 0 ) {
$sql .= " , " . MAIN_DB_PREFIX . " element_resources as r " ;
}
2015-01-15 02:06:04 +01:00
// We must filter on assignement table
2021-02-23 18:59:19 +01:00
if ( $filtert > 0 || $usergroup > 0 ) {
$sql .= " , " . MAIN_DB_PREFIX . " actioncomm_resources as ar " ;
}
if ( $usergroup > 0 ) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " usergroup_user as ugu ON ugu.fk_user = ar.fk_element " ;
}
2019-12-18 15:20:36 +01:00
$sql .= ' WHERE a.fk_action = ca.id' ;
$sql .= ' AND a.entity IN (' . getEntity ( 'agenda' ) . ')' ;
2016-11-08 12:58:07 +01:00
// Condition on actioncode
2021-02-23 18:59:19 +01:00
if ( ! empty ( $actioncode )) {
if ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE )) {
if ( $actioncode == 'AC_NON_AUTO' ) {
$sql .= " AND ca.type != 'systemauto' " ;
} elseif ( $actioncode == 'AC_ALL_AUTO' ) {
$sql .= " AND ca.type = 'systemauto' " ;
} else {
if ( $actioncode == 'AC_OTH' ) {
$sql .= " AND ca.type != 'systemauto' " ;
}
if ( $actioncode == 'AC_OTH_AUTO' ) {
$sql .= " AND ca.type = 'systemauto' " ;
}
2020-10-31 14:32:18 +01:00
}
} else {
2021-02-23 18:59:19 +01:00
if ( $actioncode == 'AC_NON_AUTO' ) {
$sql .= " AND ca.type != 'systemauto' " ;
} elseif ( $actioncode == 'AC_ALL_AUTO' ) {
$sql .= " AND ca.type = 'systemauto' " ;
} else {
if ( is_array ( $actioncode )) {
2021-03-23 03:44:50 +01:00
$sql .= " AND ca.code IN ( " . $db -> sanitize ( " ' " . implode ( " ',' " , $actioncode ) . " ' " , 1 ) . " ) " ;
2020-10-31 14:32:18 +01:00
} else {
2021-03-23 03:44:50 +01:00
$sql .= " AND ca.code IN ( " . $db -> sanitize ( " ' " . implode ( " ',' " , explode ( ',' , $actioncode )) . " ' " , 1 ) . " ) " ;
2020-10-31 14:32:18 +01:00
}
}
}
2016-11-08 12:58:07 +01:00
}
2021-02-23 18:59:19 +01:00
if ( $resourceid > 0 ) {
2021-03-23 03:44:50 +01:00
$sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = " . (( int ) $resourceid );
2021-02-23 18:59:19 +01:00
}
if ( $pid ) {
2021-03-23 03:44:50 +01:00
$sql .= " AND a.fk_project = " . (( int ) $pid );
2021-02-23 18:59:19 +01:00
}
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) && ! $socid ) {
2021-08-23 17:41:11 +02:00
$sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . (( int ) $user -> id ) . " ) " ;
2021-02-23 18:59:19 +01:00
}
if ( $socid > 0 ) {
2021-03-23 03:44:50 +01:00
$sql .= ' AND a.fk_soc = ' . (( int ) $socid );
2021-02-23 18:59:19 +01:00
}
2015-01-15 02:06:04 +01:00
// We must filter on assignement table
2021-02-23 18:59:19 +01:00
if ( $filtert > 0 || $usergroup > 0 ) {
$sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user' " ;
}
2021-12-11 13:17:31 +01:00
if ( $mode == 'show_day' ) {
2020-10-31 14:32:18 +01:00
$sql .= " AND ( " ;
2021-02-07 19:44:22 +01:00
$sql .= " (a.datep BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $month , $day , $year , 'tzuserrel' )) . " ' " ;
$sql .= " AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $month , $day , $year , 'tzuserrel' )) . " ') " ;
2020-10-31 14:32:18 +01:00
$sql .= " OR " ;
2021-02-07 19:44:22 +01:00
$sql .= " (a.datep2 BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $month , $day , $year , 'tzuserrel' )) . " ' " ;
$sql .= " AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $month , $day , $year , 'tzuserrel' )) . " ') " ;
2020-10-31 14:32:18 +01:00
$sql .= " OR " ;
2021-02-07 19:44:22 +01:00
$sql .= " (a.datep < ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $month , $day , $year , 'tzuserrel' )) . " ' " ;
$sql .= " AND a.datep2 > ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $month , $day , $year , 'tzuserrel' )) . " ') " ;
2020-10-31 14:32:18 +01:00
$sql .= ')' ;
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
// To limit array
$sql .= " AND ( " ;
$sql .= " (a.datep BETWEEN ' " . $db -> idate ( $firstdaytoshow - ( 60 * 60 * 24 * 2 )) . " ' " ; // Start 2 day before $firstdaytoshow
$sql .= " AND ' " . $db -> idate ( $lastdaytoshow + ( 60 * 60 * 24 * 2 )) . " ') " ; // End 2 day after $lastdaytoshow
$sql .= " OR " ;
$sql .= " (a.datep2 BETWEEN ' " . $db -> idate ( $firstdaytoshow - ( 60 * 60 * 24 * 2 )) . " ' " ;
$sql .= " AND ' " . $db -> idate ( $lastdaytoshow + ( 60 * 60 * 24 * 2 )) . " ') " ;
$sql .= " OR " ;
$sql .= " (a.datep < ' " . $db -> idate ( $firstdaytoshow - ( 60 * 60 * 24 * 2 )) . " ' " ;
$sql .= " AND a.datep2 > ' " . $db -> idate ( $lastdaytoshow + ( 60 * 60 * 24 * 2 )) . " ') " ;
$sql .= ')' ;
2014-07-11 13:55:15 +02:00
}
2021-02-23 18:59:19 +01:00
if ( $type ) {
2021-04-24 20:18:11 +02:00
$sql .= " AND ca.id = " . (( int ) $type );
2021-02-23 18:59:19 +01:00
}
if ( $status == '0' ) {
$sql .= " AND a.percent = 0 " ;
}
2022-07-25 13:18:03 +02:00
if ( $status == '-1' || $status == 'na' ) {
// Not applicable
2021-02-23 18:59:19 +01:00
$sql .= " AND a.percent = -1 " ;
2022-07-25 13:18:03 +02:00
}
2021-02-23 18:59:19 +01:00
if ( $status == '50' ) {
2022-07-25 13:18:03 +02:00
// Running already started
2021-02-23 18:59:19 +01:00
$sql .= " AND (a.percent > 0 AND a.percent < 100) " ;
2022-07-25 13:18:03 +02:00
}
2021-02-23 18:59:19 +01:00
if ( $status == 'done' || $status == '100' ) {
$sql .= " AND (a.percent = 100) " ;
}
if ( $status == 'todo' ) {
$sql .= " AND (a.percent >= 0 AND a.percent < 100) " ;
}
2015-01-15 02:06:04 +01:00
// We must filter on assignement table
2021-02-23 18:59:19 +01:00
if ( $filtert > 0 || $usergroup > 0 ) {
2020-10-31 14:32:18 +01:00
$sql .= " AND ( " ;
2021-02-23 18:59:19 +01:00
if ( $filtert > 0 ) {
$sql .= " ar.fk_element = " . $filtert ;
}
if ( $usergroup > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= ( $filtert > 0 ? " OR " : " " ) . " ugu.fk_usergroup = " . (( int ) $usergroup );
2021-02-23 18:59:19 +01:00
}
2020-10-31 14:32:18 +01:00
$sql .= " ) " ;
2014-07-11 13:55:15 +02:00
}
// Sort on date
2019-12-18 15:20:36 +01:00
$sql .= ' ORDER BY fk_user_action, datep' ; //fk_user_action
2018-03-10 16:46:57 +01:00
2014-07-11 13:55:15 +02:00
2016-04-23 16:51:22 +02:00
dol_syslog ( " comm/action/peruser.php " , LOG_DEBUG );
2019-12-18 15:20:36 +01:00
$resql = $db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( $resql ) {
2020-10-31 14:32:18 +01:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2021-02-23 18:59:19 +01:00
while ( $i < $num ) {
2020-10-31 14:32:18 +01:00
$obj = $db -> fetch_object ( $resql );
// Discard auto action if option is on
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> global -> AGENDA_ALWAYS_HIDE_AUTO ) && $obj -> code == 'AC_OTH_AUTO' ) {
2020-10-31 14:32:18 +01:00
$i ++ ;
continue ;
}
$datep = $db -> jdate ( $obj -> datep );
$datep2 = $db -> jdate ( $obj -> datep2 );
// Create a new object action
$event = new ActionComm ( $db );
$event -> id = $obj -> id ;
$event -> datep = $datep ; // datep and datef are GMT date
$event -> datef = $datep2 ;
$event -> type_code = $obj -> code ;
$event -> type_color = $obj -> color ;
$event -> label = $obj -> label ;
$event -> percentage = $obj -> percent ;
$event -> authorid = $obj -> fk_user_author ; // user id of creator
$event -> userownerid = $obj -> fk_user_action ; // user id of owner
$event -> priority = $obj -> priority ;
$event -> fulldayevent = $obj -> fulldayevent ;
$event -> location = $obj -> location ;
$event -> transparency = $obj -> transparency ;
$event -> fk_project = $obj -> fk_project ;
$event -> socid = $obj -> fk_soc ;
$event -> contact_id = $obj -> fk_contact ;
$event -> fk_element = $obj -> fk_element ;
$event -> elementtype = $obj -> elementtype ;
// Defined date_start_in_calendar and date_end_in_calendar property
// They are date start and end of action but modified to not be outside calendar view.
2021-02-23 18:59:19 +01:00
if ( $event -> percentage <= 0 ) {
2020-10-31 14:32:18 +01:00
$event -> date_start_in_calendar = $datep ;
2021-02-23 18:59:19 +01:00
if ( $datep2 != '' && $datep2 >= $datep ) {
$event -> date_end_in_calendar = $datep2 ;
} else {
$event -> date_end_in_calendar = $datep ;
}
2020-10-31 14:32:18 +01:00
} else {
$event -> date_start_in_calendar = $datep ;
2021-02-23 18:59:19 +01:00
if ( $datep2 != '' && $datep2 >= $datep ) {
$event -> date_end_in_calendar = $datep2 ;
} else {
$event -> date_end_in_calendar = $datep ;
}
2020-10-31 14:32:18 +01:00
}
// Check values
if ( $event -> date_end_in_calendar < $firstdaytoshow ||
2021-02-23 18:59:19 +01:00
$event -> date_start_in_calendar >= $lastdaytoshow ) {
2020-10-31 14:32:18 +01:00
// This record is out of visible range
unset ( $event );
} else {
2017-07-29 01:59:26 +02:00
//print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n";
2020-10-31 14:32:18 +01:00
$event -> fetch_userassigned (); // This load $event->userassigned
2017-07-29 01:59:26 +02:00
2021-02-23 18:59:19 +01:00
if ( $event -> date_start_in_calendar < $firstdaytoshow ) {
$event -> date_start_in_calendar = $firstdaytoshow ;
}
if ( $event -> date_end_in_calendar >= $lastdaytoshow ) {
$event -> date_end_in_calendar = ( $lastdaytoshow - 1 );
}
2020-10-31 14:32:18 +01:00
// Add an entry in actionarray for each day
$daycursor = $event -> date_start_in_calendar ;
2021-02-07 19:44:22 +01:00
$annee = dol_print_date ( $daycursor , '%Y' , 'tzuserrel' );
$mois = dol_print_date ( $daycursor , '%m' , 'tzuserrel' );
$jour = dol_print_date ( $daycursor , '%d' , 'tzuserrel' );
//print $daycursor.' '.dol_print_date($daycursor, 'dayhour', 'gmt').' '.$event->id.' -> '.$annee.'-'.$mois.'-'.$jour.'<br>';
2020-10-31 14:32:18 +01:00
// Loop on each day covered by action to prepare an index to show on calendar
$loop = true ; $j = 0 ;
2021-01-03 18:42:45 +01:00
$daykey = dol_mktime ( 0 , 0 , 0 , $mois , $jour , $annee , 'gmt' );
2020-10-31 14:32:18 +01:00
do {
//if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>';
$eventarray [ $daykey ][] = $event ;
$j ++ ;
$daykey += 60 * 60 * 24 ;
2021-02-23 18:59:19 +01:00
if ( $daykey > $event -> date_end_in_calendar ) {
$loop = false ;
}
2020-10-31 14:32:18 +01:00
} while ( $loop );
//print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef);
//print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array<br>';
}
$i ++ ;
}
$db -> free ( $resql );
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
dol_print_error ( $db );
2014-07-11 13:55:15 +02:00
}
2019-11-13 19:37:08 +01:00
$maxnbofchar = 18 ;
$cachethirdparties = array ();
$cachecontacts = array ();
$cacheusers = array ();
2014-07-11 13:55:15 +02:00
// Define theme_datacolor array
2019-03-11 20:32:25 +01:00
$color_file = DOL_DOCUMENT_ROOT . " /theme/ " . $conf -> theme . " /theme_vars.inc.php " ;
2021-02-23 18:59:19 +01:00
if ( is_readable ( $color_file )) {
2021-04-06 22:18:32 +02:00
include $color_file ;
2014-07-11 13:55:15 +02:00
}
2021-02-23 18:59:19 +01:00
if ( ! is_array ( $theme_datacolor )) {
$theme_datacolor = array ( array ( 120 , 130 , 150 ), array ( 200 , 160 , 180 ), array ( 190 , 190 , 220 ));
}
2014-07-11 13:55:15 +02:00
2019-11-13 19:37:08 +01:00
$newparam = $param ; // newparam is for birthday links
$newparam = preg_replace ( '/showbirthday=/i' , 'showbirthday_=' , $newparam ); // To avoid replacement when replace day= is done
2021-12-11 13:17:31 +01:00
$newparam = preg_replace ( '/mode=show_month&?/i' , '' , $newparam );
$newparam = preg_replace ( '/mode=show_week&?/i' , '' , $newparam );
2019-11-13 19:37:08 +01:00
$newparam = preg_replace ( '/day=[0-9]+&?/i' , '' , $newparam );
$newparam = preg_replace ( '/month=[0-9]+&?/i' , '' , $newparam );
$newparam = preg_replace ( '/year=[0-9]+&?/i' , '' , $newparam );
$newparam = preg_replace ( '/viewweek=[0-9]+&?/i' , '' , $newparam );
$newparam = preg_replace ( '/showbirthday_=/i' , 'showbirthday=' , $newparam ); // Restore correct parameter
$newparam .= '&viewweek=1' ;
2014-09-05 13:48:55 +02:00
2017-11-25 00:12:45 +01:00
echo '<input type="hidden" name="actionmove" value="mupdate">' ;
2017-06-18 21:13:48 +02:00
echo '<input type="hidden" name="backtopage" value="' . dol_escape_htmltag ( $_SERVER [ 'PHP_SELF' ]) . '?' . dol_escape_htmltag ( $_SERVER [ 'QUERY_STRING' ]) . '">' ;
2019-11-13 19:37:08 +01:00
echo '<input type="hidden" name="newdate" id="newdate">' ;
2014-09-05 13:48:55 +02:00
2015-02-03 11:25:51 +01:00
// Line header with list of days
//print "begin_d=".$begin_d." end_d=".$end_d;
2018-03-10 16:46:57 +01:00
$currentdaytoshow = $firstdaytoshow ;
2016-11-27 20:11:39 +01:00
echo '<div class="div-table-responsive">' ;
2014-09-05 13:48:55 +02:00
2019-12-18 15:20:36 +01:00
while ( $currentdaytoshow < $lastdaytoshow ) {
2021-10-26 01:30:00 +02:00
echo '<table class="centpercent noborder nocellnopadd cal_month">' ;
2018-03-16 10:51:12 +01:00
2018-03-10 16:46:57 +01:00
echo '<tr class="liste_titre">' ;
2020-12-08 17:09:48 +01:00
echo '<td class="nopaddingtopimp nopaddingbottomimp nowraponsmartphone">' ;
2020-08-30 13:14:28 +02:00
2021-12-11 13:17:31 +01:00
if ( $canedit && $mode == 'show_peruser' ) {
2020-08-30 13:14:28 +02:00
// Filter on hours
print img_picto ( '' , 'clock' , 'class="fawidth30 inline-block paddingleft"' );
print '<span class="hideonsmartphone" title="' . $langs -> trans ( " VisibleTimeRange " ) . '">' . $langs -> trans ( " Hours " ) . '</span>' ;
2021-01-03 18:42:45 +01:00
print " \n " . '<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">' ;
2020-08-30 13:14:28 +02:00
print '<input type="number" class="short" name="begin_h" value="' . $begin_h . '" min="0" max="23">' ;
2021-02-23 18:59:19 +01:00
if ( empty ( $conf -> dol_use_jmobile )) {
print ' - ' ;
} else {
print '</div><div class="ui-block-b">' ;
}
2020-08-30 13:14:28 +02:00
print '<input type="number" class="short" name="end_h" value="' . $end_h . '" min="1" max="24">' ;
2021-02-23 18:59:19 +01:00
if ( empty ( $conf -> dol_use_jmobile )) {
print ' ' . $langs -> trans ( " H " );
}
2020-08-30 13:14:28 +02:00
print '</div></div>' ;
print '<br>' ;
// Filter on days
print img_picto ( '' , 'clock' , 'class="fawidth30 inline-block paddingleft"' );
print '<span class="hideonsmartphone" title="' . $langs -> trans ( " VisibleDaysRange " ) . '">' . $langs -> trans ( " DaysOfWeek " ) . '</span>' ;
2021-10-26 01:30:00 +02:00
print " \n " . '<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">' ;
2020-08-30 13:14:28 +02:00
print '<input type="number" class="short" name="begin_d" value="' . $begin_d . '" min="1" max="7">' ;
2021-02-23 18:59:19 +01:00
if ( empty ( $conf -> dol_use_jmobile )) {
print ' - ' ;
} else {
print '</div><div class="ui-block-b">' ;
}
2020-08-30 13:14:28 +02:00
print '<input type="number" class="short" name="end_d" value="' . $end_d . '" min="1" max="7">' ;
print '</div></div>' ;
}
print '</td>' ;
2019-12-18 15:20:36 +01:00
$i = 0 ; // 0 = sunday,
2021-02-23 18:59:19 +01:00
while ( $i < 7 ) {
if (( $i + 1 ) < $begin_d || ( $i + 1 ) > $end_d ) {
2018-03-10 16:46:57 +01:00
$i ++ ;
continue ;
}
echo '<td align="center" colspan="' . ( $end_h - $begin_h ) . '">' ;
2020-08-29 03:52:27 +02:00
echo '<span class="bold spandayofweek">' . $langs -> trans ( " Day " . (( $i + ( isset ( $conf -> global -> MAIN_START_WEEK ) ? $conf -> global -> MAIN_START_WEEK : 1 )) % 7 )) . '</span>' ;
2018-03-10 16:46:57 +01:00
print " <br> " ;
2021-02-23 18:59:19 +01:00
if ( $i ) {
print dol_print_date ( dol_time_plus_duree ( $currentdaytoshow , $i , 'd' ), 'day' );
} else {
print dol_print_date ( $currentdaytoshow , 'day' );
}
2018-03-10 16:46:57 +01:00
echo " </td> \n " ;
2014-09-05 21:12:01 +02:00
$i ++ ;
}
2018-03-10 16:46:57 +01:00
echo " </tr> \n " ;
2018-03-16 10:51:12 +01:00
2018-03-10 16:46:57 +01:00
echo '<tr class="liste_titre">' ;
echo '<td></td>' ;
2019-11-13 19:37:08 +01:00
$i = 0 ;
2021-02-23 18:59:19 +01:00
while ( $i < 7 ) {
if (( $i + 1 ) < $begin_d || ( $i + 1 ) > $end_d ) {
2018-03-10 16:46:57 +01:00
$i ++ ;
continue ;
}
2021-02-23 18:59:19 +01:00
for ( $h = $begin_h ; $h < $end_h ; $h ++ ) {
2019-12-12 10:31:08 +01:00
echo '<td class="center">' ;
2019-01-27 11:55:16 +01:00
print '<small style="font-family: courier">' . sprintf ( " %02d " , $h ) . '</small>' ;
2018-03-10 16:46:57 +01:00
print " </td> " ;
}
echo " </td> \n " ;
2014-09-05 21:12:01 +02:00
$i ++ ;
}
2018-03-10 16:46:57 +01:00
echo " </tr> \n " ;
2018-03-16 10:51:12 +01:00
2018-03-10 16:46:57 +01:00
// Define $usernames
$usernames = array (); //init
$usernamesid = array ();
/* Use this to have list of users only if users have events */
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> global -> AGENDA_SHOWOWNERONLY_ONPERUSERVIEW )) {
foreach ( $eventarray as $daykey => $notused ) {
2020-10-31 14:32:18 +01:00
// Get all assigned users for each event
2021-02-23 18:59:19 +01:00
foreach ( $eventarray [ $daykey ] as $index => $event ) {
2020-10-31 14:32:18 +01:00
$event -> fetch_userassigned ();
2019-12-18 15:20:36 +01:00
$listofuserid = $event -> userassigned ;
2020-05-23 21:14:44 +02:00
foreach ( $listofuserid as $userid => $tmp ) {
2021-02-23 18:59:19 +01:00
if ( ! in_array ( $userid , $usernamesid )) {
$usernamesid [ $userid ] = $userid ;
}
2018-03-10 16:46:57 +01:00
}
2020-10-31 14:32:18 +01:00
}
2018-03-10 16:46:57 +01:00
}
2020-05-23 21:14:44 +02:00
} else {
/* Use this list to have for all users */
2021-09-09 16:06:16 +02:00
$sql = " SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity " ;
2019-11-13 19:37:08 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " user as u " ;
2021-09-09 16:06:16 +02:00
if ( ! empty ( $conf -> multicompany -> enabled ) && ! empty ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE )) {
$sql .= " , " . MAIN_DB_PREFIX . " usergroup_user as ug " ;
$sql .= " WHERE ug.entity IN ( " . getEntity ( 'usergroup' ) . " ) " ;
$sql .= " AND ug.fk_user = u.rowid " ;
} else {
if ( $usergroup > 0 ) {
2021-09-09 15:15:26 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " usergroup_user as ug ON u.rowid = ug.fk_user " ;
}
2021-09-09 16:06:16 +02:00
$sql .= " WHERE u.entity IN ( " . getEntity ( 'user' ) . " ) " ;
2021-02-23 18:59:19 +01:00
}
2021-09-09 16:06:16 +02:00
$sql .= " AND u.statut = 1 " ;
if ( $usergroup > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND ug.fk_usergroup = " . (( int ) $usergroup );
2021-02-23 18:59:19 +01:00
}
2023-02-05 11:48:29 +01:00
if ( $user -> socid > 0 ) {
2023-02-05 11:43:09 +01:00
// External users should see only contacts of their company
2023-02-06 00:05:06 +01:00
$sql .= " AND u.fk_soc = " . (( int ) $user -> socid );
2023-02-05 11:43:09 +01:00
}
2021-09-09 15:15:26 +02:00
2018-03-10 16:46:57 +01:00
//print $sql;
2019-11-13 19:37:08 +01:00
$resql = $db -> query ( $sql );
2020-05-23 21:14:44 +02:00
if ( $resql ) {
2020-10-31 14:32:18 +01:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2021-02-23 18:59:19 +01:00
if ( $num ) {
while ( $i < $num ) {
2020-10-31 14:32:18 +01:00
$obj = $db -> fetch_object ( $resql );
2019-11-13 19:37:08 +01:00
$usernamesid [ $obj -> rowid ] = $obj -> rowid ;
2018-03-10 16:46:57 +01:00
$i ++ ;
2020-10-31 14:32:18 +01:00
}
}
2021-02-23 18:59:19 +01:00
} else {
dol_print_error ( $db );
}
2014-10-13 17:45:52 +02:00
}
2018-03-10 16:46:57 +01:00
//var_dump($usernamesid);
2021-02-23 18:59:19 +01:00
foreach ( $usernamesid as $id ) {
2019-11-13 19:37:08 +01:00
$tmpuser = new User ( $db );
$result = $tmpuser -> fetch ( $id );
$usernames [] = $tmpuser ;
2018-03-10 16:46:57 +01:00
}
2018-03-16 10:51:12 +01:00
2018-03-10 16:46:57 +01:00
/*
if ( $filtert > 0 )
{
$tmpuser = new User ( $db );
$tmpuser -> fetch ( $filtert );
$usernames [] = $tmpuser ;
}
else if ( $usergroup )
{
$tmpgroup = new UserGroup ( $db );
$tmpgroup -> fetch ( $usergroup );
$usernames = $tmpgroup -> listUsersForGroup ();
}
else
{
$tmpgroup = new UserGroup ( $db );
//$tmpgroup->fetch($usergroup); No fetch, we want all users for all groups
$usernames = $tmpgroup -> listUsersForGroup ();
} */
2018-03-16 10:51:12 +01:00
2018-03-10 16:46:57 +01:00
// Load array of colors by type
2019-12-18 15:20:36 +01:00
$colorsbytype = array ();
$labelbytype = array ();
$sql = " SELECT code, color, libelle as label FROM " . MAIN_DB_PREFIX . " c_actioncomm ORDER BY position " ;
$resql = $db -> query ( $sql );
2021-02-23 18:59:19 +01:00
while ( $obj = $db -> fetch_object ( $resql )) {
2019-12-18 15:20:36 +01:00
$colorsbytype [ $obj -> code ] = $obj -> color ;
$labelbytype [ $obj -> code ] = $obj -> label ;
2014-10-13 17:45:52 +02:00
}
2018-03-16 10:51:12 +01:00
2018-03-10 16:46:57 +01:00
// Loop on each user to show calendar
2019-12-18 15:20:36 +01:00
$todayarray = dol_getdate ( $now , 'fast' );
2018-03-10 16:46:57 +01:00
$sav = $tmpday ;
$showheader = true ;
$var = false ;
2021-02-23 18:59:19 +01:00
foreach ( $usernames as $username ) {
2019-12-18 15:20:36 +01:00
$var = ! $var ;
2018-03-10 16:46:57 +01:00
echo " <tr> " ;
2019-12-18 15:20:36 +01:00
echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname' . ( $var ? ' cal_impair' : '' ) . '">' ;
2019-01-27 11:55:16 +01:00
print $username -> getNomUrl ( - 1 , '' , 0 , 0 , 20 , 1 , '' );
2018-03-10 16:46:57 +01:00
print '</td>' ;
$tmpday = $sav ;
2018-03-16 10:51:12 +01:00
2018-03-10 16:46:57 +01:00
// Lopp on each day of week
$i = 0 ;
2021-02-23 18:59:19 +01:00
for ( $iter_day = 0 ; $iter_day < 8 ; $iter_day ++ ) {
if (( $i + 1 ) < $begin_d || ( $i + 1 ) > $end_d ) {
2018-03-10 16:46:57 +01:00
$i ++ ;
continue ;
}
2018-03-16 10:51:12 +01:00
2020-10-31 14:32:18 +01:00
// Show days of the current week
2018-03-10 16:46:57 +01:00
$curtime = dol_time_plus_duree ( $currentdaytoshow , $iter_day , 'd' );
2019-01-27 11:55:16 +01:00
$tmparray = dol_getdate ( $curtime , 'fast' );
2018-03-10 16:46:57 +01:00
$tmpday = $tmparray [ 'mday' ];
$tmpmonth = $tmparray [ 'mon' ];
$tmpyear = $tmparray [ 'year' ];
2021-01-03 18:42:45 +01:00
//var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear);
2018-03-16 10:51:12 +01:00
2019-11-13 19:37:08 +01:00
$style = 'cal_current_month' ;
2021-02-23 18:59:19 +01:00
if ( $iter_day == 6 ) {
$style .= ' cal_other_month' ;
}
2019-11-13 19:37:08 +01:00
$today = 0 ;
2021-02-23 18:59:19 +01:00
if ( $todayarray [ 'mday' ] == $tmpday && $todayarray [ 'mon' ] == $tmpmonth && $todayarray [ 'year' ] == $tmpyear ) {
$today = 1 ;
}
if ( $today ) {
$style = 'cal_today_peruser' ;
}
2018-03-16 10:51:12 +01:00
2021-01-03 18:42:45 +01:00
show_day_events2 ( $username , $tmpday , $tmpmonth , $tmpyear , 0 , $style , $eventarray , 0 , $maxnbofchar , $newparam , 1 , 300 , $showheader , $colorsbytype , $var );
2018-03-16 10:51:12 +01:00
2014-09-05 21:12:01 +02:00
$i ++ ;
2014-09-05 13:48:55 +02:00
}
2018-03-10 16:46:57 +01:00
echo " </tr> \n " ;
$showheader = false ;
2014-09-05 13:48:55 +02:00
}
2018-03-16 10:51:12 +01:00
2018-03-10 16:46:57 +01:00
echo " </table> \n " ;
2018-03-11 02:18:46 +01:00
echo " <br> " ;
2018-03-16 10:51:12 +01:00
2019-11-13 19:37:08 +01:00
$currentdaytoshow = dol_time_plus_duree ( $currentdaytoshow , 7 , 'd' );
2014-09-05 13:48:55 +02:00
}
2016-11-27 20:11:39 +01:00
echo '</div>' ;
2014-07-11 13:55:15 +02:00
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) && ! empty ( $conf -> global -> AGENDA_USE_COLOR_PER_EVENT_TYPE )) {
2014-10-13 17:45:52 +02:00
$langs -> load ( " commercial " );
print '<br>' . $langs -> trans ( " Legend " ) . ': <br>' ;
2021-02-23 18:59:19 +01:00
foreach ( $colorsbytype as $code => $color ) {
if ( $color ) {
2019-11-13 19:37:08 +01:00
print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="' . ( $color ? 'background: #' . $color . ';' : '' ) . 'width:16px; float: left; margin-right: 4px;"> </div>' ;
print $langs -> trans ( " Action " . $code ) != " Action " . $code ? $langs -> trans ( " Action " . $code ) : $labelbytype [ $code ];
2014-10-13 17:45:52 +02:00
//print $code;
print '</div>' ;
}
}
//$color=sprintf("%02x%02x%02x",$theme_datacolor[0][0],$theme_datacolor[0][1],$theme_datacolor[0][2]);
print '<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>' ;
print $langs -> trans ( " Other " );
print '</div>' ;
2014-10-18 02:31:48 +02:00
/* TODO Show this if at least one cumulated event
print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #222222; width:16px; float: left; margin-right: 4px;"> </div>' ;
print $langs -> trans ( " SeveralEvents " );
print '</div>' ;
*/
2014-10-13 17:45:52 +02:00
}
2017-11-25 00:12:45 +01:00
print " \n " . '</form>' ;
print " \n " ;
2014-09-06 00:32:54 +02:00
// Add js code to manage click on a box
2021-11-29 15:09:18 +01:00
print ' < script type = " text/javascript " >
2014-09-06 00:32:54 +02:00
jQuery ( document ) . ready ( function () {
jQuery ( " .onclickopenref " ) . click ( function () {
2014-09-07 19:56:17 +02:00
var ref = $ ( this ) . attr ( \ ' ref\ ' );
var res = ref . split ( " _ " );
var userid = res [ 1 ];
var year = res [ 2 ];
var month = res [ 3 ];
var day = res [ 4 ];
var hour = res [ 5 ];
var min = res [ 6 ];
var ids = res [ 7 ];
if ( ids == \ ' none\ ' ) /* No event */
{
/* alert(\'no event\'); */
2021-02-07 19:44:22 +01:00
url = " '.DOL_URL_ROOT.'/comm/action/card.php?action=create&assignedtouser= " + userid + " &datep= " + year + month + day + hour + min + " 00&backtopage='.urlencode( $_SERVER["PHP_SELF"] .'?year='. $year .'&month='. $month .'&day='. $day .( $begin_h !== '' ? '&begin_h='. $begin_h : '').( $end_h !== '' ? '&end_h='. $end_h : '').( $begin_d !== '' ? '&begin_d='. $begin_d : '').( $end_d !== '' ? '&end_d='. $end_d : '')).' "
2014-09-07 19:56:17 +02:00
window . location . href = url ;
}
else if ( ids . indexOf ( " , " ) > - 1 ) /* There is several events */
{
/* alert(\'several events\'); */
2021-12-11 13:17:31 +01:00
url = " '.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&filtert= " + userid + " &dateselectyear= " + year + " &dateselectmonth= " + month + " &dateselectday= " + day ;
2014-09-07 19:56:17 +02:00
window . location . href = url ;
}
else /* One event */
{
/* alert(\'one event\'); */
2014-09-18 21:18:25 +02:00
url = " '.DOL_URL_ROOT.'/comm/action/card.php?action=view&id= " + ids
2014-09-07 19:56:17 +02:00
window . location . href = url ;
}
2014-09-06 00:32:54 +02:00
});
});
</ script > ' ;
2018-07-29 13:40:35 +02:00
// End of page
2014-07-11 13:55:15 +02:00
llxFooter ();
$db -> close ();
2014-09-05 13:48:55 +02:00
/**
2015-08-14 12:31:09 +02:00
* Show event line of a particular day for a user
2014-09-05 13:48:55 +02:00
*
2019-02-14 21:45:40 +01:00
* @ param User $username Login
2014-09-14 00:27:36 +02:00
* @ param int $day Day
* @ param int $month Month
* @ param int $year Year
* @ param int $monthshown Current month shown in calendar view
* @ param string $style Style to use for this day
2014-09-28 02:46:20 +02:00
* @ param array $eventarray Array of events
2014-09-14 00:27:36 +02:00
* @ param int $maxprint Nb of actions to show each day on month view ( 0 means no limit )
* @ param int $maxnbofchar Nb of characters to show for event line
* @ param string $newparam Parameters on current URL
* @ param int $showinfo Add extended information ( used by day view )
* @ param int $minheight Minimum height for each event . 60 px by default .
* @ param boolean $showheader Show header
2014-10-03 18:04:13 +02:00
* @ param array $colorsbytype Array with colors by type
2015-02-10 11:38:13 +01:00
* @ param bool $var true or false for alternat style on tr / td
2014-09-05 13:48:55 +02:00
* @ return void
*/
2019-01-27 15:20:16 +01:00
function show_day_events2 ( $username , $day , $month , $year , $monthshown , $style , & $eventarray , $maxprint = 0 , $maxnbofchar = 16 , $newparam = '' , $showinfo = 0 , $minheight = 60 , $showheader = false , $colorsbytype = array (), $var = false )
2014-09-05 13:48:55 +02:00
{
2014-09-05 21:12:01 +02:00
global $db ;
2014-10-03 15:58:08 +02:00
global $user , $conf , $langs , $hookmanager , $action ;
2019-11-13 19:37:08 +01:00
global $filter , $filtert , $status , $actioncode ; // Filters used into search form
global $theme_datacolor ; // Array with a list of different we can use (come from theme)
2017-11-25 00:12:45 +01:00
global $cachethirdparties , $cachecontacts , $cacheusers , $cacheprojects , $colorindexused ;
2014-09-05 21:12:01 +02:00
global $begin_h , $end_h ;
2014-09-05 13:48:55 +02:00
2019-11-13 19:37:08 +01:00
$cases1 = array (); // Color first half hour
2014-09-05 21:12:01 +02:00
$cases2 = array (); // Color second half hour
2014-09-05 13:48:55 +02:00
2019-11-13 19:37:08 +01:00
$i = 0 ; $numother = 0 ; $numbirthday = 0 ; $numical = 0 ; $numicals = array ();
2021-02-07 19:44:22 +01:00
//$ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
2014-09-05 13:48:55 +02:00
2019-11-13 19:37:08 +01:00
$colorindexused [ $user -> id ] = 0 ; // Color index for current user (user->id) is always 0
$nextindextouse = count ( $colorindexused ); // At first run this is 0, so first user has 0, next 1, ...
2022-05-17 14:55:38 +02:00
//if ($username->id && $day==1) {
//var_dump($eventarray);
//}
2018-03-16 10:51:12 +01:00
2014-09-26 12:27:18 +02:00
// We are in a particular day for $username, now we scan all events
2021-02-23 18:59:19 +01:00
foreach ( $eventarray as $daykey => $notused ) {
2021-02-07 19:44:22 +01:00
$annee = dol_print_date ( $daykey , '%Y' );
$mois = dol_print_date ( $daykey , '%m' );
$jour = dol_print_date ( $daykey , '%d' );
2014-09-28 16:31:37 +02:00
2021-02-23 18:59:19 +01:00
if ( $day == $jour && $month == $mois && $year == $annee ) { // Is it the day we are looking for when calling function ?
2014-09-28 16:31:37 +02:00
// Scan all event for this date
2021-02-23 18:59:19 +01:00
foreach ( $eventarray [ $daykey ] as $index => $event ) {
2021-02-07 19:44:22 +01:00
//print $daykey.' '.dol_print_date($daykey, 'dayhour', 'gmt').' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."<br>\n";
2015-08-14 13:01:20 +02:00
//var_dump($event);
2019-11-13 19:37:08 +01:00
$keysofuserassigned = array_keys ( $event -> userassigned );
$ponct = ( $event -> date_start_in_calendar == $event -> date_end_in_calendar );
2017-11-25 00:12:45 +01:00
2021-02-23 18:59:19 +01:00
if ( ! in_array ( $username -> id , $keysofuserassigned )) {
continue ; // We discard record if event is from another user than user we want to show
}
2014-09-26 12:27:18 +02:00
//if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show
2014-09-05 21:12:01 +02:00
2019-11-13 19:37:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formatEvent' , $parameters , $event , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-23 18:59:19 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2014-09-05 21:12:01 +02:00
2014-09-29 13:21:03 +02:00
// Define $color (Hex string like '0088FF') and $cssclass of event
2019-11-13 19:37:08 +01:00
$color = - 1 ; $cssclass = '' ; $colorindex = - 1 ;
2021-02-23 18:59:19 +01:00
if ( in_array ( $user -> id , $keysofuserassigned )) {
2019-11-13 19:37:08 +01:00
$cssclass = 'family_mytasks' ;
2017-11-25 00:12:45 +01:00
2021-02-23 18:59:19 +01:00
if ( empty ( $cacheusers [ $event -> userownerid ])) {
2019-11-13 19:37:08 +01:00
$newuser = new User ( $db );
2017-11-25 00:12:45 +01:00
$newuser -> fetch ( $event -> userownerid );
2019-11-13 19:37:08 +01:00
$cacheusers [ $event -> userownerid ] = $newuser ;
2017-11-25 00:12:45 +01:00
}
//var_dump($cacheusers[$event->userownerid]->color);
// We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
2021-02-23 18:59:19 +01:00
if ( ! empty ( $cacheusers [ $event -> userownerid ] -> color )) {
$color = $cacheusers [ $event -> userownerid ] -> color ;
}
2017-11-25 00:12:45 +01:00
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> global -> AGENDA_USE_COLOR_PER_EVENT_TYPE )) {
$color = $event -> type_color ;
}
} elseif ( $event -> type_code == 'ICALEVENT' ) {
2014-09-05 21:12:01 +02:00
$numical ++ ;
2021-02-23 18:59:19 +01:00
if ( ! empty ( $event -> icalname )) {
2019-11-13 19:37:08 +01:00
if ( ! isset ( $numicals [ dol_string_nospecial ( $event -> icalname )])) {
2014-09-05 21:12:01 +02:00
$numicals [ dol_string_nospecial ( $event -> icalname )] = 0 ;
}
$numicals [ dol_string_nospecial ( $event -> icalname )] ++ ;
}
2014-09-29 13:21:03 +02:00
2019-11-13 19:37:08 +01:00
$color = $event -> icalcolor ;
$cssclass = ( ! empty ( $event -> icalname ) ? 'family_ext' . md5 ( $event -> icalname ) : 'family_other unsortable' );
2021-02-23 18:59:19 +01:00
} elseif ( $event -> type_code == 'BIRTHDAY' ) {
2019-11-13 19:37:08 +01:00
$numbirthday ++ ; $colorindex = 2 ; $cssclass = 'family_birthday unsortable' ; $color = sprintf ( " %02x%02x%02x " , $theme_datacolor [ $colorindex ][ 0 ], $theme_datacolor [ $colorindex ][ 1 ], $theme_datacolor [ $colorindex ][ 2 ]);
2020-05-21 15:05:19 +02:00
} else {
2017-11-25 00:12:45 +01:00
$numother ++ ;
2019-11-13 19:37:08 +01:00
$color = ( $event -> icalcolor ? $event -> icalcolor : - 1 );
$cssclass = ( ! empty ( $event -> icalname ) ? 'family_ext' . md5 ( $event -> icalname ) : 'family_other' );
2017-11-25 00:12:45 +01:00
2021-02-23 18:59:19 +01:00
if ( empty ( $cacheusers [ $event -> userownerid ])) {
2019-11-13 19:37:08 +01:00
$newuser = new User ( $db );
2017-11-25 00:12:45 +01:00
$newuser -> fetch ( $event -> userownerid );
2019-11-13 19:37:08 +01:00
$cacheusers [ $event -> userownerid ] = $newuser ;
2017-11-25 00:12:45 +01:00
}
//var_dump($cacheusers[$event->userownerid]->color);
// We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
2021-02-23 18:59:19 +01:00
if ( ! empty ( $cacheusers [ $event -> userownerid ] -> color )) {
$color = $cacheusers [ $event -> userownerid ] -> color ;
}
2017-11-25 00:12:45 +01:00
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> global -> AGENDA_USE_COLOR_PER_EVENT_TYPE )) {
$color = $event -> type_color ;
}
2014-09-05 21:12:01 +02:00
}
2014-10-03 18:04:13 +02:00
2021-02-23 18:59:19 +01:00
if ( $color < 0 ) { // Color was not set on user card. Set color according to color index.
2014-09-05 21:12:01 +02:00
// Define color index if not yet defined
2019-11-13 19:37:08 +01:00
$idusertouse = ( $event -> userownerid ? $event -> userownerid : 0 );
2021-02-23 18:59:19 +01:00
if ( isset ( $colorindexused [ $idusertouse ])) {
2019-11-13 19:37:08 +01:00
$colorindex = $colorindexused [ $idusertouse ]; // Color already assigned to this user
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:37:08 +01:00
$colorindex = $nextindextouse ;
$colorindexused [ $idusertouse ] = $colorindex ;
2021-02-23 18:59:19 +01:00
if ( ! empty ( $theme_datacolor [ $nextindextouse + 1 ])) {
$nextindextouse ++ ; // Prepare to use next color
}
2014-09-05 21:12:01 +02:00
}
// Define color
2019-11-13 19:37:08 +01:00
$color = sprintf ( " %02x%02x%02x " , $theme_datacolor [ $colorindex ][ 0 ], $theme_datacolor [ $colorindex ][ 1 ], $theme_datacolor [ $colorindex ][ 2 ]);
2014-09-05 21:12:01 +02:00
}
2014-09-23 17:54:03 +02:00
// Define all rects with event (cases1 is first half hour, cases2 is second half hour)
2021-02-23 18:59:19 +01:00
for ( $h = $begin_h ; $h < $end_h ; $h ++ ) {
2014-09-28 16:54:42 +02:00
//if ($username->id == 1 && $day==1) print 'h='.$h;
2014-09-29 13:21:03 +02:00
$newcolor = '' ; //init
2021-02-23 18:59:19 +01:00
if ( empty ( $event -> fulldayevent )) {
2021-02-07 19:44:22 +01:00
$a = dol_mktime (( int ) $h , 0 , 0 , $month , $day , $year , 'tzuserrel' , 0 );
$b = dol_mktime (( int ) $h , 30 , 0 , $month , $day , $year , 'tzuserrel' , 0 );
$c = dol_mktime (( int ) $h + 1 , 0 , 0 , $month , $day , $year , 'tzuserrel' , 0 );
2014-09-05 21:12:01 +02:00
2019-12-18 15:20:36 +01:00
$dateendtouse = $event -> date_end_in_calendar ;
2021-02-23 18:59:19 +01:00
if ( $dateendtouse == $event -> date_start_in_calendar ) {
$dateendtouse ++ ;
}
2014-09-08 10:24:16 +02:00
2014-09-29 13:21:03 +02:00
//print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>';
2021-02-23 18:59:19 +01:00
if ( $event -> date_start_in_calendar < $b && $dateendtouse > $a ) {
2019-12-18 15:20:36 +01:00
$busy = $event -> transparency ;
$cases1 [ $h ][ $event -> id ][ 'busy' ] = $busy ;
2021-02-07 19:44:22 +01:00
$cases1 [ $h ][ $event -> id ][ 'string' ] = dol_print_date ( $event -> date_start_in_calendar , 'dayhour' , 'tzuserrel' );
2021-02-23 18:59:19 +01:00
if ( $event -> date_end_in_calendar && $event -> date_end_in_calendar != $event -> date_start_in_calendar ) {
2020-10-31 14:32:18 +01:00
$tmpa = dol_getdate ( $event -> date_start_in_calendar , true );
$tmpb = dol_getdate ( $event -> date_end_in_calendar , true );
2021-02-23 18:59:19 +01:00
if ( $tmpa [ 'mday' ] == $tmpb [ 'mday' ] && $tmpa [ 'mon' ] == $tmpb [ 'mon' ] && $tmpa [ 'year' ] == $tmpb [ 'year' ]) {
$cases1 [ $h ][ $event -> id ][ 'string' ] .= '-' . dol_print_date ( $event -> date_end_in_calendar , 'hour' , 'tzuserrel' );
} else {
$cases1 [ $h ][ $event -> id ][ 'string' ] .= '-' . dol_print_date ( $event -> date_end_in_calendar , 'dayhour' , 'tzuserrel' );
}
}
if ( $event -> label ) {
$cases1 [ $h ][ $event -> id ][ 'string' ] .= ' - ' . $event -> label ;
2020-10-31 14:32:18 +01:00
}
2019-12-18 15:20:36 +01:00
$cases1 [ $h ][ $event -> id ][ 'typecode' ] = $event -> type_code ;
$cases1 [ $h ][ $event -> id ][ 'color' ] = $color ;
2021-02-23 18:59:19 +01:00
if ( $event -> fk_project > 0 ) {
if ( empty ( $cacheprojects [ $event -> fk_project ])) {
2019-12-18 15:20:36 +01:00
$tmpproj = new Project ( $db );
2017-07-29 04:07:46 +02:00
$tmpproj -> fetch ( $event -> fk_project );
2019-12-18 15:20:36 +01:00
$cacheprojects [ $event -> fk_project ] = $tmpproj ;
2017-07-29 04:07:46 +02:00
}
2019-12-18 15:20:36 +01:00
$cases1 [ $h ][ $event -> id ][ 'string' ] .= ', ' . $langs -> trans ( " Project " ) . ': ' . $cacheprojects [ $event -> fk_project ] -> ref . ' - ' . $cacheprojects [ $event -> fk_project ] -> title ;
2017-07-29 04:07:46 +02:00
}
2021-02-23 18:59:19 +01:00
if ( $event -> socid > 0 ) {
if ( empty ( $cachethirdparties [ $event -> socid ])) {
2019-12-18 15:20:36 +01:00
$tmpthirdparty = new Societe ( $db );
2017-07-29 04:07:46 +02:00
$tmpthirdparty -> fetch ( $event -> socid );
2019-12-18 15:20:36 +01:00
$cachethirdparties [ $event -> socid ] = $tmpthirdparty ;
2017-07-29 04:07:46 +02:00
}
2019-12-18 15:20:36 +01:00
$cases1 [ $h ][ $event -> id ][ 'string' ] .= ', ' . $cachethirdparties [ $event -> socid ] -> name ;
2017-07-29 04:07:46 +02:00
}
2021-02-23 18:59:19 +01:00
if ( $event -> contact_id > 0 ) {
if ( empty ( $cachecontacts [ $event -> contact_id ])) {
2019-12-18 15:20:36 +01:00
$tmpcontact = new Contact ( $db );
2020-06-25 12:17:47 +02:00
$tmpcontact -> fetch ( $event -> contact_id );
$cachecontacts [ $event -> contact_id ] = $tmpcontact ;
2017-07-29 04:07:46 +02:00
}
2020-06-25 12:17:47 +02:00
$cases1 [ $h ][ $event -> id ][ 'string' ] .= ', ' . $cachecontacts [ $event -> contact_id ] -> getFullName ( $langs );
2014-09-23 17:54:03 +02:00
}
2014-09-05 21:12:01 +02:00
}
2021-02-23 18:59:19 +01:00
if ( $event -> date_start_in_calendar < $c && $dateendtouse > $b ) {
2019-12-18 15:20:36 +01:00
$busy = $event -> transparency ;
$cases2 [ $h ][ $event -> id ][ 'busy' ] = $busy ;
2021-02-07 19:44:22 +01:00
$cases2 [ $h ][ $event -> id ][ 'string' ] = dol_print_date ( $event -> date_start_in_calendar , 'dayhour' , 'tzuserrel' );
2021-02-23 18:59:19 +01:00
if ( $event -> date_end_in_calendar && $event -> date_end_in_calendar != $event -> date_start_in_calendar ) {
2020-10-31 14:32:18 +01:00
$tmpa = dol_getdate ( $event -> date_start_in_calendar , true );
$tmpb = dol_getdate ( $event -> date_end_in_calendar , true );
2021-02-23 18:59:19 +01:00
if ( $tmpa [ 'mday' ] == $tmpb [ 'mday' ] && $tmpa [ 'mon' ] == $tmpb [ 'mon' ] && $tmpa [ 'year' ] == $tmpb [ 'year' ]) {
$cases2 [ $h ][ $event -> id ][ 'string' ] .= '-' . dol_print_date ( $event -> date_end_in_calendar , 'hour' , 'tzuserrel' );
} else {
$cases2 [ $h ][ $event -> id ][ 'string' ] .= '-' . dol_print_date ( $event -> date_end_in_calendar , 'dayhour' , 'tzuserrel' );
}
}
if ( $event -> label ) {
$cases2 [ $h ][ $event -> id ][ 'string' ] .= ' - ' . $event -> label ;
2020-10-31 14:32:18 +01:00
}
2019-12-18 15:20:36 +01:00
$cases2 [ $h ][ $event -> id ][ 'typecode' ] = $event -> type_code ;
$cases2 [ $h ][ $event -> id ][ 'color' ] = $color ;
2021-02-23 18:59:19 +01:00
if ( $event -> fk_project > 0 ) {
if ( empty ( $cacheprojects [ $event -> fk_project ])) {
2019-12-18 15:20:36 +01:00
$tmpproj = new Project ( $db );
2017-07-29 04:07:46 +02:00
$tmpproj -> fetch ( $event -> fk_project );
2019-12-18 15:20:36 +01:00
$cacheprojects [ $event -> fk_project ] = $tmpproj ;
2017-07-29 04:07:46 +02:00
}
2019-12-18 15:20:36 +01:00
$cases2 [ $h ][ $event -> id ][ 'string' ] .= ', ' . $langs -> trans ( " Project " ) . ': ' . $cacheprojects [ $event -> fk_project ] -> ref . ' - ' . $cacheprojects [ $event -> fk_project ] -> title ;
2017-07-29 04:07:46 +02:00
}
2021-02-23 18:59:19 +01:00
if ( $event -> socid > 0 ) {
if ( empty ( $cachethirdparties [ $event -> socid ])) {
2019-12-18 15:20:36 +01:00
$tmpthirdparty = new Societe ( $db );
2017-07-29 04:07:46 +02:00
$tmpthirdparty -> fetch ( $event -> socid );
2019-12-18 15:20:36 +01:00
$cachethirdparties [ $event -> socid ] = $tmpthirdparty ;
2017-07-29 04:07:46 +02:00
}
2019-12-18 15:20:36 +01:00
$cases2 [ $h ][ $event -> id ][ 'string' ] .= ', ' . $cachethirdparties [ $event -> socid ] -> name ;
2017-07-29 04:07:46 +02:00
}
2021-02-23 18:59:19 +01:00
if ( $event -> contact_id > 0 ) {
if ( empty ( $cachecontacts [ $event -> contact_id ])) {
2019-12-18 15:20:36 +01:00
$tmpcontact = new Contact ( $db );
2020-06-25 12:17:47 +02:00
$tmpcontact -> fetch ( $event -> contact_id );
$cachecontacts [ $event -> contact_id ] = $tmpcontact ;
2017-07-29 04:07:46 +02:00
}
2020-06-25 12:17:47 +02:00
$cases2 [ $h ][ $event -> id ][ 'string' ] .= ', ' . $cachecontacts [ $event -> contact_id ] -> getFullName ( $langs );
2014-09-23 17:54:03 +02:00
}
2014-09-05 21:12:01 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2019-12-18 15:20:36 +01:00
$busy = $event -> transparency ;
$cases1 [ $h ][ $event -> id ][ 'busy' ] = $busy ;
$cases2 [ $h ][ $event -> id ][ 'busy' ] = $busy ;
$cases1 [ $h ][ $event -> id ][ 'string' ] = $event -> label ;
$cases2 [ $h ][ $event -> id ][ 'string' ] = $event -> label ;
$cases1 [ $h ][ $event -> id ][ 'typecode' ] = $event -> type_code ;
$cases2 [ $h ][ $event -> id ][ 'typecode' ] = $event -> type_code ;
$cases1 [ $h ][ $event -> id ][ 'color' ] = $color ;
$cases2 [ $h ][ $event -> id ][ 'color' ] = $color ;
2014-09-05 21:12:01 +02:00
}
}
$i ++ ;
}
2014-09-05 13:48:55 +02:00
2019-12-18 15:20:36 +01:00
break ; // We found the date we were looking for. No need to search anymore.
2014-09-05 21:12:01 +02:00
}
}
2014-09-05 13:48:55 +02:00
2017-07-29 01:59:26 +02:00
// Now output $casesX
2021-02-23 18:59:19 +01:00
for ( $h = $begin_h ; $h < $end_h ; $h ++ ) {
2019-12-18 15:20:36 +01:00
$color1 = '' ; $color2 = '' ;
$style1 = '' ; $style2 = '' ;
$string1 = ' ' ; $string2 = ' ' ;
$title1 = '' ; $title2 = '' ;
2021-02-23 18:59:19 +01:00
if ( isset ( $cases1 [ $h ]) && $cases1 [ $h ] != '' ) {
2014-10-05 01:22:17 +02:00
//$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
2021-02-23 18:59:19 +01:00
if ( count ( $cases1 [ $h ]) > 1 ) {
$title1 .= count ( $cases1 [ $h ]) . ' ' . ( count ( $cases1 [ $h ]) == 1 ? $langs -> trans ( " Event " ) : $langs -> trans ( " Events " ));
}
2019-12-18 15:20:36 +01:00
$string1 = ' ' ;
2021-02-23 18:59:19 +01:00
if ( empty ( $conf -> global -> AGENDA_NO_TRANSPARENT_ON_NOT_BUSY )) {
$style1 = 'peruser_notbusy' ;
} else {
$style1 = 'peruser_busy' ;
}
foreach ( $cases1 [ $h ] as $id => $ev ) {
if ( $ev [ 'busy' ]) {
$style1 = 'peruser_busy' ;
}
2014-09-05 13:48:55 +02:00
}
}
2021-02-23 18:59:19 +01:00
if ( isset ( $cases2 [ $h ]) && $cases2 [ $h ] != '' ) {
2014-10-05 01:22:17 +02:00
//$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
2021-02-23 18:59:19 +01:00
if ( count ( $cases2 [ $h ]) > 1 ) {
$title2 .= count ( $cases2 [ $h ]) . ' ' . ( count ( $cases2 [ $h ]) == 1 ? $langs -> trans ( " Event " ) : $langs -> trans ( " Events " ));
}
2019-12-18 15:20:36 +01:00
$string2 = ' ' ;
2021-02-23 18:59:19 +01:00
if ( empty ( $conf -> global -> AGENDA_NO_TRANSPARENT_ON_NOT_BUSY )) {
$style2 = 'peruser_notbusy' ;
} else {
$style2 = 'peruser_busy' ;
}
foreach ( $cases2 [ $h ] as $id => $ev ) {
if ( $ev [ 'busy' ]) {
$style2 = 'peruser_busy' ;
}
2014-09-05 13:48:55 +02:00
}
}
2019-12-18 15:20:36 +01:00
$ids1 = '' ;
2020-10-31 14:32:18 +01:00
$ids2 = '' ;
2021-08-25 12:02:57 +02:00
if ( ! empty ( $cases1 [ $h ]) && is_array ( $cases1 [ $h ]) && count ( $cases1 [ $h ]) && array_keys ( $cases1 [ $h ])) {
2021-02-23 18:59:19 +01:00
$ids1 = join ( ',' , array_keys ( $cases1 [ $h ]));
}
2021-08-25 12:02:57 +02:00
if ( ! empty ( $cases2 [ $h ]) && is_array ( $cases2 [ $h ]) && count ( $cases2 [ $h ]) && array_keys ( $cases2 [ $h ])) {
2021-02-23 18:59:19 +01:00
$ids2 = join ( ',' , array_keys ( $cases2 [ $h ]));
}
2014-09-05 13:48:55 +02:00
2021-02-23 18:59:19 +01:00
if ( $h == $begin_h ) {
echo '<td class="' . $style . '_peruserleft cal_peruser' . ( $var ? ' cal_impair ' . $style . '_impair' : '' ) . '">' ;
} else {
echo '<td class="' . $style . ' cal_peruser' . ( $var ? ' cal_impair ' . $style . '_impair' : '' ) . '">' ;
}
2021-08-25 12:02:57 +02:00
if ( ! empty ( $cases1 [ $h ]) && is_array ( $cases1 [ $h ]) && count ( $cases1 [ $h ]) == 1 ) { // only 1 event
2014-09-08 10:24:16 +02:00
$output = array_slice ( $cases1 [ $h ], 0 , 1 );
2019-12-18 15:20:36 +01:00
$title1 = $langs -> trans ( " Ref " ) . ' ' . $ids1 . ( $title1 ? ' - ' . $title1 : '' );
2021-02-23 18:59:19 +01:00
if ( $output [ 0 ][ 'string' ]) {
$title1 .= ( $title1 ? ' - ' : '' ) . $output [ 0 ][ 'string' ];
}
if ( $output [ 0 ][ 'color' ]) {
$color1 = $output [ 0 ][ 'color' ];
}
2021-08-25 12:02:57 +02:00
} elseif ( ! empty ( $cases1 [ $h ]) && is_array ( $cases1 [ $h ]) && count ( $cases1 [ $h ]) > 1 ) {
2019-12-18 15:20:36 +01:00
$title1 = $langs -> trans ( " Ref " ) . ' ' . $ids1 . ( $title1 ? ' - ' . $title1 : '' );
$color1 = '222222' ;
2015-08-14 12:31:09 +02:00
}
2014-09-29 13:21:03 +02:00
2021-08-25 12:02:57 +02:00
if ( ! empty ( $cases2 [ $h ]) && is_array ( $cases2 [ $h ]) && count ( $cases2 [ $h ]) == 1 ) { // only 1 event
2014-09-08 10:24:16 +02:00
$output = array_slice ( $cases2 [ $h ], 0 , 1 );
2019-12-18 15:20:36 +01:00
$title2 = $langs -> trans ( " Ref " ) . ' ' . $ids2 . ( $title2 ? ' - ' . $title2 : '' );
2021-02-23 18:59:19 +01:00
if ( $output [ 0 ][ 'string' ]) {
$title2 .= ( $title2 ? ' - ' : '' ) . $output [ 0 ][ 'string' ];
}
if ( $output [ 0 ][ 'color' ]) {
$color2 = $output [ 0 ][ 'color' ];
}
2021-08-25 12:02:57 +02:00
} elseif ( ! empty ( $cases2 [ $h ]) && is_array ( $cases2 [ $h ]) && count ( $cases2 [ $h ]) > 1 ) {
2019-12-18 15:20:36 +01:00
$title2 = $langs -> trans ( " Ref " ) . ' ' . $ids2 . ( $title2 ? ' - ' . $title2 : '' );
$color2 = '222222' ;
2015-08-14 12:31:09 +02:00
}
2014-09-07 19:56:17 +02:00
print '<table class="nobordernopadding" width="100%">' ;
2017-11-25 00:12:45 +01:00
print '<tr><td ' ;
2021-02-23 18:59:19 +01:00
if ( $style1 == 'peruser_notbusy' ) {
print 'style="border: 1px solid #' . ( $color1 ? $color1 : " 888 " ) . ' !important" ' ;
} elseif ( $color1 ) {
2019-12-18 15:20:36 +01:00
print ( $color1 ? 'style="background: #' . $color1 . ';"' : '' );
2017-11-25 00:12:45 +01:00
}
print 'class="' ;
2019-12-18 15:20:36 +01:00
print ( $style1 ? $style1 . ' ' : '' );
2022-01-16 13:22:21 +01:00
print 'onclickopenref center' . ( $title2 ? ' classfortooltip' : '' ) . ( $title1 ? ' cursorpointer' : '' ) . '" ref="ref_' . $username -> id . '_' . sprintf ( " %04d " , $year ) . '_' . sprintf ( " %02d " , $month ) . '_' . sprintf ( " %02d " , $day ) . '_' . sprintf ( " %02d " , $h ) . '_00_' . ( $ids1 ? $ids1 : 'none' ) . '"' . ( $title1 ? ' title="' . $title1 . '"' : '' ) . '>' ;
2014-09-05 21:12:01 +02:00
print $string1 ;
2017-11-25 00:12:45 +01:00
print '</td><td ' ;
2021-02-23 18:59:19 +01:00
if ( $style2 == 'peruser_notbusy' ) {
print 'style="border: 1px solid #' . ( $color2 ? $color2 : " 888 " ) . ' !important" ' ;
} elseif ( $color2 ) {
2019-12-18 15:20:36 +01:00
print ( $color2 ? 'style="background: #' . $color2 . ';"' : '' );
2017-11-25 00:12:45 +01:00
}
print 'class="' ;
2019-12-18 15:20:36 +01:00
print ( $style2 ? $style2 . ' ' : '' );
2022-01-16 13:22:21 +01:00
print 'onclickopenref center' . ( $title2 ? ' classfortooltip' : '' ) . ( $title1 ? ' cursorpointer' : '' ) . '" ref="ref_' . $username -> id . '_' . sprintf ( " %04d " , $year ) . '_' . sprintf ( " %02d " , $month ) . '_' . sprintf ( " %02d " , $day ) . '_' . sprintf ( " %02d " , $h ) . '_30_' . ( $ids2 ? $ids2 : 'none' ) . '"' . ( $title2 ? ' title="' . $title2 . '"' : '' ) . '>' ;
2014-09-05 21:12:01 +02:00
print $string2 ;
print '</td></tr>' ;
print '</table>' ;
print '</td>' ;
}
2014-09-05 13:48:55 +02:00
}