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

(-)a/C4/Members/Statistics.pm (-8 / +12 lines)
Lines 48-55 our $fields = get_fields(); Link Here
48
  Get fields form syspref 'StatisticsFields'
48
  Get fields form syspref 'StatisticsFields'
49
  Returns list of valid fields, defaults to 'location|itype|ccode'
49
  Returns list of valid fields, defaults to 'location|itype|ccode'
50
  if syspref is empty or does not contain valid fields
50
  if syspref is empty or does not contain valid fields
51
=cut
52
51
52
=cut
53
53
54
sub get_fields {
54
sub get_fields {
55
55
Lines 59-72 sub get_fields { Link Here
59
    if ( $syspref ) {
59
    if ( $syspref ) {
60
        my @ret;
60
        my @ret;
61
        my @spfields = split ('\|', $syspref);
61
        my @spfields = split ('\|', $syspref);
62
        my $dbh=C4::Context->dbh;
62
        my $schema       = Koha::Database->new()->schema();
63
        my $sth = $dbh->prepare('SHOW COLUMNS FROM items');
63
        my @columns = $schema->source('Item')->columns;
64
        $sth->execute;
65
        my $dbfields =  $sth->fetchall_hashref('Field');
66
        $sth->finish();
67
64
68
        foreach my $fn ( @spfields ) {
65
        foreach my $fn ( @spfields ) {
69
            push ( @ret, $fn ) if ( $dbfields->{ $fn } );
66
            push ( @ret, $fn ) if ( grep(/^$fn$/, @columns) );
70
        }
67
        }
71
        $ret = join( '|', @ret);
68
        $ret = join( '|', @ret);
72
    }
69
    }
Lines 76-82 sub get_fields { Link Here
76
=head2 construct_query
73
=head2 construct_query
77
  Build a sql query from a subquery
74
  Build a sql query from a subquery
78
  Adds statistics fields to the select and the group by clause
75
  Adds statistics fields to the select and the group by clause
76
79
=cut
77
=cut
78
80
sub construct_query {
79
sub construct_query {
81
    my $count    = shift;
80
    my $count    = shift;
82
    my $subquery = shift;
81
    my $subquery = shift;
Lines 95-101 sub construct_query { Link Here
95
94
96
=head2 GetTotalIssuesTodayByBorrower
95
=head2 GetTotalIssuesTodayByBorrower
97
  Return total issues for a borrower at this current day
96
  Return total issues for a borrower at this current day
97
98
=cut
98
=cut
99
99
sub GetTotalIssuesTodayByBorrower {
100
sub GetTotalIssuesTodayByBorrower {
100
    my ($borrowernumber) = @_;
101
    my ($borrowernumber) = @_;
101
    my $dbh   = C4::Context->dbh;
102
    my $dbh   = C4::Context->dbh;
Lines 114-120 sub GetTotalIssuesTodayByBorrower { Link Here
114
115
115
=head2 GetTotalIssuesReturnedTodayByBorrower
116
=head2 GetTotalIssuesReturnedTodayByBorrower
116
  Return total issues returned by a borrower at this current day
117
  Return total issues returned by a borrower at this current day
118
117
=cut
119
=cut
120
118
sub GetTotalIssuesReturnedTodayByBorrower {
121
sub GetTotalIssuesReturnedTodayByBorrower {
119
    my ($borrowernumber) = @_;
122
    my ($borrowernumber) = @_;
120
    my $dbh   = C4::Context->dbh;
123
    my $dbh   = C4::Context->dbh;
Lines 128-134 sub GetTotalIssuesReturnedTodayByBorrower { Link Here
128
131
129
=head2 GetPrecedentStateByBorrower
132
=head2 GetPrecedentStateByBorrower
130
  Return the precedent state (before today) for a borrower of his checkins and checkouts
133
  Return the precedent state (before today) for a borrower of his checkins and checkouts
134
131
=cut
135
=cut
136
132
sub GetPrecedentStateByBorrower {
137
sub GetPrecedentStateByBorrower {
133
    my ($borrowernumber) = @_;
138
    my ($borrowernumber) = @_;
134
    my $dbh   = C4::Context->dbh;
139
    my $dbh   = C4::Context->dbh;
135
- 

Return to bug 12721