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

(-)a/C4/Items.pm (-5 / +12 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[, $dbh]);
147
      = AddItemFromMarc($source_item_marc, $biblionumber[, $dbh, $postpone_indexes_update]);
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 155-160 sub AddItemFromMarc { Link Here
155
    my $source_item_marc        = shift;
155
    my $source_item_marc        = shift;
156
    my $biblionumber            = shift;
156
    my $biblionumber            = shift;
157
    my $dbh                     = @_ ? shift : C4::Context->dbh;
157
    my $dbh                     = @_ ? shift : C4::Context->dbh;
158
    my $postpone_indexes_update = @_ ? shift : undef;
158
159
159
    # parse item hash from MARC
160
    # parse item hash from MARC
160
    my $frameworkcode = C4::Biblio::GetFrameworkCode($biblionumber);
161
    my $frameworkcode = C4::Biblio::GetFrameworkCode($biblionumber);
Lines 164-176 sub AddItemFromMarc { Link Here
164
    $localitemmarc->append_fields( $source_item_marc->field($itemtag) );
165
    $localitemmarc->append_fields( $source_item_marc->field($itemtag) );
165
    my $item = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
166
    my $item = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
166
    my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode );
167
    my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode );
167
    return AddItem( $item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields );
168
    return AddItem( $item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields, $postpone_indexes_update );
168
}
169
}
169
170
170
=head2 AddItem
171
=head2 AddItem
171
172
172
  my ($biblionumber, $biblioitemnumber, $itemnumber) 
173
  my ($biblionumber, $biblioitemnumber, $itemnumber) 
173
      = AddItem($item, $biblionumber[, $dbh, $frameworkcode, $unlinked_item_subfields]);
174
      = AddItem($item, $biblionumber[, $dbh, $frameworkcode, $unlinked_item_subfields, $postpone_indexes_update]);
174
175
175
Given a hash containing item column names as keys,
176
Given a hash containing item column names as keys,
176
create a new Koha item record.
177
create a new Koha item record.
Lines 179-191 The first two optional parameters (C<$dbh> and C<$frameworkcode>) Link Here
179
do not need to be supplied for general use; they exist
180
do not need to be supplied for general use; they exist
180
simply to allow them to be picked up from AddItemFromMarc.
181
simply to allow them to be picked up from AddItemFromMarc.
181
182
182
The final optional parameter, C<$unlinked_item_subfields>, contains
183
Optional parameter, C<$unlinked_item_subfields>, contains
183
an arrayref containing subfields present in the original MARC
184
an arrayref containing subfields present in the original MARC
184
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
185
not mapped to C<items> columns directly but should instead
186
not mapped to C<items> columns directly but should instead
186
be stored in C<items.more_subfields_xml> and included in 
187
be stored in C<items.more_subfields_xml> and included in 
187
the biblio items tag for display and indexing.
188
the biblio items tag for display and indexing.
188
189
190
The final optional parameter, C<$postpone_indexes_update>, prevents
191
calling of ModZebra sub so this used when adding items in a batch and
192
then ModZebra called in C<additem.pl> after the whole loop.
193
189
=cut
194
=cut
190
195
191
sub AddItem {
196
sub AddItem {
Lines 198-203 sub AddItem { Link Here
198
    if (@_) {
203
    if (@_) {
199
        $unlinked_item_subfields = shift;
204
        $unlinked_item_subfields = shift;
200
    }
205
    }
206
    my $postpone_indexes_update = @_ ? shift : undef;
201
207
202
    # needs old biblionumber and biblioitemnumber
208
    # needs old biblionumber and biblioitemnumber
203
    $item->{'biblionumber'} = $biblionumber;
209
    $item->{'biblionumber'} = $biblionumber;
Lines 221-227 sub AddItem { Link Here
221
227
222
    $item->{'itemnumber'} = $itemnumber;
228
    $item->{'itemnumber'} = $itemnumber;
223
229
224
    C4::Biblio::ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" );
230
    C4::Biblio::ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" )
231
        unless $postpone_indexes_update;
225
232
226
    logaction( "CATALOGUING", "ADD", $itemnumber, "item" )
233
    logaction( "CATALOGUING", "ADD", $itemnumber, "item" )
227
      if C4::Context->preference("CataloguingLog");
234
      if C4::Context->preference("CataloguingLog");
(-)a/cataloguing/additem.pl (-2 / +4 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, $dbh);
603
            my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc( $record, $biblionumber, $dbh, 1 );
604
            set_item_default_location($oldbibitemnum);
604
            set_item_default_location($oldbibitemnum);
605
605
606
            # We count the item only if it was really added
606
            # We count the item only if it was really added
Lines 614-619 if ($op eq "additem") { Link Here
614
		# Preparing the next iteration
614
		# Preparing the next iteration
615
		$oldbarcode = $barcodevalue;
615
		$oldbarcode = $barcodevalue;
616
	    }
616
	    }
617
618
	    C4::Biblio::ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
619
617
	    undef($itemrecord);
620
	    undef($itemrecord);
618
	}
621
	}
619
    }	
622
    }	
620
- 

Return to bug 24027