View | Details | Raw Unified | Return to bug 24027
Collapse All | Expand All

(-)a/C4/Items.pm (-6 / +19 lines)
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
148
149
Given a MARC::Record object containing an embedded item
149
Given a MARC::Record object containing an embedded item
150
record and a biblionumber, create a new item record.
150
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
152
=cut
153
153
154
sub AddItemFromMarc {
154
sub AddItemFromMarc {
155
    my ( $source_item_marc, $biblionumber ) = @_;
155
    my $source_item_marc = shift;
156
    my $biblionumber     = shift;
157
    my $hash_params      = @_ ? shift : {};
158
156
    my $dbh = C4::Context->dbh;
159
    my $dbh = C4::Context->dbh;
157
160
158
    # parse item hash from MARC
161
    # parse item hash from MARC
Lines 163-175 sub AddItemFromMarc { Link Here
163
    $localitemmarc->append_fields( $source_item_marc->field($itemtag) );
166
    $localitemmarc->append_fields( $source_item_marc->field($itemtag) );
164
    my $item = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
167
    my $item = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
165
    my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode );
168
    my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode );
166
    return AddItem( $item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields );
169
    return AddItem( $item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields, $hash_params );
167
}
170
}
168
171
169
=head2 AddItem
172
=head2 AddItem
170
173
171
  my ($biblionumber, $biblioitemnumber, $itemnumber) 
174
  my ($biblionumber, $biblioitemnumber, $itemnumber) 
172
      = AddItem($item, $biblionumber[, $dbh, $frameworkcode, $unlinked_item_subfields]);
175
      = AddItem($item, $biblionumber[, $dbh, $frameworkcode, $unlinked_item_subfields, $hash_params]);
173
176
174
Given a hash containing item column names as keys,
177
Given a hash containing item column names as keys,
175
create a new Koha item record.
178
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
181
do not need to be supplied for general use; they exist
179
simply to allow them to be picked up from AddItemFromMarc.
182
simply to allow them to be picked up from AddItemFromMarc.
180
183
181
The final optional parameter, C<$unlinked_item_subfields>, contains
184
Optional parameter, C<$unlinked_item_subfields>, contains
182
an arrayref containing subfields present in the original MARC
185
an arrayref containing subfields present in the original MARC
183
representation of the item (e.g., from the item editor) that are
186
representation of the item (e.g., from the item editor) that are
184
not mapped to C<items> columns directly but should instead
187
not mapped to C<items> columns directly but should instead
185
be stored in C<items.more_subfields_xml> and included in 
188
be stored in C<items.more_subfields_xml> and included in 
186
the biblio items tag for display and indexing.
189
the biblio items tag for display and indexing.
187
190
191
The final optional parameter, C<$hash_params>, for now expected to contain 
192
'postpone_indexes_update' key, which when true prevents calling of ModZebra sub
193
so this used when adding items in a batch and then ModZebra called in
194
C<additem.pl> after the whole loop.
195
196
$hash_params:
197
    postpone_indexes_update => true / false
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");
(-)a/cataloguing/additem.pl (-2 / +5 lines)
Lines 600-606 if ($op eq "additem") { Link Here
600
600
601
		# Adding the item
601
		# Adding the item
602
        if (!$exist_itemnumber) {
602
        if (!$exist_itemnumber) {
603
            my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber);
603
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) =
604
                AddItemFromMarc( $record, $biblionumber, { postpone_indexes_update => 1 } );
604
            set_item_default_location($oldbibitemnum);
605
            set_item_default_location($oldbibitemnum);
605
606
606
            # We count the item only if it was really added
607
            # We count the item only if it was really added
Lines 614-619 if ($op eq "additem") { Link Here
614
		# Preparing the next iteration
615
		# Preparing the next iteration
615
		$oldbarcode = $barcodevalue;
616
		$oldbarcode = $barcodevalue;
616
	    }
617
	    }
618
619
	    C4::Biblio::ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
620
617
	    undef($itemrecord);
621
	    undef($itemrecord);
618
	}
622
	}
619
    }	
623
    }	
620
- 

Return to bug 24027