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

(-)a/C4/Reports/Guided.pm (-6 / +25 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 79-84 sub get_area_name_sql_snippet { Link Here
79
        [PAT  => "Patrons"],
79
        [PAT  => "Patrons"],
80
        [ACQ  => "Acquisition"],
80
        [ACQ  => "Acquisition"],
81
        [ACC  => "Accounts"],
81
        [ACC  => "Accounts"],
82
        [SER  => "Serials"],
82
    );
83
    );
83
84
84
    return "CASE report_area " .
85
    return "CASE report_area " .
Lines 88-94 sub get_area_name_sql_snippet { Link Here
88
89
89
sub get_report_areas {
90
sub get_report_areas {
90
91
91
    my $report_areas = [ 'CIRC', 'CAT', 'PAT', 'ACQ', 'ACC' ];
92
    my $report_areas = [ 'CIRC', 'CAT', 'PAT', 'ACQ', 'ACC', 'SER' ];
92
93
93
    return $report_areas;
94
    return $report_areas;
94
}
95
}
Lines 100-105 sub get_table_areas { Link Here
100
    PAT  => ['borrowers'],
101
    PAT  => ['borrowers'],
101
    ACQ  => [ 'aqorders', 'biblio', 'items' ],
102
    ACQ  => [ 'aqorders', 'biblio', 'items' ],
102
    ACC  => [ 'borrowers', 'accountlines' ],
103
    ACC  => [ 'borrowers', 'accountlines' ],
104
    SER  => [ 'serial', 'serialitems', 'subscription', 'subscriptionhistory', 'subscriptionroutinglist', 'biblioitems', 'biblio', 'aqbooksellers' ],
103
    );
105
    );
104
}
106
}
105
107
Lines 240-245 sub build_query { Link Here
240
        ACQ  => [ 'aqorders.biblionumber=biblio.biblionumber',
242
        ACQ  => [ 'aqorders.biblionumber=biblio.biblionumber',
241
                  'biblio.biblionumber=items.biblionumber' ],
243
                  'biblio.biblionumber=items.biblionumber' ],
242
        ACC  => ['borrowers.borrowernumber=accountlines.borrowernumber'],
244
        ACC  => ['borrowers.borrowernumber=accountlines.borrowernumber'],
245
        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'],
243
    );
246
    );
244
247
245
248
Lines 330-335 sub get_criteria { Link Here
330
        PAT  => [ 'borrowers.branchcode', 'borrowers.categorycode' ],
333
        PAT  => [ 'borrowers.branchcode', 'borrowers.categorycode' ],
331
        ACQ  => ['aqorders.datereceived|date'],
334
        ACQ  => ['aqorders.datereceived|date'],
332
        ACC  => [ 'borrowers.branchcode', 'borrowers.categorycode' ],
335
        ACC  => [ 'borrowers.branchcode', 'borrowers.categorycode' ],
336
        SER  => ['subscription.startdate|date', 'subscription.enddate|date', 'subscription.periodicity', 'subscription.callnumber', 'subscription.location', 'subscription.branchcode'],
333
    );
337
    );
334
338
335
    # Adds itemtypes to criteria, according to the syspref
339
    # Adds itemtypes to criteria, according to the syspref
Lines 386-395 sub get_criteria { Link Here
386
            $list='itemtype' if $column eq 'itype';
390
            $list='itemtype' if $column eq 'itype';
387
            $list='ccode' if $column eq 'ccode';
391
            $list='ccode' if $column eq 'ccode';
388
            # TODO : improve to let the librarian choose the description at runtime
392
            # TODO : improve to let the librarian choose the description at runtime
389
            push @values, { availablevalues => "<<$column".($list?"|$list":'').">>" };
393
            push @values, {
394
                availablevalues => "<<$column" . ( $list ? "|$list" : '' ) . ">>",
395
                display_value   => "<<$column" . ( $list ? "|$list" : '' ) . ">>",
396
            };
390
            while ( my $row = $sth->fetchrow_hashref() ) {
397
            while ( my $row = $sth->fetchrow_hashref() ) {
398
                if ($row->{'availablevalues'} eq '') { $row->{'default'} = 1 }
399
                else { $row->{display_value} = _get_display_value( $row->{'availablevalues'}, $column ); }
391
                push @values, $row;
400
                push @values, $row;
392
                if ($row->{'availablevalues'} eq '') { $row->{'default'} = 1 };
393
            }
401
            }
394
            $sth->finish();
402
            $sth->finish();
395
403
Lines 400-406 sub get_criteria { Link Here
400
408
401
            push @criteria_array, \%temp;
409
            push @criteria_array, \%temp;
402
        }
410
        }
403
404
    }
411
    }
405
    return ( \@criteria_array );
412
    return ( \@criteria_array );
406
}
413
}
Lines 1038-1043 sub ValidateSQLParameters { Link Here
1038
    return \@problematic_parameters;
1045
    return \@problematic_parameters;
1039
}
1046
}
1040
1047
1048
sub _get_display_value {
1049
    my ( $original_value, $column ) = @_;
1050
    if ( $column eq 'periodicity' ) {
1051
        my $dbh = C4::Context->dbh();
1052
        my $query = "SELECT description FROM subscription_frequencies WHERE id = ?";
1053
        my $sth   = $dbh->prepare($query);
1054
        $sth->execute($original_value);
1055
        return $sth->fetchrow;
1056
    }
1057
    return $original_value;
1058
}
1059
1041
1;
1060
1;
1042
__END__
1061
__END__
1043
1062
(-)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 / +2 lines)
Lines 7-12 Link Here
7
        [%- CASE 'PAT'  -%]Patrons
7
        [%- CASE 'PAT'  -%]Patrons
8
        [%- CASE 'ACQ'  -%]Acquisitions
8
        [%- CASE 'ACQ'  -%]Acquisitions
9
        [%- CASE 'ACC'  -%]Accounts
9
        [%- CASE 'ACC'  -%]Accounts
10
        [%- CASE 'SER'  -%]Serials
10
    [%- END -%]
11
    [%- END -%]
11
[%- END -%]
12
[%- END -%]
12
13
Lines 573-579 canned reports and writing custom SQL reports.</p> Link Here
573
            <td>
574
            <td>
574
                <select name="[% criteri.name %]_value">
575
                <select name="[% criteri.name %]_value">
575
                [% FOREACH value IN criteri.values %]
576
                [% FOREACH value IN criteri.values %]
576
                <option value="[% value.availablevalues %]">[% IF ( value.default ) %]Default[% ELSE %][% value.availablevalues |html %][% END %]</option>
577
                <option value="[% value.availablevalues %]">[% IF ( value.default ) %]Default[% ELSE %][% value.display_value |html %][% END %]</option>
577
                [% END %]
578
                [% END %]
578
                </select>
579
                </select>
579
            </td>
580
            </td>
580
- 

Return to bug 5338