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 $pid_file = '/dev/shm/bibliografija.pid';
27 open(my $fh, '<', $pid_file);
29 no autodie; # it will die on kill
30 kill 0, $pid || die "$0 allready running as pid $pid";
32 open(my $fh, '>', $pid_file);
38 my $dbh = C4::Context->dbh;
41 my ($title, $data) = @_;
42 print "# $title ",dump($data), $/ if $ENV{DEBUG};
45 my $xslfilename = 'compact.xsl';
47 my $azvo_group_title = {
48 'znanstveno nastavni' => qr/(profes|docent|znanstveni savjetnik|znanstveni suradnik)/i,
49 'lektori i predavači' => qr/(lektor|predavač)/i,
50 'asistenti i novaci' => qr/(asistent|novak)/i,
53 my $department_groups = {
54 'AAB_humanističke' => qr/(anglistiku|arheologiju|antropologiju|filozofiju|fonetiku|germanistiku|hungarologiju|indologiju|slavenske|filologiju|komparativnu|kroatistiku|lingvistiku|povijest|romanistiku|talijanistiku)/i,
55 'AAC_društvene' => qr/(informacijske|pedagogiju|psihologiju|sociologiju)/i,
62 my $department_in_sum;
63 my $department_in_group;
67 my $sth_auth = $dbh->prepare(q{
70 ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="a"]') as full_name,
71 ExtractValue(marcxml,'//datafield[@tag="680"]/subfield[@code="a"]') as department,
72 ExtractValue(marcxml,'//datafield[@tag="680"]/subfield[@code="i"]') as academic_title
77 while( my $row = $sth_auth->fetchrow_hashref ) {
78 if ( $row->{department} !~ m/Filozofski fakultet u Zagrebu/ ) {
79 push @{ $skip->{nije_ffzg} }, $row;
82 $auth_header->{ $row->{authid} } = $row->{full_name};
83 $row->{department} =~ s/, Filozofski fakultet u Zagrebu.*$//;
84 $row->{department} =~ s/^.+\.\s*//;
85 $row->{department} =~ s/\s+$//s;
87 foreach my $title ( keys %$azvo_group_title ) {
88 if ( $row->{academic_title} =~ $azvo_group_title->{$title} ) {
94 $row->{academic_group} = $group;
95 $auth_group->{ $row->{authid} } = $group;
96 $skip->{group_stat}->{$group}++;
98 push @{ $skip->{no_academic_group} }, $row;
101 # warn "# ", dump( $row );
102 push @{ $auth_department->{ $row->{department} } }, $row->{authid};
104 $department_in_sum->{ $row->{department} }++;
105 foreach my $name ( keys %$department_groups ) {
106 my $regex = $department_groups->{$name};
107 if ( $row->{department} =~ $regex ) {
108 $department_in_group->{ $row->{department} } = $name;
114 debug 'department_in_group' => $department_in_group;
116 foreach my $department ( keys %$department_in_sum ) {
117 # $department_in_sum->{$department} = 0 unless $department =~ m/(centar|croaticum|katedra|odsjek)/i;
120 debug 'auth_department' => $auth_department;
121 store $auth_department, '/dev/shm/auth_department.storable';
122 debug 'auth_group' => $auth_group;
123 debug 'department_in_sum' => $department_in_sum;
129 my $sth_select_authors = $dbh->prepare(q{
140 -- ExtractValue(marcxml,'//datafield[@tag="100"]/subfield[@code="9"]') as first_author,
141 -- ExtractValue(marcxml,'//datafield[@tag="700"]/subfield[@code="9"]') as other_authors,
142 -- ExtractValue(marcxml,'//datafield[@tag="942"]/subfield[@code="t"]') as category,
144 -- and SUBSTR(ExtractValue(marcxml,'//controlfield[@tag="008"]'),8,4) between 2008 and 2013
145 -- order by SUBSTR(ExtractValue(marcxml,'//controlfield[@tag="008"]'),8,4) desc
149 my $biblio_full_name;
152 my $parser = XML::LibXML->new();
153 $parser->recover_silently(0); # don't die when you find &, >, etc
154 my $style_doc = $parser->parse_file($xslfilename);
155 my $xslt = XML::LibXSLT->new();
156 my $parsed = $xslt->parse_stylesheet($style_doc);
161 my $biblio_author_external;
163 open(my $xml_fh, '>', '/tmp/bibliografija.xml') if $ENV{XML};
165 sub biblioitem_html {
166 my ($biblionumber, $parse_only) = @_;
168 return $biblio_html->{$biblionumber} if exists $biblio_html->{$biblionumber} && ! $parse_only;
170 my $xmlrecord = $marcxml->{$biblionumber} || confess "missing $biblionumber marcxml";
172 print $xml_fh $xmlrecord if $ENV{XML};
174 my $source = eval { $parser->parse_string($xmlrecord) };
176 # warn "SKIP $biblionumber corrupt XML";
177 push @{ $skip->{XML_corrupt} }, $biblionumber;
182 $biblio_parsed->{$biblionumber} = $source;
186 my $transformed = $parsed->transform($source);
187 $biblio_html->{$biblionumber} = $parsed->output_string( $transformed );
189 delete $biblio_parsed->{$biblionumber};
191 return $biblio_html->{$biblionumber};
194 $sth_select_authors->execute();
195 while( my $row = $sth_select_authors->fetchrow_hashref ) {
196 # warn dump($row),$/;
200 $marcxml->{ $row->{biblionumber} } = $row->{marcxml};
202 my $doc = biblioitem_html( $row->{biblionumber}, 1 );
204 # warn "ERROR can't parse MARCXML ", $row->{biblionumber}, " ", $row->{marcxml}, "\n";
208 my $root = $doc->documentElement;
210 my @leaders = $root->getElementsByLocalName('leader');
212 my $leader = $leaders[0]->textContent;
213 warn "leader $leader\n";
228 foreach my $elt ($root->getChildrenByLocalName('*')) {
229 my $tag = $elt->getAttribute('tag');
231 next unless exists $extract->{ $tag };
233 if ($elt->localname eq 'controlfield') {
234 if ( $tag eq '008' ) {
235 my $content = $elt->textContent;
236 my $year = substr($content, 7, 4 );
237 if ( $year !~ m/^\d+$/ ) {
239 push @{ $skip->{invalid_year} }, $row->{biblionumber};
241 $biblio_year->{ $row->{biblionumber} } = $data->{year} = $year;
242 $data->{'008'} = $content;
245 } elsif ($elt->localname eq 'datafield') {
247 foreach my $sfelt ($elt->getChildrenByLocalName('subfield')) {
248 my $sf = $sfelt->getAttribute('code');
249 next unless $sf =~ m/$extract->{$tag}/;
250 if ( exists $sf_data->{$sf} ) {
251 $sf_data->{$sf} .= " " . $sfelt->textContent();
253 $sf_data->{$sf} = $sfelt->textContent();
256 push @{ $data->{$tag} }, $sf_data if $sf_data;
260 if ( ! defined $data->{year} ) {
261 warn "MISSING year in ", $row->{biblionumber};
262 =for remove-year-limit
263 } elsif ( $data->{year} < 2008 ) {
264 push @{ $skip->{year_lt_2008} }, $row->{biblionumber};
266 } elsif ( $data->{year} > 2013 ) {
267 push @{ $skip->{year_gt_2013} }, $row->{biblionumber};
272 # warn "# ", $row->{biblionumber}, " data ",dump($data);
274 my $category = $data->{942}->[0]->{'t'};
276 # warn "# SKIP ", $row->{biblionumber}, " no category in ", dump($data);
277 push @{ $skip->{no_category} }, $row->{biblionumber};
283 if ( exists $data->{100} ) {
287 if ( ! exists $_->{9} ) {
288 $biblio_author_external->{ $row->{biblionumber} }++;
290 } elsif ( exists $auth_header->{ $_->{9} } ) {
297 foreach my $authid ( @first_author ) {
298 push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
300 $biblio_full_name->{ $row->{biblionumber} } = $data->{100}->[0]->{a};
305 $biblio_full_name->{ $row->{biblionumber} } ||= $data->{245}->[0]->{a};
309 if ( exists $data->{700} ) {
312 if ( ! exists $_->{9} ) {
313 $biblio_author_external->{ $row->{biblionumber} }++;
315 } elsif ( exists $auth_header->{ $_->{9} } ) {
322 foreach my $auth ( @other_authors ) {
323 my $authid = $auth->{9} || next;
324 my $type = $auth->{4} || next; #die "no 4 in ",dump($data);
326 $type_stats->{$type}++;
328 my @types = split(/[\s\/]+/, $type);
330 foreach my $type ( @types ) {
331 my $type = substr($type,0,3);
332 $type_stats->{_count_each_type}->{$type}++;
334 if ( $type =~ m/(edt|trl|com|ctb)/ ) {
335 push @{ $authors->{$authid}->{__sec}->{ $category } }, $row->{biblionumber};
336 push @{ $authors->{$authid}->{$type}->{ $category } }, $row->{biblionumber};
337 $type =~ s/(com|ctb)/_ostalo/;
338 push @{ $authors->{$authid}->{$type}->{ $category } }, $row->{biblionumber};
340 } elsif ( $type =~ m/aut/ ) {
342 $have_edt = grep { exists $_->{4} && $_->{4} =~ m/edt/ } @{ $data->{700} } if ! defined $have_edt;
344 $skip->{ have_700_edt }->{ $row->{biblionumber} }++;
346 push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
349 push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
352 # warn "# SKIP ", $row->{biblionumber}, ' no 700$4 in ', dump($data);
353 $skip->{ 'no_700$4' }->{ $row->{biblionumber} }++;
360 $biblio_data->{ $row->{biblionumber} } = $data;
364 debug 'authors' => $authors;
365 store $authors, '/dev/shm/authors.storable';
366 debug 'type_stats' => $type_stats;
367 debug 'skip' => $skip;
368 debug 'biblio_year' => $biblio_year;
369 debug 'biblio_full_name' => $biblio_full_name;
370 debug 'biblio_data' => $biblio_data;
371 debug 'biblio_author_external' => $biblio_author_external;
374 my $sth_categories = $dbh->prepare(q{
375 select authorised_value, lib from authorised_values where category = 'BIBCAT'
377 $sth_categories->execute();
378 while( my $row = $sth_categories->fetchrow_hashref ) {
379 $category_label->{ $row->{authorised_value} } = $row->{lib};
382 debug 'category_label' => $category_label;
387 <meta charset="UTF-8">
388 <title>|, join(" ", @_), qq|</title>
389 <link href="style.css" type="text/css" rel="stylesheet" />
390 <script src="//code.jquery.com/jquery-1.11.2.js"></script>
391 <script src="filters.js"></script>
399 qq|<small style="color:gray">Zadnji puta osvježeno: |,
400 strftime("%Y-%m-%d %H:%M:%S\n", localtime()),
401 qq|</body>\n</html>\n|;
404 mkdir 'html' unless -d 'html';
406 open(my $index, '>:encoding(utf-8)', 'html/index.new');
407 print $index html_title('Bibliografija Filozofskog fakulteta');
409 my $first_letter = '';
411 debug 'authors' => \@authors;
414 my ($biblionumber) = @_;
415 return qq|<li class="y|, $biblio_year->{$biblionumber}, qq|">|,
416 qq|<a href="https://koha.ffzg.hr/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber">$biblionumber</a>|,
417 biblioitem_html($biblionumber),
418 qq|<a href="https://koha.ffzg.hr:8443/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=$biblionumber">edit</a>|,
424 $unique->{$_}++ foreach @_;
425 return keys %$unique;
428 sub unique_biblionumber {
431 $biblio_year->{$b} <=> $biblio_year->{$a} ||
432 $biblio_full_name->{$a} cmp $biblio_full_name->{$b} ||
438 my ( $fh, $authid, $type, $label ) = @_;
440 return unless exists $authors->{$authid}->{$type};
442 print $fh qq|<a name="$type"><h2>$label</h2></a>\n|;
444 foreach my $category ( sort keys %{ $authors->{$authid}->{$type} } ) {
445 my $label = $category_label->{$category} || 'Bez kategorije';
446 print $fh qq|<a name="$type-$category"><h3>$label</h3></a>\n<ol>\n|;
447 foreach my $biblionumber ( unique_biblionumber @{ $authors->{$authid}->{$type}->{$category} } ) {
448 print $fh li_biblio( $biblionumber );
450 print $fh qq|</ol>\n|;
454 my @toc_type_label = (
455 'aut' => 'Primarno autorstvo',
456 'edt' => 'Uredništva',
457 'trl' => 'Prijevodi',
458 '_ostalo' => 'Ostalo',
462 sub count_author_years {
465 foreach my $type ( keys %{ $authors->{$authid} } ) {
466 # next if $type =~ m/^_/; # FIXME
467 foreach my $category ( keys %{ $authors->{$authid}->{$type} } ) {
468 foreach my $biblionumber ( unique_biblionumber @{ $authors->{$authid}->{$type}->{$category} } ) {
469 $years->{ $biblio_year->{ $biblionumber } }->{ $type . '-' . $category }->{ $biblionumber }++;
476 sub html_year_selection {
478 my @authids = unique @_;
480 debug 'html_year_selection authids=', [ @authids ];
482 print $fh qq|<span id="years">Godine:\n|;
483 my $type_cat_count = {};
486 foreach my $authid ( @authids ) {
487 $years = count_author_years( $years, $authid );
490 debug 'years' => $years;
492 foreach my $year ( sort { $b <=> $a } keys %$years ) {
493 print $fh qq|<label><input name="year_selection" value="$year" type=checkbox onClick="toggle_year($year, this)" checked="checked">$year</label> \n|;
494 foreach my $type_cat ( keys %{ $years->{$year} } ) {
495 my $count = scalar keys %{ $years->{$year}->{$type_cat} };
496 $years->{$year}->{$type_cat} = $count; # remove biblionumbers and use count
497 $type_cat_count->{ $type_cat } += $count;
498 my ($type,$cat) = split(/-/, $type_cat);
499 $type_cat_count->{_toc}->{$type}->{$cat}++;
500 $type_cat_count->{_toc_count}->{$type} += $count;
505 <input type=button value="all" onClick="all_years(1)">
506 <input type=button value="none" onClick="all_years(0)">
509 print $fh qq|</span>|;
514 var years = |, encode_json($years), q|;
516 var type_cat_count = |, encode_json($type_cat_count), q|;
522 debug 'type_cat_count' => $type_cat_count;
525 print $fh qq|<ul id="toc">\n|;
527 while ( $i < $#toc_type_label ) {
528 my $type = $toc_type_label[$i++] || die "type";
529 my $label = $toc_type_label[$i++] || die "label";
530 next unless exists $type_cat_count->{_toc}->{$type};
531 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|;
532 foreach my $category ( sort keys %{ $type_cat_count->{_toc}->{$type} } ) {
533 my $label = $category_label->{$category} || 'Bez kategorije';
534 my $count = $type_cat_count->{ $type . '-' . $category };
535 my $cat_html = $category;
536 $cat_html =~ s/\./-/g;
537 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|;
539 print $fh qq| </ul>\n|;
541 print $fh qq|</ul>\n|;
546 foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) {
548 my $first = substr( $row->{full_name}, 0, 1 );
549 if ( $first ne $first_letter ) {
550 print $index qq{</ul>\n} if $first_letter;
551 $first_letter = $first;
552 print $index qq{<h1>$first</h1>\n<ul>\n};
554 print $index qq{<li><a href="}, $row->{authid}, qq{.html">}, $row->{full_name}, "</a></li>\n";
556 my $path = "html/$row->{authid}";
557 open(my $fh, '>:encoding(utf-8)', "$path.new");
558 print $fh html_title($row->{full_name}, "bibliografija");
559 print $fh qq|<h1>$row->{full_name} - bibliografija</h1>\n|;
561 html_year_selection $fh => $row->{authid};
564 while ( $i < $#toc_type_label ) {
565 my $type = $toc_type_label[$i++] || die "type";
566 my $label = $toc_type_label[$i++] || die "label";
567 author_html( $fh, $row->{authid}, $type => $label );
572 rename "$path.new", "$path.html";
576 print $index html_end;
578 rename 'html/index.new', 'html/index.html';
580 debug 'auth_header' => $auth_header;
583 my $department_category_author;
584 foreach my $department ( sort keys %$auth_department ) {
585 foreach my $authid ( sort @{ $auth_department->{$department} } ) {
586 my @categories = keys %{ $authors->{$authid}->{aut} };
587 push @categories, keys %{ $authors->{$authid}->{__sec} };
588 foreach my $category ( sort @categories ) {
589 push @{ $department_category_author->{$department}->{$category} }, $authid;
590 push @{ $department_category_author->{'AAA_ukupno'}->{$category} }, $authid if $department_in_sum->{$department};
591 if ( my $group = $department_in_group->{ $department } ) {
592 push @{ $department_category_author->{$group}->{$category} }, $authid;
594 $skip->{'department_not_in_group'}->{ $department }++;
600 debug 'department_category_author' => $department_category_author;
603 sub department_html {
604 my ( $fh, $department, $type, $label, $csv_fh ) = @_;
606 print $fh qq|<a name="$type"><h2>$label</h2></a>\n|;
608 foreach my $category ( sort keys %{ $department_category_author->{$department} } ) {
610 my @authids = @{ $department_category_author->{$department}->{$category} };
611 next unless @authids;
613 my @biblionumber = unique_biblionumber map { @{ $authors->{$_}->{$type}->{$category} } } grep { exists $authors->{$_}->{$type}->{$category} } @authids;
615 next unless @biblionumber;
617 my $cat_label = $category_label->{$category} || 'Bez kategorije';
618 print $fh qq|<a name="$type-$category"><h3>$cat_label</h3></a>\n<ol>\n|;
620 foreach my $bib_num ( @biblionumber ) {
621 my @li = li_biblio( $bib_num );
622 my $li_html = join('', @li);
623 $li_html =~ s{<hr/?>}{}g;
630 $html =~ s{<hr/?>}{\t}gs;
631 # $html =~ s{</?[^>]*>}{}gs;
632 $html =~ s{\s+$}{}gs;
633 print $csv_fh "$bib_num\t$year\t$type\t$label\t$category\t$cat_label\t$html\n";
642 mkdir 'html/departments' unless -d 'html/departments';
644 open(my $dep_fh, '>:encoding(utf-8)', 'html/departments/index.new');
645 print $dep_fh html_title('Odsjeci Filozofskog fakulteta u Zagrebu'), qq|<ul>\n|;
646 foreach my $department ( sort keys %$department_category_author ) {
647 my $dep = $department || 'Nema odsjeka';
648 my $dep_file = unac_string('utf-8',$dep);
649 print $dep_fh qq|<li><a href="$dep_file.html">$dep</a></li>\n|;
650 open(my $fh, '>:encoding(utf-8)', "html/departments/$dep_file.new");
652 print $fh html_title($department . ' bibliografija');
653 print $fh qq|<h1>$department bibliografija</h1>\n|;
656 foreach my $category ( sort keys %{ $department_category_author->{$department} } ) {
657 push @authids, @{ $department_category_author->{$department}->{$category} };
659 html_year_selection $fh => @authids;
662 if ( $department eq 'AAA_ukupno' ) {
663 open($csv_fh, '>:encoding(utf-8)', "html/departments/$department.csv");
667 while ( $i < $#toc_type_label ) {
668 my $type = $toc_type_label[$i++] || die "type";
669 my $label = $toc_type_label[$i++] || die "label";
670 department_html( $fh, $department, $type, $label, $csv_fh );
673 close($csv_fh) if $csv_fh;
677 rename "html/departments/$dep_file.new", "html/departments/$dep_file.html";
680 print $dep_fh qq|</ul>\n|, html_end;
682 rename 'html/departments/index.new', 'html/departments/index.html';
684 my $azvo_stat_biblio;
686 foreach my $department ( sort keys %$department_category_author ) {
687 foreach my $category ( sort keys %{ $department_category_author->{$department} } ) {
688 foreach my $authid ( @{ $department_category_author->{$department}->{$category} } ) {
689 my $group = $auth_group->{$authid};
691 push @{ $skip->{no_auth_group} }, $authid;
694 foreach my $type ( keys %{ $authors->{$authid} } ) {
695 next unless exists $authors->{$authid}->{$type}->{$category};
696 push @{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{$group} }, @{ $authors->{$authid}->{$type}->{$category} };
697 push @{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{''} }, @{ $authors->{$authid}->{$type}->{$category} };
700 foreach my $type ( keys %{ $azvo_stat_biblio->{ $department }->{ $category } } ) {
701 foreach my $group ( keys %{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type } } ) {
702 my @biblios = unique_biblionumber @{ $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{ $group } };
703 $azvo_stat_biblio->{ $department }->{ $category }->{ $type }->{ $group } = [ @biblios ];
709 debug 'azvo_stat_biblio' => $azvo_stat_biblio;
716 open(my $report, '<:encoding(utf-8)', 'AZVO.txt');
719 if ( /^([^\t]+)\t+(.+)/ ) {
721 push @report_labels, $label;
722 my $type = [ map { m/\s+/ ? [ split(/\s+/,$_) ] : [ $_, 'aut' ] } split (/\s*\+\s*/, $2) ];
723 push @report_lines, [ $label, @$type ];
724 } elsif ( /^\t+([^\t]+):\t+(\d+)(\w*)\t*(.*)$/ ) {
725 push @{ $sub_labels->{$label} }, [ $1, $2, $3, $4 ];
727 pop (@report_labels) if ( $report_labels[ $#report_labels ] =~ m/^$label$/ ); # remove partial name
728 push @report_labels, $label . $sub_label;
734 debug 'report_lines', \@report_lines;
735 debug 'sub_labels', $sub_labels;
736 debug 'report_labels', \@report_labels;
738 my @departments = ( sort { lc($a) cmp lc($b) } keys %$azvo_stat_biblio );
740 debug 'departments' => \@departments;
743 $department2col->{ $departments[$_] } = $_ foreach ( 0 .. $#departments );
745 $label2row->{ $report_labels[$_] } = $_ foreach ( 0 .. $#report_labels );
750 my $label = shift @_;
751 my $department = shift @_;
752 my $group = shift @_;
753 my @biblionumbers = unique @_;
754 $table->{ffzg}->{$group}->[ $label2row->{ $label } ]->[ $department2col->{$department} ] = scalar @biblionumbers;
755 $table->{external}->{$group}->[ $label2row->{ $label } ]->[ $department2col->{$department} ] = scalar grep { $biblio_author_external->{$_} } @biblionumbers;
758 foreach my $group ( '', keys %$azvo_group_title ) {
760 foreach my $department ( @departments ) {
761 foreach my $line ( @report_lines ) {
762 my $label = $line->[0];
764 foreach ( 1 .. $#$line ) {
765 my ( $category, $type ) = @{ $line->[ $_ ] };
766 my $b = $azvo_stat_biblio->{ $department }->{$category}->{$type}->{$group};
767 push @biblionumbers, @$b if $b;
769 if ( $sub_labels->{$label} ) {
771 foreach my $biblionumber ( @biblionumbers ) {
772 my $data = $biblio_data->{$biblionumber} || die "can't find biblionumber $biblionumber";
773 foreach my $sub_label ( @{ $sub_labels->{$label} } ) {
774 my ( $sub_label, $field, $sf, $regex ) = @$sub_label;
776 push @{ $sub_stats->{ $sub_label } }, $biblionumber;
779 if ( $field < 100 ) {
780 if ( $data->{$field} =~ m/$regex/ ) {
781 push @{ $sub_stats->{ $sub_label } }, $biblionumber;
785 if ( exists $data->{$field}->[0]->{$sf} && $data->{$field}->[0]->{$sf} =~ m/$regex/ ) {
786 push @{ $sub_stats->{ $sub_label } }, $biblionumber;
792 foreach my $sub_label ( keys %$sub_stats ) {
793 my $full_label = $label . $sub_label;
794 table_count $full_label, $department, $group, @{ $sub_stats->{$sub_label} };
797 table_count $label, $department, $group, @biblionumbers;
804 debug 'table', $table;
806 open(my $fh, '>:encoding(utf-8)', 'html/azvo.new');
807 open(my $fh2, '>:encoding(utf-8)', 'html/azvo2.new');
814 print $fh html_title('AZVO tablica - FFZG');
815 print $fh2 html_title('AZVO tablica - kolaboracija sa FFZG');
817 foreach my $group ( keys %{ $table->{ffzg} } ) {
819 print_fh "<h1>$group</h1>" if $group;
821 print_fh "<table border=1>\n";
822 print_fh "<tr><th></th>";
823 print_fh "<th>$_</th>" foreach @departments;
826 foreach my $row ( 0 .. $#{ $table->{ffzg}->{$group} } ) {
827 print_fh "<tr><th>", $report_labels[$row], "</th>\n";
828 foreach ( 0 .. $#departments ) {
830 print $fh $table->{ffzg}->{$group}->[ $row ]->[ $_ ] || '';
831 print $fh2 $table->{external}->{$group}->[ $row ]->[ $_ ] || '';
837 print_fh "</table>\n";
844 rename 'html/azvo.new', 'html/azvo.html';
845 rename 'html/azvo2.new', 'html/azvo2.html';