Bug 31775: Show single library
[koha-ffzg.git] / opac / opac-topissues.pl
index ac240df..43830cc 100755 (executable)
 # 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 qw ( -utf8 );
-use C4::Auth;
+use C4::Auth qw( get_template_and_user );
 use C4::Context;
-use C4::Languages;
 use C4::Search;
-use C4::Output;
-use C4::Koha;
-use C4::Branch;
-use C4::Circulation;
-use Date::Manip;
+use C4::Output qw( output_html_with_http_headers );
+use C4::Circulation qw( GetTopIssues );
 
 =head1 NAME
 
@@ -41,7 +36,7 @@ plugin that shows a stats on borrowers
 
 =cut
 
-my $input = new CGI;
+my $input = CGI->new;
 
 # if OpacTopissue is disabled, leave immediately
 if ( ! C4::Context->preference('OpacTopissue') ) {
@@ -49,16 +44,12 @@ if ( ! C4::Context->preference('OpacTopissue') ) {
     exit;
 }
 
-my $branches = GetBranches();
-my $itemtypes = GetItemTypes();
-
 my ($template, $borrowernumber, $cookie) = get_template_and_user(
     {
         template_name   => 'opac-topissues.tt',
         query           => $input,
         type            => "opac",
         authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
-        debug           => 1,
     }
 );
 my $dbh = C4::Context->dbh;
@@ -73,7 +64,7 @@ if (!$do_it && C4::Context->userenv && C4::Context->userenv->{'branch'} ) {
 }
 my $itemtype = $input->param('itemtype') || '';
 my $timeLimit = $input->param('timeLimit') || 3;
-my $advanced_search_types = C4::Context->preference('AdvancedSearchTypes');
+my $advanced_search_types = C4::Context->preference('OpacAdvancedSearchTypes');
 my @advanced_search_types = split /\|/, $advanced_search_types;
 
 my $params = {
@@ -88,18 +79,16 @@ foreach my $type (@advanced_search_types) {
         $type = 'itemtype';
     }
     $params->{$type} = $input->param($type);
-    $template->param('selected_' . $type => $input->param($type));
+    $template->param('selected_' . $type => scalar $input->param($type));
 }
 
 my @results = GetTopIssues($params);
 
 $template->param(
     limit => $limit,
-    branch => $branches->{$branch}->{branchname},
+    branch => $branch,
     timeLimit => $timeLimit,
     results => \@results,
 );
 
-$template->param(branchloop => GetBranchesLoop($branch));
-
 output_html_with_http_headers $input, $cookie, $template->output;