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 (-5 / +21 lines)
Lines 104-110 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
		
109
		if ($tag == 952 && $subfieldtag eq 'c') {
110
			my $break = 1;
111
		}
112
		
108
  
113
  
109
  my $frameworkcode = &GetFrameworkCode($biblionumber);
114
  my $frameworkcode = &GetFrameworkCode($biblionumber);
110
        my %subfield_data;
115
        my %subfield_data;
Lines 205-211 sub generate_subfield_form { Link Here
205
            }
210
            }
206
            else {
211
            else {
207
                  push @authorised_values, qq{} unless ( $subfieldlib->{mandatory} );
212
                  push @authorised_values, qq{} unless ( $subfieldlib->{mandatory} );
208
                  my $av = GetAuthorisedValues( $subfieldlib->{authorised_value} );
213
				  my $av;
214
				  #Bug 11676 #Limit the available shelving locations based on the item's homebranch instead of the user's logged in branch
215
				  if ($subfieldlib->{authorised_value} eq 'LOC' && $itemrecord) {
216
					#Get the homebranch of the item
217
					my ( $homebranch_field, $homebranch_subfield ) = C4::Biblio::GetMarcFromKohaField( "items.homebranch", $frameworkcode );
218
					my $homebranch = $itemrecord->subfield(  $homebranch_field, $homebranch_subfield  );
219
					#Get the shelving locations limited by the item's homebranch
220
					$av = GetAuthorisedValues( $subfieldlib->{authorised_value}, undef, undef, $homebranch );
221
				  }
222
				  else {
223
					$av = GetAuthorisedValues( $subfieldlib->{authorised_value} );
224
				  }
225
				  
209
                  for my $r ( @$av ) {
226
                  for my $r ( @$av ) {
210
                      push @authorised_values, $r->{authorised_value};
227
                      push @authorised_values, $r->{authorised_value};
211
                      $authorised_lib{$r->{authorised_value}} = $r->{lib};
228
                      $authorised_lib{$r->{authorised_value}} = $r->{lib};
Lines 778-784 if($itemrecord){ Link Here
778
            next if subfield_is_koha_internal_p($subfieldtag);
795
            next if subfield_is_koha_internal_p($subfieldtag);
779
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
796
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
780
797
781
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i);        
798
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $itemrecord);
782
799
783
            push @fields, "$tag$subfieldtag";
800
            push @fields, "$tag$subfieldtag";
784
            push (@loop_data, $subfield_data);
801
            push (@loop_data, $subfield_data);
Lines 803-809 foreach my $tag ( keys %{$tagslib}){ Link Here
803
        my @values = (undef);
820
        my @values = (undef);
804
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)) && defined($itemrecord->field($tag)->subfield($subtag)));
821
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)) && defined($itemrecord->field($tag)->subfield($subtag)));
805
        for my $value (@values){
822
        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); 
823
            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);
824
            push (@loop_data, $subfield_data);
808
            $i++;
825
            $i++;
809
        } 
826
        } 
810
- 

Return to bug 11676