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 |
|