Bug 26777 - Give the user the option to display their patron card barcode from the OPAC
Summary: Give the user the option to display their patron card barcode from the OPAC
Status: Needs documenting
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low new feature
Assignee: Sam Lau
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
: 26692 27825 37118 (view as bug list)
Depends on:
Blocks: 38791 38792 37742
  Show dependency treegraph
 
Reported: 2020-10-22 08:26 UTC by Martin Renvoize (ashimema)
Modified: 2024-12-27 20:40 UTC (History)
11 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This adds the option to display the patron's library card as a barcode within their library account, so it can be scanned at the circulation desk or a self check machine. The feature can be activated using the new system preference `OPACVirtualCard`.
Version(s) released in:
24.11.00
Circulation function:


Attachments
Bug 26777: Added new sys pref 'OPACVirtualCard' (3.37 KB, patch)
2024-06-21 16:28 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Add JsBarcode library to Koha (60.31 KB, patch)
2024-06-21 16:28 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Add barcode generation to OPAC using JsBarcode (2.08 KB, patch)
2024-06-21 16:28 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Add new patron page 'My Virtual Card' (6.60 KB, patch)
2024-06-21 16:28 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: (follow-up) Adjust script, template, and CSS (4.82 KB, patch)
2024-06-21 17:18 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 26777: (follow-up) Fix file permssions and tidy (2.95 KB, patch)
2024-06-21 17:18 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 26777: (Follow-up) Add new system preference 'OPACVirtualCardBarcode' (5.47 KB, patch)
2024-06-24 16:31 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: (Follow-up) Allow ability to select diffferent barcode types (3.34 KB, patch)
2024-06-24 16:31 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Added new sys pref 'OPACVirtualCard' (3.37 KB, patch)
2024-06-26 16:33 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Add barcode generator file and initial styling (2.08 KB, patch)
2024-06-26 16:33 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Add new patron page 'My Virtual Card' (6.60 KB, patch)
2024-06-26 16:33 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: (follow-up) Adjust script, template, and CSS (4.82 KB, patch)
2024-06-26 16:33 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: (follow-up) Fix file permssions and tidy (2.95 KB, patch)
2024-06-26 16:33 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Add bwip-js library to Koha (987.09 KB, patch)
2024-06-26 16:33 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Add new system preference 'OPACVirtualCardBarcode' (5.62 KB, patch)
2024-06-26 16:33 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Allow ability to select diffferent barcode types (8.60 KB, patch)
2024-06-26 16:33 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Added new sys pref 'OPACVirtualCard' (3.44 KB, patch)
2024-06-28 19:56 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 26777: Add barcode generator file and initial styling (2.15 KB, patch)
2024-06-28 19:56 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 26777: Add new patron page 'My Virtual Card' (6.67 KB, patch)
2024-06-28 19:56 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 26777: (follow-up) Adjust script, template, and CSS (4.89 KB, patch)
2024-06-28 19:56 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 26777: (follow-up) Fix file permssions and tidy (3.01 KB, patch)
2024-06-28 19:56 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 26777: Add bwip-js library to Koha (987.16 KB, patch)
2024-06-28 19:56 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 26777: Add new system preference 'OPACVirtualCardBarcode' (5.69 KB, patch)
2024-06-28 19:56 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 26777: Allow ability to select diffferent barcode types (8.67 KB, patch)
2024-06-28 19:56 UTC, Laura Escamilla
Details | Diff | Splinter Review
Bug 26777: Added new sys pref 'OPACVirtualCard' (3.51 KB, patch)
2024-07-26 15:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 26777: Add barcode generator file and initial styling (2.22 KB, patch)
2024-07-26 15:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 26777: Add new patron page 'My Virtual Card' (6.74 KB, patch)
2024-07-26 15:17 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 26777: (follow-up) Adjust script, template, and CSS (4.96 KB, patch)
2024-07-26 15:18 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 26777: (follow-up) Fix file permssions and tidy (3.08 KB, patch)
2024-07-26 15:18 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 26777: Add bwip-js library to Koha (987.23 KB, patch)
2024-07-26 15:18 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 26777: Add new system preference 'OPACVirtualCardBarcode' (5.76 KB, patch)
2024-07-26 15:18 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 26777: Allow ability to select diffferent barcode types (8.74 KB, patch)
2024-07-26 15:18 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 26777: Added new sys pref 'OPACVirtualCard' (3.50 KB, patch)
2024-08-23 19:14 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Add barcode generator file and initial styling (2.23 KB, patch)
2024-08-23 19:14 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Add new patron page 'My Virtual Card' (6.74 KB, patch)
2024-08-23 19:14 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: (follow-up) Adjust script, template, and CSS (4.95 KB, patch)
2024-08-23 19:14 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: (follow-up) Fix file permssions and tidy (3.08 KB, patch)
2024-08-23 19:14 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Add bwip-js library to Koha (987.22 KB, patch)
2024-08-23 19:14 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Add new system preference 'OPACVirtualCardBarcode' (5.76 KB, patch)
2024-08-23 19:14 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 26777: Allow ability to select diffferent barcode types (8.73 KB, patch)
2024-08-23 19:14 UTC, Sam Lau
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2020-10-22 08:26:10 UTC
In this modern age, people are moving away from carrying cards.. but they nearly always have their smart phone to hand.

It would be nice to be able to display your barcode for scanning at self service machines directly on your phone.
Comment 1 Magnus Enger 2020-10-22 09:11:12 UTC
+1
Comment 2 Barbara Johnson 2020-10-22 12:02:07 UTC
Our patrons would love this.
Comment 3 Lisette Scheer 2020-10-22 23:52:00 UTC
Agreed, this would be useful. 

I know some websites can tell if you are on mobile and display a link or button only if you are. That could be handy since there wouldn't be a real use case for using the barcode on a PC? 

Also if we could make it so it ups the screen brightness (not sure if possible just in mobile browser) but most people don't seem to keep their phones at high enough brightness to be read by a barcode scanner.
Comment 4 Owen Leonard 2021-02-26 19:56:18 UTC
Here's what I tried today: https://zivotdesign.com/p/view.php?p=16143692116112

Using https://github.com/lindell/JsBarcode

I think we'd have to create a system preference for defining what card type to use (CODE39, Codabar, UPC, etc). The selection could also be used to set the default in the patron card creator.
Comment 5 Owen Leonard 2021-03-01 16:41:13 UTC
Looks like this tool has more options, including all the options we offer in the patron card creator:

https://github.com/metafloor/bwip-js
Comment 6 Sally 2022-03-09 15:13:06 UTC
+1 - really interested in this development.
Comment 7 Martin Renvoize (ashimema) 2022-04-12 07:35:19 UTC
Is this something you're still experimenting with Owen?
Comment 8 Owen Leonard 2022-04-12 10:50:52 UTC
(In reply to Martin Renvoize from comment #7)
> Is this something you're still experimenting with Owen?

I started working on Bug 27825 - Add preference for choosing the default format for patron barcodes - and got stalled. I don't recall what the sticking point was or if I just got redirected.
Comment 9 David Cook 2022-08-19 00:14:37 UTC
Going to mark this one as a duplicate of bug 26692...

*** This bug has been marked as a duplicate of bug 26692 ***
Comment 10 David Cook 2022-08-19 00:17:07 UTC
Actually, I take that back, as that one is a bit too generic still, despite it listing the same use case...
Comment 11 Martin Renvoize (ashimema) 2023-05-16 15:00:59 UTC
https://codelabs.developers.google.com/add-to-wallet-android#0 is interesting too
Comment 12 David Cook 2023-05-17 00:15:31 UTC
(In reply to Martin Renvoize from comment #11)
> https://codelabs.developers.google.com/add-to-wallet-android#0 is
> interesting too

Ohhh very interesting. That would be a very cool feature. I think I'll raise a ticket for that.

It's not something most of our libraries would use, but as a library user I would love to have this...
Comment 13 David Cook 2023-05-17 00:23:36 UTC
See Bug 25332 for talk about adding a library card to a smart phone wallet
Comment 14 David Cook 2024-06-18 23:38:08 UTC
*** Bug 37118 has been marked as a duplicate of this bug. ***
Comment 15 Roman Dolny 2024-06-19 17:53:57 UTC
It would by nice to have a "Barcode" tab in OPAC accout with QR image generated from cardnumber.
Comment 16 David Cook 2024-06-20 05:27:33 UTC
(In reply to Roman Dolny from comment #15)
> It would by nice to have a "Barcode" tab in OPAC accout with QR image
> generated from cardnumber.

I've accomplished something like this with a Koha plugin as I note on bug 37118. I'll have to look at sharing that plugin publicly...
Comment 17 Sam Lau 2024-06-21 16:28:30 UTC Comment hidden (obsolete)
Comment 18 Sam Lau 2024-06-21 16:28:33 UTC Comment hidden (obsolete)
Comment 19 Sam Lau 2024-06-21 16:28:35 UTC Comment hidden (obsolete)
Comment 20 Sam Lau 2024-06-21 16:28:38 UTC Comment hidden (obsolete)
Comment 21 Sam Lau 2024-06-21 16:30:47 UTC Comment hidden (obsolete)
Comment 22 Lucas Gass (lukeg) 2024-06-21 17:18:42 UTC Comment hidden (obsolete)
Comment 23 Lucas Gass (lukeg) 2024-06-21 17:18:44 UTC Comment hidden (obsolete)
Comment 24 Sam Lau 2024-06-24 16:31:23 UTC Comment hidden (obsolete)
Comment 25 Sam Lau 2024-06-24 16:31:25 UTC Comment hidden (obsolete)
Comment 26 David Cook 2024-06-25 05:34:44 UTC
I was just skimming through the patches, and this sounds pretty good I think. Excited to take a look when you're ready for a sign off.
Comment 27 Sam Lau 2024-06-26 16:33:12 UTC
Created attachment 168165 [details] [review]
Bug 26777: Added new sys pref 'OPACVirtualCard'
Comment 28 Sam Lau 2024-06-26 16:33:15 UTC
Created attachment 168166 [details] [review]
Bug 26777: Add barcode generator file and initial styling
Comment 29 Sam Lau 2024-06-26 16:33:17 UTC
Created attachment 168167 [details] [review]
Bug 26777: Add new patron page 'My Virtual Card'
Comment 30 Sam Lau 2024-06-26 16:33:20 UTC
Created attachment 168168 [details] [review]
Bug 26777: (follow-up) Adjust script, template, and CSS
Comment 31 Sam Lau 2024-06-26 16:33:23 UTC
Created attachment 168169 [details] [review]
Bug 26777: (follow-up) Fix file permssions and tidy
Comment 32 Sam Lau 2024-06-26 16:33:26 UTC
Created attachment 168170 [details] [review]
Bug 26777: Add bwip-js library to Koha

bwip-js is the chosen library for generating and displaying barcodes in the OPAC. It allows for many different barcode types and customizable settings. This patch created a new directory and file for the js library code to live as well as updating the about.tt to give credit.
Comment 33 Sam Lau 2024-06-26 16:33:28 UTC
Created attachment 168171 [details] [review]
Bug 26777: Add new system preference 'OPACVirtualCardBarcode'
Comment 34 Sam Lau 2024-06-26 16:33:31 UTC
Created attachment 168172 [details] [review]
Bug 26777: Allow ability to select diffferent barcode types

These cumalation of patches introduce a new patron page on the OPAC: "My virtual card." This page and its contents are reliant on the system preferences 'OPACVirtualCard' and 'OPACVirtualCardBarcode'. OPACVirutalCard determines whether the virtual card page is even displayed on the OPAC whereas OPACVirtualCardBarcode selects the type of barcode to display on this page (if page is displayed). Currently, the virtual card page consits of a patron image (if available), the patron's barcode, and the library name. A potential follow up would be to allow customization of this page. The barcode generation is handled by a new library bwip-js.

To test:
1) Apply patch, updatedatabase, restart_all, build yarn
2) In system preferences, search for 'OPACVirtualCard'. Both this and the barcode sys. pref should show up with the same search. Notice they are dependent on one another. The default for the first pref should be "Don't allow". Leave this as is for now.
3) Leave the preference page open and log into the OPAC. Visit the user page. Notice that the navbar on the left consiting of 'Summary', 'Charges', etc. looks the same.
4) Go back to the sys. pref page and set the OPACVirtualCard to "Allow"
5) Also in the sys. prefs, make a search for "patron images" and set 'OPACpatronimages' to "Show" and 'patronimages' to allow.
6) Visit the patron's page that you used to sign in to the OPAC. Add a patron image if there is not one already.
7) Now, edit their details and change their card number to '00012345678905'
8) Venture back to the OPAC patron page. Refresh this and you should see a new "My Virtual Card" page at the bottom.
9) Click this page and you should see a new virtual card for you patron, consiting of their image, a barcode, and their library.
10) Open the dev tools for your browser and switch to vieiwing in mobile mode. Make sure the card looks good. This would likely be the most common use case.
11) Switch back to a system preference page and try playing around with the 'OPACVirtualCardBarcode'. Note that these changes affect the type of barcode that is display in the virtual card page. If you selected a barcode format that is incompatible, an error message should display in the virtual card page.
Comment 35 Laura Escamilla 2024-06-28 19:56:13 UTC
Created attachment 168289 [details] [review]
Bug 26777: Added new sys pref 'OPACVirtualCard'

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 36 Laura Escamilla 2024-06-28 19:56:16 UTC
Created attachment 168290 [details] [review]
Bug 26777: Add barcode generator file and initial styling

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 37 Laura Escamilla 2024-06-28 19:56:19 UTC
Created attachment 168291 [details] [review]
Bug 26777: Add new patron page 'My Virtual Card'

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 38 Laura Escamilla 2024-06-28 19:56:22 UTC
Created attachment 168292 [details] [review]
Bug 26777: (follow-up) Adjust script, template, and CSS

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 39 Laura Escamilla 2024-06-28 19:56:24 UTC
Created attachment 168293 [details] [review]
Bug 26777: (follow-up) Fix file permssions and tidy

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 40 Laura Escamilla 2024-06-28 19:56:27 UTC
Created attachment 168294 [details] [review]
Bug 26777: Add bwip-js library to Koha

bwip-js is the chosen library for generating and displaying barcodes in the OPAC. It allows for many different barcode types and customizable settings. This patch created a new directory and file for the js library code to live as well as updating the about.tt to give credit.

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 41 Laura Escamilla 2024-06-28 19:56:30 UTC
Created attachment 168295 [details] [review]
Bug 26777: Add new system preference 'OPACVirtualCardBarcode'

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 42 Laura Escamilla 2024-06-28 19:56:33 UTC
Created attachment 168296 [details] [review]
Bug 26777: Allow ability to select diffferent barcode types

These cumalation of patches introduce a new patron page on the OPAC: "My virtual card." This page and its contents are reliant on the system preferences 'OPACVirtualCard' and 'OPACVirtualCardBarcode'. OPACVirutalCard determines whether the virtual card page is even displayed on the OPAC whereas OPACVirtualCardBarcode selects the type of barcode to display on this page (if page is displayed). Currently, the virtual card page consits of a patron image (if available), the patron's barcode, and the library name. A potential follow up would be to allow customization of this page. The barcode generation is handled by a new library bwip-js.

To test:
1) Apply patch, updatedatabase, restart_all, build yarn
2) In system preferences, search for 'OPACVirtualCard'. Both this and the barcode sys. pref should show up with the same search. Notice they are dependent on one another. The default for the first pref should be "Don't allow". Leave this as is for now.
3) Leave the preference page open and log into the OPAC. Visit the user page. Notice that the navbar on the left consiting of 'Summary', 'Charges', etc. looks the same.
4) Go back to the sys. pref page and set the OPACVirtualCard to "Allow"
5) Also in the sys. prefs, make a search for "patron images" and set 'OPACpatronimages' to "Show" and 'patronimages' to allow.
6) Visit the patron's page that you used to sign in to the OPAC. Add a patron image if there is not one already.
7) Now, edit their details and change their card number to '00012345678905'
8) Venture back to the OPAC patron page. Refresh this and you should see a new "My Virtual Card" page at the bottom.
9) Click this page and you should see a new virtual card for you patron, consiting of their image, a barcode, and their library.
10) Open the dev tools for your browser and switch to vieiwing in mobile mode. Make sure the card looks good. This would likely be the most common use case.
11) Switch back to a system preference page and try playing around with the 'OPACVirtualCardBarcode'. Note that these changes affect the type of barcode that is display in the virtual card page. If you selected a barcode format that is incompatible, an error message should display in the virtual card page.

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Comment 43 Kyle M Hall (khall) 2024-07-11 12:15:41 UTC
*** Bug 26692 has been marked as a duplicate of this bug. ***
Comment 44 Owen Leonard 2024-07-24 16:39:02 UTC
*** Bug 27825 has been marked as a duplicate of this bug. ***
Comment 45 Martin Renvoize (ashimema) 2024-07-26 15:17:52 UTC
Created attachment 169742 [details] [review]
Bug 26777: Added new sys pref 'OPACVirtualCard'

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 46 Martin Renvoize (ashimema) 2024-07-26 15:17:55 UTC
Created attachment 169743 [details] [review]
Bug 26777: Add barcode generator file and initial styling

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 47 Martin Renvoize (ashimema) 2024-07-26 15:17:59 UTC
Created attachment 169744 [details] [review]
Bug 26777: Add new patron page 'My Virtual Card'

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 48 Martin Renvoize (ashimema) 2024-07-26 15:18:02 UTC
Created attachment 169745 [details] [review]
Bug 26777: (follow-up) Adjust script, template, and CSS

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 49 Martin Renvoize (ashimema) 2024-07-26 15:18:06 UTC
Created attachment 169746 [details] [review]
Bug 26777: (follow-up) Fix file permssions and tidy

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 50 Martin Renvoize (ashimema) 2024-07-26 15:18:11 UTC
Created attachment 169747 [details] [review]
Bug 26777: Add bwip-js library to Koha

bwip-js is the chosen library for generating and displaying barcodes in the OPAC. It allows for many different barcode types and customizable settings. This patch created a new directory and file for the js library code to live as well as updating the about.tt to give credit.

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 51 Martin Renvoize (ashimema) 2024-07-26 15:18:15 UTC
Created attachment 169748 [details] [review]
Bug 26777: Add new system preference 'OPACVirtualCardBarcode'

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 52 Martin Renvoize (ashimema) 2024-07-26 15:18:18 UTC
Created attachment 169749 [details] [review]
Bug 26777: Allow ability to select diffferent barcode types

These cumalation of patches introduce a new patron page on the OPAC: "My virtual card." This page and its contents are reliant on the system preferences 'OPACVirtualCard' and 'OPACVirtualCardBarcode'. OPACVirutalCard determines whether the virtual card page is even displayed on the OPAC whereas OPACVirtualCardBarcode selects the type of barcode to display on this page (if page is displayed). Currently, the virtual card page consits of a patron image (if available), the patron's barcode, and the library name. A potential follow up would be to allow customization of this page. The barcode generation is handled by a new library bwip-js.

To test:
1) Apply patch, updatedatabase, restart_all, build yarn
2) In system preferences, search for 'OPACVirtualCard'. Both this and the barcode sys. pref should show up with the same search. Notice they are dependent on one another. The default for the first pref should be "Don't allow". Leave this as is for now.
3) Leave the preference page open and log into the OPAC. Visit the user page. Notice that the navbar on the left consiting of 'Summary', 'Charges', etc. looks the same.
4) Go back to the sys. pref page and set the OPACVirtualCard to "Allow"
5) Also in the sys. prefs, make a search for "patron images" and set 'OPACpatronimages' to "Show" and 'patronimages' to allow.
6) Visit the patron's page that you used to sign in to the OPAC. Add a patron image if there is not one already.
7) Now, edit their details and change their card number to '00012345678905'
8) Venture back to the OPAC patron page. Refresh this and you should see a new "My Virtual Card" page at the bottom.
9) Click this page and you should see a new virtual card for you patron, consiting of their image, a barcode, and their library.
10) Open the dev tools for your browser and switch to vieiwing in mobile mode. Make sure the card looks good. This would likely be the most common use case.
11) Switch back to a system preference page and try playing around with the 'OPACVirtualCardBarcode'. Note that these changes affect the type of barcode that is display in the virtual card page. If you selected a barcode format that is incompatible, an error message should display in the virtual card page.

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 53 Martin Renvoize (ashimema) 2024-07-26 15:19:30 UTC
Nice to see this moved along.  Passing QA
Comment 54 Katrin Fischer 2024-08-23 16:27:56 UTC
This needs a rebase, probably because of bug 35402. Please fix, it will appear back on top of my queue then.
Comment 55 Sam Lau 2024-08-23 19:14:29 UTC
Created attachment 170667 [details] [review]
Bug 26777: Added new sys pref 'OPACVirtualCard'

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 56 Sam Lau 2024-08-23 19:14:31 UTC
Created attachment 170668 [details] [review]
Bug 26777: Add barcode generator file and initial styling

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 57 Sam Lau 2024-08-23 19:14:34 UTC
Created attachment 170669 [details] [review]
Bug 26777: Add new patron page 'My Virtual Card'

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 58 Sam Lau 2024-08-23 19:14:37 UTC
Created attachment 170670 [details] [review]
Bug 26777: (follow-up) Adjust script, template, and CSS

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 59 Sam Lau 2024-08-23 19:14:40 UTC
Created attachment 170671 [details] [review]
Bug 26777: (follow-up) Fix file permssions and tidy

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 60 Sam Lau 2024-08-23 19:14:43 UTC
Created attachment 170672 [details] [review]
Bug 26777: Add bwip-js library to Koha

bwip-js is the chosen library for generating and displaying barcodes in the OPAC. It allows for many different barcode types and customizable settings. This patch created a new directory and file for the js library code to live as well as updating the about.tt to give credit.

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 61 Sam Lau 2024-08-23 19:14:46 UTC
Created attachment 170673 [details] [review]
Bug 26777: Add new system preference 'OPACVirtualCardBarcode'

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 62 Sam Lau 2024-08-23 19:14:49 UTC
Created attachment 170674 [details] [review]
Bug 26777: Allow ability to select diffferent barcode types

These cumalation of patches introduce a new patron page on the OPAC: "My virtual card." This page and its contents are reliant on the system preferences 'OPACVirtualCard' and 'OPACVirtualCardBarcode'. OPACVirutalCard determines whether the virtual card page is even displayed on the OPAC whereas OPACVirtualCardBarcode selects the type of barcode to display on this page (if page is displayed). Currently, the virtual card page consits of a patron image (if available), the patron's barcode, and the library name. A potential follow up would be to allow customization of this page. The barcode generation is handled by a new library bwip-js.

To test:
1) Apply patch, updatedatabase, restart_all, build yarn
2) In system preferences, search for 'OPACVirtualCard'. Both this and the barcode sys. pref should show up with the same search. Notice they are dependent on one another. The default for the first pref should be "Don't allow". Leave this as is for now.
3) Leave the preference page open and log into the OPAC. Visit the user page. Notice that the navbar on the left consiting of 'Summary', 'Charges', etc. looks the same.
4) Go back to the sys. pref page and set the OPACVirtualCard to "Allow"
5) Also in the sys. prefs, make a search for "patron images" and set 'OPACpatronimages' to "Show" and 'patronimages' to allow.
6) Visit the patron's page that you used to sign in to the OPAC. Add a patron image if there is not one already.
7) Now, edit their details and change their card number to '00012345678905'
8) Venture back to the OPAC patron page. Refresh this and you should see a new "My Virtual Card" page at the bottom.
9) Click this page and you should see a new virtual card for you patron, consiting of their image, a barcode, and their library.
10) Open the dev tools for your browser and switch to vieiwing in mobile mode. Make sure the card looks good. This would likely be the most common use case.
11) Switch back to a system preference page and try playing around with the 'OPACVirtualCardBarcode'. Note that these changes affect the type of barcode that is display in the virtual card page. If you selected a barcode format that is incompatible, an error message should display in the virtual card page.

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 63 Katrin Fischer 2024-08-26 08:30:19 UTC
Please verify my changes once pushed and reply to 1) :)

1) Naming and positioning

This is a question: You named the tab "My virtual card", but that appears very general. What about we named it "Library card" or "Virtual library card" instead? 
Tbh I struggle a bit with the 'virtual and the "my" that we once had removed from all the other tabs.

Also, right now the tab appears last in the patron's account, should we move it to be first or second?

2) Capitalization

- My Virtual Card => My virtual card

I've fixed this in a follow-up patch.

3) Translatability

This is untranslatable:
+        document.getElementById('barcode-container').innerHTML = `<p><strong>Error: </strong>${errorMessage}</p>`;

Also, strings should always be enclosed using double quotes. That's so that languages using single quotes like French don't break the JS by accident.
See: JS2: Enabling translation of language strings in embedded JavaScript

I attached a follow-up patch.

4) Missing CSS file 

This is not right, maybe related to the Bootstrap 5 change:

koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-virtual-card.tt:    [% Asset.css("css/src/opac.css") | $raw %]

This file doesn't exist. Updated to: css/opac.css in a follow-up patch.
Comment 64 Katrin Fischer 2024-08-26 15:43:32 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 65 David Cook 2024-08-27 02:04:40 UTC
I wanted to thoroughly test this but ran out of time chasing a different bug...

Just wanted to point out that you almost never want to use innerHTML() for setting a value. It's a good way to accidentally introduce a XSS vulnerability. Look at OWASP documents for preventing Cross-Site Scripting (XSS).

In this case, I think that you're mostly, as it seems unlikely someone could slip XSS in through the SVG. I'm more worried about the error message, which appears to be broken anyway...
Comment 66 David Cook 2024-08-27 02:08:48 UTC
(In reply to Katrin Fischer from comment #63)
> 3) Translatability
> 
> This is untranslatable:
> +        document.getElementById('barcode-container').innerHTML =
> `<p><strong>Error: </strong>${errorMessage}</p>`;
> 
> Also, strings should always be enclosed using double quotes. That's so that
> languages using single quotes like French don't break the JS by accident.
> See: JS2: Enabling translation of language strings in embedded JavaScript

So this was using a template literal, which I thought the translations could use? 

Personally, I quite like template literals, but using innerHTML here was a good way to potentially introduce XSS via the errorMessage... (although it would need to come from the third party Javascript in this case which is probably unlikely but still better to be safe than sorry...)

> I attached a follow-up patch.

The follow-up patch accidentally broke the errorMessage display, since it retained the template literal syntax for errorMessage. See bug 37742.
Comment 67 David Cook 2024-08-27 03:53:32 UTC
(In reply to David Cook from comment #66)
> The follow-up patch accidentally broke the errorMessage display, since it
> retained the template literal syntax for errorMessage. See bug 37742.

Btw, while I fix this in bug 37742, I don't think that we should actually show the error message to patrons. If we're going to show an error message, it would probably be better to say "Failed to generate barcode" or something like that.

A user doesn't need to see "Code 39 must contain only digits, capital letters, spaces and the symbols -.$/+%"
Comment 68 Katrin Fischer 2024-08-27 05:17:16 UTC
(In reply to David Cook from comment #67)
> (In reply to David Cook from comment #66)
> > The follow-up patch accidentally broke the errorMessage display, since it
> > retained the template literal syntax for errorMessage. See bug 37742.
> 
> Btw, while I fix this in bug 37742, I don't think that we should actually
> show the error message to patrons. If we're going to show an error message,
> it would probably be better to say "Failed to generate barcode" or something
> like that.
> 
> A user doesn't need to see "Code 39 must contain only digits, capital
> letters, spaces and the symbols -.$/+%"

Sorry for breaking it. :( I did check for JS errors, and didn't see any, but that was not enough.
Comment 69 Katrin Fischer 2024-11-14 15:15:16 UTC
Fixed on 37742 I believe.