Fixing a bug caused by the syncing with the 2.2 branch
[koha.git] / opac / opac-main.pl
1 #!/usr/bin/perl
2 use strict;
3 require Exporter;
4 use CGI;
5 use HTML::Template;
6
7 use C4::Auth;       # get_template_and_user
8 use C4::Interface::CGI::Output;
9 use C4::BookShelves;
10 use C4::Koha;
11 use C4::Members;
12
13 my $input = new CGI;
14 my $dbh = C4::Context->dbh;
15 my $query="Select itemtype,description from itemtypes order by description";
16 my $sth=$dbh->prepare($query);
17 $sth->execute;
18 my  @itemtype;
19 my %itemtypes;
20 while (my ($value,$lib) = $sth->fetchrow_array) {
21         push @itemtype, $value;
22         $itemtypes{$value}=$lib;
23 }
24
25 my $CGIitemtype=CGI::scrolling_list( -name     => 'value',
26                         -values   => \@itemtype,
27                         -labels   => \%itemtypes,
28                         -size     => 1,
29                         -multiple => 0 );
30 $sth->finish;
31
32 my ($template, $borrowernumber, $cookie)
33     = get_template_and_user({template_name => "opac-main.tmpl",
34                              type => "opac",
35                              query => $input,
36                              authnotrequired => 1,
37                              flagsrequired => {borrow => 1},
38                          });
39 my $borrower = getmember('',$borrowernumber);
40 my @options;
41 my $counter=0;
42 foreach my $language (getalllanguages()) {
43         next if $language eq 'images';
44         my $selected='0';
45 #                            next if $currently_selected_languages->{$language};
46         push @options, { language => $language, counter => $counter };
47         $counter++;
48 }
49
50 $template->param(CGIitemtype => $CGIitemtype,
51                                 suggestion => C4::Context->preference("suggestion"),
52                                 virtualshelves => C4::Context->preference("virtualshelves"),
53                                 languages => \@options,
54                                 textmessaging => $borrower->{textmessaging},
55                                 opaclargeimage => C4::Context->preference("opaclargeimage"),
56 );
57 output_html_with_http_headers $input, $cookie, $template->output;