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

(-)a/C4/Reports/Guided.pm (-67 / +1 lines)
Lines 44-50 BEGIN { Link Here
44
      save_report get_saved_reports execute_query get_saved_report create_compound run_compound
44
      save_report get_saved_reports execute_query get_saved_report create_compound run_compound
45
      get_column_type get_distinct_values save_dictionary get_from_dictionary
45
      get_column_type get_distinct_values save_dictionary get_from_dictionary
46
      delete_definition delete_report format_results get_sql
46
      delete_definition delete_report format_results get_sql
47
      nb_rows update_sql build_authorised_value_list
47
      nb_rows update_sql
48
      GetReservedAuthorisedValues
48
      GetReservedAuthorisedValues
49
      GetParametersFromSQL
49
      GetParametersFromSQL
50
      IsAuthorisedValueValid
50
      IsAuthorisedValueValid
Lines 896-966 sub _get_column_defs { Link Here
896
    return \%columns;
896
    return \%columns;
897
}
897
}
898
898
899
=head2 build_authorised_value_list($authorised_value)
900
901
Returns an arrayref - hashref pair. The hashref consists of
902
various code => name lists depending on the $authorised_value.
903
The arrayref is the hashref keys, in appropriate order
904
905
=cut
906
907
sub build_authorised_value_list {
908
    my ( $authorised_value ) = @_;
909
910
    my $dbh = C4::Context->dbh;
911
    my @authorised_values;
912
    my %authorised_lib;
913
914
    # builds list, depending on authorised value...
915
    if ( $authorised_value eq "branches" ) {
916
        my $branches = GetBranchesLoop();
917
        foreach my $thisbranch (@$branches) {
918
            push @authorised_values, $thisbranch->{value};
919
            $authorised_lib{ $thisbranch->{value} } = $thisbranch->{branchname};
920
        }
921
    } elsif ( $authorised_value eq "itemtypes" ) {
922
        my $sth = $dbh->prepare("SELECT itemtype,description FROM itemtypes ORDER BY description");
923
        $sth->execute;
924
        while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
925
            push @authorised_values, $itemtype;
926
            $authorised_lib{$itemtype} = $description;
927
        }
928
    } elsif ( $authorised_value eq "cn_source" ) {
929
        my $class_sources  = GetClassSources();
930
        my $default_source = C4::Context->preference("DefaultClassificationSource");
931
        foreach my $class_source ( sort keys %$class_sources ) {
932
            next
933
              unless $class_sources->{$class_source}->{'used'}
934
                  or ( $class_source eq $default_source );
935
            push @authorised_values, $class_source;
936
            $authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'};
937
        }
938
    } elsif ( $authorised_value eq "categorycode" ) {
939
        my $sth = $dbh->prepare("SELECT categorycode, description FROM categories ORDER BY description");
940
        $sth->execute;
941
        while ( my ( $categorycode, $description ) = $sth->fetchrow_array ) {
942
            push @authorised_values, $categorycode;
943
            $authorised_lib{$categorycode} = $description;
944
        }
945
946
        #---- "true" authorised value
947
    } else {
948
        my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib");
949
950
        $authorised_values_sth->execute($authorised_value);
951
952
        while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
953
            push @authorised_values, $value;
954
            $authorised_lib{$value} = $lib;
955
956
            # For item location, we show the code and the libelle
957
            $authorised_lib{$value} = $lib;
958
        }
959
    }
960
961
    return (\@authorised_values, \%authorised_lib);
962
}
963
964
=head2 GetReservedAuthorisedValues
899
=head2 GetReservedAuthorisedValues
965
900
966
    my %reserved_authorised_values = GetReservedAuthorisedValues();
901
    my %reserved_authorised_values = GetReservedAuthorisedValues();
967
- 

Return to bug 15731