13 my $dbh = C4::Context->dbh();
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 my $holidaytype = $input->param('showHolidayType');
24 my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
25 my $isodate = C4::Dates->new($calendardate, 'iso');
26 $calendardate = $isodate->output('syspref');
28 my $calendar = C4::Calendar->new(branchcode => $branchcode);
30 $title || ($title = '');
32 $description =~ s/\r/\\r/g;
33 $description =~ s/\n/\\n/g;
38 if ($input->param('showOperation') eq 'exception') {
39 $calendar->insert_exception_holiday(day => $day,
43 description => $description);
44 } elsif ($input->param('showOperation') eq 'edit') {
45 if($holidaytype eq 'weekday') {
46 $calendar->ModWeekdayholiday(weekday => $weekday,
48 description => $description);
49 } elsif ($holidaytype eq 'daymonth') {
50 $calendar->ModDaymonthholiday(day => $day,
53 description => $description);
54 } elsif ($holidaytype eq 'ymd') {
55 $calendar->ModSingleholiday(day => $day,
59 description => $description);
60 } elsif ($holidaytype eq 'exception') {
61 $calendar->ModExceptionholiday(day => $day,
65 description => $description);
67 } elsif ($input->param('showOperation') eq 'delete') {
68 $calendar->delete_holiday(weekday => $weekday,
73 print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode&calendardate=$calendardate");