per row inserts
[koha.git] / tools / exceptionHolidays.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use CGI;
5
6 use C4::Auth;
7 use C4::Output;
8 use C4::Interface::CGI::Output;
9
10
11 use C4::Calendar;
12
13 my $input = new CGI;
14 my $dbh = C4::Context->dbh();
15
16 my $branchcode = $input->param('showBranchName');
17 my $weekday = $input->param('showWeekday');
18 my $day = $input->param('showDay');
19 my $month = $input->param('showMonth');
20 my $year = $input->param('showYear');
21 my $title = $input->param('showTitle');
22 my $description = $input->param('showDescription');
23
24 my $calendar = C4::Calendar->new(branchcode => $branchcode);
25
26 $title || ($title = '');
27 if ($description) {
28     $description =~ s/\r/\\r/g;
29     $description =~ s/\n/\\n/g;
30 } else {
31     $description = '';
32 }   
33
34 if ($input->param('showOperation') eq 'exception') {
35         $calendar->insert_exception_holiday(day => $day,
36                                                                                 month => $month,
37                                                                             year => $year,
38                                                                 title => $title,
39                                                                 description => $description);
40 } elsif ($input->param('showOperation') eq 'delete') {
41         $calendar->delete_holiday(weekday => $weekday,
42                                   day => $day,
43                                   month => $month,
44                                               year => $year);
45 }
46 print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode");