[Koha-patches] [PATCH 1/1] Bug 6751: Adds a link "Export checkin barcodes" in readingrec

Jonathan Druart jonathan.druart at biblibre.com
Mon Jan 2 13:30:04 CET 2012


to export a file containing a list of checkin barcode for the current day.
---
 .../prog/en/modules/members/readingrec.tt          |    1 +
 members/readingrec.pl                              |   23 +++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt
index f1554f0..be62076 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt
@@ -34,6 +34,7 @@
 [% IF ( loop_reading ) %]
 <form action="/cgi-bin/koha/members/readingrec.pl" method="get"><input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" /></form>
 
+<p><a href="readingrec.pl?borrowernumber=[% borrowernumber %]&amp;op=export_barcodes">Export checkin barcodes</a></p>
 <div id="pagertable_readingrec">
 [% INCLUDE 'table-pager.inc' perpage='20' %]
 </div>
diff --git a/members/readingrec.pl b/members/readingrec.pl
index b4fb8a7..dc0807f 100755
--- a/members/readingrec.pl
+++ b/members/readingrec.pl
@@ -29,7 +29,7 @@ use C4::Auth;
 use C4::Output;
 use C4::Members;
 use C4::Branch;
-use List::MoreUtils qw/any/;
+use List::MoreUtils qw/any uniq/;
 
 use C4::Dates qw/format_date/;
 use C4::Members::Attributes qw(GetBorrowerAttributes);
@@ -64,6 +64,9 @@ my $limit = 0;
 my ( $issues ) = GetAllIssues($borrowernumber,$order,$limit);
 
 my @loop_reading;
+my @barcodes;
+my $today = C4::Dates->new();
+$today = $today->output("iso");
 
 foreach my $issue (@{$issues}){
  	my %line;
@@ -80,6 +83,24 @@ foreach my $issue (@{$issues}){
 	$line{barcode}         = $issue->{'barcode'};
 	$line{volumeddesc}     = $issue->{'volumeddesc'};
 	push(@loop_reading,\%line);
+    if (($input->param('op') eq 'export_barcodes') and ($today eq $issue->{'returndate'})) {
+        push( @barcodes, $issue->{'barcode'} );
+    }
+}
+
+if ($input->param('op') eq 'export_barcodes') {
+    my $borrowercardnumber = GetMember( borrowernumber => $borrowernumber )->{'cardnumber'} ;
+    my $delimiter = ":";
+    $delimiter = "\n";
+    binmode( STDOUT, ":utf8" );
+    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') {
-- 
1.7.7.3



More information about the Koha-patches mailing list