Bug 21853: Fix PDF export of basketgroups

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 3c18d4c18f)

Signed-off-by: Jesse Maseto <jesse@bywatersolution.com>
This commit is contained in:
Julian Maurice 2018-11-17 11:58:02 +01:00 committed by Jesse Maseto
parent 857b1524a9
commit 320f9bf3d2
5 changed files with 19 additions and 23 deletions

View File

@ -1,4 +1,4 @@
#!/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
@ -21,7 +21,6 @@
# 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;

View File

@ -1,4 +1,4 @@
#!/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
@ -21,7 +21,6 @@
# 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;

View File

@ -1,4 +1,4 @@
#!/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
@ -21,7 +21,6 @@
# 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/;

View File

@ -1,4 +1,4 @@
#!/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

View File

@ -49,6 +49,7 @@ use Carp;
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/;
@ -123,29 +124,27 @@ sub displaybasketgroups {
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;