Adding SpecifyDueDate
[koha.git] / tools / exceptionHolidays.pl
blob64a48600636c37dda57c16155af47f9f00d968e0
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use CGI;
8 use C4::Auth;
9 use C4::Output;
12 use C4::Calendar;
14 my $input = new CGI;
15 my $dbh = C4::Context->dbh();
17 my $branchcode = $input->param('showBranchName');
18 my $weekday = $input->param('showWeekday');
19 my $day = $input->param('showDay');
20 my $month = $input->param('showMonth');
21 my $year = $input->param('showYear');
22 my $title = $input->param('showTitle');
23 my $description = $input->param('showDescription');
24 my $holidaytype = $input->param('showHolidayType');
26 my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
27 my $isodate = C4::Dates->new($calendardate, 'iso');
28 $calendardate = $isodate->output('syspref');
30 my $calendar = C4::Calendar->new(branchcode => $branchcode);
32 $title || ($title = '');
33 if ($description) {
34 $description =~ s/\r/\\r/g;
35 $description =~ s/\n/\\n/g;
36 } else {
37 $description = '';
40 if ($input->param('showOperation') eq 'exception') {
41 $calendar->insert_exception_holiday(day => $day,
42 month => $month,
43 year => $year,
44 title => $title,
45 description => $description);
46 } elsif ($input->param('showOperation') eq 'edit') {
47 if($holidaytype eq 'weekday') {
48 $calendar->ModWeekdayholiday(weekday => $weekday,
49 title => $title,
50 description => $description);
51 } elsif ($holidaytype eq 'daymonth') {
52 $calendar->ModDaymonthholiday(day => $day,
53 month => $month,
54 title => $title,
55 description => $description);
56 } elsif ($holidaytype eq 'ymd') {
57 $calendar->ModSingleholiday(day => $day,
58 month => $month,
59 year => $year,
60 title => $title,
61 description => $description);
62 } elsif ($holidaytype eq 'exception') {
63 $calendar->ModExceptionholiday(day => $day,
64 month => $month,
65 year => $year,
66 title => $title,
67 description => $description);
69 } elsif ($input->param('showOperation') eq 'delete') {
70 $calendar->delete_holiday(weekday => $weekday,
71 day => $day,
72 month => $month,
73 year => $year);
75 print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode&calendardate=$calendardate");