Bug 1768: Calendar now retains the month on which the user was entering data.
authorGarry Collum <gcollum@gmail.com>
Sun, 17 May 2009 22:20:05 +0000 (18:20 -0400)
committerGalen Charlton <galen.charlton@liblime.com>
Mon, 18 May 2009 21:37:58 +0000 (16:37 -0500)
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>
koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tmpl
tools/exceptionHolidays.pl
tools/holidays.pl
tools/newHolidays.pl

index d8b0e06..34dc4f3 100644 (file)
@@ -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
                }
        );
index dd47161..82a5c4a 100755 (executable)
@@ -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");
index d3a450c..c92e521 100755 (executable)
@@ -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
        );
 
index d8a51e1..7e85de8 100755 (executable)
@@ -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");