[followup](bug #4334) fix duplicate entries in sql
[koha.git] / catalogue / showmarc.pl
index 6239b71..06bf843 100755 (executable)
@@ -35,13 +35,13 @@ use C4::Context;
 use C4::Output;
 use C4::Auth;
 use C4::Biblio;
+use C4::ImportBatch;
 use XML::LibXSLT;
 use XML::LibXML;
 
-my $userid = $ENV{'REMOTE_USER'};
-
 my $input       = new CGI;
 my $biblionumber = $input->param('id');
+my $importid           =       $input->param('importid');
 my $view               = $input->param('viewas');
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@@ -50,16 +50,25 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         query           => $input,
         type            => "intranet",
         authnotrequired => 0,
-        flagsrequired   => { acquisition => 1  },
+        flagsrequired   => { catalogue => 1  },
         debug           => 1,
     }
 );
 
 $template->param( SCRIPT_NAME => $ENV{'SCRIPT_NAME'}, );
+my ($record, $xmlrecord);
+if($importid) {
+       my ($marc,$encoding) = GetImportRecordMarc($importid);
+               $record = MARC::Record->new_from_usmarc($marc) ;
+       if($view eq 'card') {
+               $xmlrecord = $record->as_xml();
+       } 
+}
+               
 if($view eq 'card') {
-my $xmlrecord = GetXmlBiblio($biblionumber);
+$xmlrecord = GetXmlBiblio($biblionumber) unless $xmlrecord;
 
-my $xslfile = C4::Context->config('intranetdir')."/koha-tmpl/intranet-tmpl/prog/en/xslt/compact.xsl";
+my $xslfile = C4::Context->config('intrahtdocs')."/prog/en/xslt/compact.xsl";
 my $parser = XML::LibXML->new();
 my $xslt = XML::LibXSLT->new();
 my $source = $parser->parse_string($xmlrecord);
@@ -73,7 +82,7 @@ print $newxmlrecord;
 
 } else {
 
-my $record =GetMarcBiblio($biblionumber)
+$record =GetMarcBiblio($biblionumber) unless $record
 
 my $formatted = $record->as_formatted;
 $template->param( MARC_FORMATTED => $formatted );