Bugzilla – Attachment 187697 Details for
Bug 40659
Allow "My virtual card" format and content to be set using a Notices & Slips template
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40659: Add ability to customize OPACVirtualCard
Bug-40659-Add-ability-to-customize-OPACVirtualCard.patch (text/plain), 7.01 KB, created by
Lucas Gass (lukeg)
on 2025-10-09 16:28:56 UTC
(
hide
)
Description:
Bug 40659: Add ability to customize OPACVirtualCard
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-10-09 16:28:56 UTC
Size:
7.01 KB
patch
obsolete
>From d000bd49c59862cf9ecd1ffdd359940dd79c388e Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Thu, 9 Oct 2025 16:11:56 +0000 >Subject: [PATCH] Bug 40659: Add ability to customize OPACVirtualCard > >To test: > >1. Turn on the OPACVirtualCard. >2. Log in to the OPAC as a patron and go look at your Library card ( opac-virtual-card.pl ) >3. APPLY PATCH, updatedatabase, restart_all >4. Go again at your patron's card on the OPAC ( opac-virtual-card.pl ), it should look exactly the same. >5. Go to Tools > Notices > VIRTUALCARD >6. You should see the default content for the library card. >7. Play around with different variables from borrower, like [% borrower.firstname%] and branches, like [% branch.branchcode %] >8. You can also move around the barcode by using the placeholder value [% my_barcode %]. >9. Put the [% my_barcode %] variable anywhere you want in the notice then go to the sys pref "OPACVirtualCardBarcode". >10. Change to different barcode types and relaod the library card page ( opac-virtual-card.pl ). You should notice the barcode type is being honored. >11. Turn on OPACpatronimages AND patronimages, then upload a patron image for your patron. >12. Use the [% my_image %] variable anywhere you want in the notice to place the patron image. >13. Leaving the [% my_image %] variable as is, turn off OPACpatronimages. >14. Reload the OPAC page, no image should display. >15. Delete the VIRTUALCARD notice. >16. Go back to the OPAC page and with the notice deleted you should see the hardcoded content. ie: the page should look exactly the same as it does without this patch. >--- > .../bootstrap/en/modules/opac-virtual-card.tt | 38 ++++++++++--------- > opac/opac-virtual-card.pl | 32 ++++++++++++++-- > 2 files changed, 50 insertions(+), 20 deletions(-) > >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 >index b0a9980c3ba..7448c0a9d13 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-virtual-card.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-virtual-card.tt >@@ -33,24 +33,28 @@ > <div class="col-lg-10 order-first order-lg-2"> > <h1>Your library card </h1> > <div id="patron-virtual-card"> >- [% IF ( display_patron_image ) %] >- <div id="image-container"> >- <img id="patron-image" src="/cgi-bin/koha/opac-patron-image.pl" alt="" /> >- </div> >- [% END %] > <div id="card-details"> >- <div id="barcode-container"> >- <svg id="patron-barcode" data-barcode="[% patron.cardnumber | html %]" data-barcode-format="[% barcode_format | html %]"></svg> >- </div> >- <div id="lib-container"> >- <p id="patron-lib"><strong>Library:</strong> [% Branches.GetName( patron.branchcode ) | html %]</p> >- </div> >- <div id="cardnumber-container"> >- <p id="patron-cardnumber"><strong>Card number:</strong> [% patron.cardnumber | html %]</p> >- </div> >- <div id="dateexpiry-container"> >- <p id="patron-dateexpiry"><strong>Expiration date:</strong> [% patron.dateexpiry | $KohaDates %]</p> >- </div> >+ [% IF content.content %] >+ [% content.content | $raw %] >+ [% ELSE %] >+ [% IF ( display_patron_image ) %] >+ <div id="image-container"> >+ <img id="patron-image" src="/cgi-bin/koha/opac-patron-image.pl" alt="" /> >+ </div> >+ [% END %] >+ <div id="barcode-container"> >+ <svg id="patron-barcode" data-barcode="[% patron.cardnumber | html %]" data-barcode-format="[% barcode_format | html %]"></svg> >+ </div> >+ <div id="lib-container"> >+ <p id="patron-lib"><strong>Library:</strong> [% Branches.GetName( patron.branchcode ) | html %]</p> >+ </div> >+ <div id="cardnumber-container"> >+ <p id="patron-cardnumber"><strong>Card number:</strong> [% patron.cardnumber | html %]</p> >+ </div> >+ <div id="dateexpiry-container"> >+ <p id="patron-dateexpiry"><strong>Expiration date:</strong> [% patron.dateexpiry | $KohaDates %]</p> >+ </div> >+ [% END %] > </div> > </div> > </div> >diff --git a/opac/opac-virtual-card.pl b/opac/opac-virtual-card.pl >index aa2fe57187e..c44f84910d7 100755 >--- a/opac/opac-virtual-card.pl >+++ b/opac/opac-virtual-card.pl >@@ -24,6 +24,8 @@ use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use Koha::Libraries; > use Koha::Patrons; >+use C4::Letters qw( GetPreparedLetter ); >+use C4::Scrubber; > > my $query = CGI->new; > >@@ -44,17 +46,41 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > 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 $image_html = ''; >+if ( C4::Context->preference('OPACpatronimages') && $patron->image ) { >+ $template->param( display_patron_image => 1 ); >+ $image_html = >+ '<div id="image-container"><img id="patron-image" src="/cgi-bin/koha/opac-patron-image.pl" alt="" /></div>'; > } > > # Get the desired barcode format >-my $barcode_format = C4::Context->preference('OPACVirtualCardBarcode'); >+my $barcode_format = C4::Context->preference('OPACVirtualCardBarcode') || 'Code39'; >+my $barcode_html = >+ qq{<div id="barcode-container"><svg id="patron-barcode" data-barcode="${\$patron->cardnumber}" data-barcode-format="$barcode_format"></svg></div>}; >+ >+my $content = C4::Letters::GetPreparedLetter( >+ ( >+ module => 'members', >+ letter_code => 'VIRTUALCARD', >+ branchcode => $patron->branchcode, >+ tables => { >+ borrowers => $patron->borrowernumber, >+ branches => $patron->branchcode, >+ }, >+ lang => $patron->lang, >+ message_transport_type => 'email', >+ substitute => { >+ my_barcode => $barcode_html, >+ my_image => $image_html, >+ }, >+ ) >+); > > $template->param( > virtualcardview => 1, > patron => $patron, > barcode_format => $barcode_format, >+ content => $content, > ); > > output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40659
:
187695
|
187696
| 187697 |
187706