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

(-)a/C4/Koha.pm (-3 / +8 lines)
Lines 1018-1024 sub GetAuthValCodeFromField { Link Here
1018
1018
1019
=head2 GetAuthorisedValues
1019
=head2 GetAuthorisedValues
1020
1020
1021
  $authvalues = GetAuthorisedValues([$category], [$selected]);
1021
  $authvalues = GetAuthorisedValues([$category], [$selected], [$opac], [$branch_limit]);
1022
1022
1023
This function returns all authorised values from the'authorised_value' table in a reference to array of hashrefs.
1023
This function returns all authorised values from the'authorised_value' table in a reference to array of hashrefs.
1024
1024
Lines 1026-1036 C<$category> returns authorised values for just one category (optional). Link Here
1026
1026
1027
C<$opac> If set to a true value, displays OPAC descriptions rather than normal ones when they exist.
1027
C<$opac> If set to a true value, displays OPAC descriptions rather than normal ones when they exist.
1028
1028
1029
C<$branch_limit> branchcode, returns authorised values for this branchcode and for authorised values for the default branch (optional).
1030
1029
=cut
1031
=cut
1030
1032
1031
sub GetAuthorisedValues {
1033
sub GetAuthorisedValues {
1032
    my ( $category, $selected, $opac ) = @_;
1034
    my ( $category, $selected, $opac, $branch_limit ) = @_;
1033
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1035
    if (! $branch_limit) {
1036
        $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1037
    }  
1038
    
1034
    my @results;
1039
    my @results;
1035
    my $dbh      = C4::Context->dbh;
1040
    my $dbh      = C4::Context->dbh;
1036
    my $query = qq{
1041
    my $query = qq{
(-)a/cataloguing/additem.pl (-12 / +23 lines)
Lines 104-112 sub _increment_barcode { Link Here
104
104
105
105
106
sub generate_subfield_form {
106
sub generate_subfield_form {
107
        my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i) = @_;
107
        my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i, $itemrecord) = @_;
108
  
108
        
109
  my $frameworkcode = &GetFrameworkCode($biblionumber);
109
    my $frameworkcode = &GetFrameworkCode($biblionumber);
110
        my %subfield_data;
110
        my %subfield_data;
111
        my $dbh = C4::Context->dbh;
111
        my $dbh = C4::Context->dbh;
112
        
112
        
Lines 204-215 sub generate_subfield_form { Link Here
204
                  #---- "true" authorised value
204
                  #---- "true" authorised value
205
            }
205
            }
206
            else {
206
            else {
207
                  push @authorised_values, qq{} unless ( $subfieldlib->{mandatory} );
207
                push @authorised_values, qq{} unless ( $subfieldlib->{mandatory} );
208
                  my $av = GetAuthorisedValues( $subfieldlib->{authorised_value} );
208
                my $av;
209
                  for my $r ( @$av ) {
209
                #Bug 11676 #Limit the available shelving locations based on the item's homebranch instead of the user's logged in branch
210
                      push @authorised_values, $r->{authorised_value};
210
                if ($subfieldlib->{authorised_value} eq 'LOC' && $itemrecord) {
211
                      $authorised_lib{$r->{authorised_value}} = $r->{lib};
211
                    #Get the homebranch of the item
212
                  }
212
                    my ( $homebranch_field, $homebranch_subfield ) = C4::Biblio::GetMarcFromKohaField( "items.homebranch", $frameworkcode );
213
                    my $homebranch = $itemrecord->subfield(  $homebranch_field, $homebranch_subfield  );
214
                    #Get the shelving locations limited by the item's homebranch
215
                    $av = GetAuthorisedValues( $subfieldlib->{authorised_value}, undef, undef, $homebranch );
216
                }
217
                else {
218
                    $av = GetAuthorisedValues( $subfieldlib->{authorised_value} );
219
                }
220
                
221
                for my $r ( @$av ) {
222
                    push @authorised_values, $r->{authorised_value};
223
                    $authorised_lib{$r->{authorised_value}} = $r->{lib};
224
                }
213
            }
225
            }
214
226
215
            if ($subfieldlib->{'hidden'}) {
227
            if ($subfieldlib->{'hidden'}) {
Lines 778-784 if($itemrecord){ Link Here
778
            next if subfield_is_koha_internal_p($subfieldtag);
790
            next if subfield_is_koha_internal_p($subfieldtag);
779
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
791
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
780
792
781
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i);        
793
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $itemrecord);
782
794
783
            push @fields, "$tag$subfieldtag";
795
            push @fields, "$tag$subfieldtag";
784
            push (@loop_data, $subfield_data);
796
            push (@loop_data, $subfield_data);
Lines 803-809 foreach my $tag ( keys %{$tagslib}){ Link Here
803
        my @values = (undef);
815
        my @values = (undef);
804
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)) && defined($itemrecord->field($tag)->subfield($subtag)));
816
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)) && defined($itemrecord->field($tag)->subfield($subtag)));
805
        for my $value (@values){
817
        for my $value (@values){
806
            my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); 
818
            my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $itemrecord); 
807
            push (@loop_data, $subfield_data);
819
            push (@loop_data, $subfield_data);
808
            $i++;
820
            $i++;
809
        } 
821
        } 
810
- 

Return to bug 11676