Bug 35131

Summary: Add scan-able barcode to the patron sidebar (patroninfo)
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: PatronsAssignee: Lucas Gass (lukeg) <lucas>
Status: Failed QA --- QA Contact: Kyle M Hall (khall) <kyle>
Severity: enhancement    
Priority: P5 - low CC: dcook, ddaghita, edward.m.veal, gmcharlt, kyle.m.hall, kyle, martin.renvoize, pasi.kallinen, sally.healey
Version: MainKeywords: Sandbox
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 35131: Show the patron cardnumber as a borcode in the patron record
Bug 35131: Add new system preference and DBRev
Bug 35131: Show the patron cardnumber as a borcode in the patron record
Bug 35131: Fix preference description and move barcode to bottom of patroninfo
Bug 35131: Add new system preference and DBRev
Bug 35131: Show the patron cardnumber as a borcode in the patron record
Bug 35131: Fix preference description and move barcode to bottom of patroninfo
Bug 35131: Add new system preference and DBRev
Bug 35131: Add new system preference and DBRev
Bug 35131: Show the patron cardnumber as a borcode in the patron record
Bug 35131: Fix preference description and move barcode to bottom of patroninfo

Description Lucas Gass (lukeg) 2023-10-23 14:41:31 UTC
Many libraries have requested this and I have been obliging with custom JS. I think it would be nice to add to Koha properly.

This would be a scan-able barcode from 'patroninfo' sidebar. I could be controlled by a system preference that display or does not display it and allows for a choice of barcode type.
Comment 1 Lucas Gass (lukeg) 2023-10-23 15:23:09 UTC Comment hidden (obsolete)
Comment 2 Lucas Gass (lukeg) 2023-10-23 15:24:07 UTC
Created attachment 157675 [details] [review]
Bug 35131: Add new system preference and DBRev
Comment 3 Lucas Gass (lukeg) 2023-10-23 15:24:09 UTC
Created attachment 157676 [details] [review]
Bug 35131: Show the patron cardnumber as a borcode in the patron record

To test:
1. Apply patch, updatedatabase, yarn build, and restart services
2. Search for the system preference 'ShowBarcodeOnPatronRecord' and set it to something other than 'Don't show'.
3. Now go to any page that shows the 'patroninfo' section. ( circ/circulation.pl, members/moremember.pl, members/pay.pl, etc )
4. Make sure this patron has a cardnumber.
5. From any of the aforementioned pages make sure you can see the patron barcode.
6. Try many different barcode types, making sure they each display well.
7. Remove the patron cardnumber and confirm that nothing displays.
Comment 4 Owen Leonard 2023-10-23 16:46:09 UTC
What is the use case here? If the patron record is already up why scan the barcode?

I ask in part because my impulse is to say the barcode should go below the patron info, but I don't know if that conflicts with the original requirements.

I think the preference description should be a little more specific:

"Show a <type> barcode of the patron record."

Could be... "Show a <type> barcode of the patron's card number in the sidebar of patron-related pages" ?
Comment 5 davedaghita 2023-10-23 16:53:38 UTC
Case use for when patrons forget their library card.  Staff can scan their barcode from the staff side account to quickly checkout them on the self-checkout kiosks.
Comment 6 Ed Veal 2023-10-23 17:00:22 UTC
At the risk of asking for a bit more please. Might we have the option of the barcode being a printable QR Code? Just asking!
Comment 7 Lucas Gass (lukeg) 2023-10-23 19:16:55 UTC
(In reply to Ed Veal from comment #6)
> At the risk of asking for a bit more please. Might we have the option of the
> barcode being a printable QR Code? Just asking!

One of the barcode type options is QRCode.
Comment 8 David Cook 2023-10-24 00:19:08 UTC
(In reply to Owen Leonard from comment #4)
> What is the use case here? If the patron record is already up why scan the
> barcode?

I'm also curious why we'd need the barcode on the staff interface...
Comment 9 David Cook 2023-10-24 00:19:56 UTC
(In reply to Dave from comment #5)
> Case use for when patrons forget their library card.  Staff can scan their
> barcode from the staff side account to quickly checkout them on the
> self-checkout kiosks.

Could you elaborate on that? How would the self-checkout kiosk have access to the staff interface?
Comment 10 davedaghita 2023-10-24 16:08:14 UTC
We use tablets to access the staff intranet to look at patron accounts and other modules in koha on the main library floor.  This mobile circulation method gives full staff access to all aspects of the patron account.  
We use koha module self-checkout kiosks only with 2D barcode scanner and RFiD pad.  If a patron forgets their library card or did not bring their phone with digital card.  The scannable barcode within their patron account allows staff then walk over to a self-checkout kiosk scan their barcode from our tablets and let the patron continue their checkout unaided.  

Side note: This also helps with new library cards as we went to preferred digital cards method.  When logging-in a user for the first time to the Aspen LiDA app.  We use the barcode scan function in Aspen LiDA on their phone to scan the patron’s barcode from their account via out tablets with the staff side intranet to quickly fill that library barcode section of Aspen LiDA.  We do use that staff side intranet barcode for multiple options.
Comment 11 Ed Veal 2023-10-24 16:58:07 UTC
David, 

I hope Dave answered your question about use case. The second part of my request is that we have almost moved completely away from giving out cards, 90+% use of AspenLiDa app or Aspen website. However, there are times that a child really wants a card and we are working on workflows to create a quick card on the fly rather than purchasing enough pre-printed cards to get a discount and tracking the barcode numbers so that we don't have conflicts.  We are also going to be moving to using "Internet Only" accounts for our homeless to access computers. For this we want to provide a special card we create on the fly as well. However, for those that have mobile phones the app and/or website will work just as well. 

Ed
Comment 12 David Cook 2023-10-24 22:20:25 UTC
Thanks Dave and Ed. Those explanations were really helpful :).
Comment 13 Lucas Gass (lukeg) 2023-10-26 16:11:52 UTC
The feedback I am getting from libraries is very similar to the workflow explained by Ed and Dave:

"This will enable us to quickly aid a patron who has forgotten their library card at the self-check machines. We would be able to scan this rather than put it in manually by hand. It would make us much more efficient on the floor."
Comment 14 Lucas Gass (lukeg) 2023-10-26 16:13:12 UTC
(In reply to Owen Leonard from comment #4)
> What is the use case here? If the patron record is already up why scan the
> barcode?
> 
> I ask in part because my impulse is to say the barcode should go below the
> patron info, but I don't know if that conflicts with the original
> requirements.
> 
> I think the preference description should be a little more specific:
> 
> "Show a <type> barcode of the patron record."
> 
> Could be... "Show a <type> barcode of the patron's card number in the
> sidebar of patron-related pages" ?

I agree. I will change the pref and add the barcode below the patron info.
Comment 15 Lucas Gass (lukeg) 2023-10-26 16:55:52 UTC
Created attachment 157936 [details] [review]
Bug 35131: Fix preference description and move barcode to bottom of patroninfo
Comment 16 paxed 2023-11-01 10:05:23 UTC
This can be done with just javascript without needing to change Koha code, something like

$(document).ready(function () {
  if (window.location.pathname == '/cgi-bin/koha/members/moremember.pl') {
    cardnumber = document.getElementById('patron-cardnumber').childNodes[2].nodeValue.trim();
    barcodeurl = "/cgi-bin/koha/svc/barcode?barcode=" + cardnumber.toUpperCase() + "&notext=1";
    $('li#patron-cardnumber').append('<br><img src="' + barcodeurl + '">');
  }
});
Comment 17 Lucas Gass (lukeg) 2023-11-01 17:10:42 UTC
(In reply to paxed from comment #16)
> This can be done with just javascript without needing to change Koha code,
> something like
> 
> $(document).ready(function () {
>   if (window.location.pathname == '/cgi-bin/koha/members/moremember.pl') {
>     cardnumber =
> document.getElementById('patron-cardnumber').childNodes[2].nodeValue.trim();
>     barcodeurl = "/cgi-bin/koha/svc/barcode?barcode=" +
> cardnumber.toUpperCase() + "&notext=1";
>     $('li#patron-cardnumber').append('<br><img src="' + barcodeurl + '">');
>   }
> });

Sure, but we'd rather see this get into Koha as a feature instead of having to upkeep any custom javascript.
Comment 18 David Cook 2023-11-01 23:56:34 UTC
At the risk of flogging this horse to death, another thought would be to have a "Barcode" or "Card" circ menu option. Of course, that would be another Perl script/template combo, but then we wouldn't need a new syspref/database change I think.
Comment 19 Owen Leonard 2023-11-02 11:00:45 UTC
Created attachment 158242 [details] [review]
Bug 35131: Add new system preference and DBRev

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 20 Owen Leonard 2023-11-02 11:00:48 UTC
Created attachment 158243 [details] [review]
Bug 35131: Show the patron cardnumber as a borcode in the patron record

To test:
1. Apply patch, updatedatabase, yarn build, and restart services
2. Search for the system preference 'ShowBarcodeOnPatronRecord' and set
   it to something other than 'Don't show'.
3. Now go to any page that shows the 'patroninfo' section. (
   circ/circulation.pl, members/moremember.pl, members/pay.pl, etc )
4. Make sure this patron has a cardnumber.
5. From any of the aforementioned pages make sure you can see the
   patron barcode.
6. Try many different barcode types, making sure they each display well.
7. Remove the patron cardnumber and confirm that nothing displays.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 21 Owen Leonard 2023-11-02 11:00:51 UTC
Created attachment 158244 [details] [review]
Bug 35131: Fix preference description and move barcode to bottom of patroninfo

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 22 Kyle M Hall (khall) 2023-12-01 16:33:11 UTC
Created attachment 159459 [details] [review]
Bug 35131: Add new system preference and DBRev

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 23 Kyle M Hall (khall) 2023-12-01 16:37:27 UTC
Created attachment 159460 [details] [review]
Bug 35131: Add new system preference and DBRev

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 24 Kyle M Hall (khall) 2023-12-01 16:37:33 UTC
Created attachment 159461 [details] [review]
Bug 35131: Show the patron cardnumber as a borcode in the patron record

To test:
1. Apply patch, updatedatabase, yarn build, and restart services
2. Search for the system preference 'ShowBarcodeOnPatronRecord' and set
   it to something other than 'Don't show'.
3. Now go to any page that shows the 'patroninfo' section. (
   circ/circulation.pl, members/moremember.pl, members/pay.pl, etc )
4. Make sure this patron has a cardnumber.
5. From any of the aforementioned pages make sure you can see the
   patron barcode.
6. Try many different barcode types, making sure they each display well.
7. Remove the patron cardnumber and confirm that nothing displays.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 25 Kyle M Hall (khall) 2023-12-01 16:37:35 UTC
Created attachment 159462 [details] [review]
Bug 35131: Fix preference description and move barcode to bottom of patroninfo

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 26 Katrin Fischer 2024-01-30 16:44:59 UTC
There is some small stuff adding up here, please follow-up!

1) sysprefs.sql

 FAIL	installer/data/mysql/mandatory/sysprefs.sql
   FAIL	  sysprefs_order
		Not blocker: Sysprefs ShowBarcodeOnPatronRecord is bad placed (see bug 10610)

Please fix, but also take a look at the SQL. I believe options and value are switched in sysprefs.sql:

INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
('ShowBarcodeOnPatronRecord','|0|Code39|COOP2of5|EAN13|EAN8|IATA2of5|Industrial2of5|ITF|Matrix2of5|NW7|QRcode|UPCA|UPCE','0','Show a patron\'s carnumber as a barcode on the patron record','Choice'),

2) .pref 

+         - "Show a "
+         - pref: ShowBarcodeOnPatronRecord
+           default: no
+           choices:
+               0: "Don't show"
+               Code39: "Code39"
+               COOP2of5: "COOP2of5"
+               EAN13: "EAN13"
+               EAN8: "EAN8"
+               IATA2of5: "IATA2of5"
+               Industrial2of5: "Industrial2of5"
+               ITF: "ITF"
+               Matrix2of5: "Matrix2of5"
+               NW7: "NW7"
+               QRcode: "QRcode"
+               UPCA: "UPCA"
+               UPCE: "UPCE"
+         - " barcode of the patron's card number in the sidebar of patron-related pages."

The sentence here doesn't work:

Show a [Don't show] barcode...
Show a [QRcode] barcode...