use strict;
use warnings;
+use Carp;
use C4::Input;
use C4::Auth;
my $input=new CGI;
-my ($template, $loggedinuser, $cookie)
+our ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "acqui/basketgroup.tmpl",
query => $input,
type => "intranet",
my ($basketgroupid) = @_;
my $pdfformat = C4::Context->preference("OrderPdfFormat");
- eval "use $pdfformat";
- # FIXME consider what would happen if $pdfformat does not
- # contain the name of a valid Perl module.
+ if ($pdfformat eq 'pdfformat::layout3pages' || $pdfformat eq 'pdfformat::layout2pages'){
+ eval {
+ eval "require $pdfformat";
+ import $pdfformat;
+ };
+ if ($@){
+ }
+ }
+ else {
+ print $input->header;
+ print $input->start_html; # FIXME Should do a nicer page
+ print "<h1>Invalid PDF Format set</h1>";
+ print "Please go to the systempreferences and set a valid pdfformat";
+ exit;
+ }
my $basketgroup = GetBasketgroup($basketgroupid);
my $bookseller = GetBookSellerFromId($basketgroup->{'booksellerid'});
#isbn, itemtype, author, title, publishercode, quantity, listprice ecost discount gstrate
my @ba_order;
if ( $ord->{biblionumber} && $ord->{quantity}> 0 ) {
- eval "use C4::Biblio";
- eval "use C4::Koha";
+ eval {
+ require C4::Biblio;
+ import C4::Biblio;
+ };
+ if ($@){
+ croak $@;
+ }
+ eval {
+ require C4::Koha;
+ import C4::Koha;
+ };
+ if ($@){
+ croak $@;
+ }
my $bib = GetBiblioData($ord->{biblionumber});
my $itemtypes = GetItemTypes();
if($ord->{isbn}){
} else {
push(@ba_order, undef);
}
- if ($ord->{itemtype}){
- push(@ba_order, $itemtypes->{$bib->{itemtype}}->{description}) if $bib->{itemtype};
+ if ($ord->{itemtype} and $bib->{itemtype}){
+ push(@ba_order, $itemtypes->{$bib->{itemtype}}->{description});
} else {
push(@ba_order, undef);
}
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);
);
my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->{gstrate} // C4::Context->preference("gist")) || die "pdf generation failed";
print $pdf;
+
}
my $op = $input->param('op');
# Build the combobox to select the billing place
my @billingplaceloop;
for (sort keys %$branches) {
- my $selected = 1 if $_ eq $billingplace;
- my %row = (
+ push @billingplaceloop, {
value => $_,
- selected => $selected,
+ selected => $_ eq $billingplace,
branchname => $branches->{$_}->{branchname},
- );
- push @billingplaceloop, \%row;
+ };
}
$template->param( billingplaceloop => \@billingplaceloop );
# Build the combobox to select the delivery place
my @deliveryplaceloop;
for (sort keys %$branches) {
- my $selected = 1 if $_ eq $deliveryplace;
- my %row = (
+ push @deliveryplaceloop, {
value => $_,
- selected => $selected,
+ selected => $_ eq $deliveryplace,
branchname => $branches->{$_}->{branchname},
- );
- push @deliveryplaceloop, \%row;
+ };
}
$template->param( deliveryplaceloop => \@deliveryplaceloop );