Bug 9416: (follow-up) fix neworderempty and templates
[koha.git] / opac / svc / shelfbrowser.pl
1 #!/usr/bin/perl
2
3 use Modern::Perl;
4 use CGI;
5
6 use C4::Auth;
7 use C4::Context;
8 use C4::Output;
9 use C4::ShelfBrowser;
10
11 my $cgi = new CGI;
12
13 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
14     {
15         template_name   => "svc/shelfbrowser.tt",
16         query           => $cgi,
17         type            => "opac",
18         authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
19         flagsrequired   => { borrow => 1 },
20     }
21 );
22
23 # Shelf Browser Stuff
24 if (C4::Context->preference("OPACShelfBrowser")) {
25     my $starting_itemnumber = $cgi->param('shelfbrowse_itemnumber');
26     if (defined($starting_itemnumber)) {
27         my $nearby = GetNearbyItems($starting_itemnumber);
28
29         $template->param(
30             starting_homebranch => $nearby->{starting_homebranch}->{description},
31             starting_location => $nearby->{starting_location}->{description},
32             starting_ccode => $nearby->{starting_ccode}->{description},
33             shelfbrowser_prev_item => $nearby->{prev_item},
34             shelfbrowser_next_item => $nearby->{next_item},
35             shelfbrowser_items => $nearby->{items},
36             OpenOPACShelfBrowser => 1,
37         );
38     }
39 }
40
41 print $template->output;