';
+echo '';
echo '';
echo ' | ';
@@ -847,10 +847,11 @@ foreach ($typeofevents as $typeofevent) {
// Show days of the current week
$curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd');
- $tmparray = dol_getdate($curtime, 'fast');
- $tmpday = $tmparray['mday'];
- $tmpmonth = $tmparray['mon'];
- $tmpyear = $tmparray['year'];
+ // $curtime is a gmt time, but we want the day, month, year in user TZ
+ $tmpday = dol_print_date($curtime, "%d", "tzuserrel");
+ $tmpmonth = dol_print_date($curtime, "%m", "tzuserrel");
+ $tmpyear = dol_print_date($curtime, "%Y", "tzuserrel");
+ //var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear);
$style = 'cal_current_month';
if ($iter_day == 6) {
@@ -875,6 +876,8 @@ foreach ($typeofevents as $typeofevent) {
echo "
\n";
echo "
";
+echo '';
+
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
$langs->load("commercial");
print '
'.$langs->trans("Legend").':
';
@@ -984,14 +987,14 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
// We are in a particular day for $username, now we scan all events
foreach ($eventarray as $daykey => $notused) {
- $annee = dol_print_date($daykey, '%Y');
- $mois = dol_print_date($daykey, '%m');
- $jour = dol_print_date($daykey, '%d');
+ $annee = dol_print_date($daykey, '%Y', 'tzuserrel');
+ $mois = dol_print_date($daykey, '%m', 'tzuserrel');
+ $jour = dol_print_date($daykey, '%d', 'tzuserrel');
- if ($day == $jour && $month == $mois && $year == $annee) { // Is it the day we are looking for when calling function ?
+ if ($day == $jour && (int) $month == (int) $mois && $year == $annee) { // Is it the day we are looking for when calling function ?
// Scan all event for this date
foreach ($eventarray[$daykey] as $index => $event) {
- //print $daykey.' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."
\n";
+ //print 'daykey='.$daykey.' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."
\n";
//var_dump($event);
$keysofuserassigned = array_keys($event->userassigned);
@@ -1173,7 +1176,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
}
}
- // Now output $casesX
+ // Now output $casesX from start hour to end hour
for ($h = $begin_h; $h < $end_h; $h++) {
$color1 = ''; $color2 = '';
$style1 = ''; $style2 = '';
@@ -1214,11 +1217,12 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
}
}
- $ids1 = ''; $ids2 = '';
- if (count($cases1[$h]) && array_keys($cases1[$h])) {
+ $ids1 = '';
+ $ids2 = '';
+ if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) {
$ids1 = join(',', array_keys($cases1[$h]));
}
- if (count($cases2[$h]) && array_keys($cases2[$h])) {
+ if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) {
$ids2 = join(',', array_keys($cases2[$h]));
}
@@ -1227,7 +1231,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
} else {
echo '';
}
- if (count($cases1[$h]) == 1) { // only 1 event
+ if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) { // only 1 event
$output = array_slice($cases1[$h], 0, 1);
$title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
if ($output[0]['string']) {
@@ -1236,12 +1240,12 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
if ($output[0]['color']) {
$color1 = $output[0]['color'];
}
- } elseif (count($cases1[$h]) > 1) {
+ } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) {
$title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
$color1 = '222222';
}
- if (count($cases2[$h]) == 1) { // only 1 event
+ if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) { // only 1 event
$output = array_slice($cases2[$h], 0, 1);
$title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
if ($output[0]['string']) {
@@ -1250,7 +1254,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
if ($output[0]['color']) {
$color2 = $output[0]['color'];
}
- } elseif (count($cases2[$h]) > 1) {
+ } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) {
$title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
$color2 = '222222';
}
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index c6c91228af0..993bc3a908a 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -349,14 +349,14 @@ $next_year = $next['year'];
$next_month = $next['month'];
$next_day = $next['day'];
-// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
-$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt');
-
+// Define firstdaytoshow and lastdaytoshow. Warning: lastdaytoshow is last second to show + 1
+// $firstdaytoshow and lastdaytoshow become a gmt dates to use to search/compare because first_xxx are in tz idea and we used tzuserrel
+$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'tzuserrel');
$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');
//print $firstday.'-'.$first_month.'-'.$first_year;
-//print dol_print_date($firstdaytoshow,'dayhour');
-//print dol_print_date($lastdaytoshow,'dayhour');
+//print dol_print_date($firstdaytoshow, 'dayhour', 'gmt');
+//print dol_print_date($lastdaytoshow,'dayhour', 'gmt');
$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt'));
@@ -655,6 +655,7 @@ if ($filtert > 0 || $usergroup > 0) {
}
// Sort on date
$sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action
+//print $sql;
dol_syslog("comm/action/peruser.php", LOG_DEBUG);
@@ -665,6 +666,7 @@ if ($resql) {
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
+ //print $obj->fk_user_action.' '.$obj->id." ";
// Discard auto action if option is on
if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') {
@@ -675,6 +677,7 @@ if ($resql) {
$datep = $db->jdate($obj->datep);
$datep2 = $db->jdate($obj->datep2);
+
// Create a new object action
$event = new ActionComm($db);
$event->id = $obj->id;
@@ -717,13 +720,15 @@ if ($resql) {
}
}
+ //print ' '.$i.' - eventid='.$event->id.' '.dol_print_date($event->date_start_in_calendar, 'dayhour').' '.dol_print_date($firstdaytoshow, 'dayhour').' - '.dol_print_date($event->date_end_in_calendar, 'dayhour').' '.dol_print_date($lastdaytoshow, 'dayhour').' '."\n";
+
// Check values
if ($event->date_end_in_calendar < $firstdaytoshow ||
$event->date_start_in_calendar >= $lastdaytoshow) {
// This record is out of visible range
unset($event);
} else {
- //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').' '."\n";
+ //print $i.' - eventid='.$event->id.' '.dol_print_date($event->date_start_in_calendar, 'dayhour').' - '.dol_print_date($event->date_end_in_calendar, 'dayhour').' '."\n";
$event->fetch_userassigned(); // This load $event->userassigned
if ($event->date_start_in_calendar < $firstdaytoshow) {
@@ -744,7 +749,7 @@ if ($resql) {
$loop = true; $j = 0;
$daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
do {
- //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.' ';
+ //print 'Add event into eventarray for daykey='.$daykey.'='.dol_print_date($daykey, 'dayhour', 'gmt').' '.$event->id.' '.$event->datep.' '.$event->datef.' ';
$eventarray[$daykey][] = $event;
$j++;
@@ -802,6 +807,7 @@ echo '';
$currentdaytoshow = $firstdaytoshow;
echo '';
+//print dol_print_date($currentdaytoshow, 'dayhour', 'gmt');
while ($currentdaytoshow < $lastdaytoshow) {
echo ' ';
@@ -853,9 +859,9 @@ while ($currentdaytoshow < $lastdaytoshow) {
echo ''.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).'';
print " ";
if ($i) {
- print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day');
+ print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day', 'tzuserrel');
} else {
- print dol_print_date($currentdaytoshow, 'day');
+ print dol_print_date($currentdaytoshow, 'day', 'tzuserrel');
}
echo "\n";
$i++;
@@ -976,6 +982,8 @@ while ($currentdaytoshow < $lastdaytoshow) {
$showheader = true;
$var = false;
foreach ($usernames as $username) {
+ //if ($username->login != 'admin') continue;
+
$var = !$var;
echo "";
echo '';
@@ -993,10 +1001,10 @@ while ($currentdaytoshow < $lastdaytoshow) {
// Show days of the current week
$curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd');
- $tmparray = dol_getdate($curtime, 'fast');
- $tmpday = $tmparray['mday'];
- $tmpmonth = $tmparray['mon'];
- $tmpyear = $tmparray['year'];
+ // $curtime is a gmt time, but we want the day, month, year in user TZ
+ $tmpday = dol_print_date($curtime, "%d", "tzuserrel");
+ $tmpmonth = dol_print_date($curtime, "%m", "tzuserrel");
+ $tmpyear = dol_print_date($curtime, "%Y", "tzuserrel");
//var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear);
$style = 'cal_current_month';
@@ -1134,17 +1142,22 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
//if ($username->id && $day==1) {
//var_dump($eventarray);
//}
+ //var_dump("------ username=".$username->login." for day=".$day);
// We are in a particular day for $username, now we scan all events
foreach ($eventarray as $daykey => $notused) {
- $annee = dol_print_date($daykey, '%Y');
- $mois = dol_print_date($daykey, '%m');
- $jour = dol_print_date($daykey, '%d');
+ $annee = dol_print_date($daykey, '%Y', 'tzuserrel');
+ $mois = dol_print_date($daykey, '%m', 'tzuserrel');
+ $jour = dol_print_date($daykey, '%d', 'tzuserrel');
+ //var_dump("daykey=$daykey day=$day jour=$jour, month=$month mois=$mois, year=$year annee=$annee");
+
+
+ if ($day == $jour && (int) $month == (int) $mois && $year == $annee) { // Is it the day we are looking for when calling function ?
+ //var_dump("day=$day jour=$jour month=$month mois=$mois year=$year annee=$annee");
- if ($day == $jour && $month == $mois && $year == $annee) { // Is it the day we are looking for when calling function ?
// Scan all event for this date
foreach ($eventarray[$daykey] as $index => $event) {
- //print $daykey.' '.dol_print_date($daykey, 'dayhour', 'gmt').' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour." \n";
+ //print 'daykey='.$daykey.'='.dol_print_date($daykey, 'dayhour', 'gmt').' '.$year.'-'.$month.'-'.$day.' -> This event: '.$event->id.' '.$index.' is open for this daykey '.$annee.'-'.$mois.'-'.$jour." \n";
//var_dump($event);
$keysofuserassigned = array_keys($event->userassigned);
@@ -1353,7 +1366,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
}
}
- // Now output $casesX
+ // Now output $casesX from start hour to end hour
for ($h = $begin_h; $h < $end_h; $h++) {
$color1 = ''; $color2 = '';
$style1 = ''; $style2 = '';
@@ -1435,7 +1448,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
$title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
$color2 = '222222';
}
- print ' | |