|
Lines 38-67
Koha::ERM::EHoldings::Title - Koha ERM Title Object class
Link Here
|
| 38 |
=cut |
38 |
=cut |
| 39 |
|
39 |
|
| 40 |
sub store { |
40 |
sub store { |
| 41 |
my ($self) = @_; |
41 |
my ($self, $args) = @_; |
| 42 |
|
42 |
|
|
|
43 |
my $create_linked_biblio = $args->{create_linked_biblio} || 0; |
| 43 |
# FIXME This is terrible and ugly, we need to: |
44 |
# FIXME This is terrible and ugly, we need to: |
| 44 |
# * Provide a mapping for each attribute of title |
45 |
# * Provide a mapping for each attribute of title |
| 45 |
# * Create a txn |
46 |
# * Create a txn |
| 46 |
|
47 |
|
| 47 |
# If the 'title' is already linked to a biblio, then we update the title subfield only |
48 |
if($create_linked_biblio) { |
| 48 |
if ( $self->biblio_id ) { |
49 |
# If the 'title' is already linked to a biblio, then we update the title subfield only |
| 49 |
my $biblio = Koha::Biblios->find( $self->biblio_id ); |
50 |
if ( $self->biblio_id ) { |
| 50 |
my ( $title_tag, $title_subfield ) = GetMarcFromKohaField('biblio.title'); |
51 |
my $biblio = Koha::Biblios->find( $self->biblio_id ); |
| 51 |
my $record = $biblio->metadata->record(); |
52 |
my ( $title_tag, $title_subfield ) = GetMarcFromKohaField('biblio.title'); |
| 52 |
my $title_field = $record->field($title_tag); |
53 |
my $record = $biblio->metadata->record(); |
| 53 |
$title_field->update( $title_subfield => $self->publication_title ); |
54 |
my $title_field = $record->field($title_tag); |
| 54 |
C4::Biblio::ModBiblio( $record, $self->biblio_id, '' ); |
55 |
$title_field->update( $title_subfield => $self->publication_title ); |
| 55 |
} else { |
56 |
C4::Biblio::ModBiblio( $record, $self->biblio_id, '' ); |
| 56 |
|
57 |
} else { |
| 57 |
# If it's not linked, we create a simple biblio and save the biblio id to the 'title' |
58 |
# If it's not linked, we create a simple biblio and save the biblio id to the 'title' |
| 58 |
my $marc_record = TransformKohaToMarc( |
59 |
my $marc_record = TransformKohaToMarc( |
| 59 |
{ |
60 |
{ |
| 60 |
'biblio.title' => $self->publication_title, |
61 |
'biblio.title' => $self->publication_title, |
| 61 |
} |
62 |
} |
| 62 |
); |
63 |
); |
| 63 |
my ($biblio_id) = C4::Biblio::AddBiblio( $marc_record, '' ); |
64 |
my ($biblio_id) = C4::Biblio::AddBiblio( $marc_record, '' ); |
| 64 |
$self->biblio_id($biblio_id); |
65 |
$self->biblio_id($biblio_id); |
|
|
66 |
} |
| 65 |
} |
67 |
} |
| 66 |
|
68 |
|
| 67 |
$self = $self->SUPER::store; |
69 |
$self = $self->SUPER::store; |