From 38427cc357de46d60114ca308329c89f3220a9dd Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 27 Jul 2021 21:17:48 +0000 Subject: [PATCH] Bug 28762: add staff item-status.inc and better handle statues on course-details.tt This patch adds an item-status.inc to the staff side much like what is already in place on the OPAC. To test: 1. create a course in course reserves, add an item to it. 2. confirm your item shows Available for its status on course-details.pl 3. edit your item to be withdrawn, lost, damaged, notforloan, and restricted use 4. reload course-details.pl, confirm it still shows available 5. apply patch 6. repeat step 3 with each of the statuses and make sure it correctly shows on course-details.pl Signed-off-by: Hayley Pelham Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize --- .../prog/css/src/staff-global.scss | 6 +- .../prog/en/includes/item-status.inc | 107 ++++++++++++++++++ .../modules/course_reserves/course-details.tt | 8 +- 3 files changed, 113 insertions(+), 8 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/item-status.inc diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 43115f8ce8..5c6ffac4f7 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -2282,7 +2282,11 @@ td { .lost, .dmg, -.wdn { +.wdn, +.restricted, +.damaged, +.lost, +.withdrawn { color: #990000; display: block; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/item-status.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/item-status.inc new file mode 100644 index 0000000000..7da27283f6 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/item-status.inc @@ -0,0 +1,107 @@ +[% USE Branches %] +[% USE AuthorisedValues %] +[% SET itemavailable = 1 %] + +[%#- This include takes two parameters: an item structure -%] +[%#- and an optional loan (issue) structure. The issue -%] +[%#- structure is used by course reserves pages, which do -%] +[%#- not use an API to fetch items that populates item.datedue. -%] + +[% IF ( item.itemlost ) %] + [% SET itemavailable = 0 %] + [% av_lib_include = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost ) %] + [% IF ( av_lib_include ) %] + [% av_lib_include | html %] + [% ELSE %] + Item lost + [% END %] +[% END %] + +[% IF item.isa('Koha::Item') %] + [% SET datedue = issue.date_due %] + [% SET onsite_checkout = issue.onsite_checkout %] +[% ELSE %] + [% SET datedue = item.datedue || issue.date_due %] + [% SET onsite_checkout = item.onsite_checkout %] +[% END %] +[% IF datedue %] + [% SET itemavailable = 0 %] + [% IF onsite_checkout %] + [% IF ( OPACShowCheckoutName ) %] + Currently in local use by [% item.firstname | html %] [% item.surname | html %] [% IF ( item.cardnumber ) %]([% item.cardnumber | html %])[% END %] + [% ELSE %] + Currently in local use + [% END %] + [% ELSE %] + [% IF ( OPACShowCheckoutName ) %] + Checked out to [% item.firstname | html %] [% item.surname | html %] [% IF ( item.cardnumber ) %]([% item.cardnumber | html %])[% END %] + [% ELSE %] + Checked out + [% END %] + [% END %] +[% END %] + +[% IF NOT ( item.isa('Koha::Item') ) AND item.transfertwhen %] [%# transfertwhen is set in C4::Search, do not have it for course reserves %] + [% SET itemavailable = 0 %] + In transit from [% Branches.GetName( item.transfertfrom ) | html %] + to [% Branches.GetName( item.transfertto ) | html %] since [% item.transfertwhen | $KohaDates %] +[% END %] + +[% IF NOT( item.isa('Koha::Item') ) AND item.waiting %] [%# Not sure where does come from this waiting flag %] + [% SET itemavailable = 0 %] + On hold +[% END %] + +[% IF ( item.withdrawn ) %] + [% SET itemavailable = 0 %] + [% av_lib_include = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn ) %] + [% IF av_lib_include %] + [% av_lib_include | html %] + [% ELSE %] + Item withdrawn + [% END %] +[% END %] + + +[% IF NOT ( item.isa('Koha::Item') ) AND item.itemnotforloan %] + [% SET itemavailable = 0 %] + [% IF ( item.notforloanvalueopac ) %] + [% item.notforloanvalueopac | html %] + [% ELSE %] + Not for loan + [% END %] +[% ELSIF NOT ( item.isa('Koha::Item') ) AND item.notforloan_per_itemtype %] + [% SET itemavailable = 0 %] + Not for loan +[% END %] + +[% IF ( item.damaged ) %] + [% SET itemavailable = 0 %] + [% av_lib_include = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.damaged', authorised_value => item.damaged ) %] + [% IF av_lib_include %] + [% av_lib_include | html %] + [% ELSE %] + Item damaged + [% END %] +[% END %] + +[% IF ( item.restricted ) %] + [% SET itemavailable = 0 %] + [% av_lib_include = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.restricted', authorised_value => item.restricted ) %] + [% IF av_lib_include %] + [% av_lib_include | html %] + [% ELSE %] + On order + [% END %] +[% END %] + +[% IF item.has_pending_hold %] + [% SET itemavailable = 0 %] + Pending hold +[% END %] + +[% IF ( itemavailable ) %] + [% IF NOT item.isa('Koha::Item') %] + Available + [% END %] +[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt index dfcb472ba6..acda85b512 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt @@ -292,13 +292,7 @@ - - [% IF cr.item.onloan %] - Checked out - [% ELSE %] - Available - [% END %] - + [% INCLUDE 'item-status.inc' item=cr.item issue=cr.issue %] [% IF CAN_user_coursereserves_add_reserves || CAN_user_coursereserves_delete_reserves %] -- 2.39.5