Bug 18789: (QA follow-up) Fix viewlog when accessed via circulation
[koha.git] / tools / newHolidays.pl
index eda4c1b..a161eaf 100755 (executable)
@@ -1,16 +1,30 @@
 #!/usr/bin/perl
-#FIXME: add a license
 #FIXME: perltidy this file
 
-use strict;
-use warnings;
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public Lic# along with Koha; if not, see <http://www.gnu.org/licenses>.
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+
+use Modern::Perl;
 
 use CGI qw ( -utf8 );
 
 use C4::Auth;
 use C4::Output;
 
-use Koha::Cache;
+use Koha::Caches;
 
 use C4::Calendar;
 use DateTime;
@@ -57,13 +71,12 @@ if ($end_dt){
 }
 
 if($allbranches) {
-       my $branch;
-       my @branchcodes = split(/\|/, $input->param('branchCodes')); 
-       foreach $branch (@branchcodes) {
-               add_holiday($newoperation, $branch, $weekday, $day, $month, $year, $title, $description);
-       }
+    my $libraries = Koha::Libraries->search;
+    while ( my $library = $libraries->next ) {
+        add_holiday($newoperation, $library->branchcode, $weekday, $day, $month, $year, $title, $description);
+    }
 } else {
-       add_holiday($newoperation, $branchcode, $weekday, $day, $month, $year, $title, $description);
+    add_holiday($newoperation, $branchcode, $weekday, $day, $month, $year, $title, $description);
 }
 
 print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$originalbranchcode&calendardate=$calendardate");
@@ -129,6 +142,6 @@ sub add_holiday {
         }
     }
     # we updated the single_holidays table, so wipe its cache
-    my $cache = Koha::Cache->get_instance();
+    my $cache = Koha::Caches->get_instance();
     $cache->clear_from_cache( 'single_holidays') ;
 }