Finalized XML version for intranet
[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 use C4::Interface::CGI::Output;
9 use C4::Calendar::Calendar;
10
11 my $input = new CGI;
12 my $dbh = C4::Context->dbh();
13
14 my $branchcode = $input->param('newBranchName');
15 my $weekday = $input->param('newWeekday');
16 my $day = $input->param('newDay');
17 my $month = $input->param('newMonth');
18 my $year = $input->param('newYear');
19 my $title = $input->param('newTitle');
20 my $description = $input->param('newDescription');
21
22 my $calendar = C4::Calendar::Calendar->new(branchcode => $branchcode);
23
24 if ($input->param('newOperation') eq 'weekday') {
25         $calendar->insert_week_day_holiday(weekday => $weekday,
26                                                                    title => $title,
27                                                                    description => $description);
28 } elsif ($input->param('newOperation') eq 'repeatable') {
29         $calendar->insert_day_month_holiday(day => $day,
30                                             month => $month,
31                                                                     title => $title,
32                                                                     description => $description);
33 } elsif ($input->param('newOperation') eq 'holiday') {
34         $calendar->insert_single_holiday(day => $day,
35                                          month => $month,
36                                                              year => $year,
37                                                              title => $title,
38                                                              description => $description);
39
40 }
41 print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode");