Skip to content

Commit

Permalink
Fix: Bad days returned by function
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 5, 2014
1 parent 742d0e3 commit c73f4a1
Showing 1 changed file with 22 additions and 33 deletions.
55 changes: 22 additions & 33 deletions htdocs/comm/action/index.php
Expand Up @@ -184,18 +184,19 @@
$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, 7, 'd');

$max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year));

Expand Down Expand Up @@ -870,39 +871,27 @@
}
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";

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.'" 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";

Expand Down

0 comments on commit c73f4a1

Please sign in to comment.