Bug 23228: (QA follow-up) Add required filters
[koha.git] / mainpage.pl
blob49f46fc272f594848c9ac3cca3bb956ac4c4b000
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Copyright Paul Poulain 2002
6 # Parts Copyright Liblime 2007
7 # Copyright (C) 2013 Mark Tompsett
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Modern::Perl;
23 use CGI qw ( -utf8 );
24 use C4::Output;
25 use C4::Auth;
26 use C4::Koha;
27 use C4::NewsChannels; # GetNewsToDisplay
28 use C4::Suggestions qw/CountSuggestion/;
29 use C4::Tags qw/get_count_by_tag_status/;
30 use Koha::Patron::Modifications;
31 use Koha::Patron::Discharge;
32 use Koha::Reviews;
33 use Koha::ArticleRequests;
35 my $query = new CGI;
37 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
39 template_name => "intranet-main.tt",
40 query => $query,
41 type => "intranet",
42 authnotrequired => 0,
43 flagsrequired => { catalogue => 1, },
47 my $homebranch;
48 if (C4::Context->userenv) {
49 $homebranch = C4::Context->userenv->{'branch'};
51 my $all_koha_news = &GetNewsToDisplay("koha",$homebranch);
52 my $koha_news_count = scalar @$all_koha_news;
54 $template->param(
55 koha_news => $all_koha_news,
56 koha_news_count => $koha_news_count
59 my $branch =
60 ( C4::Context->preference("IndependentBranchesPatronModifications")
61 || C4::Context->preference("IndependentBranches") )
62 && !$flags->{'superlibrarian'}
63 ? C4::Context->userenv()->{'branch'}
64 : undef;
66 my $pendingcomments = Koha::Reviews->search_limited({ approved => 0 })->count;
67 my $pendingtags = get_count_by_tag_status(0);
68 my $pendingsuggestions = CountSuggestion("ASKED");
69 my $pending_borrower_modifications = Koha::Patron::Modifications->pending_count( $branch );
70 my $pending_discharge_requests = Koha::Patron::Discharge::count({ pending => 1 });
71 my $pending_article_requests = Koha::ArticleRequests->search_limited(
73 status => Koha::ArticleRequest::Status::Pending,
74 $branch ? ( 'me.branchcode' => $branch ) : (),
76 )->count;
78 $template->param(
79 pendingcomments => $pendingcomments,
80 pendingtags => $pendingtags,
81 pendingsuggestions => $pendingsuggestions,
82 pending_borrower_modifications => $pending_borrower_modifications,
83 pending_discharge_requests => $pending_discharge_requests,
84 pending_article_requests => $pending_article_requests,
87 output_html_with_http_headers $query, $cookie, $template->output;