diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tmpl index d8b0e064c0..34dc4f3643 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tmpl @@ -85,7 +85,7 @@ function changeBranch () { var branch = $("#branch option:selected").val(); - location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch; + location.href='/cgi-bin/koha/tools/holidays.pl?branch=' + branch + '&calendardate=' + ""; } function additionalInformation (anExplanation) { @@ -345,6 +345,7 @@ h1 select { width: 20em; } { flat : "calendar-container", flatCallback : dateChanged, + date: "", dateStatusFunc : dateStatusHandler } ); diff --git a/tools/exceptionHolidays.pl b/tools/exceptionHolidays.pl index dd47161334..82a5c4a001 100755 --- a/tools/exceptionHolidays.pl +++ b/tools/exceptionHolidays.pl @@ -20,6 +20,10 @@ my $year = $input->param('showYear'); my $title = $input->param('showTitle'); my $description = $input->param('showDescription'); +my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day); +my $isodate = C4::Dates->new($calendardate, 'iso'); +$calendardate = $isodate->output('syspref'); + my $calendar = C4::Calendar->new(branchcode => $branchcode); $title || ($title = ''); @@ -42,4 +46,4 @@ if ($input->param('showOperation') eq 'exception') { month => $month, year => $year); } -print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode"); +print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode&calendardate=$calendardate"); diff --git a/tools/holidays.pl b/tools/holidays.pl index d3a450c42e..c92e521479 100755 --- a/tools/holidays.pl +++ b/tools/holidays.pl @@ -38,6 +38,21 @@ my ($template, $loggedinuser, $cookie) debug => 1, }); +# keydate - date passed to calendar.js. calendar.js does not process dashes within a date. +my $keydate; +# calendardate - date passed in url for human readability (syspref) +my $calendardate; +my $today = C4::Dates->new(); +my $calendarinput = C4::Dates->new($input->param('calendardate')) || $today; +# if the url has an invalid date default to 'now.' +unless($calendardate = $calendarinput->output('syspref')) { + $calendardate = $today->output('syspref'); +} +unless($keydate = $calendarinput->output('iso')) { + $keydate = $today->output('iso'); +} +$keydate =~ s/-/\//g; + my $branch= $input->param('branch') || C4::Context->userenv->{'branch'}; # Set all the branches. my $onlymine=(C4::Context->preference('IndependantBranches') && @@ -122,6 +137,8 @@ $template->param(WEEK_DAYS_LOOP => \@week_days, HOLIDAYS_LOOP => \@holidays, EXCEPTION_HOLIDAYS_LOOP => \@exception_holidays, DAY_MONTH_HOLIDAYS_LOOP => \@day_month_holidays, + calendardate => $calendardate, + keydate => $keydate, branch => $branch ); diff --git a/tools/newHolidays.pl b/tools/newHolidays.pl index d8a51e1aef..7e85de884c 100755 --- a/tools/newHolidays.pl +++ b/tools/newHolidays.pl @@ -20,6 +20,10 @@ my $year = $input->param('newYear'); my $title = $input->param('newTitle'); my $description = $input->param('newDescription'); +my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day); +my $isodate = C4::Dates->new($calendardate, 'iso'); +$calendardate = $isodate->output('syspref'); + $title || ($title = ''); if ($description) { $description =~ s/\r/\\r/g; @@ -51,4 +55,4 @@ if ($input->param('newOperation') eq 'weekday') { description => $description); } -print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode"); +print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode&calendardate=$calendardate");