Bug 20341: Use AuthorisedValues plugin on the staff side
authorKyle M Hall <kyle@bywatetsolutions.com>
Fri, 9 Mar 2018 11:43:18 +0000 (06:43 -0500)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 19 Mar 2018 15:23:15 +0000 (12:23 -0300)
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
catalogue/detail.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt

index 704c595..b29d858 100755 (executable)
@@ -203,20 +203,7 @@ my $copynumbers =
 my (@itemloop, @otheritemloop, %itemfields);
 my $norequests = 1;
 
-my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => { not => undef } });
-if ( $mss->count ) {
-    $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
-}
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => { not => undef } });
-if ( $mss->count ) {
-    $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
-}
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn', authorised_value => { not => undef } });
-if ( $mss->count ) {
-    $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorised_value) );
-}
-
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => { not => undef } });
+my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => { not => undef } });
 my %materials_map;
 if ($mss->count) {
     my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value);
index d3b12b4..635781b 100644 (file)
                             <span class="intransit">In transit from [% Branches.GetName( item.transfertfrom ) %] to [% Branches.GetName( item.transfertto ) %] since [% item.transfertwhen | $KohaDates %]</span>
                         [% END %]
 
+                        [% itemlost_desc = AuthorisedValues.GetByCode( 'LOST', item.itemlost ) %]
                         [% IF ( item.itemlost ) %]
-                            [% IF itemlostloop %]
-                                [% FOREACH itemlostloo IN itemlostloop %]
-                                    [% IF itemlostloo.authorised_value == item.itemlost %]
-                                        <span class="lost">[% itemlostloo.lib %]</span>
-                                    [% END %]
-                                [% END %]
+                            [% IF itemlost_desc %]
+                                <span class="lost">[% itemlost_desc %]</span>
                             [% ELSE %]
                                 <span class="lost">Unavailable (lost or missing)</span>
                             [% END %]
                         [% END %]
 
+                        [% withdrawn_desc = AuthorisedValues.GetByCode( 'WITHDRAWN', item.withdrawn ) %]
                         [% IF ( item.withdrawn ) %]
-                            [% IF itemwithdrawnloop %]
-                                [% FOREACH itemwithdrawnloo IN itemwithdrawnloop %]
-                                    [% IF itemwithdrawnloo.authorised_value == item.withdrawn %]
-                                        <span class="wdn">[% itemwithdrawnloo.lib %]</span>
-                                    [% END %]
-                                [% END %]
+                            [% IF withdrawn_desc %]
+                                <span class="wdn">[% withdrawn_desc %]</span>
                             [% ELSE %]
                                 <span class="wdn">Withdrawn</span>
                             [% END %]
                         [% END %]
 
+                        [% damaged_desc = AuthorisedValues.GetByCode( 'DAMAGED', item.damaged ) %]
                         [% IF ( item.damaged ) %]
-                            [% IF itemdamagedloop %]
-                                [% FOREACH itemdamagedloo IN itemdamagedloop %]
-                                    [% IF itemdamagedloo.authorised_value == item.damaged %]
-                                        <span class="dmg">[% itemdamagedloo.lib %]</span>
-                                    [% END %]
-                                [% END %]
+                            [% IF damaged_desc %]
+                                <span class="dmg">[% damaged_desc %]</span>
                             [% ELSE %]
                                 <span class="dmg">Damaged</span>
                             [% END %]