5a0f7dfc89
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>
58 lines
1.8 KiB
Perl
Executable file
58 lines
1.8 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
use CGI;
|
|
|
|
use C4::Auth;
|
|
use C4::Output;
|
|
|
|
|
|
use C4::Calendar;
|
|
|
|
my $input = new CGI;
|
|
my $dbh = C4::Context->dbh();
|
|
|
|
my $branchcode = $input->param('newBranchName');
|
|
my $weekday = $input->param('newWeekday');
|
|
my $day = $input->param('newDay');
|
|
my $month = $input->param('newMonth');
|
|
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;
|
|
$description =~ s/\n/\\n/g;
|
|
} else {
|
|
$description = '';
|
|
}
|
|
my $calendar = C4::Calendar->new(branchcode => $branchcode);
|
|
|
|
if ($input->param('newOperation') eq 'weekday') {
|
|
unless ( $weekday && ($weekday ne '') ) {
|
|
# was dow calculated by javascript? original code implies it was supposed to be.
|
|
# if not, we need it.
|
|
$weekday = &Date::Calc::Day_of_Week($year, $month, $day) % 7 unless($weekday);
|
|
}
|
|
$calendar->insert_week_day_holiday(weekday => $weekday,
|
|
title => $title,
|
|
description => $description);
|
|
} elsif ($input->param('newOperation') eq 'repeatable') {
|
|
$calendar->insert_day_month_holiday(day => $day,
|
|
month => $month,
|
|
title => $title,
|
|
description => $description);
|
|
} elsif ($input->param('newOperation') eq 'holiday') {
|
|
$calendar->insert_single_holiday(day => $day,
|
|
month => $month,
|
|
year => $year,
|
|
title => $title,
|
|
description => $description);
|
|
|
|
}
|
|
print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode&calendardate=$calendardate");
|