Bug 1768: Calendar now retains the month on which the user was entering data.
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>
This commit is contained in:
parent
794b39a84e
commit
5a0f7dfc89
|
|
@ -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
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in New Issue