MARC import: part 2 of large file support
[koha.git] / tools / newHolidays.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use CGI;
5
6 use C4::Auth;
7 use C4::Output;
8
9
10 use C4::Calendar;
11
12 my $input = new CGI;
13 my $dbh = C4::Context->dbh();
14
15 my $branchcode = $input->param('newBranchName');
16 my $weekday = $input->param('newWeekday');
17 my $day = $input->param('newDay');
18 my $month = $input->param('newMonth');
19 my $year = $input->param('newYear');
20 my $title = $input->param('newTitle');
21 my $description = $input->param('newDescription');
22
23 $title || ($title = '');
24 if ($description) {
25         $description =~ s/\r/\\r/g;
26         $description =~ s/\n/\\n/g;
27 } else {
28         $description = '';
29 }
30
31 my $calendar = C4::Calendar->new(branchcode => $branchcode);
32
33 if ($input->param('newOperation') eq 'weekday') {
34         $calendar->insert_week_day_holiday(weekday => $weekday,
35                                                                    title => $title,
36                                                                    description => $description);
37 } elsif ($input->param('newOperation') eq 'repeatable') {
38         $calendar->insert_day_month_holiday(day => $day,
39                                             month => $month,
40                                                                     title => $title,
41                                                                     description => $description);
42 } elsif ($input->param('newOperation') eq 'holiday') {
43         $calendar->insert_single_holiday(day => $day,
44                                          month => $month,
45                                                              year => $year,
46                                                              title => $title,
47                                                              description => $description);
48
49 }
50 print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode");