big commit, still breaking things...
[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::Context;
8 use C4::Auth;       # get_template_and_user
9 use C4::Interface::CGI::Output;
10 use C4::BookShelves;
11 use C4::Koha;
12 use C4::Members;
13
14 my $input = new CGI;
15 my $kohaVersion = C4::Context->config("kohaversion");
16 my $dbh = C4::Context->dbh;
17 my $query="Select itemtype,description from itemtypes order by description";
18 my $sth=$dbh->prepare($query);
19 $sth->execute;
20 my  @itemtype;
21 my %itemtypes;
22 while (my ($value,$lib) = $sth->fetchrow_array) {
23         push @itemtype, $value;
24         $itemtypes{$value}=$lib;
25 }
26
27 my $CGIitemtype=CGI::scrolling_list( -name     => 'value',
28                         -values   => \@itemtype,
29                         -labels   => \%itemtypes,
30                         -size     => 1,
31                         -multiple => 0 );
32 $sth->finish;
33
34 my ($template, $borrowernumber, $cookie)
35     = get_template_and_user({template_name => "opac-main.tmpl",
36                              type => "opac",
37                              query => $input,
38                              authnotrequired => 1,
39                              flagsrequired => {borrow => 1},
40                          });
41 my $borrower = getmember('',$borrowernumber);
42 my @options;
43 my $counter=0;
44 foreach my $language (getalllanguages()) {
45         next if $language eq 'images';
46         next if $language eq 'CVS';
47         my $selected='0';
48 #                            next if $currently_selected_languages->{$language};
49         push @options, { language => $language, counter => $counter };
50         $counter++;
51 }
52 my $languages_count = @options;
53
54 if($languages_count > 1){
55                 $template->param(languages => \@options);
56 }
57 $template->param(CGIitemtype => $CGIitemtype,
58                                 suggestion => C4::Context->preference("suggestion"),
59                                 virtualshelves => C4::Context->preference("virtualshelves"),
60                                 textmessaging => $borrower->{textmessaging},
61                                 opaclargeimage => C4::Context->preference("opaclargeimage"),
62                                 kohaversion => $kohaVersion
63 );
64 output_html_with_http_headers $input, $cookie, $template->output;