3 # LC_COLLATE=hr_HR.utf8 KOHA_CONF=/etc/koha/sites/ffzg/koha-conf.xml ./html.pl
9 use Data::Dump qw(dump);
16 use POSIX qw(strftime);
19 use lib '/srv/koha_ffzg';
24 my $dbh = C4::Context->dbh;
27 my ($title, $data) = @_;
28 print "# $title ",dump($data), $/ if $ENV{DEBUG};
31 my $xslfilename = 'compact.xsl';
33 my $azvo_group_title = {
34 'znanstveno nastavni' => qr/(profes|docent|znanstveni savjetnik|znanstveni suradnik)/i,
35 'lektori i predavači' => qr/(lektor|predavač)/i,
36 'asistenti i novaci' => qr/(asistent|novak)/i,
39 my $department_groups = {
40 'AAB_humanističke' => qr/(anglistiku|arheologiju|antropologiju|filozofiju|fonetiku|germanistiku|hungarologiju|indologiju|slavenske|filologiju|komparativnu|kroatistiku|lingvistiku|povijest|romanistiku|talijanistiku)/i,
41 'AAC_društvene' => qr/(informacijske|pedagogiju|psihologiju|sociologiju)/i,
48 my $department_in_sum;
49 my $department_in_group;
53 my $sth_auth = $dbh->prepare(q{
56 ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="a"]') as full_name,
57 ExtractValue(marcxml,'//datafield[@tag="680"]/subfield[@code="a"]') as department,
58 ExtractValue(marcxml,'//datafield[@tag="680"]/subfield[@code="i"]') as academic_title
63 while( my $row = $sth_auth->fetchrow_hashref ) {
64 if ( $row->{department} !~ m/Filozofski fakultet u Zagrebu/ ) {
65 push @{ $skip->{nije_ffzg} }, $row;
68 $auth_header->{ $row->{authid} } = $row->{full_name};
69 $row->{department} =~ s/, Filozofski fakultet u Zagrebu.*$//;
70 $row->{department} =~ s/^.+\.\s*//;
71 $row->{department} =~ s/\s+$//s;
73 foreach my $title ( keys %$azvo_group_title ) {
74 if ( $row->{academic_title} =~ $azvo_group_title->{$title} ) {
80 $row->{academic_group} = $group;
81 $auth_group->{ $row->{authid} } = $group;
82 $skip->{group_stat}->{$group}++;
84 push @{ $skip->{no_academic_group} }, $row;
87 # warn "# ", dump( $row );
88 push @{ $auth_department->{ $row->{department} } }, $row->{authid};
90 $department_in_sum->{ $row->{department} }++;
91 foreach my $name ( keys %$department_groups ) {
92 my $regex = $department_groups->{$name};
93 if ( $row->{department} =~ $regex ) {
94 $department_in_group->{ $row->{department} } = $name;
100 debug 'department_in_group' => $department_in_group;
102 foreach my $department ( keys %$department_in_sum ) {
103 $department_in_sum->{$department} = 0 unless $department =~ m/(centar|croaticum|katedra|odsjek)/i;
106 debug 'auth_department' => $auth_department;
107 store $auth_department, '/dev/shm/auth_department.storable';
108 debug 'auth_group' => $auth_group;
109 debug 'department_in_sum' => $department_in_sum;
115 my $sth_select_authors = $dbh->prepare(q{
126 -- ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="9"]') as first_author,
127 -- ExtractValue(marcxml,'//datafield[@tag="700"]/subfield[@code="9"]') as other_authors,
128 -- ExtractValue(marcxml,'//datafield[@tag="942"]/subfield[@code="t"]') as category,
130 -- and SUBSTR(ExtractValue(marcxml,'//controlfield[@tag="008"]'),8,4) between 2008 and 2013
131 -- order by SUBSTR(ExtractValue(marcxml,'//controlfield[@tag="008"]'),8,4) desc
135 my $biblio_full_name;
138 my $parser = XML::LibXML->new();
139 $parser->recover_silently(0); # don't die when you find &, >, etc
140 my $style_doc = $parser->parse_file($xslfilename);
141 my $xslt = XML::LibXSLT->new();
142 my $parsed = $xslt->parse_stylesheet($style_doc);
147 my $biblio_author_external;
149 open(my $xml_fh, '>', '/tmp/bibliografija.xml') if $ENV{XML};
151 sub biblioitem_html {
152 my ($biblionumber, $parse_only) = @_;
154 return $biblio_html->{$biblionumber} if exists $biblio_html->{$biblionumber} && ! $parse_only;
156 my $xmlrecord = $marcxml->{$biblionumber} || confess "missing $biblionumber marcxml";
158 print $xml_fh $xmlrecord if $ENV{XML};
160 my $source = eval { $parser->parse_string($xmlrecord) };
162 # warn "SKIP $biblionumber corrupt XML";
163 push @{ $skip->{XML_corrupt} }, $biblionumber;
168 $biblio_parsed->{$biblionumber} = $source;
172 my $transformed = $parsed->transform($source);
173 $biblio_html->{$biblionumber} = $parsed->output_string( $transformed );
175 delete $biblio_parsed->{$biblionumber};
177 return $biblio_html->{$biblionumber};
180 $sth_select_authors->execute();
181 while( my $row = $sth_select_authors->fetchrow_hashref ) {
182 # warn dump($row),$/;
186 $marcxml->{ $row->{biblionumber} } = $row->{marcxml};
188 my $doc = biblioitem_html( $row->{biblionumber}, 1 );
190 # warn "ERROR can't parse MARCXML ", $row->{biblionumber}, " ", $row->{marcxml}, "\n";
194 my $root = $doc->documentElement;
196 my @leaders = $root->getElementsByLocalName('leader');
198 my $leader = $leaders[0]->textContent;
199 warn "leader $leader\n";
214 foreach my $elt ($root->getChildrenByLocalName('*')) {
215 my $tag = $elt->getAttribute('tag');
217 next unless exists $extract->{ $tag };
219 if ($elt->localname eq 'controlfield') {
220 if ( $tag eq '008' ) {
221 my $content = $elt->textContent;
222 my $year = substr($content, 7, 4 );
223 if ( $year !~ m/^\d+$/ ) {
225 push @{ $skip->{invalid_year} }, $row->{biblionumber};
227 $biblio_year->{ $row->{biblionumber} } = $data->{year} = $year;
228 $data->{'008'} = $content;
231 } elsif ($elt->localname eq 'datafield') {
233 foreach my $sfelt ($elt->getChildrenByLocalName('subfield')) {
234 my $sf = $sfelt->getAttribute('code');
235 next unless $sf =~ m/$extract->{$tag}/;
236 if ( exists $sf_data->{$sf} ) {
237 $sf_data->{$sf} .= " " . $sfelt->textContent();
239 $sf_data->{$sf} = $sfelt->textContent();
242 push @{ $data->{$tag} }, $sf_data if $sf_data;
246 if ( ! defined $data->{year} ) {
247 warn "MISSING year in ", $row->{biblionumber};
248 =for remove-year-limit
249 } elsif ( $data->{year} < 2008 ) {
250 push @{ $skip->{year_lt_2008} }, $row->{biblionumber};
252 } elsif ( $data->{year} > 2013 ) {
253 push @{ $skip->{year_gt_2013} }, $row->{biblionumber};
258 # warn "# ", $row->{biblionumber}, " data ",dump($data);
260 my $category = $data->{942}->[0]->{'t'};
262 # warn "# SKIP ", $row->{biblionumber}, " no category in ", dump($data);
263 push @{ $skip->{no_category} }, $row->{biblionumber};
269 if ( exists $data->{100} ) {
273 if ( ! exists $_->{9} ) {
274 $biblio_author_external->{ $row->{biblionumber} }++;
276 } elsif ( exists $auth_header->{ $_->{9} } ) {
283 foreach my $authid ( @first_author ) {
284 push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
286 $biblio_full_name->{ $row->{biblionumber} } = $data->{100}->[0]->{a};
291 $biblio_full_name->{ $row->{biblionumber} } ||= $data->{245}->[0]->{a};
295 if ( exists $data->{700} ) {
298 if ( ! exists $_->{9} ) {
299 $biblio_author_external->{ $row->{biblionumber} }++;
301 } elsif ( exists $auth_header->{ $_->{9} } ) {
308 foreach my $auth ( @other_authors ) {
309 my $authid = $auth->{9} || next;
310 my $type = $auth->{4} || next; #die "no 4 in ",dump($data);
312 $type_stats->{$type}++;
314 my @types = split(/\s+/, $type);
316 foreach my $type ( @types ) {
317 $type_stats->{_count_each_type}->{$type}++;
319 if ( $type =~ m/(edt|trl|com|ctb)/ ) {
320 push @{ $authors->{$authid}->{sec}->{ $category } }, $row->{biblionumber};
321 push @{ $authors->{$authid}->{$type}->{ $category } }, $row->{biblionumber};
322 $type =~ s/(com|ctb)/_ostalo/;
323 push @{ $authors->{$authid}->{$type}->{ $category } }, $row->{biblionumber};
325 } elsif ( $type =~ m/aut/ ) {
327 $have_edt = grep { exists $_->{4} && $_->{4} =~ m/edt/ } @{ $data->{700} } if ! defined $have_edt;
329 $skip->{ have_700_edt }->{ $row->{biblionumber} }++;
331 push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
334 push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
337 # warn "# SKIP ", $row->{biblionumber}, ' no 700$4 in ', dump($data);
338 $skip->{ 'no_700$4' }->{ $row->{biblionumber} }++;
345 $biblio_data->{ $row->{biblionumber} } = $data;
349 debug 'authors' => $authors;
350 store $authors, '/dev/shm/authors.storable';
351 debug 'type_stats' => $type_stats;
352 debug 'skip' => $skip;
353 debug 'biblio_year' => $biblio_year;
354 debug 'biblio_full_name' => $biblio_full_name;
355 debug 'biblio_data' => $biblio_data;
356 debug 'biblio_author_external' => $biblio_author_external;
359 my $sth_categories = $dbh->prepare(q{
360 select authorised_value, lib from authorised_values where category = 'BIBCAT'
362 $sth_categories->execute();
363 while( my $row = $sth_categories->fetchrow_hashref ) {
364 $category_label->{ $row->{authorised_value} } = $row->{lib};
367 debug 'category_label' => $category_label;
372 <meta charset="UTF-8">
373 <title>|, join(" ", @_), qq|</title>
374 <link href="style.css" type="text/css" rel="stylesheet" />
375 <script src="//code.jquery.com/jquery-1.11.2.js"></script>
383 qq|<small style="color:gray">Zadnji puta osvježeno: |,
384 strftime("%Y-%m-%d %H:%M:%S\n", localtime()),
385 qq|</body>\n</html>\n|;
388 mkdir 'html' unless -d 'html';
390 open(my $index, '>:encoding(utf-8)', 'html/index.new');
391 print $index html_title('Bibliografija Filozofskog fakulteta');
393 my $first_letter = '';
395 debug 'authors' => \@authors;
398 my ($biblionumber) = @_;
399 return qq|<li class="y|, $biblio_year->{$biblionumber}, qq|">|,
400 qq|<a href="https://koha.ffzg.hr/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber">$biblionumber</a>|,
401 biblioitem_html($biblionumber),
402 qq|<a href="https://koha.ffzg.hr:8443/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=$biblionumber">edit</a>|,
406 sub unique_biblionumber {
409 $u->{$_}++ foreach @v;
411 $biblio_year->{$b} <=> $biblio_year->{$a} ||
412 $biblio_full_name->{$a} cmp $biblio_full_name->{$b} ||
418 my ( $fh, $authid, $type, $label ) = @_;
420 return unless exists $authors->{$authid}->{$type};
422 print $fh qq|<a name="$type"><h2>$label</h2></a>\n|;
424 foreach my $category ( sort keys %{ $authors->{$authid}->{$type} } ) {
425 my $label = $category_label->{$category} || 'Bez kategorije';
426 print $fh qq|<a name="$type-$category"><h3>$label</h3></a>\n<ol>\n|;
427 foreach my $biblionumber ( unique_biblionumber @{ $authors->{$authid}->{$type}->{$category} } ) {
428 print $fh li_biblio( $biblionumber );
430 print $fh qq|</ol>\n|;
435 sub count_author_years {
438 foreach my $type ( keys %{ $authors->{$authid} } ) {
439 foreach my $category ( keys %{ $authors->{$authid}->{$type} } ) {
440 foreach my $biblionumber ( @{ $authors->{$authid}->{$type}->{$category} } ) {
441 $years->{ $biblio_year->{ $biblionumber } }->{ $type . '-' . $category }++;
448 my @toc_type_label = (
449 'aut' => 'Primarno autorstvo',
450 'edt' => 'Uredništva',
451 'trl' => 'Prijevodi',
452 '_ostalo' => 'Ostalo',
455 sub html_year_selection {
459 print $fh qq|<span id="years">Godine:\n|;
460 my $type_cat_count = {};
463 foreach my $authid ( @authids ) {
464 $years = count_author_years( $years, $authid );
467 foreach my $year ( sort { $b <=> $a } keys %$years ) {
468 print $fh qq|<label><input name="year_selection" value="$year" type=checkbox onClick="toggle_year($year, this)" checked="checked">$year</label> \n|;
469 foreach my $type_cat ( keys %{ $years->{$year} } ) {
470 $type_cat_count->{ $type_cat } += $years->{$year}->{$type_cat};
471 my ($type,$cat) = split(/-/, $type_cat);
472 $type_cat_count->{_toc}->{$type}->{$cat}++;
473 $type_cat_count->{_toc_count}->{$type} += $years->{$year}->{$type_cat};
478 <input type=button value="all" onClick="all_years(1)">
479 <input type=button value="none" onClick="all_years(0)">
482 print $fh qq|</span>|;
487 var years = |, encode_json($years), q|;
489 var type_cat_count = |, encode_json($type_cat_count), q|;
491 function toc_count_update(type_cat) {
492 var selector = '#toc-count-'+type_cat.replace(/\./g,'-');
495 console.error(selector, 'not found');
498 var old_val = e.text();
499 var new_val = type_cat_count[type_cat];
501 if ( old_val != new_val ) {
503 console.debug( selector, 'old', old_val, 'new', new_val);
507 function year_show(year) {
509 console.debug('show', year);
510 for(var type_cat in years[year]) {
511 if ( ( type_cat_count[ type_cat ] += years[year][type_cat] ) == years[year][type_cat]) {
512 $('a[name="'+type_cat+'"]').show();
513 console.debug(type_cat, 'show');
515 toc_count_update(type_cat);
519 function year_hide(year) {
521 console.debug('hide', year);
522 for(var type_cat in years[year]) {
523 if ( ( type_cat_count[ type_cat ] -= years[year][type_cat] ) == 0 ) {
524 $('a[name="'+type_cat+'"]').hide();
525 console.debug(type_cat, 'hide');
527 toc_count_update(type_cat);
531 function toggle_year(year, el) {
539 function all_years( turn_on ) {
540 $('input[name=year_selection]').each( function(i,el) {
542 if ( ! el.checked ) {
544 year_show( el.value );
549 year_hide( el.value );
555 $(document).ready( function() {
556 console.info('ready');
558 $('input[name=year_selection]').each( function(i, el) {
560 console.debug( 'on load', year, el.checked );
561 if (! el.checked) year_hide(year);
570 print $fh qq|<ul id="toc">\n|;
572 while ( $i < $#toc_type_label ) {
573 my $type = $toc_type_label[$i++] || die "type";
574 my $label = $toc_type_label[$i++] || die "label";
575 next unless exists $type_cat_count->{_toc}->{$type};
576 print $fh qq| <li class="toc" id="toc-$type"><a href="#$type">$label</a> <tt id="toc-count-$type">$type_cat_count->{_toc_count}->{$type}</tt></li>\n <ul>\n|;
577 foreach my $category ( sort keys %{ $type_cat_count->{_toc}->{$type} } ) {
578 my $label = $category_label->{$category} || 'Bez kategorije';
579 my $count = $type_cat_count->{ $type . '-' . $category };
580 my $cat_html = $category;
581 $cat_html =~ s/\./-/g;
582 print $fh qq| <li class="toc" id="toc-$category"><a href="#$type-$category">$label</a> <tt id="toc-count-$type-$cat_html">$count</tt></li>\n|;
584 print $fh qq| </ul>\n|;
586 print $fh qq|</ul>\n|;
591 foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) {
593 my $first = substr( $row->{full_name}, 0, 1 );
594 if ( $first ne $first_letter ) {
595 print $index qq{</ul>\n} if $first_letter;
596 $first_letter = $first;
597 print $index qq{<h1>$first</h1>\n<ul>\n};
599 print $index qq{<li><a href="}, $row->{authid}, qq{.html">}, $row->{full_name}, "</a></li>\n";
601 my $path = "html/$row->{authid}";
602 open(my $fh, '>:encoding(utf-8)', "$path.new");
603 print $fh html_title($row->{full_name}, "bibliografija");
604 print $fh qq|<h1>$row->{full_name} - bibliografija</h1>\n|;
606 html_year_selection $fh => $row->{authid};
609 while ( $i < $#toc_type_label ) {
610 my $type = $toc_type_label[$i++] || die "type";
611 my $label = $toc_type_label[$i++] || die "label";
612 author_html( $fh, $row->{authid}, $type => $label );
617 rename "$path.new", "$path.html";
621 print $index html_end;
623 rename 'html/index.new', 'html/index.html';
625 debug 'auth_header' => $auth_header;
628 my $department_category_author;
629 foreach my $department ( sort keys %$auth_department ) {
630 foreach my $authid ( sort @{ $auth_department->{$department} } ) {
631 my @categories = keys %{ $authors->{$authid}->{aut} };
632 push @categories, keys %{ $authors->{$authid}->{sec} };
633 foreach my $category ( sort @categories ) {
634 push @{ $department_category_author->{$department}->{$category} }, $authid;
635 push @{ $department_category_author->{'AAA_ukupno'}->{$category} }, $authid if $department_in_sum->{$department};
636 if ( my $group = $department_in_group->{ $department } ) {
637 push @{ $department_category_author->{$group}->{$category} }, $authid;
639 $skip->{'department_not_in_group'}->{ $department }++;
645 debug 'department_category_author' => $department_category_author;
648 sub department_html {
649 my ( $fh, $department, $type, $label ) = @_;
651 print $fh qq|<a name="$type"><h2>$label</h2></a>\n|;
653 foreach my $category ( sort keys %{ $department_category_author->{$department} } ) {
655 my @authids = @{ $department_category_author->{$department}->{$category} };
656 next unless @authids;
658 my @biblionumber = unique_biblionumber map { @{ $authors->{$_}->{$type}->{$category} } } grep { exists $authors->{$_}->{$type}->{$category} } @authids;
660 next unless @biblionumber;
662 my $label = $category_label->{$category} || 'Bez kategorije';
663 print $fh qq|<a name="$type-$category"><h3>$label</h3></a>\n<ol>\n|;
665 print $fh li_biblio( $_ ) foreach @biblionumber;
673 mkdir 'html/departments' unless -d 'html/departments';
675 open(my $dep_fh, '>:encoding(utf-8)', 'html/departments/index.new');
676 print $dep_fh html_title('Odsjeci Filozofskog fakulteta u Zagrebu'), qq|<ul>\n|;
677 foreach my $department ( sort keys %$department_category_author ) {
678 my $dep = $department || 'Nema odsjeka';
679 my $dep_file = unac_string('utf-8',$dep);
680 print $dep_fh qq|<li><a href="$dep_file.html">$dep</a></li>\n|;
681 open(my $fh, '>:encoding(utf-8)', "html/departments/$dep_file.new");
683 print $fh html_title($department . ' bibliografija');
684 print $fh qq|<h1>$department bibliografija</h1>\n|;
687 foreach my $category ( sort keys %{ $department_category_author->{$department} } ) {
688 push @authids, @{ $department_category_author->{$department}->{$category} };
690 html_year_selection $fh => @authids;
692 department_html( $fh, $department, 'aut', 'Primarno autorstvo' );
694 # department_html( $fh, $department, 'sec', 'Sekundarno autorstvo' );
695 department_html( $fh, $department, 'edt', 'Uredništva' );
696 department_html( $fh, $department, 'trl', 'Prijevodi' );
697 department_html( $fh, $department, '_ostalo', 'Ostalo' );
701 rename "html/departments/$dep_file.new", "html/departments/$dep_file.html";
703 print $dep_fh qq|</ul>\n|, html_end;
705 rename 'html/departments/index.new', 'html/departments/index.html';
707 my $azvo_stat_biblio;
709 foreach my $department ( sort keys %$department_category_author ) {
710 foreach my $category ( sort keys %{ $department_category_author->{$department} } ) {
711 foreach my $authid ( @{ $department_category_author->{$department}->{$category} } ) {
712 my $group = $auth_group->{$authid};
714 push @{ $skip->{no_auth_group} }, $authid;
717 foreach my $type ( keys %{ $authors->{$authid} } ) {
718 next unless exists $authors->{$authid}->{$type}->{$category};
719 push @{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{$group} }, @{ $authors->{$authid}->{$type}->{$category} };
720 push @{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{''} }, @{ $authors->{$authid}->{$type}->{$category} };
723 foreach my $type ( keys %{ $azvo_stat_biblio->{ $department }->{ $category } } ) {
724 foreach my $group ( keys %{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type } } ) {
725 my @biblios = unique_biblionumber @{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{ $group } };
726 $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{ $group } = [ @biblios ];
732 debug 'azvo_stat_biblio' => $azvo_stat_biblio;
739 open(my $report, '<:encoding(utf-8)', 'AZVO.txt');
742 if ( /^([^\t]+)\t+(.+)/ ) {
744 push @report_labels, $label;
745 my $type = [ map { m/\s+/ ? [ split(/\s+/,$_) ] : [ $_, 'aut' ] } split (/\s*\+\s*/, $2) ];
746 push @report_lines, [ $label, @$type ];
747 } elsif ( /^\t+([^\t]+):\t+(\d+)(\w*)\t*(.*)$/ ) {
748 push @{ $sub_labels->{$label} }, [ $1, $2, $3, $4 ];
750 pop (@report_labels) if ( $report_labels[ $#report_labels ] =~ m/^$label$/ ); # remove partial name
751 push @report_labels, $label . $sub_label;
757 debug 'report_lines', \@report_lines;
758 debug 'sub_labels', $sub_labels;
759 debug 'report_labels', \@report_labels;
761 my @departments = ( sort { lc($a) cmp lc($b) } keys %$azvo_stat_biblio );
763 debug 'departments' => \@departments;
766 $department2col->{ $departments[$_] } = $_ foreach ( 0 .. $#departments );
768 $label2row->{ $report_labels[$_] } = $_ foreach ( 0 .. $#report_labels );
773 my $label = shift @_;
774 my $department = shift @_;
775 my $group = shift @_;
776 my @biblionumbers = @_;
778 $unique->{$_}++ foreach @biblionumbers;
779 my @bibs = keys %$unique;
780 $table->{ffzg}->{$group}->[ $label2row->{ $label } ]->[ $department2col->{$department} ] = scalar @bibs;
781 $table->{external}->{$group}->[ $label2row->{ $label } ]->[ $department2col->{$department} ] = scalar grep { $biblio_author_external->{$_} } @bibs;
784 foreach my $group ( '', keys %$azvo_group_title ) {
786 foreach my $department ( @departments ) {
787 foreach my $line ( @report_lines ) {
788 my $label = $line->[0];
790 foreach ( 1 .. $#$line ) {
791 my ( $category, $type ) = @{ $line->[ $_ ] };
792 my $b = $azvo_stat_biblio->{ $department }->{$category}->{$type}->{$group};
793 push @biblionumbers, @$b if $b;
795 if ( $sub_labels->{$label} ) {
797 foreach my $biblionumber ( @biblionumbers ) {
798 my $data = $biblio_data->{$biblionumber} || die "can't find biblionumber $biblionumber";
799 foreach my $sub_label ( @{ $sub_labels->{$label} } ) {
800 my ( $sub_label, $field, $sf, $regex ) = @$sub_label;
802 push @{ $sub_stats->{ $sub_label } }, $biblionumber;
805 if ( $field < 100 ) {
806 if ( $data->{$field} =~ m/$regex/ ) {
807 push @{ $sub_stats->{ $sub_label } }, $biblionumber;
811 if ( exists $data->{$field}->[0]->{$sf} && $data->{$field}->[0]->{$sf} =~ m/$regex/ ) {
812 push @{ $sub_stats->{ $sub_label } }, $biblionumber;
818 foreach my $sub_label ( keys %$sub_stats ) {
819 my $full_label = $label . $sub_label;
820 table_count $full_label, $department, $group, @{ $sub_stats->{$sub_label} };
823 table_count $label, $department, $group, @biblionumbers;
830 debug 'table', $table;
832 open(my $fh, '>:encoding(utf-8)', 'html/azvo.new');
833 open(my $fh2, '>:encoding(utf-8)', 'html/azvo2.new');
840 print $fh html_title('AZVO tablica - FFZG');
841 print $fh2 html_title('AZVO tablica - kolaboracija sa FFZG');
843 foreach my $group ( keys %{ $table->{ffzg} } ) {
845 print_fh "<h1>$group</h1>" if $group;
847 print_fh "<table border=1>\n";
848 print_fh "<tr><th></th>";
849 print_fh "<th>$_</th>" foreach @departments;
852 foreach my $row ( 0 .. $#{ $table->{ffzg}->{$group} } ) {
853 print_fh "<tr><th>", $report_labels[$row], "</th>\n";
854 foreach ( 0 .. $#departments ) {
856 print $fh $table->{ffzg}->{$group}->[ $row ]->[ $_ ] || '';
857 print $fh2 $table->{external}->{$group}->[ $row ]->[ $_ ] || '';
863 print_fh "</table>\n";
870 rename 'html/azvo.new', 'html/azvo.html';
871 rename 'html/azvo2.new', 'html/azvo2.html';