3 # Copyright 2013 C & P Bibliography Services
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 Koha::Record - base class for MARC records
26 my $record = new Koha::Record({ 'record' => $marcrecord });
30 Object-oriented class that encapsulates all records in Koha.
39 use base qw(Class::Accessor);
41 __PACKAGE__->mk_accessors(qw( record marcflavour ));
46 Create a MARC hash for use when merging records.
51 my ($self, $tagslib) = @_;
52 my $record = $self->record;
54 my @fields = $record->fields();
57 foreach my $field (@fields) {
58 my $fieldtag = $field->tag();
60 if (!defined($tagslib) || $tagslib->{$fieldtag}->{'@'}->{'tab'} >= 0) {
66 value => $field->data(),
72 my @subfields = $field->subfields();
74 foreach my $subfield (@subfields) {
75 if (!defined($tagslib) || $tagslib->{$fieldtag}->{@$subfield[0]}->{'tab'} >= 0) {
76 push @subfield_array, {
77 subtag => @$subfield[0],
78 subkey => _createKey(),
79 value => @$subfield[1],
85 if ((!defined($tagslib) || $tagslib->{$fieldtag}->{'tab'} >= 0) && $fieldtag ne '995' && $fieldtag ne '999') {
91 indicator1 => $field->indicator(1),
92 indicator2 => $field->indicator(2),
93 subfield => [@subfield_array],
107 Create a random value to set it into the input name
112 return int(rand(1000000));