View | Details | Raw Unified | Return to bug 14103
Collapse All | Expand All

(-)a/Koha/Borrower/Discharge.pm (-5 / +16 lines)
Lines 3-9 package Koha::Borrower::Discharge; Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
use CGI;
4
use CGI;
5
use File::Temp qw( :POSIX );
5
use File::Temp qw( :POSIX );
6
use Carp;
6
7
8
use C4::Templates qw ( gettemplate );
7
use C4::Members qw( GetPendingIssues );
9
use C4::Members qw( GetPendingIssues );
8
use C4::Reserves qw( GetReservesFromBorrowernumber CancelReserve );
10
use C4::Reserves qw( GetReservesFromBorrowernumber CancelReserve );
9
11
Lines 113-123 sub generate_as_pdf { Link Here
113
    open my $html_fh, '>:encoding(utf8)', $html_path;
115
    open my $html_fh, '>:encoding(utf8)', $html_path;
114
    say $html_fh $html_content;
116
    say $html_fh $html_content;
115
    close $html_fh;
117
    close $html_fh;
116
    require PDF::FromHTML;
118
    my $output = eval { require PDF::FromHTML; return; } || $@;
117
    my $pdf = PDF::FromHTML->new( encoding => 'utf-8' );
119
    if ($output && $params->{testing}) {
118
    $pdf->load_file( $html_path );
120
        carp $output;
119
    $pdf->convert;
121
        $pdf_path = undef;
120
    $pdf->write_file( $pdf_path );
122
    }
123
    elsif ($output) {
124
        die $output;
125
    }
126
    else {
127
        my $pdf = PDF::FromHTML->new( encoding => 'utf-8' );
128
        $pdf->load_file( $html_path );
129
        $pdf->convert;
130
        $pdf->write_file( $pdf_path );
131
    }
121
132
122
    return $pdf_path;
133
    return $pdf_path;
123
}
134
}
(-)a/t/db_dependent/Borrower_Discharge.t (-1 / +17 lines)
Lines 2-7 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::More;
4
use Test::More;
5
use Test::Warn;
5
use MARC::Record;
6
use MARC::Record;
6
7
7
use C4::Biblio qw( AddBiblio );
8
use C4::Biblio qw( AddBiblio );
Lines 46-51 AddReturn( $barcode ); Link Here
46
# Discharge possible without issue
47
# Discharge possible without issue
47
is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrowernumber }), 1, 'A patron without issues can be discharged' );
48
is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrowernumber }), 1, 'A patron without issues can be discharged' );
48
49
50
is(Koha::Borrower::Discharge::generate_as_pdf,undef,"Confirm failure when lacking borrower number");
51
52
# Check if PDF::FromHTML is installed.
53
my $check = eval { require PDF::FromHTML; };
54
55
# Tests for if PDF::FromHTML is installed
56
if ($check) {
57
    isnt( Koha::Borrower::Discharge::generate_as_pdf({ borrowernumber => $borrowernumber }), undef, "Temporary PDF generated." );
58
}
59
# Tests for if PDF::FromHTML is not installed
60
else {
61
    warning_like { Koha::Borrower::Discharge::generate_as_pdf({ borrowernumber => $borrowernumber, testing => 1 }) }
62
          [ qr/Can't locate PDF\/FromHTML.pm in \@INC/ ],
63
          "Expected failure because of missing PDF::FromHTML.";
64
}
65
49
# FIXME
66
# FIXME
50
# At this point, there is a problem with the AutoCommit off
67
# At this point, there is a problem with the AutoCommit off
51
# The transaction is bloked into DBIx::Class::Storage::DBI::_dbh_execute
68
# The transaction is bloked into DBIx::Class::Storage::DBI::_dbh_execute
52
- 

Return to bug 14103