From 3b5b84034c06ed939d65e531aabd3613a4495ff9 Mon Sep 17 00:00:00 2001 From: Sam Lau Date: Tue, 18 Jun 2024 22:47:47 +0000 Subject: [PATCH] Bug 26777: Add new patron page 'My Virtual Card' Signed-off-by: Laura Escamilla Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- .../bootstrap/en/includes/usermenu.inc | 8 +++ .../bootstrap/en/modules/opac-virtual-card.tt | 60 ++++++++++++++++ opac/opac-virtual-card.pl | 71 +++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-virtual-card.tt create mode 100644 opac/opac-virtual-card.pl diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc index 87268831fc..e6290a26c4 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc @@ -167,6 +167,14 @@ Alert subscriptions ([% logged_in_user.alert_subscriptions.count | html %]) [% END %] + [% IF Koha.Preference( 'OPACVirtualCard' ) %] + [% IF ( virtualcardview ) %] +
  • + [% ELSE %] +
  • + [% END %] + My Virtual Card
  • + [% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-virtual-card.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-virtual-card.tt new file mode 100644 index 0000000000..b21dcf98b2 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-virtual-card.tt @@ -0,0 +1,60 @@ +[% USE AdditionalContents %] +[% USE raw %] +[% USE Asset %] +[% USE Koha %] +[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] +[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] +[% INCLUDE 'doc-head-open.inc' %] +My Virtual Card › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %] + [% Asset.css("css/src/opac.css") | $raw %] +[% END %] + +[% INCLUDE 'bodytag.inc' bodyid='opac-virtual-card' %] +[% INCLUDE 'masthead.inc' %] + +
    + [% WRAPPER breadcrumbs %] + [% WRAPPER breadcrumb_item %] + [% INCLUDE 'patron-title.inc' patron = logged_in_user %] + [% END %] + [% WRAPPER breadcrumb_item bc_active= 1 %] + My virtual card + [% END %] + [% END #/ WRAPPER breadcrumbs %] + +
    +
    +
    + +
    +
    +
    +

    My virtual card

    +
    + +
    +
    + [% IF ( display_patron_image ) %] +
    + +
    + [% END %] +
    +

    Library: [% library | html %]

    +
    +
    +
    +
    +
    +
    +
    + +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %] + [% Asset.js("lib/js-barcode/js-barcode.js") | $raw %] + [% Asset.js("js/barcode-generator.js") | $raw %] +[% END %] diff --git a/opac/opac-virtual-card.pl b/opac/opac-virtual-card.pl new file mode 100644 index 0000000000..26cd722d85 --- /dev/null +++ b/opac/opac-virtual-card.pl @@ -0,0 +1,71 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright (C) 2024 Sam Lau (ByWater Solutions) +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +#need +use CGI qw ( -utf8 ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use Koha::Libraries; + +#unsure +use C4::Biblio; +use C4::External::BakerTaylor qw( image_url link_url ); +use MARC::Record; +use Koha::Patrons; +use Koha::ItemTypes; + +my $query = CGI->new; + +# if OPACVirtualCard is disabled, leave immediately +if ( ! C4::Context->preference('OPACVirtualCard') ) { + print $query->redirect("/cgi-bin/koha/errors/404.pl"); + exit; +} + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-virtual-card.tt", + query => $query, + type => "opac", + } +); + +my $patron = Koha::Patrons->find( $borrowernumber ); +# Find and display patron image if allowed +if (C4::Context->preference('OPACpatronimages')) { + $template->param( display_patron_image => 1 ) if $patron->image; + } + +my $branchcode = $patron->branchcode; +# Fetch the library object using the branchcode +my $library = Koha::Libraries->find($branchcode); + +# Get the library name +my $library_name = $library ? $library->branchname : 'Unknown Library'; + +$template->param( + virtualcardview => 1, + cardnumber => $patron->cardnumber, + library => $library_name, +); + + +output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; -- 2.39.5