Lines 159-224
sub AddItemFromMarc {
Link Here
|
159 |
my $localitemmarc = MARC::Record->new; |
159 |
my $localitemmarc = MARC::Record->new; |
160 |
$localitemmarc->append_fields( $source_item_marc->field($itemtag) ); |
160 |
$localitemmarc->append_fields( $source_item_marc->field($itemtag) ); |
161 |
|
161 |
|
162 |
#RMME |
|
|
163 |
my $item = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); |
164 |
my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); |
165 |
return AddItem( $item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields ); |
166 |
|
167 |
my $item_values = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); |
162 |
my $item_values = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); |
|
|
163 |
my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); |
164 |
$item_values->{more_subfields_xml} = _get_unlinked_subfields_xml($unlinked_item_subfields); |
168 |
$item_values->{biblionumber} = $biblionumber; |
165 |
$item_values->{biblionumber} = $biblionumber; |
169 |
# FIXME RM my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); |
166 |
my $item = Koha::Item->new( $item_values )->store; |
170 |
my $item = Koha::Item->new( $item_values ); # FIXME Handle $unlinked_item_subfields |
|
|
171 |
return ( $item->biblionumber, $item->biblioitemnumber, $item->itemnumber ); |
167 |
return ( $item->biblionumber, $item->biblioitemnumber, $item->itemnumber ); |
172 |
} |
168 |
} |
173 |
|
169 |
|
174 |
=head2 AddItem |
|
|
175 |
|
176 |
my ($biblionumber, $biblioitemnumber, $itemnumber) |
177 |
= AddItem($item, $biblionumber[, $dbh, $frameworkcode, $unlinked_item_subfields]); |
178 |
|
179 |
Given a hash containing item column names as keys, |
180 |
create a new Koha item record. |
181 |
|
182 |
The first two optional parameters (C<$dbh> and C<$frameworkcode>) |
183 |
do not need to be supplied for general use; they exist |
184 |
simply to allow them to be picked up from AddItemFromMarc. |
185 |
|
186 |
The final optional parameter, C<$unlinked_item_subfields>, contains |
187 |
an arrayref containing subfields present in the original MARC |
188 |
representation of the item (e.g., from the item editor) that are |
189 |
not mapped to C<items> columns directly but should instead |
190 |
be stored in C<items.more_subfields_xml> and included in |
191 |
the biblio items tag for display and indexing. |
192 |
|
193 |
=cut |
194 |
|
195 |
sub AddItem { |
196 |
my $item = shift; |
197 |
my $biblionumber = shift; |
198 |
|
199 |
my $dbh = @_ ? shift : C4::Context->dbh; |
200 |
my $unlinked_item_subfields; |
201 |
if (@_) { |
202 |
$unlinked_item_subfields = shift; |
203 |
} |
204 |
|
205 |
$item->{'more_subfields_xml'} = _get_unlinked_subfields_xml($unlinked_item_subfields); |
206 |
|
207 |
my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} ); |
208 |
return if $error; |
209 |
|
210 |
$item->{'itemnumber'} = $itemnumber; |
211 |
|
212 |
C4::Biblio::ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" ); |
213 |
|
214 |
logaction( "CATALOGUING", "ADD", $itemnumber, "item" ) |
215 |
if C4::Context->preference("CataloguingLog"); |
216 |
|
217 |
_after_item_action_hooks({ action => 'create', item_id => $itemnumber }); |
218 |
|
219 |
return ( $item->{biblionumber}, $item->{biblioitemnumber}, $itemnumber ); |
220 |
} |
221 |
|
222 |
=head2 AddItemBatchFromMarc |
170 |
=head2 AddItemBatchFromMarc |
223 |
|
171 |
|
224 |
($itemnumber_ref, $error_ref) = AddItemBatchFromMarc($record, |
172 |
($itemnumber_ref, $error_ref) = AddItemBatchFromMarc($record, |