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

(-)a/C4/Reports/Guided.pm (-5 / +26 lines)
Lines 17-24 package C4::Reports::Guided; Link Here
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
use strict;
20
use Modern::Perl;
21
#use warnings; FIXME - Bug 2505 this module needs a lot of repair to run clean under warnings
22
use CGI;
21
use CGI;
23
use Carp;
22
use Carp;
24
23
Lines 49-54 BEGIN { Link Here
49
      GetParametersFromSQL
48
      GetParametersFromSQL
50
      IsAuthorisedValueValid
49
      IsAuthorisedValueValid
51
      ValidateSQLParameters
50
      ValidateSQLParameters
51
      nb_rows update_sql
52
    );
52
    );
53
}
53
}
54
54
Lines 78-83 my @REPORT_AREA = ( Link Here
78
    [PAT  => "Patrons"],
78
    [PAT  => "Patrons"],
79
    [ACQ  => "Acquisition"],
79
    [ACQ  => "Acquisition"],
80
    [ACC  => "Accounts"],
80
    [ACC  => "Accounts"],
81
    [SER  => "Serials"],
81
);
82
);
82
my $AREA_NAME_SQL_SNIPPET
83
my $AREA_NAME_SQL_SNIPPET
83
  = "CASE report_area " .
84
  = "CASE report_area " .
Lines 93-98 my %table_areas = ( Link Here
93
    PAT  => ['borrowers'],
94
    PAT  => ['borrowers'],
94
    ACQ  => [ 'aqorders', 'biblio', 'items' ],
95
    ACQ  => [ 'aqorders', 'biblio', 'items' ],
95
    ACC  => [ 'borrowers', 'accountlines' ],
96
    ACC  => [ 'borrowers', 'accountlines' ],
97
    SER  => [ 'serial', 'serialitems', 'subscription', 'subscriptionhistory', 'subscriptionroutinglist', 'biblioitems', 'biblio', 'aqbooksellers' ],
96
);
98
);
97
my %keys = (
99
my %keys = (
98
    CIRC => [ 'statistics.borrowernumber=borrowers.borrowernumber',
100
    CIRC => [ 'statistics.borrowernumber=borrowers.borrowernumber',
Lines 104-109 my %keys = ( Link Here
104
    ACQ  => [ 'aqorders.biblionumber=biblio.biblionumber',
106
    ACQ  => [ 'aqorders.biblionumber=biblio.biblionumber',
105
              'biblio.biblionumber=items.biblionumber' ],
107
              'biblio.biblionumber=items.biblionumber' ],
106
    ACC  => ['borrowers.borrowernumber=accountlines.borrowernumber'],
108
    ACC  => ['borrowers.borrowernumber=accountlines.borrowernumber'],
109
    SER  => [ 'serial.serialid=serialitems.serialid', 'serial.subscriptionid=subscription.subscriptionid', 'serial.subscriptionid=subscriptionhistory.subscriptionid', 'serial.subscriptionid=subscriptionroutinglist.subscriptionid', 'biblioitems.biblionumber=serial.biblionumber', 'biblio.biblionumber=biblioitems.biblionumber', 'subscription.aqbooksellerid=aqbooksellers.id'],
107
);
110
);
108
111
109
# have to do someting here to know if its dropdown, free text, date etc
112
# have to do someting here to know if its dropdown, free text, date etc
Lines 120-125 my %criteria = ( Link Here
120
    PAT  => [ 'borrowers.branchcode', 'borrowers.categorycode' ],
123
    PAT  => [ 'borrowers.branchcode', 'borrowers.categorycode' ],
121
    ACQ  => ['aqorders.datereceived|date'],
124
    ACQ  => ['aqorders.datereceived|date'],
122
    ACC  => [ 'borrowers.branchcode', 'borrowers.categorycode' ],
125
    ACC  => [ 'borrowers.branchcode', 'borrowers.categorycode' ],
126
    SER  => ['subscription.startdate|date', 'subscription.enddate|date', 'subscription.periodicity', 'subscription.callnumber', 'subscription.location', 'subscription.branchcode'],
123
);
127
);
124
128
125
# Adds itemtypes to criteria, according to the syspref
129
# Adds itemtypes to criteria, according to the syspref
Lines 371-380 sub get_criteria { Link Here
371
            $list='itemtype' if $column eq 'itype';
375
            $list='itemtype' if $column eq 'itype';
372
            $list='ccode' if $column eq 'ccode';
376
            $list='ccode' if $column eq 'ccode';
373
            # TODO : improve to let the librarian choose the description at runtime
377
            # TODO : improve to let the librarian choose the description at runtime
374
            push @values, { availablevalues => "<<$column".($list?"|$list":'').">>" };
378
            push @values, {
379
                availablevalues => "<<$column" . ( $list ? "|$list" : '' ) . ">>",
380
                display_value   => "<<$column" . ( $list ? "|$list" : '' ) . ">>",
381
            };
375
            while ( my $row = $sth->fetchrow_hashref() ) {
382
            while ( my $row = $sth->fetchrow_hashref() ) {
383
                if ($row->{'availablevalues'} eq '') { $row->{'default'} = 1 }
384
                else { $row->{display_value} = _get_display_value( $row->{'availablevalues'}, $column ); }
376
                push @values, $row;
385
                push @values, $row;
377
                if ($row->{'availablevalues'} eq '') { $row->{'default'} = 1 };
378
            }
386
            }
379
            $sth->finish();
387
            $sth->finish();
380
388
Lines 385-391 sub get_criteria { Link Here
385
393
386
            push @criteria_array, \%temp;
394
            push @criteria_array, \%temp;
387
        }
395
        }
388
389
    }
396
    }
390
    return ( \@criteria_array );
397
    return ( \@criteria_array );
391
}
398
}
Lines 1017-1022 sub ValidateSQLParameters { Link Here
1017
    return \@problematic_parameters;
1024
    return \@problematic_parameters;
1018
}
1025
}
1019
1026
1027
sub _get_display_value {
1028
    my ( $original_value, $column ) = @_;
1029
    for ( $column ) {
1030
        when ("periodicity") {
1031
            my $dbh = C4::Context->dbh();
1032
            my $query = "SELECT description FROM subscription_frequencies WHERE id = ?";
1033
            my $sth   = $dbh->prepare($query);
1034
            $sth->execute($original_value);
1035
            return $sth->fetchrow;
1036
        }
1037
    }
1038
    return $original_value;
1039
}
1040
1020
1;
1041
1;
1021
__END__
1042
__END__
1022
1043
(-)a/koha-tmpl/intranet-tmpl/prog/en/columns.def (+6 lines)
Lines 139-141 Link Here
139
<field name="biblioitems.marcxml">MARC blob</field>
139
<field name="biblioitems.marcxml">MARC blob</field>
140
<field name="biblioitems.url">URL</field>
140
<field name="biblioitems.url">URL</field>
141
<field name="biblioitems.title">Title</field>
141
<field name="biblioitems.title">Title</field>
142
<field name="subscription.startdate">Start date</field>
143
<field name="subscription.enddate">End date</field>
144
<field name="subscription.periodicity">Periodicity</field>
145
<field name="subscription.callnumber">Call number</field>
146
<field name="subscription.location">Location</field>
147
<field name="subscription.branchcode">Library</field>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-2 / +1 lines)
Lines 551-557 canned reports and writing custom SQL reports.</p> Link Here
551
            <td>
551
            <td>
552
                <select name="[% criteri.name %]_value">
552
                <select name="[% criteri.name %]_value">
553
                [% FOREACH value IN criteri.values %]
553
                [% FOREACH value IN criteri.values %]
554
                <option value="[% value.availablevalues %]">[% IF ( value.default ) %]Default[% ELSE %][% value.availablevalues |html %][% END %]</option>
554
                <option value="[% value.availablevalues %]">[% IF ( value.default ) %]Default[% ELSE %][% value.display_value |html %][% END %]</option>
555
                [% END %]
555
                [% END %]
556
                </select>
556
                </select>
557
            </td>
557
            </td>
558
- 

Return to bug 5338