| Lines 25-30
          use base qw( Template::Plugin );
      
      
        Link Here | 
        
          | 25 |  | 25 |  | 
        
          | 26 | use C4::Koha; | 26 | use C4::Koha; | 
        
          | 27 | use C4::Context; | 27 | use C4::Context; | 
            
              |  |  | 28 | use Koha::Caches; | 
        
          | 28 | use Koha::Libraries; | 29 | use Koha::Libraries; | 
        
          | 29 |  | 30 |  | 
        
          | 30 | sub GetName { | 31 | sub GetName { | 
  
    | Lines 105-110
          sub pickup_locations {
      
      
        Link Here | 
        
          | 105 |     my $selected      = $params->{selected}; | 106 |     my $selected      = $params->{selected}; | 
        
          | 106 |     my @libraries; | 107 |     my @libraries; | 
        
          | 107 |  | 108 |  | 
            
              |  |  | 109 |     my $cache  = Koha::Caches->get_instance(); | 
            
              | 110 |     my $cache_key; | 
            
              | 111 |  | 
        
          | 108 |     if(defined $search_params->{item} || defined $search_params->{biblio}) { | 112 |     if(defined $search_params->{item} || defined $search_params->{biblio}) { | 
        
          | 109 |         my $item = $search_params->{'item'}; | 113 |         my $item = $search_params->{'item'}; | 
        
          | 110 |         my $biblio = $search_params->{'biblio'}; | 114 |         my $biblio = $search_params->{'biblio'}; | 
  
    | Lines 117-138
          sub pickup_locations {
      
      
        Link Here | 
        
          | 117 |         if ($item) { | 121 |         if ($item) { | 
        
          | 118 |             $item = Koha::Items->find($item) | 122 |             $item = Koha::Items->find($item) | 
        
          | 119 |               unless ref($item) eq 'Koha::Item'; | 123 |               unless ref($item) eq 'Koha::Item'; | 
          
            
              | 120 |             @libraries = @{ $item->pickup_locations( { patron => $patron } ) } | 124 |  | 
            
              | 121 |               if defined $item; | 125 |             if ( defined $item ) { | 
            
              |  |  | 126 |                 $cache_key = "I" . $item->homebranch . "-" . $patron->branchcode; | 
            
              | 127 |                 my $result = $cache->get_from_cache($cache_key); | 
            
              | 128 |                 if ( $result ) { | 
            
              | 129 |                     @libraries = @{$result}; | 
            
              | 130 |                 } else { | 
            
              | 131 |                     @libraries = @{ $item->pickup_locations( { patron => $patron } ) }; | 
            
              | 132 |                     @libraries = map { $_->unblessed } @libraries; | 
            
              | 133 |                 } | 
            
              | 134 |             } | 
        
          | 122 |         } | 135 |         } | 
        
          | 123 |         elsif ($biblio) { | 136 |         elsif ($biblio) { | 
        
          | 124 |             $biblio = Koha::Biblios->find($biblio) | 137 |             $biblio = Koha::Biblios->find($biblio) | 
        
          | 125 |               unless ref($biblio) eq 'Koha::Biblio'; | 138 |               unless ref($biblio) eq 'Koha::Biblio'; | 
          
            
              | 126 |             @libraries = @{ $biblio->pickup_locations( { patron => $patron } ) } | 139 |  | 
            
              | 127 |               if defined $biblio; | 140 |             if ( defined $biblio ) { | 
            
              |  |  | 141 |                 $cache_key = "B" . $biblio->id . "-" . $patron->branchcode; | 
            
              | 142 |                 my $result = $cache->get_from_cache($cache_key); | 
            
              | 143 |                 if ( $result ) { | 
            
              | 144 |                     @libraries = @{$result}; | 
            
              | 145 |                 } else { | 
            
              | 146 |                     @libraries = @{ $biblio->pickup_locations( { patron => $patron } ) }; | 
            
              | 147 |                     @libraries = map { $_->unblessed } @libraries; | 
            
              | 148 |                 } | 
            
              | 149 |             } | 
        
          | 128 |         } | 150 |         } | 
        
          | 129 |     } | 151 |     } | 
        
          | 130 |  | 152 |  | 
          
            
              | 131 |     @libraries = Koha::Libraries->search( { pickup_location => 1 }, | 153 |     unless ( @libraries ) { | 
            
              | 132 |         { order_by => ['branchname'] } )->as_list | 154 |         @libraries = Koha::Libraries->search( { pickup_location => 1 }, | 
            
              | 133 |       unless @libraries; | 155 |         { order_by => ['branchname'] } )->as_list; | 
        
          | 134 |  | 156 |  | 
          
            
              | 135 |     @libraries = map { $_->unblessed } @libraries; | 157 |         @libraries = map { $_->unblessed } @libraries; | 
            
              |  |  | 158 |     } | 
        
          | 136 |  | 159 |  | 
        
          | 137 |     for my $l (@libraries) { | 160 |     for my $l (@libraries) { | 
        
          | 138 |         if ( defined $selected and $l->{branchcode} eq $selected | 161 |         if ( defined $selected and $l->{branchcode} eq $selected | 
  
    | Lines 144-149
          sub pickup_locations {
      
      
        Link Here | 
        
          | 144 |         } | 167 |         } | 
        
          | 145 |     } | 168 |     } | 
        
          | 146 |  | 169 |  | 
            
              |  |  | 170 |     $cache->set_in_cache( $cache_key, \@libraries ); | 
        
          | 147 |     return \@libraries; | 171 |     return \@libraries; | 
        
          | 148 | } | 172 | } | 
        
          | 149 |  | 173 |  | 
            
              | 150 | -  |  |  |