Bug 31779

Summary: Article request form shows all locations in pickup library menu
Product: Koha Reporter: Eric Phetteplace <ephetteplace>
Component: CirculationAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: gmcharlt, kyle.m.hall
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Eric Phetteplace 2022-10-13 19:44:51 UTC
To recreate:

1. have multiple locations/branches
2. set one to not be available as a pickup location
3. have an item where you can make article requests (e.g. a newspaper or journal)
4. go to the article request form for the item /cgi-bin/koha/opac-request-article.pl?biblionumber={{biblionumber}}
5. note the "pickup library" select menue at the bottom of the form

Expected behavior: the location in step #2 will not be listed in the select menu because it is not an available pickup location. This is the case, for instance, on the holds form at /cgi-bin/koha/opac-reserve.pl?biblionumber={{biblionumber}}.

Actual behavior: all libraries are listed. The template iterates over all branches `FOREACH b IN Branches.all` without discrimination.

There's a question of whether article pickups and holds pickups should be treated the same, maybe there's some edge case where these are different, but for us and I would imagine the vast majority of libraries it doesn't make sense to offer a pickup location for articles when the branch itself doesn't process holds (usually means there are no circulation functions or staff at that location).

I looked at the logic in koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt to see if it could be easily copied over to the koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt but it is not as straightforward as I'd expected. We will probably resort to OPACUserJS to work around this in the meantime.
Comment 1 Eric Phetteplace 2022-10-13 19:57:21 UTC
In case it's useful for other people, this is the custom JS I've added:

if (location.pathname.match('/cgi-bin/koha/opac-request-article.pl')) {
    // remove invalid pickup library options
    $('option[value="NOTAPICKUPLIB1"], option[value="NOTAPICKUPLIB2"]').remove()
}

You need to add in your own branch codes. We actually only have one valid location so I added another line `$('#branchcode').parent().hide()` to hide the menu and its label altogether since there's no choice for users to make.
Comment 2 Katrin Fischer 2022-11-14 22:20:12 UTC
Changing from OPAC to circulation as the article request form in staff probably shows the same behavior.