Lines 144-150
sub CartToShelf {
Link Here
|
144 |
=head2 AddItemFromMarc |
144 |
=head2 AddItemFromMarc |
145 |
|
145 |
|
146 |
my ($biblionumber, $biblioitemnumber, $itemnumber) |
146 |
my ($biblionumber, $biblioitemnumber, $itemnumber) |
147 |
= AddItemFromMarc($source_item_marc, $biblionumber); |
147 |
= AddItemFromMarc($source_item_marc, $biblionumber[, $hash_params]); |
|
|
148 |
|
149 |
$hash_params: |
150 |
postpone_indexes_update => true / false |
148 |
|
151 |
|
149 |
Given a MARC::Record object containing an embedded item |
152 |
Given a MARC::Record object containing an embedded item |
150 |
record and a biblionumber, create a new item record. |
153 |
record and a biblionumber, create a new item record. |
Lines 152-158
record and a biblionumber, create a new item record.
Link Here
|
152 |
=cut |
155 |
=cut |
153 |
|
156 |
|
154 |
sub AddItemFromMarc { |
157 |
sub AddItemFromMarc { |
155 |
my ( $source_item_marc, $biblionumber ) = @_; |
158 |
my $source_item_marc = shift; |
|
|
159 |
my $biblionumber = shift; |
160 |
my $hash_params = @_ ? shift : {}; |
161 |
|
156 |
my $dbh = C4::Context->dbh; |
162 |
my $dbh = C4::Context->dbh; |
157 |
|
163 |
|
158 |
# parse item hash from MARC |
164 |
# parse item hash from MARC |
Lines 163-175
sub AddItemFromMarc {
Link Here
|
163 |
$localitemmarc->append_fields( $source_item_marc->field($itemtag) ); |
169 |
$localitemmarc->append_fields( $source_item_marc->field($itemtag) ); |
164 |
my $item = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); |
170 |
my $item = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); |
165 |
my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); |
171 |
my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); |
166 |
return AddItem( $item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields ); |
172 |
return AddItem( $item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields, $hash_params ); |
167 |
} |
173 |
} |
168 |
|
174 |
|
169 |
=head2 AddItem |
175 |
=head2 AddItem |
170 |
|
176 |
|
171 |
my ($biblionumber, $biblioitemnumber, $itemnumber) |
177 |
my ($biblionumber, $biblioitemnumber, $itemnumber) |
172 |
= AddItem($item, $biblionumber[, $dbh, $frameworkcode, $unlinked_item_subfields]); |
178 |
= AddItem($item, $biblionumber[, $dbh, $frameworkcode, $unlinked_item_subfields, $hash_params]); |
173 |
|
179 |
|
174 |
Given a hash containing item column names as keys, |
180 |
Given a hash containing item column names as keys, |
175 |
create a new Koha item record. |
181 |
create a new Koha item record. |
Lines 178-190
The first two optional parameters (C<$dbh> and C<$frameworkcode>)
Link Here
|
178 |
do not need to be supplied for general use; they exist |
184 |
do not need to be supplied for general use; they exist |
179 |
simply to allow them to be picked up from AddItemFromMarc. |
185 |
simply to allow them to be picked up from AddItemFromMarc. |
180 |
|
186 |
|
181 |
The final optional parameter, C<$unlinked_item_subfields>, contains |
187 |
Optional parameter, C<$unlinked_item_subfields>, contains |
182 |
an arrayref containing subfields present in the original MARC |
188 |
an arrayref containing subfields present in the original MARC |
183 |
representation of the item (e.g., from the item editor) that are |
189 |
representation of the item (e.g., from the item editor) that are |
184 |
not mapped to C<items> columns directly but should instead |
190 |
not mapped to C<items> columns directly but should instead |
185 |
be stored in C<items.more_subfields_xml> and included in |
191 |
be stored in C<items.more_subfields_xml> and included in |
186 |
the biblio items tag for display and indexing. |
192 |
the biblio items tag for display and indexing. |
187 |
|
193 |
|
|
|
194 |
The final optional parameter, C<$hash_params>, for now expected to contain |
195 |
'postpone_indexes_update' key, which when true prevents calling of ModZebra sub |
196 |
so this used when adding items in a batch and then ModZebra called in |
197 |
C<additem.pl> after the whole loop. |
198 |
|
188 |
=cut |
199 |
=cut |
189 |
|
200 |
|
190 |
sub AddItem { |
201 |
sub AddItem { |
Lines 197-202
sub AddItem {
Link Here
|
197 |
if (@_) { |
208 |
if (@_) { |
198 |
$unlinked_item_subfields = shift; |
209 |
$unlinked_item_subfields = shift; |
199 |
} |
210 |
} |
|
|
211 |
my $hash_params = @_ ? shift : {}; |
200 |
|
212 |
|
201 |
# needs old biblionumber and biblioitemnumber |
213 |
# needs old biblionumber and biblioitemnumber |
202 |
$item->{'biblionumber'} = $biblionumber; |
214 |
$item->{'biblionumber'} = $biblionumber; |
Lines 220-226
sub AddItem {
Link Here
|
220 |
|
232 |
|
221 |
$item->{'itemnumber'} = $itemnumber; |
233 |
$item->{'itemnumber'} = $itemnumber; |
222 |
|
234 |
|
223 |
C4::Biblio::ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" ); |
235 |
C4::Biblio::ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" ) |
|
|
236 |
unless $hash_params->{postpone_indexes_update}; |
224 |
|
237 |
|
225 |
logaction( "CATALOGUING", "ADD", $itemnumber, "item" ) |
238 |
logaction( "CATALOGUING", "ADD", $itemnumber, "item" ) |
226 |
if C4::Context->preference("CataloguingLog"); |
239 |
if C4::Context->preference("CataloguingLog"); |