Merge remote-tracking branch 'origin/new/bug_2629'
[koha_gimpoz] / acqui / basketgroup.pl
index 5dbae17..d2e1856 100755 (executable)
@@ -187,7 +187,7 @@ sub printbasketgrouppdf{
     my $pdfformat = C4::Context->preference("OrderPdfFormat");
     if ($pdfformat eq 'pdfformat::layout3pages' || $pdfformat eq 'pdfformat::layout2pages'){
        eval {
-           require $pdfformat;
+        eval "require $pdfformat";
            import $pdfformat;
        };
        if ($@){
@@ -251,10 +251,13 @@ sub printbasketgrouppdf{
                 push(@ba_orders, \@ba_order);
                 # Editor Number
                 my $en;
-                if (C4::Context->preference("marcflavour") eq 'UNIMARC') {
-                    $en = MARC::Record::new_from_xml($ord->{marcxml},'UTF-8')->subfield('345',"b");
-                } elsif (C4::Context->preference("marcflavour") eq 'MARC21') {
-                    $en = MARC::Record::new_from_xml($ord->{marcxml},'UTF-8')->subfield('037',"a");
+                my $marcrecord=eval{MARC::Record::new_from_xml( $ord->{marcxml},'UTF-8' )};
+                if ($marcrecord){
+                    if ( C4::Context->preference("marcflavour") eq 'UNIMARC' ) {
+                        $en = $marcrecord->subfield( '345', "b" );
+                    } elsif ( C4::Context->preference("marcflavour") eq 'MARC21' ) {
+                        $en = $marcrecord->subfield( '037', "a" );
+                    }
                 }
                 if($en){
                     push(@ba_order, $en);