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 = '');
34 $description =~ s/\r/\\r/g;
35 $description =~ s/\n/\\n/g;
40 if ($input->param('showOperation') eq 'exception') {
41 $calendar->insert_exception_holiday(day
=> $day,
45 description
=> $description);
46 } elsif ($input->param('showOperation') eq 'edit') {
47 if($holidaytype eq 'weekday') {
48 $calendar->ModWeekdayholiday(weekday
=> $weekday,
50 description
=> $description);
51 } elsif ($holidaytype eq 'daymonth') {
52 $calendar->ModDaymonthholiday(day
=> $day,
55 description
=> $description);
56 } elsif ($holidaytype eq 'ymd') {
57 $calendar->ModSingleholiday(day
=> $day,
61 description
=> $description);
62 } elsif ($holidaytype eq 'exception') {
63 $calendar->ModExceptionholiday(day
=> $day,
67 description
=> $description);
69 } elsif ($input->param('showOperation') eq 'delete') {
70 $calendar->delete_holiday(weekday
=> $weekday,
75 print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$branchcode&calendardate=$calendardate");