Main Koha release repository https://koha-community.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

107 lines
3.8 KiB

  1. #!/usr/bin/perl
  2. # This file is part of Koha.
  3. #
  4. # Copyright Paul Poulain 2002
  5. # Parts Copyright Liblime 2007
  6. # Copyright (C) 2013 Mark Tompsett
  7. #
  8. # Koha is free software; you can redistribute it and/or modify it
  9. # under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # Koha is distributed in the hope that it will be useful, but
  14. # WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with Koha; if not, see <http://www.gnu.org/licenses>.
  20. use Modern::Perl;
  21. use CGI qw ( -utf8 );
  22. use C4::Output;
  23. use C4::Auth;
  24. use C4::Koha;
  25. use C4::NewsChannels; # GetNewsToDisplay
  26. use C4::Tags qw/get_count_by_tag_status/;
  27. use Koha::Patron::Modifications;
  28. use Koha::Patron::Discharge;
  29. use Koha::Reviews;
  30. use Koha::ArticleRequests;
  31. use Koha::ProblemReports;
  32. use Koha::Quotes;
  33. use Koha::Suggestions;
  34. my $query = CGI->new;
  35. my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
  36. {
  37. template_name => "intranet-main.tt",
  38. query => $query,
  39. type => "intranet",
  40. flagsrequired => { catalogue => 1, },
  41. }
  42. );
  43. my $homebranch;
  44. if (C4::Context->userenv) {
  45. $homebranch = C4::Context->userenv->{'branch'};
  46. }
  47. my $all_koha_news = &GetNewsToDisplay("koha",$homebranch);
  48. my $koha_news_count = scalar @$all_koha_news;
  49. $template->param(
  50. koha_news => $all_koha_news,
  51. koha_news_count => $koha_news_count,
  52. daily_quote => Koha::Quotes->get_daily_quote(),
  53. );
  54. my $branch =
  55. ( C4::Context->preference("IndependentBranchesPatronModifications")
  56. || C4::Context->preference("IndependentBranches") )
  57. && !$flags->{'superlibrarian'}
  58. ? C4::Context->userenv()->{'branch'}
  59. : undef;
  60. my $pendingcomments = Koha::Reviews->search_limited({ approved => 0 })->count;
  61. my $pendingtags = get_count_by_tag_status(0);
  62. # Get current branch count and total viewable count, if they don't match then pass
  63. # both to template
  64. if( C4::Context->only_my_library ){
  65. my $local_pendingsuggestions_count = Koha::Suggestions->search({ status => "ASKED", branchcode => C4::Context->userenv()->{'branch'} })->count();
  66. $template->param( pendingsuggestions => $local_pendingsuggestions_count );
  67. } else {
  68. my $pendingsuggestions = Koha::Suggestions->search({ status => "ASKED" });
  69. my $local_pendingsuggestions_count = $pendingsuggestions->search({ 'me.branchcode' => C4::Context->userenv()->{'branch'} })->count();
  70. my $pendingsuggestions_count = $pendingsuggestions->count();
  71. $template->param(
  72. all_pendingsuggestions => $pendingsuggestions_count != $local_pendingsuggestions_count ? $pendingsuggestions_count : 0,
  73. pendingsuggestions => $local_pendingsuggestions_count
  74. );
  75. }
  76. my $pending_borrower_modifications = Koha::Patron::Modifications->pending_count( $branch );
  77. my $pending_discharge_requests = Koha::Patron::Discharge::count({ pending => 1 });
  78. my $pending_article_requests = Koha::ArticleRequests->search_limited(
  79. {
  80. status => Koha::ArticleRequest::Status::Pending,
  81. $branch ? ( 'me.branchcode' => $branch ) : (),
  82. }
  83. )->count;
  84. my $pending_problem_reports = Koha::ProblemReports->search({ status => 'New' });
  85. $template->param(
  86. pendingcomments => $pendingcomments,
  87. pendingtags => $pendingtags,
  88. pending_borrower_modifications => $pending_borrower_modifications,
  89. pending_discharge_requests => $pending_discharge_requests,
  90. pending_article_requests => $pending_article_requests,
  91. pending_problem_reports => $pending_problem_reports
  92. );
  93. output_html_with_http_headers $query, $cookie, $template->output;