Bug 2616: Remove unnecessary 'use HTML::Template' calls
[srvgit] / catalogue / export.pl
index 0093ce0..2b55d9f 100755 (executable)
@@ -1,27 +1,32 @@
 #!/usr/bin/perl
-use HTML::Template::Pro;
 use strict;
+#use warnings; FIXME - Bug 2505
 
 use C4::Record;
 use C4::Auth;
 use C4::Output;
 use C4::Biblio;
 use CGI;
-use C4::Auth;
+
+
 
 my $query = new CGI;
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
+                                                                     template_name   => "tools/export.tt",
+                                                                     query           => $query,
+                                                                     type            => "intranet",
+                                                                     authnotrequired => 0,
+                                                                     flagsrequired   => { tools => 'export_catalog' },
+                                                                     debug           => 1,
+                                                                     });
+
 my $op=$query->param("op");
 my $format=$query->param("format");
 if ($op eq "export") {
        my $biblionumber = $query->param("bib");
-       my $dbh=C4::Context->dbh;
-       my $sth;
-       if ($biblionumber) {
-               $sth=$dbh->prepare("SELECT marc FROM biblioitems WHERE biblionumber =?");
-               $sth->execute($biblionumber);
-       }
-       while (my ($marc) = $sth->fetchrow) {
-               if ($marc){
+               if ($biblionumber){
+
+                       my $marc = GetMarcBiblio($biblionumber, 1);
 
                        if ($format =~ /endnote/) {
                                $marc = marc2endnote($marc);
@@ -43,12 +48,12 @@ if ($op eq "export") {
                                $marc = $marc->as_usmarc();
                        }
                        elsif ($format =~ /utf8/) {
-                               #default
+                               C4::Charset::SetUTF8Flag($marc, 1);
+                               $marc = $marc->as_usmarc();
                        }
                        print $query->header(
                                -type => 'application/octet-stream',
                 -attachment=>"bib-$biblionumber.$format");
                        print $marc;
                }
-       }
 }