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.
---
.../prog/en/modules/tools/holidays.tmpl | 3 ++-
tools/exceptionHolidays.pl | 6 +++++-
tools/holidays.pl | 17 +++++++++++++++++
tools/newHolidays.pl | 6 +++++-
4 files changed, 29 insertions(+), 3 deletions(-)
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 d8b0e06..34dc4f3 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=' + "<!-- TMPL_VAR NAME='calendardate' -->";
}
function additionalInformation (anExplanation) {
@@ -345,6 +345,7 @@ h1 select { width: 20em; }
{
flat : "calendar-container",
flatCallback : dateChanged,
+ date: "<!-- TMPL_VAR NAME='keydate' -->",
dateStatusFunc : dateStatusHandler
}
);
diff --git a/tools/exceptionHolidays.pl b/tools/exceptionHolidays.pl
index dd47161..82a5c4a 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 d3a450c..c92e521 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 d8a51e1..7e85de8 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");
--
1.5.6.5
_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches