4 # script to display borrowers reading record
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 use C4
::Branch
qw(GetBranches);
32 use List
::MoreUtils qw
/any uniq/;
35 use C4
::Dates qw
/format_date/;
36 use C4
::Members
::Attributes
qw(GetBorrowerAttributes);
42 my $borrowernumber = undef;
43 my $cardnumber = undef;
45 my ($template, $loggedinuser, $cookie)= get_template_and_user
({template_name
=> "members/readingrec.tt",
49 flagsrequired
=> {borrowers
=> 1},
53 my $op = $input->param('op') || '';
54 if ($input->param('cardnumber')) {
55 $cardnumber = $input->param('cardnumber');
56 $data = GetMember
(cardnumber
=> $cardnumber);
57 $borrowernumber = $data->{'borrowernumber'}; # we must define this as it is used to retrieve other data about the patron
59 if ($input->param('borrowernumber')) {
60 $borrowernumber = $input->param('borrowernumber');
61 $data = GetMember
(borrowernumber
=> $borrowernumber);
64 my $order = 'date_due desc';
67 # Do not request the old issues of anonymous patron
68 if ( $borrowernumber eq C4
::Context
->preference('AnonymousPatron') ){
69 # use of 'eq' in the above comparison is intentional -- the
70 # system preference value could be blank
71 $template->param( is_anonymous
=> 1 );
73 $issues = GetAllIssues
($borrowernumber,$order,$limit);
76 my $branches = GetBranches
();
77 foreach my $issue ( @
{$issues} ) {
78 $issue->{issuingbranch
} = $branches->{ $issue->{branchcode
} }->{branchname
};
82 if ( $op eq 'export_barcodes' ) {
83 my $today = C4
::Dates
->new();
84 $today = $today->output('iso');
86 map { $_->{barcode
} } grep { $_->{returndate
} =~ m/^$today/o } @
{$issues};
87 my $borrowercardnumber =
88 GetMember
( borrowernumber
=> $borrowernumber )->{'cardnumber'};
90 binmode( STDOUT
, ":encoding(UTF-8)" );
92 -type
=> 'application/octet-stream',
94 -attachment
=> "$today-$borrowercardnumber-checkinexport.txt"
96 my $content = join $delimiter, uniq
(@barcodes);
101 if ( $data->{'category_type'} eq 'C') {
102 my ( $catcodes, $labels ) = GetborCatFromCatType
( 'A', 'WHERE category_type = ?' );
103 my $cnt = scalar(@
$catcodes);
104 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
105 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
108 $template->param( adultborrower
=> 1 ) if ( $data->{'category_type'} eq 'A' );
114 my ($picture, $dberror) = GetPatronImage
($data->{'borrowernumber'});
115 $template->param( picture
=> 1 ) if $picture;
117 if (C4
::Context
->preference('ExtendedPatronAttributes')) {
118 my $attributes = GetBorrowerAttributes
($borrowernumber);
120 ExtendedPatronAttributes
=> 1,
121 extendedattributes
=> $attributes
126 # Computes full borrower address
127 my $roadtype = C4
::Koha
::GetAuthorisedValueByCode
( 'ROADTYPE', $data->{streettype
} );
128 my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
131 readingrecordview
=> 1,
132 title
=> $data->{title
},
133 initials
=> $data->{initials
},
134 surname
=> $data->{surname
},
135 othernames
=> $data->{othernames
},
136 borrowernumber
=> $borrowernumber,
137 firstname
=> $data->{firstname
},
138 cardnumber
=> $data->{cardnumber
},
139 categorycode
=> $data->{categorycode
},
140 category_type
=> $data->{category_type
},
141 categoryname
=> $data->{description
},
143 address2
=> $data->{address2
},
144 city
=> $data->{city
},
145 state => $data->{state},
146 zipcode
=> $data->{zipcode
},
147 country
=> $data->{country
},
148 phone
=> $data->{phone
},
149 phonepro
=> $data->{phonepro
},
150 mobile
=> $data->{mobile
},
151 email
=> $data->{email
},
152 emailpro
=> $data->{emailpro
},
153 branchcode
=> $data->{branchcode
},
154 is_child
=> ( $data->{category_type
} eq 'C' ),
155 branchname
=> $branches->{ $data->{branchcode
} }->{branchname
},
156 loop_reading
=> $issues,
157 activeBorrowerRelationship
=>
158 ( C4
::Context
->preference('borrowerRelationship') ne '' ),
159 RoutingSerials
=> C4
::Context
->preference('RoutingSerials'),
161 output_html_with_http_headers
$input, $cookie, $template->output;