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

(-)a/C4/Members/Statistics.pm (-6 / +26 lines)
Lines 43-55 BEGIN { Link Here
43
43
44
our $fields = get_fields();
44
our $fields = get_fields();
45
45
46
47
=head2 get_fields
48
  Get fields form syspref 'StatisticsFields'
49
  Returns list of valid fields, defaults to 'location|itype|ccode'
50
  if syspref is empty or does not contain valid fields
51
=cut
52
53
46
sub get_fields {
54
sub get_fields {
47
    my $r = C4::Context->preference('StatisticsFields') || 'location|itype|ccode';
55
48
    unless ( $r =~ m/^(\w|\d|\||-)+$/) {
56
    my $syspref = C4::Context->preference('StatisticsFields');
49
        warn "Members/Statistics : Bad value for syspref StatisticsFields" if $debug;
57
    my $ret;
50
        $r = 'location|itype|ccode';
58
59
    if ( $syspref ) {
60
        my @ret;
61
        my @spfields = split ('\|', $syspref);
62
        my $dbh=C4::Context->dbh;
63
        my $sth = $dbh->prepare('SHOW COLUMNS FROM items');
64
        $sth->execute;
65
        my $dbfields =  $sth->fetchall_hashref('Field');
66
        $sth->finish();
67
68
        foreach my $fn ( @spfields ) {
69
            push ( @ret, $fn ) if ( $dbfields->{ $fn } );
70
        }
71
        $ret = join( '|', @ret);
51
    }
72
    }
52
    return $r;
73
    return $ret || 'location|itype|ccode';
53
}
74
}
54
75
55
=head2 construct_query
76
=head2 construct_query
56
- 

Return to bug 12721