+my $newoperation = $input->param('newOperation');
+my $allbranches = $input->param('allBranches');
+
+my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
+my $isodate = C4::Dates->new($calendardate, 'iso');
+$calendardate = $isodate->output('syspref');
+
+$title || ($title = '');
+if ($description) {
+ $description =~ s/\r/\\r/g;
+ $description =~ s/\n/\\n/g;
+} else {
+ $description = '';
+}
+
+if($allbranches) {
+ my $branch;
+ my @branchcodes = split(/\|/, $input->param('branchCodes'));
+ foreach $branch (@branchcodes) {
+ add_holiday($newoperation, $branch, $weekday, $day, $month, $year, $title, $description);
+ }
+} else {
+ add_holiday($newoperation, $branchcode, $weekday, $day, $month, $year, $title, $description);
+}
+
+print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$originalbranchcode&calendardate=$calendardate");