nAZVO.txt report config
[koha-bibliografija] / department_marc.pl
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use Data::Dump qw(dump);
7 use autodie;
8 use Storable;
9
10 use lib '/srv/koha_ffzg';
11 use C4::Context;
12
13 my $dbh = C4::Context->dbh;
14
15 sub debug {
16         my ($title, $data) = @_;
17         print "# $title ",dump($data), $/ if $ENV{DEBUG};
18 }
19
20 my $auth_department = retrieve '/dev/shm/auth_department.storable';
21
22 my $authors = retrieve '/dev/shm/authors.storable';
23
24 my $sth_marc  = $dbh->prepare(q{
25 select
26         marc
27 from biblioitems
28 where
29         biblionumber = ?
30 });
31
32 my $biblio;
33
34 foreach ( keys %$auth_department ) {
35         next unless m/psiho/;
36
37         foreach my $auth ( @{ $auth_department->{$_} } ) {
38                 foreach my $l1 ( keys %{ $authors->{$auth} } ) {
39                         foreach my $l2 ( keys %{ $authors->{$auth}->{$l1} } ) {
40                                 foreach my $biblionumber ( @{ $authors->{$auth}->{$l1}->{$l2} } ) {
41                                         $biblio->{$biblionumber}++;
42
43                                 }
44                         }
45                 }
46         }
47
48         my $marc_file = "/dev/shm/$_.marc";
49         warn "# $marc_file\n";
50
51         open(my $marc_fh, '>', $marc_file);
52
53         foreach my $biblionumber ( sort keys %$biblio ) {
54                 $sth_marc->execute($biblionumber);
55                 my ( $marc ) = $sth_marc->fetchrow_array;
56                 print $marc_fh $marc;
57         }
58
59         close($marc_fh);
60
61 }