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 >
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
* Copyright ( C ) 2011 Juanjo Menent < jmenent @ 2 byte . es >
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
/**
* \file htdocs / comm / action / peruser . php
* \ingroup agenda
* \brief Tab of calendar events per user
*/
require '../../main.inc.php' ;
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/agenda.lib.php' ;
if ( ! empty ( $conf -> projet -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
}
if ( ! isset ( $conf -> global -> AGENDA_MAX_EVENTS_DAY_VIEW )) $conf -> global -> AGENDA_MAX_EVENTS_DAY_VIEW = 3 ;
$filter = GETPOST ( " filter " , '' , 3 );
$filtera = GETPOST ( " userasked " , " int " , 3 ) ? GETPOST ( " userasked " , " int " , 3 ) : GETPOST ( " filtera " , " int " , 3 );
$filtert = GETPOST ( " usertodo " , " int " , 3 ) ? GETPOST ( " usertodo " , " int " , 3 ) : GETPOST ( " filtert " , " int " , 3 );
$filterd = GETPOST ( " userdone " , " int " , 3 ) ? GETPOST ( " userdone " , " int " , 3 ) : GETPOST ( " filterd " , " int " , 3 );
$usergroup = GETPOST ( " usergroup " , " int " , 3 );
$showbirthday = empty ( $conf -> use_javascript_ajax ) ? GETPOST ( " showbirthday " , " int " ) : 1 ;
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
$page = GETPOST ( " page " , " int " );
if ( $page == - 1 ) { $page = 0 ; }
$limit = $conf -> liste_limit ;
$offset = $limit * $page ;
if ( ! $sortorder ) $sortorder = " ASC " ;
if ( ! $sortfield ) $sortfield = " a.datec " ;
// Security check
$socid = GETPOST ( " socid " , " int " );
if ( $user -> societe_id ) $socid = $user -> societe_id ;
$result = restrictedArea ( $user , 'agenda' , 0 , '' , 'myactions' );
if ( $socid < 0 ) $socid = '' ;
$canedit = 1 ;
if ( ! $user -> rights -> agenda -> myactions -> read ) accessforbidden ();
if ( ! $user -> rights -> agenda -> allactions -> read ) $canedit = 0 ;
if ( ! $user -> rights -> agenda -> allactions -> read || $filter == 'mine' ) // If no permission to see all, we show only affected to me
{
$filtera = $user -> id ;
$filtert = $user -> id ;
$filterd = $user -> id ;
}
$action = GETPOST ( 'action' , 'alpha' );
//$year=GETPOST("year");
$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 " ) : 0 ;
$pid = GETPOST ( " projectid " , " int " , 3 );
$status = GETPOST ( " status " );
$type = GETPOST ( " type " );
$maxprint = ( isset ( $_GET [ " maxprint " ]) ? GETPOST ( " maxprint " ) : $conf -> global -> AGENDA_MAX_EVENTS_DAY_VIEW );
$actioncode = GETPOST ( " actioncode " , " alpha " , 3 ) ? GETPOST ( " actioncode " , " alpha " , 3 ) : ( GETPOST ( " actioncode " ) == '0' ? '0' : '' );
if ( $actioncode == '' ) $actioncode = ( empty ( $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE ) ? '' : $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE );
if ( $status == '' ) $status = ( empty ( $conf -> global -> AGENDA_DEFAULT_FILTER_STATUS ) ? '' : $conf -> global -> AGENDA_DEFAULT_FILTER_STATUS );
if ( empty ( $action )) $action = ( empty ( $conf -> global -> AGENDA_DEFAULT_VIEW ) ? 'show_month' : $conf -> global -> AGENDA_DEFAULT_VIEW );
if ( GETPOST ( 'viewcal' ) && $action != 'show_day' && $action != 'show_week' ) {
$action = 'show_month' ; $day = '' ;
} // View by month
if ( GETPOST ( 'viewweek' ) || $action == 'show_week' ) {
$action = 'show_week' ; $week = ( $week ? $week : date ( " W " )); $day = ( $day ? $day : date ( " d " ));
} // View by week
if ( GETPOST ( 'viewday' ) || $action == 'show_day' ) {
$action = 'show_day' ; $day = ( $day ? $day : date ( " d " ));
} // View by day
$langs -> load ( " agenda " );
$langs -> load ( " other " );
$langs -> load ( " commercial " );
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager -> initHooks ( array ( 'agenda' ));
/*
* Actions
*/
// None
/*
* View
*/
$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda' ;
llxHeader ( '' , $langs -> trans ( " Agenda " ), $help_url );
$form = new Form ( $db );
$companystatic = new Societe ( $db );
$contactstatic = new Contact ( $db );
$now = dol_now ();
$nowarray = dol_getdate ( $now );
$nowyear = $nowarray [ 'year' ];
$nowmonth = $nowarray [ 'mon' ];
$nowday = $nowarray [ 'mday' ];
// Define list of all external calendars
$listofextcals = array ();
if ( empty ( $conf -> global -> AGENDA_DISABLE_EXT ) && $conf -> global -> AGENDA_EXT_NB > 0 )
{
$i = 0 ;
while ( $i < $conf -> global -> AGENDA_EXT_NB )
{
$i ++ ;
$source = 'AGENDA_EXT_SRC' . $i ;
$name = 'AGENDA_EXT_NAME' . $i ;
$color = 'AGENDA_EXT_COLOR' . $i ;
$buggedfile = 'AGENDA_EXT_BUGGEDFILE' . $i ;
if ( ! empty ( $conf -> global -> $source ) && ! empty ( $conf -> global -> $name ))
{
// Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
$listofextcals [] = array ( 'src' => $conf -> global -> $source , 'name' => $conf -> global -> $name , 'color' => $conf -> global -> $color , 'buggedfile' => ( isset ( $conf -> global -> buggedfile ) ? $conf -> global -> buggedfile : 0 ));
}
}
}
if ( empty ( $action ) || $action == 'show_month' )
{
$prev = dol_get_prev_month ( $month , $year );
$prev_year = $prev [ 'year' ];
$prev_month = $prev [ 'month' ];
$next = dol_get_next_month ( $month , $year );
$next_year = $next [ 'year' ];
$next_month = $next [ 'month' ];
$max_day_in_prev_month = date ( " t " , dol_mktime ( 0 , 0 , 0 , $prev_month , 1 , $prev_year )); // Nb of days in previous month
$max_day_in_month = date ( " t " , dol_mktime ( 0 , 0 , 0 , $month , 1 , $year )); // Nb of days in next month
// tmpday is a negative or null cursor to know how many days before the 1 to show on month view (if tmpday=0 we start on monday)
$tmpday = - date ( " w " , dol_mktime ( 0 , 0 , 0 , $month , 1 , $year )) + 2 ;
$tmpday += (( isset ( $conf -> global -> MAIN_START_WEEK ) ? $conf -> global -> MAIN_START_WEEK : 1 ) - 1 );
if ( $tmpday >= 1 ) $tmpday -= 7 ;
// Define firstdaytoshow and lastdaytoshow
$firstdaytoshow = dol_mktime ( 0 , 0 , 0 , $prev_month , $max_day_in_prev_month + $tmpday , $prev_year );
$next_day = 7 - ( $max_day_in_month + 1 - $tmpday ) % 7 ;
if ( $next_day < 6 ) $next_day += 7 ;
$lastdaytoshow = dol_mktime ( 0 , 0 , 0 , $next_month , $next_day , $next_year );
}
if ( $action == 'show_week' )
{
$prev = dol_get_first_day_week ( $day , $month , $year );
$prev_year = $prev [ 'prev_year' ];
$prev_month = $prev [ 'prev_month' ];
$prev_day = $prev [ 'prev_day' ];
$first_day = $prev [ 'first_day' ];
$week = $prev [ 'week' ];
$day = ( int ) $day ;
$next = dol_get_next_week ( $day , $week , $month , $year );
$next_year = $next [ 'year' ];
$next_month = $next [ 'month' ];
$next_day = $next [ 'day' ];
// Define firstdaytoshow and lastdaytoshow
$firstdaytoshow = dol_mktime ( 0 , 0 , 0 , $prev_month , $first_day , $prev_year );
$lastdaytoshow = dol_mktime ( 0 , 0 , 0 , $next_month , $next_day , $next_year );
$max_day_in_month = date ( " t " , dol_mktime ( 0 , 0 , 0 , $month , 1 , $year ));
$tmpday = $first_day ;
}
if ( $action == 'show_day' )
{
$prev = dol_get_prev_day ( $day , $month , $year );
$prev_year = $prev [ 'year' ];
$prev_month = $prev [ 'month' ];
$prev_day = $prev [ 'day' ];
$next = dol_get_next_day ( $day , $month , $year );
$next_year = $next [ 'year' ];
$next_month = $next [ 'month' ];
$next_day = $next [ 'day' ];
// Define firstdaytoshow and lastdaytoshow
$firstdaytoshow = dol_mktime ( 0 , 0 , 0 , $prev_month , $prev_day , $prev_year );
$lastdaytoshow = dol_mktime ( 0 , 0 , 0 , $next_month , $next_day , $next_year );
}
//print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day;
//print 'xx'.$next_year.'-'.$next_month.'-'.$next_day;
//print dol_print_date($firstdaytoshow,'day');
//print dol_print_date($lastdaytoshow,'day');
$title = $langs -> trans ( " DoneAndToDoActions " );
if ( $status == 'done' ) $title = $langs -> trans ( " DoneActions " );
if ( $status == 'todo' ) $title = $langs -> trans ( " ToDoActions " );
$param = '' ;
if ( $status ) $param = " &status= " . $status ;
if ( $filter ) $param .= " &filter= " . $filter ;
if ( $filtera ) $param .= " &filtera= " . $filtera ;
if ( $filtert ) $param .= " &filtert= " . $filtert ;
if ( $filterd ) $param .= " &filterd= " . $filterd ;
if ( $socid ) $param .= " &socid= " . $socid ;
if ( $showbirthday ) $param .= " &showbirthday=1 " ;
if ( $pid ) $param .= " &projectid= " . $pid ;
if ( $actioncode != '' ) $param .= " &actioncode= " . $actioncode ;
if ( $type ) $param .= " &type= " . $type ;
if ( $action == 'show_day' || $action == 'show_week' ) $param .= '&action=' . $action ;
$param .= " &maxprint= " . $maxprint ;
// Show navigation bar
if ( empty ( $action ) || $action == 'show_month' )
{
$nav = " <a href= \" ?year= " . $prev_year . " &month= " . $prev_month . $param . " \" > " . img_previous ( $langs -> trans ( " Previous " )) . " </a> \n " ;
$nav .= " <span id= \" month_name \" > " . dol_print_date ( dol_mktime ( 0 , 0 , 0 , $month , 1 , $year ), " %b %Y " );
$nav .= " </span> \n " ;
$nav .= " <a href= \" ?year= " . $next_year . " &month= " . $next_month . $param . " \" > " . img_next ( $langs -> trans ( " Next " )) . " </a> \n " ;
$nav .= " (<a href= \" ?year= " . $nowyear . " &month= " . $nowmonth . $param . " \" > " . $langs -> trans ( " Today " ) . " </a>) " ;
$picto = 'calendar' ;
}
if ( $action == 'show_week' )
{
$nav = " <a href= \" ?year= " . $prev_year . " &month= " . $prev_month . " &day= " . $prev_day . $param . " \" > " . img_previous ( $langs -> trans ( " Previous " )) . " </a> \n " ;
$nav .= " <span id= \" month_name \" > " . dol_print_date ( dol_mktime ( 0 , 0 , 0 , $month , 1 , $year ), " %Y " ) . " , " . $langs -> trans ( " Week " ) . " " . $week ;
$nav .= " </span> \n " ;
$nav .= " <a href= \" ?year= " . $next_year . " &month= " . $next_month . " &day= " . $next_day . $param . " \" > " . img_next ( $langs -> trans ( " Next " )) . " </a> \n " ;
$nav .= " (<a href= \" ?year= " . $nowyear . " &month= " . $nowmonth . " &day= " . $nowday . $param . " \" > " . $langs -> trans ( " Today " ) . " </a>) " ;
$picto = 'calendarweek' ;
}
if ( $action == 'show_day' )
{
$nav = " <a href= \" ?year= " . $prev_year . " &month= " . $prev_month . " &day= " . $prev_day . $param . " \" > " . img_previous ( $langs -> trans ( " Previous " )) . " </a> \n " ;
$nav .= " <span id= \" month_name \" > " . dol_print_date ( dol_mktime ( 0 , 0 , 0 , $month , $day , $year ), " daytextshort " );
$nav .= " </span> \n " ;
$nav .= " <a href= \" ?year= " . $next_year . " &month= " . $next_month . " &day= " . $next_day . $param . " \" > " . img_next ( $langs -> trans ( " Next " )) . " </a> \n " ;
$nav .= " (<a href= \" ?year= " . $nowyear . " &month= " . $nowmonth . " &day= " . $nowday . $param . " \" > " . $langs -> trans ( " Today " ) . " </a>) " ;
$picto = 'calendarday' ;
}
// Must be after the nav definition
$param .= '&year=' . $year . '&month=' . $month . ( $day ? '&day=' . $day : '' );
//print 'x'.$param;
$tabactive = 'cardperuser' ;
$paramnoaction = preg_replace ( '/action=[a-z_]+/' , '' , $param );
$head = calendars_prepare_head ( $paramnoaction );
dol_fiche_head ( $head , $tabactive , $langs -> trans ( 'Agenda' ), 0 , 'action' );
2014-07-19 22:37:18 +02:00
print_actions_filter ( $form , $canedit , $status , $year , $month , $day , $showbirthday , $filtera , $filtert , $filterd , $pid , $socid , $action , $listofextcals , $actioncode , $usergroup );
2014-07-11 13:55:15 +02:00
dol_fiche_end ();
print_fiche_titre ( $s , $link . ' ' . $nav , '' );
// Get event in an array
$eventarray = array ();
$sql = 'SELECT a.id,a.label,' ;
$sql .= ' a.datep,' ;
$sql .= ' a.datep2,' ;
$sql .= ' a.datea,' ;
$sql .= ' a.datea2,' ;
$sql .= ' a.percent,' ;
$sql .= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,' ;
$sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,' ;
$sql .= ' a.fk_soc, a.fk_contact,' ;
$sql .= ' ca.code' ;
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_actioncomm as ca, ' . MAIN_DB_PREFIX . " actioncomm as a " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe_commerciaux as sc ON a.fk_soc = sc.fk_soc " ;
if ( $usergroup > 0 ) $sql .= " , " . MAIN_DB_PREFIX . " usergroup_user as ugu " ;
$sql .= ' WHERE a.fk_action = ca.id' ;
$sql .= ' AND a.entity IN (' . getEntity ( 'agenda' , 1 ) . ')' ;
if ( $actioncode ) $sql .= " AND ca.code=' " . $db -> escape ( $actioncode ) . " ' " ;
if ( $pid ) $sql .= " AND a.fk_project= " . $db -> escape ( $pid );
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . $user -> id . " ) " ;
if ( $socid > 0 ) $sql .= ' AND a.fk_soc = ' . $socid ;
if ( $usergroup > 0 ) $sql .= " AND ugu.fk_user = a.fk_user_action " ;
if ( $action == 'show_day' )
{
$sql .= " AND ( " ;
$sql .= " (a.datep BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $month , $day , $year )) . " ' " ;
$sql .= " AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $month , $day , $year )) . " ') " ;
$sql .= " OR " ;
$sql .= " (a.datep2 BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $month , $day , $year )) . " ' " ;
$sql .= " AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $month , $day , $year )) . " ') " ;
$sql .= " OR " ;
$sql .= " (a.datep < ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $month , $day , $year )) . " ' " ;
$sql .= " AND a.datep2 > ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $month , $day , $year )) . " ') " ;
$sql .= ')' ;
}
else
{
// To limit array
$sql .= " AND ( " ;
$sql .= " (a.datep BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $month , 1 , $year ) - ( 60 * 60 * 24 * 7 )) . " ' " ; // Start 7 days before
$sql .= " AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $month , 28 , $year ) + ( 60 * 60 * 24 * 10 )) . " ') " ; // End 7 days after + 3 to go from 28 to 31
$sql .= " OR " ;
$sql .= " (a.datep2 BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $month , 1 , $year ) - ( 60 * 60 * 24 * 7 )) . " ' " ;
$sql .= " AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $month , 28 , $year ) + ( 60 * 60 * 24 * 10 )) . " ') " ;
$sql .= " OR " ;
$sql .= " (a.datep < ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $month , 1 , $year ) - ( 60 * 60 * 24 * 7 )) . " ' " ;
$sql .= " AND a.datep2 > ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $month , 28 , $year ) + ( 60 * 60 * 24 * 10 )) . " ') " ;
$sql .= ')' ;
}
if ( $type ) $sql .= " AND ca.id = " . $type ;
if ( $status == '0' ) { $sql .= " AND a.percent = 0 " ; }
if ( $status == '-1' ) { $sql .= " AND a.percent = -1 " ; } // Not applicable
if ( $status == '50' ) { $sql .= " AND (a.percent >= 0 AND a.percent < 100) " ; } // Running
if ( $status == 'done' || $status == '100' ) { $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= ' " . $db -> idate ( $now ) . " ')) " ; }
if ( $status == 'todo' ) { $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > ' " . $db -> idate ( $now ) . " ')) " ; }
if ( $filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0 )
{
$sql .= " AND ( " ;
if ( $filtera > 0 ) $sql .= " a.fk_user_author = " . $filtera ;
if ( $filtert > 0 ) $sql .= ( $filtera > 0 ? " OR " : " " ) . " a.fk_user_action = " . $filtert ;
if ( $filterd > 0 ) $sql .= ( $filtera > 0 || $filtert > 0 ? " OR " : " " ) . " a.fk_user_done = " . $filterd ;
if ( $usergroup > 0 ) $sql .= ( $filtera > 0 || $filtert > 0 || $filterd > 0 ? " OR " : " " ) . " ugu.fk_usergroup = " . $usergroup ;
$sql .= " ) " ;
}
// Sort on date
$sql .= ' ORDER BY datep' ;
//print $sql;
dol_syslog ( " comm/action/index.php " , LOG_DEBUG );
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
$i = 0 ;
while ( $i < $num )
{
$obj = $db -> fetch_object ( $resql );
// Create a new object action
$event = new ActionComm ( $db );
$event -> id = $obj -> id ;
$event -> datep = $db -> jdate ( $obj -> datep ); // datep and datef are GMT date
$event -> datef = $db -> jdate ( $obj -> datep2 );
$event -> type_code = $obj -> code ;
$event -> libelle = $obj -> label ;
$event -> percentage = $obj -> percent ;
$event -> author -> id = $obj -> fk_user_author ; // user id of creator
$event -> usertodo -> id = $obj -> fk_user_action ; // user id of owner
$event -> userdone -> id = $obj -> fk_user_done ; // deprecated
// $event->userstodo=... with s after user, in future version, will be an array with all id of user assigned to event
$event -> priority = $obj -> priority ;
$event -> fulldayevent = $obj -> fulldayevent ;
$event -> location = $obj -> location ;
$event -> transparency = $obj -> transparency ;
$event -> societe -> id = $obj -> fk_soc ;
$event -> contact -> id = $obj -> fk_contact ;
// 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.
if ( $event -> percentage <= 0 )
{
$event -> date_start_in_calendar = $event -> datep ;
if ( $event -> datef != '' && $event -> datef >= $event -> datep ) $event -> date_end_in_calendar = $event -> datef ;
else $event -> date_end_in_calendar = $event -> datep ;
}
else
{
$event -> date_start_in_calendar = $event -> datep ;
if ( $event -> datef != '' && $event -> datef >= $event -> datep ) $event -> date_end_in_calendar = $event -> datef ;
else $event -> date_end_in_calendar = $event -> datep ;
}
// Define ponctual property
if ( $event -> date_start_in_calendar == $event -> date_end_in_calendar )
{
$event -> ponctuel = 1 ;
}
// Check values
if ( $event -> date_end_in_calendar < $firstdaytoshow ||
$event -> date_start_in_calendar > $lastdaytoshow )
{
// This record is out of visible range
}
else
{
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 ;
// Add an entry in actionarray for each day
$daycursor = $event -> date_start_in_calendar ;
$annee = date ( 'Y' , $daycursor );
$mois = date ( 'm' , $daycursor );
$jour = date ( 'd' , $daycursor );
// Loop on each day covered by action to prepare an index to show on calendar
$loop = true ; $j = 0 ;
$daykey = dol_mktime ( 0 , 0 , 0 , $mois , $jour , $annee );
do
{
//if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>';
$eventarray [ $daykey ][] = $event ;
$j ++ ;
$daykey += 60 * 60 * 24 ;
if ( $daykey > $event -> date_end_in_calendar ) $loop = false ;
}
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 ++ ;
}
}
else
{
dol_print_error ( $db );
}
$maxnbofchar = 18 ;
$cachethirdparties = array ();
$cachecontacts = array ();
// Define theme_datacolor array
$color_file = DOL_DOCUMENT_ROOT . " /theme/ " . $conf -> theme . " /graph-color.php " ;
if ( is_readable ( $color_file ))
{
include_once $color_file ;
}
if ( ! is_array ( $theme_datacolor )) $theme_datacolor = array ( array ( 120 , 130 , 150 ), array ( 200 , 160 , 180 ), array ( 190 , 190 , 220 ));
/* TODO Export
print '
< a href = " " id = " actionagenda_ical_link " >< img src = " '.DOL_URL_ROOT.'/theme/common/ical.gif " border = " 0 " /></ a >
< a href = " " id = " actionagenda_vcal_link " >< img src = " '.DOL_URL_ROOT.'/theme/common/vcal.gif " border = " 0 " /></ a >
< a href = " " id = " actionagenda_rss_link " >< img src = " '.DOL_URL_ROOT.'/theme/common/rss.gif " border = " 0 " /></ a >
< script >
$ ( " #actionagenda_rss_link " ) . attr ( " href " , " /public/agenda/agendaexport.php?format=rss&type=ActionAgenda&exportkey=dolibarr&token= " + getToken () + " &status= " + getStatus () + " &userasked= " + getUserasked () + " &usertodo= " + getUsertodo () + " &userdone= " + getUserdone () + " &year= " + getYear () + " &month= " + getMonth () + " &day= " + getDay () + " &showbirthday= " + getShowbirthday () + " &action= " + getAction () + " &projectid= " + getProjectid () + " " );
$ ( " #actionagenda_ical_link " ) . attr ( " href " , " /public/agenda/agendaexport.php?format=ical&type=ActionAgenda&exportkey=dolibarr&token= " + getToken () + " &status= " + getStatus () + " &userasked= " + getUserasked () + " &usertodo= " + getUsertodo () + " &userdone= " + getUserdone () + " &year= " + getYear () + " &month= " + getMonth () + " &day= " + getDay () + " &showbirthday= " + getShowbirthday () + " &action= " + getAction () + " &projectid= " + getProjectid () + " " );
$ ( " #actionagenda_vcal_link " ) . attr ( " href " , " /public/agenda/agendaexport.php?format=vcal&type=ActionAgenda&exportkey=dolibarr&token= " + getToken () + " &status= " + getStatus () + " &userasked= " + getUserasked () + " &usertodo= " + getUsertodo () + " &userdone= " + getUserdone () + " &year= " + getYear () + " &month= " + getMonth () + " &day= " + getDay () + " &showbirthday= " + getShowbirthday () + " &action= " + getAction () + " &projectid= " + getProjectid () + " " );
</ script >
' ;
*/
llxFooter ();
$db -> close ();