Skip to content
Snippets Groups Projects
Commit c73f4a14 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Bad days returned by function

parent 742d0e37
No related branches found
No related tags found
No related merge requests found
...@@ -184,18 +184,19 @@ if ($action=='show_week') ...@@ -184,18 +184,19 @@ if ($action=='show_week')
$prev_month = $prev['prev_month']; $prev_month = $prev['prev_month'];
$prev_day = $prev['prev_day']; $prev_day = $prev['prev_day'];
$first_day = $prev['first_day']; $first_day = $prev['first_day'];
$first_month= $prev['first_month'];
$first_year = $prev['first_year'];
$week = $prev['week']; $week = $prev['week'];
$day = (int) $day; $day = (int) $day;
$next = dol_get_next_week($day, $week, $month, $year); $next = dol_get_next_week($first_day, $week, $first_month, $first_year);
$next_year = $next['year']; $next_year = $next['year'];
$next_month = $next['month']; $next_month = $next['month'];
$next_day = $next['day']; $next_day = $next['day'];
// Define firstdaytoshow and lastdaytoshow // Define firstdaytoshow and lastdaytoshow
$firstdaytoshow=dol_mktime(0,0,0,$prev_month,$first_day,$prev_year); $firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year);
$lastdaytoshow=dol_mktime(0,0,0,$next_month,$next_day,$next_year); $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd');
$max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year)); $max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year));
...@@ -870,40 +871,28 @@ elseif ($action == 'show_week') // View by week ...@@ -870,40 +871,28 @@ elseif ($action == 'show_week') // View by week
} }
echo " </tr>\n"; echo " </tr>\n";
// In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month)
//var_dump($eventarray);
//print $tmpday;
echo " <tr>\n"; echo " <tr>\n";
for($iter_day = 0; $iter_day < 7; $iter_day++) for($iter_day = 0; $iter_day < 7; $iter_day++)
{
if(($tmpday <= $max_day_in_month))
{ {
// Show days of the current week // Show days of the current week
$curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd');
$tmparray = dol_getdate($curtime,'fast');
$tmpday = $tmparray['mday'];
$tmpmonth = $tmparray['mon'];
$tmpyear = $tmparray['year'];
$style='cal_current_month'; $style='cal_current_month';
if ($iter_day == 6) $style.=' cal_other_month_right'; if ($iter_day == 6) $style.=' cal_other_month_right';
$today=0; $today=0;
$todayarray=dol_getdate($now,'fast'); $todayarray=dol_getdate($now,'fast');
if ($todayarray['mday']==$tmpday && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1; if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1;
if ($today) $style='cal_today'; if ($today) $style='cal_today';
echo ' <td class="'.$style.' nowrap" width="14%" valign="top">'; echo ' <td class="'.$style.'" width="14%" valign="top">';
show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
echo " </td>\n"; echo " </td>\n";
} }
else
{
$style='cal_current_month';
if ($iter_day == 6) $style.=' cal_other_month_right';
echo ' <td class="'.$style.' nowrap" width="14%" valign="top">';
show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
echo "</td>\n";
}
$tmpday++;
}
echo " </tr>\n"; echo " </tr>\n";
echo "</table>\n"; echo "</table>\n";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment