ffzg/recall_notices.pl: added --interval and --dedup
[koha.git] / admin / item_circulation_alerts.pl
index cf74f8f..9ea89a5 100755 (executable)
@@ -2,23 +2,22 @@
 
 # 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 2 of the License, or (at your option) any later
-# version.
+# 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.
+# 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 License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
+use Modern::Perl;
 
-use CGI;
+use CGI qw ( -utf8 );
 use File::Basename;
 use Encode;
 use JSON;
@@ -26,34 +25,14 @@ use JSON;
 
 use C4::Auth;
 use C4::Context;
-use C4::Branch;
-use C4::Category;
-use C4::ItemType;
 use C4::ItemCirculationAlertPreference;
 use C4::Output;
 
-# shortcut for long package name
-my $preferences = 'C4::ItemCirculationAlertPreference';
-
-# utf8 filter
-sub utf8 {
-    my ($data, @keys) = @_;
-    for (@keys) {
-        $data->{$_} = decode('utf8', $data->{$_});
-    }
-    $data;
-}
+use Koha::ItemTypes;
+use Koha::Patron::Categories;
 
-# prepend "br_" to column name and replace spaces with "<br/>"
-sub br {
-    my ($data, @keys) = @_;
-    for (@keys) {
-        my $br = $data->{$_};
-        $br =~ s{\s+}{<br/>}g;
-        $data->{'br_'.$_} = $br;
-    }
-    $data;
-}
+# shortcut for long package name
+our $preferences = 'C4::ItemCirculationAlertPreference';
 
 # display item circulation alerts
 sub show {
@@ -61,41 +40,22 @@ sub show {
     my $dbh = C4::Context->dbh;
     my ($template, $user, $cookie) = get_template_and_user(
         {
-            template_name   => "admin/item_circulation_alerts.tmpl",
+            template_name   => "admin/item_circulation_alerts.tt",
             query           => $input,
             type            => "intranet",
             authnotrequired => 0,
-            flagsrequired   => { admin => 1 },
+            flagsrequired   => { parameters => 'item_circ_alerts' },
             debug           => defined($input->param('debug')),
         }
     );
 
-    my $br       = GetBranches;
     my $branch   = $input->param('branch') || '*';
-    my @branches = (
-        {
-            branchcode => '*',
-            branchname => 'Default',
-        },
-        sort { $a->{branchname} cmp $b->{branchname} } values %$br,
-    );
-    for (@branches) {
-        $_->{selected} = "selected" if ($branch eq $_->{branchcode});
-    }
-    my $branch_name = exists($br->{$branch}) && $br->{$branch}->{branchname};
-
-    my @categories = (
-        C4::Category->all
-    );
-    my @item_types = map { br($_, 'description') }  (
-        C4::ItemType->all
-    );
+    my @categories = Koha::Patron::Categories->search_limited;
+    my @item_types = Koha::ItemTypes->search;
     my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
     my $grid_checkin  = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' });
 
     $template->param(branch             => $branch);
-    $template->param(branch_name        => $branch_name || 'Default');
-    $template->param(branches           => \@branches);
     $template->param(categories         => \@categories);
     $template->param(item_types         => \@item_types);
     $template->param(grid_checkout      => $grid_checkout);
@@ -225,14 +185,3 @@ Branch code to apply this preference to
 =back
 
 =cut
-
-# Local Variables: ***
-# mode: cperl ***
-# indent-tabs-mode: nil ***
-# cperl-close-paren-offset: -4 ***
-# cperl-continued-statement-offset: 4 ***
-# cperl-indent-level: 4 ***
-# cperl-indent-parens-as-block: t ***
-# cperl-tab-always-indent: nil ***
-# End: ***
-# vim:tabstop=8 softtabstop=4 shiftwidth=4 shiftround expandtab