|
Line 0
Link Here
|
| 0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 5 |
# Copyright (C) 2024 Sam Lau (ByWater Solutions) |
| 6 |
# |
| 7 |
# Koha is free software; you can redistribute it and/or modify it |
| 8 |
# under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation; either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# Koha is distributed in the hope that it will be useful, but |
| 13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
| 20 |
use Modern::Perl; |
| 21 |
|
| 22 |
#need |
| 23 |
use CGI qw ( -utf8 ); |
| 24 |
use C4::Auth qw( get_template_and_user ); |
| 25 |
use C4::Output qw( output_html_with_http_headers ); |
| 26 |
use Koha::Libraries; |
| 27 |
|
| 28 |
#unsure |
| 29 |
use C4::Biblio; |
| 30 |
use C4::External::BakerTaylor qw( image_url link_url ); |
| 31 |
use MARC::Record; |
| 32 |
use Koha::Patrons; |
| 33 |
use Koha::ItemTypes; |
| 34 |
|
| 35 |
my $query = CGI->new; |
| 36 |
|
| 37 |
# if OPACVirtualCard is disabled, leave immediately |
| 38 |
if ( ! C4::Context->preference('OPACVirtualCard') ) { |
| 39 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); |
| 40 |
exit; |
| 41 |
} |
| 42 |
|
| 43 |
my ( $template, $borrowernumber, $cookie ) = get_template_and_user( |
| 44 |
{ |
| 45 |
template_name => "opac-virtual-card.tt", |
| 46 |
query => $query, |
| 47 |
type => "opac", |
| 48 |
} |
| 49 |
); |
| 50 |
|
| 51 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
| 52 |
# Find and display patron image if allowed |
| 53 |
if (C4::Context->preference('OPACpatronimages')) { |
| 54 |
$template->param( display_patron_image => 1 ) if $patron->image; |
| 55 |
} |
| 56 |
|
| 57 |
my $branchcode = $patron->branchcode; |
| 58 |
# Fetch the library object using the branchcode |
| 59 |
my $library = Koha::Libraries->find($branchcode); |
| 60 |
|
| 61 |
# Get the library name |
| 62 |
my $library_name = $library ? $library->branchname : 'Unknown Library'; |
| 63 |
|
| 64 |
$template->param( |
| 65 |
virtualcardview => 1, |
| 66 |
cardnumber => $patron->cardnumber, |
| 67 |
library => $library_name, |
| 68 |
); |
| 69 |
|
| 70 |
|
| 71 |
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; |