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

(-)a/C4/Reports/Guided.pm (-37 / +13 lines)
Lines 32-37 use C4::Output; Link Here
32
use C4::Log qw( logaction );
32
use C4::Log qw( logaction );
33
use Koha::Notice::Templates;
33
use Koha::Notice::Templates;
34
34
35
use Koha::Database::Columns;
35
use Koha::Logger;
36
use Koha::Logger;
36
use Koha::AuthorisedValues;
37
use Koha::AuthorisedValues;
37
use Koha::Patron::Categories;
38
use Koha::Patron::Categories;
Lines 212-218 sub _get_columns { Link Here
212
    my $sth         = $dbh->prepare("show columns from $tablename");
213
    my $sth         = $dbh->prepare("show columns from $tablename");
213
    $sth->execute();
214
    $sth->execute();
214
    my @columns;
215
    my @columns;
215
	my $column_defs = _get_column_defs($cgi);
216
    my $columns = Koha::Database::Columns->columns;
216
	my %tablehash;
217
	my %tablehash;
217
	$tablehash{'table'}=$tablename;
218
	$tablehash{'table'}=$tablename;
218
    $tablehash{'__first__'} = $first;
219
    $tablehash{'__first__'} = $first;
Lines 220-226 sub _get_columns { Link Here
220
    while ( my $data = $sth->fetchrow_arrayref() ) {
221
    while ( my $data = $sth->fetchrow_arrayref() ) {
221
        my %temphash;
222
        my %temphash;
222
        $temphash{'name'}        = "$tablename.$data->[0]";
223
        $temphash{'name'}        = "$tablename.$data->[0]";
223
        $temphash{'description'} = $column_defs->{"$tablename.$data->[0]"};
224
        $temphash{'description'} = $columns->{$tablename}->{$data->[0]};
224
        push @columns, \%temphash;
225
        push @columns, \%temphash;
225
    }
226
    }
226
    $sth->finish();
227
    $sth->finish();
Lines 353-377 sub get_criteria { Link Here
353
354
354
355
355
    my $crit   = $criteria{$area};
356
    my $crit   = $criteria{$area};
356
    my $column_defs = _get_column_defs($cgi);
357
    my $columns = Koha::Database::Columns->columns;
357
    my @criteria_array;
358
    my @criteria_array;
358
    foreach my $localcrit (@$crit) {
359
    foreach my $localcrit (@$crit) {
359
        my ( $value, $type )   = split( /\|/, $localcrit );
360
        my ( $value, $type )   = split( /\|/, $localcrit );
360
        my ( $table, $column ) = split( /\./, $value );
361
        my ( $table, $column ) = split( /\./, $value );
362
        my $description = $columns->{$table}->{$column};
361
        if ($type eq 'textrange') {
363
        if ($type eq 'textrange') {
362
            my %temp;
364
            my %temp;
363
            $temp{'name'}        = $value;
365
            $temp{'name'}        = $value;
364
            $temp{'from'}        = "from_" . $value;
366
            $temp{'from'}        = "from_" . $value;
365
            $temp{'to'}          = "to_" . $value;
367
            $temp{'to'}          = "to_" . $value;
366
            $temp{'textrange'}   = 1;
368
            $temp{'textrange'}   = 1;
367
            $temp{'description'} = $column_defs->{$value};
369
            $temp{'description'} = $description;
368
            push @criteria_array, \%temp;
370
            push @criteria_array, \%temp;
369
        }
371
        }
370
        elsif ($type eq 'date') {
372
        elsif ($type eq 'date') {
371
            my %temp;
373
            my %temp;
372
            $temp{'name'}        = $value;
374
            $temp{'name'}        = $value;
373
            $temp{'date'}        = 1;
375
            $temp{'date'}        = 1;
374
            $temp{'description'} = $column_defs->{$value};
376
            $temp{'description'} = $description;
375
            push @criteria_array, \%temp;
377
            push @criteria_array, \%temp;
376
        }
378
        }
377
        elsif ($type eq 'daterange') {
379
        elsif ($type eq 'daterange') {
Lines 380-386 sub get_criteria { Link Here
380
            $temp{'from'}        = "from_" . $value;
382
            $temp{'from'}        = "from_" . $value;
381
            $temp{'to'}          = "to_" . $value;
383
            $temp{'to'}          = "to_" . $value;
382
            $temp{'daterange'}   = 1;
384
            $temp{'daterange'}   = 1;
383
            $temp{'description'} = $column_defs->{$value};
385
            $temp{'description'} = $description;
384
            push @criteria_array, \%temp;
386
            push @criteria_array, \%temp;
385
        }
387
        }
386
        else {
388
        else {
Lines 407-418 sub get_criteria { Link Here
407
            }
409
            }
408
            $sth->finish();
410
            $sth->finish();
409
411
410
            my %temp;
412
            push @criteria_array, {
411
            $temp{'name'}        = $value;
413
                name        => $value,
412
            $temp{'description'} = $column_defs->{$value};
414
                description => $description,
413
            $temp{'values'}      = \@values;
415
                values      => \@values,
414
416
            };
415
            push @criteria_array, \%temp;
416
        }
417
        }
417
    }
418
    }
418
    return ( \@criteria_array );
419
    return ( \@criteria_array );
Lines 896-925 sub get_results { Link Here
896
    |, { Slice => {} }, $report_id);
897
    |, { Slice => {} }, $report_id);
897
}
898
}
898
899
899
sub _get_column_defs {
900
    my ($cgi) = @_;
901
    my %columns;
902
    my $columns_def_file = "columns.def";
903
    my $htdocs = C4::Context->config('intrahtdocs');
904
    my $section = 'intranet';
905
906
    # We need the theme and the lang
907
    # Since columns.def is not in the modules directory, we cannot sent it for the $tmpl var
908
    my ($theme, $lang, $availablethemes) = C4::Templates::themelanguage($htdocs, 'about.tt', $section, $cgi);
909
910
    my $full_path_to_columns_def_file="$htdocs/$theme/$lang/$columns_def_file";
911
    open (my $fh, '<:encoding(utf-8)', $full_path_to_columns_def_file);
912
    while ( my $input = <$fh> ){
913
        chomp $input;
914
        if ( $input =~ m|<field name="(.*)">(.*)</field>| ) {
915
            my ( $field, $translation ) = ( $1, $2 );
916
            $columns{$field} = $translation;
917
        }
918
    }
919
    close $fh;
920
    return \%columns;
921
}
922
923
=head2 GetReservedAuthorisedValues
900
=head2 GetReservedAuthorisedValues
924
901
925
    my %reserved_authorised_values = GetReservedAuthorisedValues();
902
    my %reserved_authorised_values = GetReservedAuthorisedValues();
926
- 

Return to bug 29695