Bug 20629: Pass accountline objects to template instead of hashref
[koha.git] / reviews / reviewswaiting.pl
blob6dc51f1349e99b5c473b40da728fe62953489c89
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::Biblio;
25 use Koha::Biblios;
26 use Koha::Patrons;
27 use Koha::Reviews;
29 my $query = new CGI;
30 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32 template_name => "reviews/reviewswaiting.tt",
33 query => $query,
34 type => "intranet",
35 authnotrequired => 0,
36 flagsrequired => { tools => 'moderate_comments' },
37 debug => 1,
41 my $op = $query->param('op') || '';
42 my $status = $query->param('status') || 0;
43 my $reviewid = $query->param('reviewid');
44 my $page = $query->param('page') || 1;
45 my $count = C4::Context->preference('numSearchResults') || 20;
46 my $total = Koha::Reviews->search_limited({ approved => $status })->count;
48 if ( $op eq 'approve' ) {
49 my $review = Koha::Reviews->find( $reviewid );
50 $review->approve if $review;
52 elsif ( $op eq 'unapprove' ) {
53 my $review = Koha::Reviews->find( $reviewid );
54 $review->unapprove if $review;
56 elsif ( $op eq 'delete' ) {
57 my $review = Koha::Reviews->find( $reviewid );
58 $review->delete if $review;
61 my $reviews = Koha::Reviews->search_limited(
62 { approved => $status },
64 rows => $count,
65 page => $page,
66 order_by => { -desc => 'datereviewed' },
68 )->unblessed;
70 for my $review ( @$reviews ) {
71 my $biblio = Koha::Biblios->find( $review->{biblionumber} );
72 # setting some borrower info into this hash
73 $review->{bibliotitle} = $biblio->title;
75 my $borrowernumber = $review->{borrowernumber};
76 my $patron = Koha::Patrons->find( $borrowernumber);
77 if ( $patron ) {
78 $review->{patron} = $patron;
82 my $url = "/cgi-bin/koha/reviews/reviewswaiting.pl?status=$status";
84 $template->param(
85 status => $status,
86 reviews => $reviews,
87 pagination_bar => pagination_bar( $url, ( int( $total / $count ) ) + ( ( $total % $count ) > 0 ? 1 : 0 ), $page, "page" )
90 output_html_with_http_headers $query, $cookie, $template->output;