3 # Copyright 2012 ByWater Solutions
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 use C4
::Members
::Attributes
qw(GetBorrowerAttributes);
33 use Koha
::Borrower
::Files
;
37 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
39 template_name
=> "members/files.tt",
43 flagsrequired
=> { borrowers
=> 1 },
47 $template->param( 'borrower_files' => 1 );
49 my $borrowernumber = $cgi->param('borrowernumber');
50 my $bf = Koha
::Borrower
::Files
->new( borrowernumber
=> $borrowernumber );
52 my $op = $cgi->param('op') || '';
54 if ( $op eq 'download' ) {
55 my $file_id = $cgi->param('file_id');
56 my $file = $bf->GetFile( id
=> $file_id );
59 -type
=> $file->{'file_type'},
61 -attachment
=> $file->{'file_name'}
63 print $file->{'file_content'};
66 my $data = GetMember
( borrowernumber
=> $borrowernumber );
67 $template->param(%$data);
71 if ( $op eq 'upload' ) {
72 my $uploaded_file = $cgi->upload('uploadfile');
75 my $filename = $cgi->param('uploadfile');
76 my $mimetype = $cgi->uploadInfo($filename)->{'Content-Type'};
78 $errors{'empty_upload'} = 1 if ( -z
$uploaded_file );
81 $template->param( errors
=> %errors );
85 while (<$uploaded_file>) {
92 content
=> $file_content,
93 description
=> $cgi->param('description'),
98 $errors{'no_file'} = 1;
100 } elsif ( $op eq 'delete' ) {
101 $bf->DelFile( id
=> $cgi->param('file_id') );
105 categoryname
=> $data->{'description'},
106 branchname
=> GetBranchName
($data->{'branchcode'}),
107 RoutingSerials
=> C4
::Context
->preference('RoutingSerials'),
110 if (C4
::Context
->preference('ExtendedPatronAttributes')) {
111 my $attributes = GetBorrowerAttributes
($borrowernumber);
113 ExtendedPatronAttributes
=> 1,
114 extendedattributes
=> $attributes
118 my ($picture, $dberror) = GetPatronImage
($data->{'borrowernumber'});
119 $template->param( picture
=> 1 ) if $picture;
121 # Computes full borrower address
122 my $roadtype = C4
::Koha
::GetAuthorisedValueByCode
( 'ROADTYPE', $data->{streettype
} );
123 my $address = $data->{'streetnumber'} . " $roadtype " . $data->{'address'};
126 files
=> Koha
::Borrower
::Files
->new( borrowernumber
=> $borrowernumber )
132 output_html_with_http_headers
$cgi, $cookie, $template->output;
137 Kyle M Hall <kyle@bywatersolutions.com>