Fixing error on duplicate entry process.
[koha.git] / opac / opac-readingrecord.pl
blob9d4f0b1bce6ef5a4dc4f49e8c5c5c7490ea45d19
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
18 # $Id$
20 use strict;
21 require Exporter;
22 use CGI;
24 use C4::Auth;
25 use C4::Koha;
26 use C4::Circulation;
27 use C4::Date;
28 use C4::Members;
30 use C4::Output;
32 my $query = new CGI;
33 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
35 template_name => "opac-readingrecord.tmpl",
36 query => $query,
37 type => "opac",
38 authnotrequired => 0,
39 flagsrequired => { borrow => 1 },
40 debug => 1,
44 # get borrower information ....
45 my ( $borr, $flags ) = GetMemberDetails( $borrowernumber );
47 $template->param($borr);
49 # get the record
50 my $order = $query->param('order');
51 my $order2 = $order;
52 if ( $order2 eq '' ) {
53 $order2 = "date_due desc";
54 $template->param( orderbydate => 1 );
57 if ( $order2 eq 'title' ) {
58 $template->param( orderbytitle => 1 );
61 if ( $order2 eq 'author' ) {
62 $template->param( orderbyauthor => 1 );
65 my $limit = $query->param('limit');
66 if ( $limit eq 'full' ) {
67 $limit = 0;
69 else {
70 $limit = 50;
72 my ( $count, $issues ) = GetAllIssues( $borrowernumber, $order2, $limit );
74 # add the row parity
75 #my $num = 0;
76 #foreach my $row (@$issues) {
77 # $row->{'even'} = 1 if $num % 2 == 0;
78 # $row->{'odd'} = 1 if $num % 2 == 1;
79 # $num++;
82 my @loop_reading;
84 for ( my $i = 0 ; $i < $count ; $i++ ) {
85 my %line;
86 if ( $i % 2 ) {
87 $line{'toggle'} = 1;
89 $line{biblionumber} = $issues->[$i]->{'biblionumber'};
90 $line{title} = $issues->[$i]->{'title'};
91 $line{author} = $issues->[$i]->{'author'};
92 $line{classification} = $issues->[$i]->{'classification'};
93 $line{date_due} = format_date( $issues->[$i]->{'date_due'} );
94 $line{returndate} = format_date( $issues->[$i]->{'returndate'} );
95 $line{volumeddesc} = $issues->[$i]->{'volumeddesc'};
96 $line{counter} = $i + 1;
97 push( @loop_reading, \%line );
100 $template->param(
101 count => $count,
102 READING_RECORD => \@loop_reading,
103 limit => $limit,
104 showfulllink => ( $count > 50 ),
107 output_html_with_http_headers $query, $cookie, $template->output;