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.
31 use Koha::Borrower::Files;
35 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
37 template_name => "members/files.tmpl",
41 flagsrequired => { borrowers => 1 },
45 $template->param( 'borrower_files' => 1 );
47 my $borrowernumber = $cgi->param('borrowernumber');
48 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
50 my $op = $cgi->param('op') || '';
52 if ( $op eq 'download' ) {
53 my $file_id = $cgi->param('file_id');
54 my $file = $bf->GetFile( id => $file_id );
57 -type => $file->{'file_type'},
59 -attachment => $file->{'file_name'}
61 print $file->{'file_content'};
64 my $data = GetMember( borrowernumber => $borrowernumber );
65 $template->param(%$data);
69 if ( $op eq 'upload' ) {
70 my $uploaded_file = $cgi->upload('uploadfile');
73 my $filename = $cgi->param('uploadfile');
74 my $mimetype = $cgi->uploadInfo($filename)->{'Content-Type'};
76 $errors{'empty_upload'} = 1 unless ( length($uploaded_file) > 0 );
79 $template->param( errors => %errors );
83 while (<$uploaded_file>) {
90 content => $file_content,
91 description => $cgi->param('description'),
96 $errors{'no_file'} = 1;
98 } elsif ( $op eq 'delete' ) {
99 $bf->DelFile( id => $cgi->param('file_id') );
103 files => Koha::Borrower::Files->new( borrowernumber => $borrowernumber )
108 output_html_with_http_headers $cgi, $cookie, $template->output;
113 Kyle M Hall <kyle@bywatersolutions.com>