Lines 284-289
if ( $op and $op eq 'serialchangestatus' ) {
Link Here
|
284 |
my @itemid = $query->multi_param('itemid'); |
284 |
my @itemid = $query->multi_param('itemid'); |
285 |
my @ind_tag = $query->multi_param('ind_tag'); |
285 |
my @ind_tag = $query->multi_param('ind_tag'); |
286 |
my @indicator = $query->multi_param('indicator'); |
286 |
my @indicator = $query->multi_param('indicator'); |
|
|
287 |
my @num_copies = $query->multi_param('number_of_copies'); |
287 |
|
288 |
|
288 |
#Rebuilding ALL the data for items into a hash |
289 |
#Rebuilding ALL the data for items into a hash |
289 |
# parting them on $itemid. |
290 |
# parting them on $itemid. |
Lines 310-315
if ( $op and $op eq 'serialchangestatus' ) {
Link Here
|
310 |
$field_values[$i]; |
311 |
$field_values[$i]; |
311 |
push @{ $itemhash{ $itemid[$i] }->{'ind_tag'} }, $ind_tag[$i]; |
312 |
push @{ $itemhash{ $itemid[$i] }->{'ind_tag'} }, $ind_tag[$i]; |
312 |
push @{ $itemhash{ $itemid[$i] }->{'indicator'} }, $indicator[$i]; |
313 |
push @{ $itemhash{ $itemid[$i] }->{'indicator'} }, $indicator[$i]; |
|
|
314 |
push @{ $itemhash{ $itemid[$i] }->{'num_copies'} }, $num_copies[$i]; |
313 |
} |
315 |
} |
314 |
foreach my $item ( keys %itemhash ) { |
316 |
foreach my $item ( keys %itemhash ) { |
315 |
|
317 |
|
Lines 333-343
if ( $op and $op eq 'serialchangestatus' ) {
Link Here
|
333 |
$itemhash{$item}->{'ind_tag'} |
335 |
$itemhash{$item}->{'ind_tag'} |
334 |
); |
336 |
); |
335 |
|
337 |
|
336 |
# warn $xml; |
338 |
# warn $xml; |
337 |
my $bib_record = MARC::Record::new_from_xml( $xml, 'UTF-8' ); |
339 |
my $bib_record = MARC::Record::new_from_xml( $xml, 'UTF-8' ); |
338 |
if ( $item =~ /^N/ ) { |
340 |
if ( $item =~ /^N/ ) { |
339 |
|
341 |
|
340 |
#New Item |
342 |
$itemhash{$item}->{'num_copies'} //= 1; |
|
|
343 |
|
344 |
for (my $copy = 0; $copy < $itemhash{$item}->{'num_copies'}[$index];){ |
345 |
|
346 |
# New Item |
341 |
|
347 |
|
342 |
# if autoBarcode is set to 'incremental', calculate barcode... |
348 |
# if autoBarcode is set to 'incremental', calculate barcode... |
343 |
my ( $barcodetagfield, $barcodetagsubfield ) = GetMarcFromKohaField( 'items.barcode' ); |
349 |
my ( $barcodetagfield, $barcodetagsubfield ) = GetMarcFromKohaField( 'items.barcode' ); |
Lines 356-376
if ( $op and $op eq 'serialchangestatus' ) {
Link Here
|
356 |
$sth_barcode->execute; |
362 |
$sth_barcode->execute; |
357 |
my ($newbarcode) = $sth_barcode->fetchrow; |
363 |
my ($newbarcode) = $sth_barcode->fetchrow; |
358 |
|
364 |
|
359 |
# OK, we have the new barcode, add the entry in MARC record # FIXME -> should be using barcode plugin here. |
365 |
# OK, we have the new barcode, add the entry in MARC record # FIXME -> should be using barcode plugin here. |
360 |
$bib_record->field($barcodetagfield) |
366 |
$bib_record->field($barcodetagfield)->update( $barcodetagsubfield => ++$newbarcode ); |
361 |
->update( $barcodetagsubfield => ++$newbarcode ); |
|
|
362 |
} |
367 |
} |
363 |
} |
368 |
} |
364 |
|
369 |
|
365 |
# check for item barcode # being unique |
370 |
# check for item barcode # being unique |
366 |
my $exists; |
371 |
my $exists; |
367 |
if ( |
372 |
if ( $bib_record->subfield( $barcodetagfield, $barcodetagsubfield ) ) { |
368 |
$bib_record->subfield( |
|
|
369 |
$barcodetagfield, $barcodetagsubfield |
370 |
) |
371 |
) |
372 |
{ |
373 |
my $barcode = $bib_record->subfield( $barcodetagfield, $barcodetagsubfield ); |
373 |
my $barcode = $bib_record->subfield( $barcodetagfield, $barcodetagsubfield ); |
|
|
374 |
|
375 |
if ($copy > 0){ |
376 |
use C4::Barcodes; |
377 |
my $barcodeobj = C4::Barcodes->new; |
378 |
my $newbarcode = $barcodeobj->next_value($barcode); |
379 |
$barcode = $newbarcode; |
380 |
$bib_record->field($barcodetagfield)->update($barcodetagsubfield => $barcode); |
381 |
} |
382 |
|
374 |
$exists = Koha::Items->find({barcode => $barcode}); |
383 |
$exists = Koha::Items->find({barcode => $barcode}); |
375 |
} |
384 |
} |
376 |
|
385 |
|
Lines 387-393
if ( $op and $op eq 'serialchangestatus' ) {
Link Here
|
387 |
AddItem2Serial( $itemhash{$item}->{serial}, |
396 |
AddItem2Serial( $itemhash{$item}->{serial}, |
388 |
$itemnumber ); |
397 |
$itemnumber ); |
389 |
} |
398 |
} |
|
|
399 |
$copy++; |
390 |
} |
400 |
} |
|
|
401 |
|
402 |
} # num_copies for loop |
403 |
|
391 |
else { |
404 |
else { |
392 |
|
405 |
|
393 |
#modify item |
406 |
#modify item |
394 |
- |
|
|