+# barcode export
+if ( $op eq 'export_barcodes' ) {
+ my $today = C4::Dates->new();
+ $today = $today->output('iso');
+ my @barcodes =
+ map { $_->{barcode} } grep { $_->{returndate} =~ m/^$today/o } @{$issues};
+ my $borrowercardnumber =
+ GetMember( borrowernumber => $borrowernumber )->{'cardnumber'};
+ my $delimiter = "\n";
+ binmode( STDOUT, ":encoding(UTF-8)" );
+ print $input->header(
+ -type => 'application/octet-stream',
+ -charset => 'utf-8',
+ -attachment => "$today-$borrowercardnumber-checkinexport.txt"
+ );
+ my $content = join $delimiter, uniq(@barcodes);
+ print $content;
+ exit;
+}
+
+if ( $data->{'category_type'} eq 'C') {
+ my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
+ my $cnt = scalar(@$catcodes);
+ $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
+ $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
+}
+
+$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
+if (! $limit){
+ $limit = 'full';
+}
+
+
+my ($picture, $dberror) = GetPatronImage($data->{'borrowernumber'});
+$template->param( picture => 1 ) if $picture;
+
+if (C4::Context->preference('ExtendedPatronAttributes')) {
+ my $attributes = GetBorrowerAttributes($borrowernumber);
+ $template->param(
+ ExtendedPatronAttributes => 1,
+ extendedattributes => $attributes
+ );
+}
+
+$template->param(
+ readingrecordview => 1,
+ title => $data->{title},
+ initials => $data->{initials},
+ surname => $data->{surname},
+ othernames => $data->{othernames},
+ borrowernumber => $borrowernumber,
+ firstname => $data->{firstname},
+ cardnumber => $data->{cardnumber},
+ categorycode => $data->{categorycode},
+ category_type => $data->{category_type},
+ categoryname => $data->{description},
+ address => $data->{address},
+ address2 => $data->{address2},
+ city => $data->{city},
+ state => $data->{state},
+ zipcode => $data->{zipcode},
+ country => $data->{country},
+ phone => $data->{phone},
+ email => $data->{email},
+ branchcode => $data->{branchcode},
+ is_child => ( $data->{category_type} eq 'C' ),
+ branchname => $branches->{ $data->{branchcode} }->{branchname},
+ loop_reading => $issues,
+ activeBorrowerRelationship =>
+ ( C4::Context->preference('borrowerRelationship') ne '' ),
+ RoutingSerials => C4::Context->preference('RoutingSerials'),
+);
+output_html_with_http_headers $input, $cookie, $template->output;