If a user adds or edits a holiday, the calendar will now return to the month in which the user was working. Also after an add or an edit, if the user selects another location, the calendar remains in the same month for which the add or edit took place. The user sees a 'calendardate' parameter in the URL in the format that is chosen as the system preference. If an invalid date is entered in the url, the current date is used.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
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=' + "<!-- TMPL_VAR NAME='calendardate' -->";
}
function additionalInformation (anExplanation) {
{
flat : "calendar-container",
flatCallback : dateChanged,
+ date: "<!-- TMPL_VAR NAME='keydate' -->",
dateStatusFunc : dateStatusHandler
}
);
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 = '');
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");
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') &&
HOLIDAYS_LOOP => \@holidays,
EXCEPTION_HOLIDAYS_LOOP => \@exception_holidays,
DAY_MONTH_HOLIDAYS_LOOP => \@day_month_holidays,
+ calendardate => $calendardate,
+ keydate => $keydate,
branch => $branch
);
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;
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");