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