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

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