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

Jonathan Druart jonathan.druart at biblibre.com
Mon Aug 22 10:00:37 CEST 2011


to export a file containing a list of checkin barcode for the current day.
---
 .../prog/en/modules/members/readingrec.tt          |    2 +-
 members/readingrec.pl                              |   23 +++++++++++++++++++-
 2 files changed, 23 insertions(+), 2 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 c61006b..45ba1da 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt
@@ -31,7 +31,7 @@
 [% INCLUDE 'circ-toolbar.inc' %]
 <h1>Circulation History</h1>
 <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>
 <span id="pagertable_readingrec" class="pager">
 	<form class="formpager">&nbsp;<strong>page(s)</strong>&nbsp;:
 		<img src="[% interface %]/prog/img/first.png" class="first"/>
diff --git a/members/readingrec.pl b/members/readingrec.pl
index e7586a0..532d285 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/;
 
@@ -63,6 +63,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;
@@ -79,6 +82,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.1



More information about the Koha-patches mailing list