diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 41435afc84d..38e8ab24bb1 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -184,18 +184,19 @@ 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, 7, 'd');
$max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year));
@@ -870,39 +871,27 @@ elseif ($action == 'show_week') // View by week
}
echo " \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 "
\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);
+ // 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']==$month && $todayarray['year']==$year) $today=1;
- if ($today) $style='cal_today';
+ $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 ' | ';
- show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
- echo " | \n";
- }
- else
- {
- $style='cal_current_month';
- if ($iter_day == 6) $style.=' cal_other_month_right';
- echo ' ';
- show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
- echo " | \n";
- }
- $tmpday++;
+ echo ' ';
+ show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
+ echo " | \n";
}
echo "
\n";
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index 1d447430dfe..48ccec88cf1 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -482,7 +482,7 @@ function dol_get_last_day($year,$month=12,$gm=false)
* @param int $month Month
* @param int $year Year
* @param int $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
- * @return array year,month, week,first_day,prev_year,prev_month,prev_day
+ * @return array year,month,week,first_day,prev_year,prev_month,prev_day
*/
function dol_get_first_day_week($day,$month,$year,$gm=false)
{
@@ -532,7 +532,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
$prev_day = $tmparray['mday'];
//Check prev day of week is in same month than first day or not
- if ($prev_day>$tmpday)
+ if ($prev_day > $tmpday)
{
$prev_month = $month-1;
$prev_year = $year;
@@ -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);
}
diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php
index a785b499642..0a68ca211b9 100644
--- a/htdocs/cron/card.php
+++ b/htdocs/cron/card.php
@@ -95,9 +95,18 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex
}
else
{
- if ($object->lastresult > 0) setEventMessage($langs->trans("JobFinished"),'warnings');
- else setEventMessage($langs->trans("JobFinished"),'mesgs');
- $action='';
+ $res = $object->reprogram_jobs($user->login);
+ if ($res > 0)
+ {
+ if ($object->lastresult > 0) setEventMessage($langs->trans("JobFinished"),'warnings');
+ else setEventMessage($langs->trans("JobFinished"),'mesgs');
+ $action='';
+ }
+ else
+ {
+ setEventMessage($object->error,'errors');
+ $action='';
+ }
}
}
diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php
index dd9eb8b6289..95dd669d023 100644
--- a/htdocs/cron/list.php
+++ b/htdocs/cron/list.php
@@ -100,6 +100,21 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex
if ($result < 0) {
setEventMessage($object->error,'errors');
}
+ else
+ {
+ $res = $object->reprogram_jobs($user->login);
+ if ($res > 0)
+ {
+ if ($object->lastresult > 0) setEventMessage($langs->trans("JobFinished"),'warnings');
+ else setEventMessage($langs->trans("JobFinished"),'mesgs');
+ $action='';
+ }
+ else
+ {
+ setEventMessage($object->error,'errors');
+ $action='';
+ }
+ }
header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-1'); // Make a call to avoid to run twice job when using back
exit;