View | Details | Raw Unified | Return to bug 26587
Collapse All | Expand All

(-)a/C4/Items.pm (-12 / +32 lines)
Lines 758-766 sub GetItemsInfo { Link Here
758
    my $i = 0;
758
    my $i = 0;
759
    my @results;
759
    my @results;
760
    my $serial;
760
    my $serial;
761
762
    my $userenv = C4::Context->userenv;
761
    my $userenv = C4::Context->userenv;
763
    my $want_not_same_branch = C4::Context->preference("IndependentBranches") && !C4::Context->IsSuperLibrarian();
762
    my $want_not_same_branch = C4::Context->preference("IndependentBranches") && !C4::Context->IsSuperLibrarian();
763
764
    my $av_cache = {};# Initializing a chache for auth. values looked up in loops below
765
    foreach my $itemcol (qw/notforloan restricted stack/){
766
        $av_cache->{$itemcol} = {};
767
    }
764
    while ( my $data = $sth->fetchrow_hashref ) {
768
    while ( my $data = $sth->fetchrow_hashref ) {
765
        if ( $data->{borrowernumber} && $want_not_same_branch) {
769
        if ( $data->{borrowernumber} && $want_not_same_branch) {
766
            $data->{'NOTSAMEBRANCH'} = $data->{'bcode'} ne $userenv->{branch};
770
            $data->{'NOTSAMEBRANCH'} = $data->{'bcode'} ne $userenv->{branch};
Lines 770-787 sub GetItemsInfo { Link Here
770
774
771
        my $descriptions;
775
        my $descriptions;
772
        # get notforloan complete status if applicable
776
        # get notforloan complete status if applicable
773
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.notforloan', authorised_value => $data->{itemnotforloan} });
777
        if (exists $av_cache->{notforloan}->{$data->{itemnotforloan} // ''} ){
774
        $data->{notforloanvalue}     = $descriptions->{lib} // '';
778
            $data->{notforloanvalue} = $av_cache->{notforloan}->{$data->{itemnotforloan} // ''}->{lib};
775
        $data->{notforloanvalueopac} = $descriptions->{opac_description} // '';
779
            $data->{notforloanvalueopac} = $av_cache->{notforloan}->{$data->{itemnotforloan} // ''}->{opac_description};
776
780
        }else{
781
            $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.notforloan', authorised_value => $data->{itemnotforloan} });
782
            $data->{notforloanvalue}     = $descriptions->{lib} // '';
783
            $data->{notforloanvalueopac} = $descriptions->{opac_description} // '';
784
            $av_cache->{notforloan}->{$data->{itemnotforloan} // ''}->{lib} = $data->{notforloanvalue};
785
            $av_cache->{notforloan}->{$data->{itemnotforloan} // ''}->{opac_description} = $data->{notforloanvalueopac};
786
        }
777
        # get restricted status and description if applicable
787
        # get restricted status and description if applicable
778
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.restricted', authorised_value => $data->{restricted} });
788
        if (exists $av_cache->{restricted}->{$data->{restricted} // ''} ) {
779
        $data->{restrictedvalue}     = $descriptions->{lib} // '';
789
            $data->{restrictedvalue}     = $av_cache->{restricted}->{$data->{restricted} // ''}->{lib};
780
        $data->{restrictedvalueopac} = $descriptions->{opac_description} // '';
790
            $data->{restrictedvalueopac} = $av_cache->{restricted}->{$data->{restricted} // ''}->{opac_description};
781
791
        }else{
792
            $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.restricted', authorised_value => $data->{restricted} });
793
            $data->{restrictedvalue}     = $descriptions->{lib} // '';
794
            $data->{restrictedvalueopac} = $descriptions->{opac_description} // '';
795
            $av_cache->{restricted}->{$data->{restricted} // ''}->{lib} = $data->{restrictedvalue} ;
796
            $av_cache->{restricted}->{$data->{restricted} // ''}->{opac_description} = $data->{restrictedvalueopac};
797
        }
782
        # my stack procedures
798
        # my stack procedures
783
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.stack', authorised_value => $data->{stack} });
799
        if (exists $av_cache->{stack}->{$data->{stack} // ''} ) {
784
        $data->{stack}          = $descriptions->{lib} // '';
800
            $data->{stack} = $av_cache->{stack}->{$data->{stack} // ''}->{lib};
801
        }else{
802
            $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.stack', authorised_value => $data->{stack} });
803
            $data->{stack} = $descriptions->{lib} // '';
804
            $av_cache->{stack}->{$data->{stack}}->{lib} = $data->{stack};
805
        }
785
806
786
        # Find the last 3 people who borrowed this item.
807
        # Find the last 3 people who borrowed this item.
787
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
808
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
788
- 

Return to bug 26587