fix for #614
[koha.git] / opac / opac-search.pl
index 200531c..80736a6 100755 (executable)
@@ -2,15 +2,34 @@
 use strict;
 require Exporter;
 
-use C4::Output;
-use CGI;
 use C4::Auth;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use CGI;
+use C4::Database;
+use HTML::Template;
+
+my $classlist='';
+
+my $dbh=C4::Context->dbh;
+my $sth=$dbh->prepare("select description,itemtype from itemtypes order by description");
+$sth->execute;
+while (my ($description,$itemtype) = $sth->fetchrow) {
+    $classlist.="<option value=\"$itemtype\">$description\n";
+}
+
 
 my $query = new CGI;
-my ($loggedinuser, $cookie, $sessionID) = checkauth($query ,1);
 
-my $template = gettemplate("opac-search.tmpl", "opac");
+my ($template, $borrowernumber, $cookie)
+    = get_template_and_user({template_name => "opac-search.tmpl",
+                            query => $query,
+                            type => "opac",
+                            authnotrequired => 1,
+                            flagsrequired => {borrow => 1},
+                        });
+
 
-$template->param(loggedinuser => $loggedinuser);
+$template->param(classlist => $classlist);
 
-print "Content-Type: text/html\n\n", $template->output;
+output_html_with_http_headers $query, $cookie, $template->output;