15 my $dbh = C4
::Context
->dbh();
17 my $branchcode = $input->param('newBranchName');
18 my $originalbranchcode = $branchcode;
19 my $weekday = $input->param('newWeekday');
20 my $day = $input->param('newDay');
21 my $month = $input->param('newMonth');
22 my $year = $input->param('newYear');
23 my $title = $input->param('newTitle');
24 my $description = $input->param('newDescription');
25 my $newoperation = $input->param('newOperation');
26 my $allbranches = $input->param('allBranches');
28 my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
29 my $isodate = C4
::Dates
->new($calendardate, 'iso');
30 $calendardate = $isodate->output('syspref');
32 $title || ($title = '');
34 $description =~ s/\r/\\r/g;
35 $description =~ s/\n/\\n/g;
42 my @branchcodes = split(/\|/, $input->param('branchCodes'));
43 foreach $branch (@branchcodes) {
44 add_holiday
($newoperation, $branch, $weekday, $day, $month, $year, $title, $description);
47 add_holiday
($newoperation, $branchcode, $weekday, $day, $month, $year, $title, $description);
50 print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$originalbranchcode&calendardate=$calendardate");
53 ($newoperation, $branchcode, $weekday, $day, $month, $year, $title, $description) = @_;
54 my $calendar = C4
::Calendar
->new(branchcode
=> $branchcode);
56 if ($newoperation eq 'weekday') {
57 unless ( $weekday && ($weekday ne '') ) {
58 # was dow calculated by javascript? original code implies it was supposed to be.
60 $weekday = &Date
::Calc
::Day_of_Week
($year, $month, $day) % 7 unless($weekday);
62 unless($calendar->isHoliday($day, $month, $year)) {
63 $calendar->insert_week_day_holiday(weekday
=> $weekday,
65 description
=> $description);
67 } elsif ($newoperation eq 'repeatable') {
68 unless($calendar->isHoliday($day, $month, $year)) {
69 $calendar->insert_day_month_holiday(day
=> $day,
72 description
=> $description);
74 } elsif ($newoperation eq 'holiday') {
75 unless($calendar->isHoliday($day, $month, $year)) {
76 $calendar->insert_single_holiday(day
=> $day,
80 description
=> $description);