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

(-)a/patroncards/create-pdf.pl (-28 / +31 lines)
Lines 184-219 foreach my $item (@{$items}) { Link Here
184
        my $error = undef;
184
        my $error = undef;
185
        my $images = $print_layout_xml->{'images'};
185
        my $images = $print_layout_xml->{'images'};
186
        PROCESS_IMAGES:
186
        PROCESS_IMAGES:
187
        foreach my $card_image (sort(keys %{$images})) {
187
            foreach my $card_image ( sort( keys %{$images} ) ) {
188
            if (grep{m/(source)/} keys(%{$images->{$card_image}->{'data_source'}->[0]})) {
188
                if ( grep { m/(source)/ } keys( %{ $images->{$card_image}->{'data_source'}->[0] } ) ) {
189
                if ($images->{$card_image}->{'data_source'}->[0]->{'image_source'} eq 'none') {
189
                    if ( $images->{$card_image}->{'data_source'}->[0]->{'image_source'} eq 'none' ) {
190
                }
190
                    } elsif ( $images->{$card_image}->{'data_source'}->[0]->{'image_source'} eq 'patronimages' ) {
191
                elsif ($images->{$card_image}->{'data_source'}->[0]->{'image_source'} eq 'patronimages') {
191
                        my $patron_image = Koha::Patron::Images->find($borrower_number);
192
                    my $patron_image = Koha::Patron::Images->find($borrower_number);
192
                        if ($patron_image) {
193
                    if ($patron_image) {
193
                            $image_data->{'imagefile'} = $patron_image->imagefile;
194
                        $image_data->{'imagefile'} = $patron_image->imagefile;
194
                        } else {
195
                    }
195
                            warn sprintf( 'No image exists for borrower number %s.', $borrower_number );
196
                    else {
196
                        }
197
                        warn sprintf('No image exists for borrower number %s.', $borrower_number);
197
                    } elsif ( $images->{$card_image}->{'data_source'}->[0]->{'image_source'} eq 'creator_images' ) {
198
                        ## FIXME: The DB stuff here needs to be religated to a Koha::Creator::Images object -chris_n
199
                        my $dbh = C4::Context->dbh();
200
                        $dbh->{LongReadLen} = 1000000;                   # allows us to read approx 1MB
201
                        $image_data = $dbh->selectrow_hashref(
202
                            "SELECT imagefile FROM creator_images WHERE image_name = \'$images->{$card_image}->{'data_source'}->[0]->{'image_name'}\'"
203
                        );
204
                        warn sprintf( 'Database returned the following error: %s.', $error ) if $error;
205
                        unless ($image_data) {
206
                            warn sprintf(
207
                                'Image does not exists in db table %s.',
208
                                $images->{$card_image}->{'data_source'}->[0]->{'image_name'}
209
                            );
210
                        }
211
                    } else {
212
                        warn sprintf(
213
                            'No retrieval method for image source %s.',
214
                            $images->{$card_image}->{'data_source'}->[0]->{'image_source'}
215
                        );
198
                    }
216
                    }
217
                } else {
218
                    warn sprintf( "Unrecognized image data source: %s", $images->{$card_image}->{'data_source'} );
199
                }
219
                }
200
                elsif ($images->{$card_image}->{'data_source'}->[0]->{'image_source'} eq 'creator_images') {
201
                    ## FIXME: The DB stuff here needs to be religated to a Koha::Creator::Images object -chris_n
202
                    my $dbh = C4::Context->dbh();
203
                    $dbh->{LongReadLen} = 1000000;      # allows us to read approx 1MB
204
                    $image_data = $dbh->selectrow_hashref("SELECT imagefile FROM creator_images WHERE image_name = \'$images->{$card_image}->{'data_source'}->[0]->{'image_name'}\'");
205
                    warn sprintf('Database returned the following error: %s.', $error) if $error;
206
                    unless($image_data){
207
                        warn sprintf('Image does not exists in db table %s.', $images->{$card_image}->{'data_source'}->[0]->{'image_name'});
208
                    }
209
                }
210
                else {
211
                    warn sprintf('No retrieval method for image source %s.', $images->{$card_image}->{'data_source'}->[0]->{'image_source'});
212
                }
213
            }
214
            else {
215
                warn sprintf("Unrecognized image data source: %s", $images->{$card_image}->{'data_source'});
216
            }
217
220
218
        my $binary_data = $image_data->{'imagefile'} || next PROCESS_IMAGES;
221
        my $binary_data = $image_data->{'imagefile'} || next PROCESS_IMAGES;
219
222
(-)a/patroncards/print.pl (-13 / +17 lines)
Lines 79-97 if ($op eq 'export') { Link Here
79
    elsif (@borrower_numbers) {
79
    elsif (@borrower_numbers) {
80
        my $borrower_number_param = '&borrower_number=';
80
        my $borrower_number_param = '&borrower_number=';
81
        $borrower_number_param .= join ('&borrower_number=',@borrower_numbers);
81
        $borrower_number_param .= join ('&borrower_number=',@borrower_numbers);
82
        push (@batches, {create_script   => ($output_format eq 'pdf' ? 'create-pdf.pl' : 'create-csv.pl'),    #FIXME csv not supported, no script?
82
        push(
83
                         template_id     => $template_id,
83
            @batches,
84
                         layout_id       => $layout_id,
84
            {
85
                         layout_back_id  => $layout_back_id,
85
                create_script => ( $output_format eq 'pdf' ? 'create-pdf.pl' : 'create-csv.pl' )
86
                         start_card      => $start_card,
86
                ,    #FIXME csv not supported, no script?
87
                         borrower_numbers    => $borrower_number_param,
87
                template_id      => $template_id,
88
                         card_count      => scalar(@borrower_numbers),
88
                layout_id        => $layout_id,
89
                        });
89
                layout_back_id   => $layout_back_id,
90
                start_card       => $start_card,
91
                borrower_numbers => $borrower_number_param,
92
                card_count       => scalar(@borrower_numbers),
93
            }
94
        );
90
        $template->param(
95
        $template->param(
91
                        batches     => \@batches,
96
            batches  => \@batches,
92
                        referer     => $referer,
97
            referer  => $referer,
93
                        order_by    => $order_by,
98
            order_by => $order_by,
94
                        );
99
        );
95
    }
100
    }
96
    elsif (@batch_ids) {
101
    elsif (@batch_ids) {
97
        foreach my $batch_id (@batch_ids) {
102
        foreach my $batch_id (@batch_ids) {
98
- 

Return to bug 32742