In recent versions of Perl, '.' is not included by default in @INC. This
breaks PDF export of basketgroups.
This patch moves acqui/pdfformat/*.pm files in Koha namespace so that
they can be 'require'd without manipulating @INC
Test plan:
1. Turn off Plack/Starman and test PDF export for every value of
OrderPdfFormat system preference
2. Turn on Plack/Starman and test PDF export for every value of
OrderPdfFormat system preference
3. Test on a dev install and a standard/package install
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit
3c18d4c18fad5a0d470c7bdf1ac746a640f25099)
Signed-off-by: Jesse Maseto <jesse@bywatersolution.com>
-#!/usr/bin/perl
+package Koha::pdfformat::layout2pages;
#example script to print a basketgroup
#written 07/11/08 by john.soros@biblibre.com and paul.poulain@biblibre.com
# along with Koha; if not, see <http://www.gnu.org/licenses>.
#you can use any PDF::API2 module, all you need to do is return the stringifyed pdf object from the printpdf sub.
-package pdfformat::layout2pages;
use vars qw(@ISA @EXPORT);
use MIME::Base64;
use Modern::Perl;
-#!/usr/bin/perl
+package Koha::pdfformat::layout2pagesde;
#example script to print a basketgroup
#written 07/11/08 by john.soros@biblibre.com and paul.poulain@biblibre.com
# along with Koha; if not, see <http://www.gnu.org/licenses>.
#you can use any PDF::API2 module, all you need to do is return the stringifyed pdf object from the printpdf sub.
-package pdfformat::layout2pagesde;
use vars qw(@ISA @EXPORT);
use MIME::Base64;
use Modern::Perl;
-#!/usr/bin/perl
+package Koha::pdfformat::layout3pages;
#example script to print a basketgroup
#written 07/11/08 by john.soros@biblibre.com and paul.poulain@biblibre.com
# along with Koha; if not, see <http://www.gnu.org/licenses>.
#you can use any PDF::API2 module, all you need to do is return the stringifyed pdf object from the printpdf sub.
-package pdfformat::layout3pages;
use vars qw(@ISA @EXPORT);
use MIME::Base64;
use List::MoreUtils qw/uniq/;
-#!/usr/bin/perl
+package Koha::pdfformat::layout3pagesfr;
#example script to print a basketgroup
#written 07/11/08 by john.soros@biblibre.com and paul.poulain@biblibre.com
use C4::Auth;
use C4::Output;
use CGI qw ( -utf8 );
+use File::Spec;
use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/;
use Koha::EDI qw/create_edi_order get_edifact_ean/;
sub printbasketgrouppdf{
my ($basketgroupid) = @_;
-
+
my $pdfformat = C4::Context->preference("OrderPdfFormat");
- if ($pdfformat eq 'pdfformat::layout3pages' || $pdfformat eq 'pdfformat::layout2pages' || $pdfformat eq 'pdfformat::layout3pagesfr'
- || $pdfformat eq 'pdfformat::layout2pagesde'){
- eval {
- eval "require $pdfformat";
- import $pdfformat;
- };
- if ($@){
- }
+ my @valid_pdfformats = qw(pdfformat::layout3pages pdfformat::layout2pages pdfformat::layout3pagesfr pdfformat::layout2pagesde);
+ if (grep {$_ eq $pdfformat} @valid_pdfformats) {
+ $pdfformat = "Koha::$pdfformat";
+ my $pdfformat_filepath = File::Spec->catfile(split /::/, $pdfformat) . '.pm';
+ require $pdfformat_filepath;
+ import $pdfformat;
}
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;
+ 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 = Koha::Acquisition::Booksellers->find( $basketgroup->{booksellerid} );
my $baskets = GetBasketsByBasketgroup($basketgroupid);
-
+
my %orders;
for my $basket (@$baskets) {
my @ba_orders;