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

Fix: Bad position of week

parent 175e3eca
No related branches found
No related tags found
No related merge requests found
......@@ -231,18 +231,20 @@ if ($action=='show_week')
$prev_month = $prev['prev_month'];
$prev_day = $prev['prev_day'];
$first_day = $prev['first_day'];
$first_month= $prev['first_month'];
$first_year = $prev['first_year'];
$week = $prev['week'];
$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_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);
$firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year);
$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 6, 'd');
$max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year));
......@@ -299,7 +301,7 @@ if (empty($action) || $action=='show_month')
if ($action=='show_week')
{
$nav ="<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;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 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."&amp;month=".$next_month."&amp;day=".$next_day.$param."\">".img_next($langs->trans("Next"))."</a>\n";
$nav.=" &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
......@@ -992,33 +994,25 @@ elseif ($action == 'show_week') // View by week
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
$curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year);
$style='cal_current_month';
if ($iter_day == 6) $style.=' cal_other_month_right';
$today=0;
$todayarray=dol_getdate($now,'fast');
if ($todayarray['mday']==$tmpday && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1;
if ($today) $style='cal_today';
echo ' <td class="'.$style.' nowrap" width="14%" valign="top">';
show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
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++;
// 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'];
$style='cal_current_month';
if ($iter_day == 6) $style.=' cal_other_month_right';
$today=0;
$todayarray=dol_getdate($now,'fast');
if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1;
if ($today) $style='cal_today';
echo ' <td class="'.$style.' nowrap" width="14%" valign="top">';
show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
echo " </td>\n";
}
echo " </tr>\n";
......
......@@ -544,7 +544,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
}
}
$week = date("W",dol_mktime(0,0,0,$month,$tmpday,$year,$gm));
$week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm));
return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'first_month' => $tmpmonth, 'first_year' => $tmpyear, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment