Bug 15752 - Automatically switch from circulation to new patron when a cardnumber is scanned during circulation
Summary: Automatically switch from circulation to new patron when a cardnumber is scan...
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: chad
QA Contact: Kyle M Hall
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-05 19:53 UTC by chad
Modified: 2018-05-24 18:24 UTC (History)
12 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:
The new system preference AutoSwitchPatron allows to automatically switch to another patron record on scanning the cardnumber during circulation. This will allow to streamline processes at the circulation desk a bit more. Note: Use only if there is no overlap in your cardnumber and barcode ranges.


Attachments
Bug 15752 - Automatically switch patron during circulation (4.60 KB, patch)
2016-02-05 20:00 UTC, chad
Details | Diff | Splinter Review
Bug 15752 - Automatically switch patron during circulation (4.63 KB, patch)
2016-09-30 10:25 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 15752 - Automatically switch patron during circulation (4.67 KB, patch)
2016-11-01 10:52 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 15752 - Automatically switch patron during circulation (4.33 KB, patch)
2017-08-18 11:03 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 15752: QA followup - search for patrons only if param barcode is defined (1.28 KB, patch)
2017-08-18 11:03 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 17572: QA followup - inform user that patron was automatically switched (2.50 KB, patch)
2017-08-18 11:03 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 15752 - Automatically switch patron during circulation (4.33 KB, patch)
2017-09-11 09:15 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 15752: QA followup - search for patrons only if param barcode is defined (1.28 KB, patch)
2017-09-11 09:15 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 15752: QA followup - inform user that patron was automatically switched (2.45 KB, patch)
2017-09-11 09:15 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 15752 - Automatically switch patron during circulation (4.44 KB, patch)
2017-09-17 03:59 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 15752: QA followup - search for patrons only if param barcode is defined (1.33 KB, patch)
2017-09-17 04:01 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 15752: QA followup - inform user that patron was automatically switched (2.57 KB, patch)
2017-09-17 04:04 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 15752 - Automatically switch patron during circulation (4.49 KB, patch)
2017-12-21 10:54 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 15752: QA followup - search for patrons only if param barcode is defined (1.39 KB, patch)
2017-12-21 10:54 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 15752: QA followup - inform user that patron was automatically switched (2.63 KB, patch)
2017-12-21 10:54 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 15752: Remove unecessary redirect (1.90 KB, patch)
2017-12-21 18:14 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 15752: Remove unecessary redirect (follow-up) (1.38 KB, patch)
2017-12-21 21:00 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 15752: Automatically switch to patron when cardnumber is read during circulation (4.57 KB, patch)
2018-02-09 07:14 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 15752: (follow-up) Search for patrons only if param barcode is defined (1.44 KB, patch)
2018-02-09 07:14 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 15752: (QA follow-up) Inform user that patron was automatically switched (2.68 KB, patch)
2018-02-09 07:14 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 15752: (QA follow-up) Remove unecessary redirect (1.97 KB, patch)
2018-02-09 07:14 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 15752: (QA follow-up) Remove unecessary redirect (1.45 KB, patch)
2018-02-09 07:14 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description chad 2016-02-05 19:53:54 UTC
Our library staff requested that koha automatically switch patrons when a patron barcode is scanned into the item barcode field during circulation. They frequently have large number of kids line up to checkout books and wanted this feature to speed up the process.

I have implemented a patch that enables this functionality.

To test:

- Disable  the autoswitchpatron system preference. 
- Go to the "Check out" section of a patron "circ/circulation.pl"
- Enter a patron barcode into item barcode field. 
- You should get a message about the barcode not being found
- Enable autoswitchpatron preference
- Enter a patron barcode into the item barcode field
- You should be redirected to that patron's circulation page.
Comment 1 chad 2016-02-05 20:00:26 UTC
Created attachment 47716 [details] [review]
Bug 15752 - Automatically switch patron during circulation

With this syspref enabled scanning a patron barcode into the item
barcode field during circulation will redirect you to the patron's
circulation page.

This allows circulation with only a barcode scanner.

Testing:

- Enable the AutoSwitchPatron syspref
- Navigate to a patron's check out screen
- Enter a patron barcode into the "Enter item barcode" field

Result
- Browser should be redirected to the entered patron
Comment 2 Nick Clemens 2016-02-25 21:54:20 UTC
Hi Chad,

Patch works as expected but atomicupdate file should be a *.sql file instead of a *.pl file :-)

Fix that and I can retest/signoff
Comment 3 Marc Véron 2016-08-10 18:47:58 UTC
Patch does no longer apply.
Comment 4 Jonathan Druart 2016-09-30 10:25:47 UTC
Created attachment 55953 [details] [review]
Bug 15752 - Automatically switch patron during circulation

With this syspref enabled scanning a patron barcode into the item
barcode field during circulation will redirect you to the patron's
circulation page.

This allows circulation with only a barcode scanner.

Testing:

- Enable the AutoSwitchPatron syspref
- Navigate to a patron's check out screen
- Enter a patron barcode into the "Enter item barcode" field

Result
- Browser should be redirected to the entered patron
Comment 5 Jonathan Druart 2016-09-30 10:26:08 UTC
Easy conflict fixed, atomic .pl moved to .sql
Comment 6 Marc Véron 2016-09-30 16:47:58 UTC
Hi Jonathan,
With patch applied I can not open the checkout page e.g. from the link "My checkouts" or the link "Check out" at the left hand of a patron detail page.

To make it work, I changed the following line:
if (C4::Context->preference("AutoSwitchPatron") ) {
to:
if (C4::Context->preference("AutoSwitchPatron") && $query->param('barcode') ) {

With this change, the patch behaves as expected.
Comment 7 Jonathan Druart 2016-10-03 07:38:53 UTC
I'd like to get feedback from others to know if it is a good behaviour to implement before fixing it.
Comment 8 Katrin Fischer 2016-10-03 07:45:30 UTC
I think this could speed up things at the desk, but I have one worry: What happens when there is an overlap between item barcodes and patron cardnumbers? 

Maybe we should show a warning message in that case, asking if the number was one or the other before proceeding.
Comment 9 Katrin Fischer 2016-10-03 07:48:14 UTC
Hm, if this is to avoid using the mouse to switch to the check-in field - have you seen that there are keyboard shortcuts for this too? From the circulation start page help:

- jump to the catalog search with Alt+Q
- jump to the checkout with Alt+U (this will not work for Mac user)
- jump to the checkin with Alt+R
Comment 10 Marc Véron 2016-10-03 07:58:03 UTC
(In reply to Katrin Fischer from comment #8)
> I think this could speed up things at the desk, but I have one worry: What
> happens when there is an overlap between item barcodes and patron
> cardnumbers? 
> 
> Maybe we should show a warning message in that case, asking if the number
> was one or the other before proceeding.

I think in the case of overlapping barcodes the feature should be turned off anyway, as
the explanation for syspref AutoSwitchPatron says:

"This should not be enabled if you have overlapping patron and book barcodes."

If in the future a library with overlapping barcodes wants to have this feature, they can ask for or provide an enhancement.
Comment 11 Fred 2016-10-10 15:21:09 UTC
Hi,
For autoswitch, in my library we use this JavaScript code (thanks to S.D.):
/////////////////
$(document).ready(function ()
{
if (window.location.href.indexOf("cgi-bin/koha/circ/circulation.pl") > -1)
if ($("#circ_impossible ul li").html())
{
 var message = $("#circ_impossible ul li").html(); 
 var terme = message.split(' ');
 var cb= terme[9];
 var n= cb.length;}
if (n==5)
if (check_numerique(cb) == true)
{$("#patronsearch #findborrower").val(cb);
$("#patronsearch #autocsubmit").click();
}
else {return false;}
function check_numerique(input){
            return !isNaN(input);
        }

}
////////////////////

This present 1 or 2 seconds the usual yellow message : Barcode not found

we are satisfied with this solution for 1 year. Is it possible to make the same timing in this patch ?

Thanks,
Fred
Comment 12 sandboxes@biblibre.com 2016-10-13 09:16:11 UTC
Patch tested with a sandbox, by Joel <aloi54@live.fr>
Comment 13 Jonathan Druart 2016-11-01 10:52:21 UTC
Created attachment 57015 [details] [review]
Bug 15752 - Automatically switch patron during circulation

With this syspref enabled scanning a patron barcode into the item
barcode field during circulation will redirect you to the patron's
circulation page.

This allows circulation with only a barcode scanner.

Testing:

- Enable the AutoSwitchPatron syspref
- Navigate to a patron's check out screen
- Enter a patron barcode into the "Enter item barcode" field

Result
- Browser should be redirected to the entered patron

Signed-off-by: Joel <aloi54@live.fr>
Comment 14 Jonathan Druart 2016-11-01 11:15:42 UTC
Should not we add a message box if the switch happened?
Comment 15 Jonathan Druart 2016-11-01 11:18:52 UTC
From the Koha log file:

circulation.pl: CGI::param called in list context from package main line 83, this can lead to vulnerabilities. See the warning in "Fetching the value or values of a single named parameter" at /usr/share/perl5/CGI.pm line 436., referer: http://pro.kohadev.vm/cgi-bin/koha/circ/circulation-home.pl

circulation.pl: Odd number of elements in anonymous hash at /home/vagrant/kohaclone/circ/circulation.pl line 83., referer: http://pro.kohadev.vm/cgi-bin/koha/circ/circulation-home.pl

The search should only be done if the barcode field has been filled.
Comment 16 Josef Moravec 2017-08-18 11:03:12 UTC
Created attachment 66175 [details] [review]
Bug 15752 - Automatically switch patron during circulation

With this syspref enabled scanning a patron barcode into the item
barcode field during circulation will redirect you to the patron's
circulation page.

This allows circulation with only a barcode scanner.

Testing:

- Enable the AutoSwitchPatron syspref
- Navigate to a patron's check out screen
- Enter a patron barcode into the "Enter item barcode" field

Result
- Browser should be redirected to the entered patron

Signed-off-by: Joel <aloi54@live.fr>
Comment 17 Josef Moravec 2017-08-18 11:03:16 UTC
Created attachment 66176 [details] [review]
Bug 15752: QA followup - search for patrons only if param barcode is defined
Comment 18 Josef Moravec 2017-08-18 11:03:20 UTC
Created attachment 66177 [details] [review]
Bug 17572: QA followup - inform user that patron was automatically switched

Test plan:

1) Start checking out to some patron - there should be no message about
auto switching
2) read the another patrons card - note the patron is switched and there
is a message about it at top of the main page content
Comment 19 Alex Buckley 2017-09-08 03:46:36 UTC
Hi Josef

Sorry but failed in the running of QA test tools:

 OK	circ/circulation.pl
   OK	  critic
   OK	  forbidden patterns
   OK	  git manipulation
   OK	  pod
   OK	  spelling
   OK	  valid

 OK	installer/data/mysql/sysprefs.sql
   OK	  git manipulation
   OK	  semicolon
   OK	  sysprefs_order

 FAIL	koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
   OK	  forbidden patterns
   OK	  git manipulation
   OK	  spelling
   OK	  tt_valid
   FAIL	  valid_template


After that is fixed up I will be happy to test and signoff as the patches worked as described in the test plans
Comment 20 Josef Moravec 2017-09-11 09:15:00 UTC
Created attachment 67037 [details] [review]
Bug 15752 - Automatically switch patron during circulation

With this syspref enabled scanning a patron barcode into the item
barcode field during circulation will redirect you to the patron's
circulation page.

This allows circulation with only a barcode scanner.

Testing:

- Enable the AutoSwitchPatron syspref
- Navigate to a patron's check out screen
- Enter a patron barcode into the "Enter item barcode" field

Result
- Browser should be redirected to the entered patron

Signed-off-by: Joel <aloi54@live.fr>
Comment 21 Josef Moravec 2017-09-11 09:15:04 UTC
Created attachment 67038 [details] [review]
Bug 15752: QA followup - search for patrons only if param barcode is defined
Comment 22 Josef Moravec 2017-09-11 09:15:08 UTC
Created attachment 67039 [details] [review]
Bug 15752: QA followup - inform user that patron was automatically switched

Test plan:

1) Start checking out to some patron - there should be no message about
auto switching
2) read the another patrons card - note the patron is switched and there
is a message about it at top of the main page content
Comment 23 Josef Moravec 2017-09-11 09:16:54 UTC
(In reply to Alex Buckley from comment #19)
> Hi Josef
> 
> Sorry but failed in the running of QA test tools:
> 
>  OK	circ/circulation.pl
>    OK	  critic
>    OK	  forbidden patterns
>    OK	  git manipulation
>    OK	  pod
>    OK	  spelling
>    OK	  valid
> 
>  OK	installer/data/mysql/sysprefs.sql
>    OK	  git manipulation
>    OK	  semicolon
>    OK	  sysprefs_order
> 
>  FAIL	koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
>    OK	  forbidden patterns
>    OK	  git manipulation
>    OK	  spelling
>    OK	  tt_valid
>    FAIL	  valid_template
> 
> 
> After that is fixed up I will be happy to test and signoff as the patches
> worked as described in the test plans

Did you have any conflicts applying the patches?

For me it passes the QA test tools...

Anyway, I rebased the patches on master and fixed commit message on 3rd patch (wrong bug number). Could you try it again?
Comment 24 Alex Buckley 2017-09-17 03:59:10 UTC
Created attachment 67174 [details] [review]
Bug 15752 - Automatically switch patron during circulation

With this syspref enabled scanning a patron barcode into the item
barcode field during circulation will redirect you to the patron's
circulation page.

This allows circulation with only a barcode scanner.

Testing:

- Enable the AutoSwitchPatron syspref
- Navigate to a patron's check out screen
- Enter a patron barcode into the "Enter item barcode" field

Result
- Browser should be redirected to the entered patron

Signed-off-by: Joel <aloi54@live.fr>

Followed test plan, patch works as described
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Comment 25 Alex Buckley 2017-09-17 04:01:49 UTC
Created attachment 67175 [details] [review]
Bug 15752: QA followup - search for patrons only if param barcode is defined

Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Comment 26 Alex Buckley 2017-09-17 04:04:29 UTC
Created attachment 67176 [details] [review]
Bug 15752: QA followup - inform user that patron was automatically switched

Test plan:

1) Start checking out to some patron - there should be no message about
auto switching
2) read the another patrons card - note the patron is switched and there
is a message about it at top of the main page content

Followed test plan, patch worked as described. Passed QA test tool
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Comment 27 Kyle M Hall 2017-12-21 10:54:21 UTC
Created attachment 69994 [details] [review]
Bug 15752 - Automatically switch patron during circulation

With this syspref enabled scanning a patron barcode into the item
barcode field during circulation will redirect you to the patron's
circulation page.

This allows circulation with only a barcode scanner.

Testing:

- Enable the AutoSwitchPatron syspref
- Navigate to a patron's check out screen
- Enter a patron barcode into the "Enter item barcode" field

Result
- Browser should be redirected to the entered patron

Signed-off-by: Joel <aloi54@live.fr>

Followed test plan, patch works as described
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 28 Kyle M Hall 2017-12-21 10:54:29 UTC
Created attachment 69995 [details] [review]
Bug 15752: QA followup - search for patrons only if param barcode is defined

Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 29 Kyle M Hall 2017-12-21 10:54:32 UTC
Created attachment 69996 [details] [review]
Bug 15752: QA followup - inform user that patron was automatically switched

Test plan:

1) Start checking out to some patron - there should be no message about
auto switching
2) read the another patrons card - note the patron is switched and there
is a message about it at top of the main page content

Followed test plan, patch worked as described. Passed QA test tool
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 30 Jonathan Druart 2017-12-21 18:14:55 UTC
Created attachment 70077 [details] [review]
Bug 15752: Remove unecessary redirect

We are on circulation.pl, no need to redirect.
Comment 31 Jonathan Druart 2017-12-21 18:15:47 UTC
We should not need to redirect, we are on circulation.pl. Could someone take a look and retest quickly?
Comment 32 Josef Moravec 2017-12-21 21:00:14 UTC
Created attachment 70085 [details] [review]
Bug 15752: Remove unecessary redirect (follow-up)

If the borrowernumber is defined in query, it starts to get information
about previous borrower and the new one is taken into account fully on
second page reload
Comment 33 Josef Moravec 2017-12-21 21:02:19 UTC
(In reply to Jonathan Druart from comment #31)
> We should not need to redirect, we are on circulation.pl. Could someone take
> a look and retest quickly?

True, but probably not so easy... I tested your patch and added followup - now it is working for me... but I am not sure if it is enough in all situations...
Comment 34 Katrin Fischer 2018-02-09 07:14:09 UTC
Created attachment 71359 [details] [review]
Bug 15752: Automatically switch to patron when cardnumber is read during circulation

With this syspref enabled scanning a patron barcode into the item
barcode field during circulation will redirect you to the patron's
circulation page.

This allows circulation with only a barcode scanner.

Testing:

- Enable the AutoSwitchPatron syspref
- Navigate to a patron's check out screen
- Enter a patron barcode into the "Enter item barcode" field

Result
- Browser should be redirected to the entered patron

Signed-off-by: Joel <aloi54@live.fr>

Followed test plan, patch works as described
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 35 Katrin Fischer 2018-02-09 07:14:13 UTC
Created attachment 71360 [details] [review]
Bug 15752: (follow-up) Search for patrons only if param barcode is defined

Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 36 Katrin Fischer 2018-02-09 07:14:18 UTC
Created attachment 71361 [details] [review]
Bug 15752: (QA follow-up) Inform user that patron was automatically switched

Test plan:

1) Start checking out to some patron - there should be no message about
auto switching
2) read the another patrons card - note the patron is switched and there
is a message about it at top of the main page content

Followed test plan, patch worked as described. Passed QA test tool
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 37 Katrin Fischer 2018-02-09 07:14:22 UTC
Created attachment 71362 [details] [review]
Bug 15752: (QA follow-up) Remove unecessary redirect

We are on circulation.pl, no need to redirect.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 38 Katrin Fischer 2018-02-09 07:14:27 UTC
Created attachment 71363 [details] [review]
Bug 15752: (QA follow-up)  Remove unecessary redirect

If the borrowernumber is defined in query, it starts to get information
about previous borrower and the new one is taken into account fully on
second page reload

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 39 Jonathan Druart 2018-02-12 21:08:23 UTC
Patches pushed to master for 18.05.

Congratulations Chad for your first patch in!
Comment 40 Nick Clemens 2018-02-16 01:50:33 UTC
Awesome work all! Enhancement, not backported to stable.