do not use REPLACE in SQL statements : it is not standard SQL, and don't work with...
[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
9
10 use C4::Calendar;
11
12 my $input = new CGI;
13 my $dbh = C4::Context->dbh();
14
15 my $branchcode = $input->param('showBranchName');
16 my $weekday = $input->param('showWeekday');
17 my $day = $input->param('showDay');
18 my $month = $input->param('showMonth');
19 my $year = $input->param('showYear');
20 my $title = $input->param('showTitle');
21 my $description = $input->param('showDescription');
22
23 my $calendar = C4::Calendar->new(branchcode => $branchcode);
24
25 $title || ($title = '');
26 if ($description) {
27     $description =~ s/\r/\\r/g;
28     $description =~ s/\n/\\n/g;
29 } else {
30     $description = '';
31 }   
32
33 if ($input->param('showOperation') eq 'exception') {
34         $calendar->insert_exception_holiday(day => $day,
35                                                                                 month => $month,
36                                                                             year => $year,
37                                                                 title => $title,
38                                                                 description => $description);
39 } elsif ($input->param('showOperation') eq 'delete') {
40         $calendar->delete_holiday(weekday => $weekday,
41                                   day => $day,
42                                   month => $month,
43                                               year => $year);
44 }
45 print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode");