Bug 17952 - Lost items not skipped by overdue_notices.pl
[koha.git] / reviews / reviewswaiting.pl
blob452b54c283a3002b44556b6319fe7fadac168ced
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 use Modern::Perl;
20 use CGI qw ( -utf8 );
21 use C4::Auth;
22 use C4::Output;
23 use C4::Context;
24 use C4::Members;
25 use C4::Biblio;
26 use Koha::Reviews;
28 my $query = new CGI;
29 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31 template_name => "reviews/reviewswaiting.tt",
32 query => $query,
33 type => "intranet",
34 authnotrequired => 0,
35 flagsrequired => { tools => 'moderate_comments' },
36 debug => 1,
40 my $op = $query->param('op') || '';
41 my $status = $query->param('status') || 0;
42 my $reviewid = $query->param('reviewid');
43 my $page = $query->param('page') || 1;
44 my $count = C4::Context->preference('numSearchResults') || 20;
45 my $total = Koha::Reviews->search({ approved => $status })->count;
47 if ( $op eq 'approve' ) {
48 my $review = Koha::Reviews->find( $reviewid );
49 $review->approve if $review;
51 elsif ( $op eq 'unapprove' ) {
52 my $review = Koha::Reviews->find( $reviewid );
53 $review->unapprove if $review;
55 elsif ( $op eq 'delete' ) {
56 my $review = Koha::Reviews->find( $reviewid );
57 $review->delete if $review;
60 my $reviews = Koha::Reviews->search(
61 { approved => $status },
63 rows => $count,
64 page => $page,
65 order_by => { -desc => 'datereviewed' },
67 )->unblessed;
69 foreach ( @$reviews ) {
70 my $borrowernumber = $_->{borrowernumber};
71 my $borrowerData = GetMember('borrowernumber' => $borrowernumber);
72 my $biblioData = GetBiblioData($_->{biblionumber});
73 # setting some borrower info into this hash
74 $_->{bibliotitle} = $biblioData->{'title'};
75 $_->{surname} = $borrowerData->{'surname'};
76 $_->{firstname} = $borrowerData->{'firstname'};
79 my $url = "/cgi-bin/koha/reviews/reviewswaiting.pl?status=$status";
81 $template->param(
82 status => $status,
83 reviews => $reviews,
84 pagination_bar => pagination_bar( $url, ( int( $total / $count ) ) + ( ( $total % $count ) > 0 ? 1 : 0 ), $page, "page" )
87 output_html_with_http_headers $query, $cookie, $template->output;