From 0ffedf5aca03d1b8ae0059df8e64219e7ae691bd Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 9 Dec 2013 21:52:30 +0100 Subject: [PATCH] breakout by author groups --- html.pl | 59 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/html.pl b/html.pl index c6a2750..a6c2558 100755 --- a/html.pl +++ b/html.pl @@ -75,7 +75,7 @@ while( my $row = $sth_auth->fetchrow_hashref ) { push @{ $skip->{no_academic_group} }, $row; } - warn dump( $row ); + warn "# ", dump( $row ); push @{ $auth_department->{ $row->{department} } }, $row->{authid}; push @authors, $row; $department_in_sum->{ $row->{department} }++; @@ -313,7 +313,7 @@ sub html_title { } sub html_end { - return qq|\n\n\n|; } mkdir 'html' unless -d 'html'; @@ -471,15 +471,22 @@ my $azvo_stat_biblio; foreach my $department ( sort keys %$department_category_author ) { foreach my $category ( sort keys %{ $department_category_author->{$department} } ) { foreach my $authid ( @{ $department_category_author->{$department}->{$category} } ) { + my $group = $auth_group->{$authid}; + if ( ! $group ) { + push @{ $skip->{no_auth_group} }, $authid; + next; + } foreach my $type ( keys %{ $authors->{$authid} } ) { next unless exists $authors->{$authid}->{$type}->{$category}; - push @{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type } }, @{ $authors->{$authid}->{$type}->{$category} }; + push @{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{$group} }, @{ $authors->{$authid}->{$type}->{$category} }; + push @{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{''} }, @{ $authors->{$authid}->{$type}->{$category} }; } } foreach my $type ( keys %{ $azvo_stat_biblio->{ $department }->{ $category } } ) { - my @biblios = unique_biblionumber @{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type } }; -# $azvo_stat_biblio->{ $department }->{ $category }->{ $type } = $#biblios + 1; - $azvo_stat_biblio->{ $department }->{ $category }->{ $type } = [ @biblios ]; + foreach my $group ( keys %{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type } } ) { + my @biblios = unique_biblionumber @{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{ $group } }; + $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{ $group } = [ @biblios ]; + } } } } @@ -527,19 +534,22 @@ my $table; sub table_count { my $label = shift @_; my $department = shift @_; + my $group = shift @_; my @biblionumbers = @_; my $unique; $unique->{$_}++ foreach @biblionumbers; - $table->[ $label2row->{ $label } ]->[ $department2col->{$department} ] = scalar keys %$unique; + $table->{$group}->[ $label2row->{ $label } ]->[ $department2col->{$department} ] = scalar keys %$unique; } +foreach my $group ( '', keys %$azvo_group_title ) { + foreach my $department ( @departments ) { foreach my $line ( @report_lines ) { my $label = $line->[0]; my @biblionumbers; foreach ( 1 .. $#$line ) { my ( $category, $type ) = @{ $line->[ $_ ] }; - my $b = $azvo_stat_biblio->{ $department }->{$category}->{$type}; + my $b = $azvo_stat_biblio->{ $department }->{$category}->{$type}->{$group}; push @biblionumbers, @$b if $b; } if ( $sub_labels->{$label} ) { @@ -567,33 +577,42 @@ foreach my $department ( @departments ) { } foreach my $sub_label ( keys %$sub_stats ) { my $full_label = $label . $sub_label; - table_count $full_label, $department, @{ $sub_stats->{$sub_label} }; + table_count $full_label, $department, $group, @{ $sub_stats->{$sub_label} }; } } else { - table_count $label, $department, @biblionumbers; + table_count $label, $department, $group, @biblionumbers; } } } +} # group + debug 'table', $table; open(my $fh, '>:encoding(utf-8)', 'html/azvo.new'); print $fh html_title('AZVO tablica'); -print $fh "\n"; -print $fh ""; -print $fh "" foreach @departments; -print $fh "\n"; +foreach my $group ( keys %$table ) { -foreach my $row ( 0 .. $#$table ) { - print $fh ""; - print $fh "" foreach 0 .. $#departments; - print $fh ""; -} + print $fh "

$group

" if $group; + + print $fh "
$_
", $report_labels[$row], "", $table->[ $row ]->[ $_ ] || '', "
\n"; + print $fh ""; + print $fh "" foreach @departments; + print $fh "\n"; + + foreach my $row ( 0 .. $#{ $table->{$group} } ) { + print $fh ""; + print $fh "" foreach 0 .. $#departments; + print $fh ""; + } + + print $fh "
$_
", $report_labels[$row], "", $table->{$group}->[ $row ]->[ $_ ] || '', "
\n"; -print $fh "\n", html_end; +} # group +print $fh html_end; close($fh); rename 'html/azvo.new', 'html/azvo.html'; -- 2.20.1