Bug 32712: Fix OPAC breakage when OPACShowCheckoutName enabled

Bug 31313 removed GetItemsInfo and proper Koha::Object-based objects are
passed now. But some automatic search & replace kept patron-related
attributes incorrectly linked to Koha::Item.

This patch makes the item-status.inc file reuse the checkout object and
get the linked patron to gather the required information. Some
simplification is done on hte same patch... should be trivial.

To test:
1. Have OpacShowCheckoutName enabled
2. Pick a biblio with items (all of them not checkecd-out)
3. Open the OPAC detail view for the biblio
=> SUCCESS: You see the biblio and the items
4. Check one of the items out
5. Refresh the OPAC page
=> FAIL: The page explodes!
6. Apply this patch
7. Refresh the OPAC page
=> SUCCESS: You see the biblio and the items, the patron info is
correctly displayed.
8. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Tomas Cohen Arazi 2023-01-30 17:08:36 -03:00
parent 8f38f3b74b
commit d74fe69d2c
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 9 additions and 8 deletions

View File

@ -19,9 +19,10 @@
[% SET transfertto = transfer.tobranch %]
[% END %]
[% SET waiting = item.holds.waiting.count %]
[% SET checkout = item.checkout %]
[% SET waiting = item.holds.waiting.count %]
[% IF include_schema_org %]
[% IF item.damaged or item.checkout.date_due or item.itemlost or transfertwhen or waiting %]
[% IF item.damaged or checkout or item.itemlost or transfertwhen or waiting %]
<link property="availability" href="http://schema.org/OutOfStock" />
[% ELSIF item.withdrawn %]
<link property="availability" href="http://schema.org/Discontinued" />
@ -42,26 +43,26 @@
[% END %]
[% END %]
[% SET datedue = item.checkout.date_due %]
[% SET onsite_checkout = item.checkout.onsite_checkout %]
[% IF checkout %]
[% SET checkout_patron = checkout.patron %]
[% SET onsite_checkout = checkout.onsite_checkout %]
[% IF datedue %]
[% SET itemavailable = 0 %]
[% IF onsite_checkout %]
[% IF ( OPACShowCheckoutName ) %]
<span class="item-status checkedout">Currently in local use by [% item.firstname | html %] [% item.surname | html %] [% IF ( item.cardnumber ) %]([% item.cardnumber | html %])[% END %]</span>
<span class="item-status checkedout">Currently in local use by [% checkout_patron.firstname | html %] [% checkout_patron.surname | html %] [% IF ( checkout_patron.cardnumber ) %]([% checkout_patron.cardnumber | html %])[% END %]</span>
[% ELSE %]
<span class="item-status checkedout">Currently in local use</span>
[% END %]
[% ELSE %]
[% IF ( OPACShowCheckoutName ) %]
<span class="item-status checkedout">Checked out to [% item.firstname | html %] [% item.surname | html %] [% IF ( item.cardnumber ) %]([% item.cardnumber | html %])[% END %]</span>
<span class="item-status checkedout">Checked out to [% checkout_patron.firstname | html %] [% checkout_patron.surname | html %] [% IF ( checkout_patron.cardnumber ) %]([% checkout_patron.cardnumber | html %])[% END %]</span>
[% ELSE %]
<span class="item-status checkedout">Checked out</span>
[% END %]
[% END %]
[% IF show_recall_link %]
[% IF datedue && logged_in_user.borrowernumber != issue.borrowernumber %]
[% IF logged_in_user.borrowernumber != issue.borrowernumber %]
<a href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% item.biblionumber | uri %]" class="btn btn-default btn-xs">Recall</a>
[% END %]
[% END %]