Bug 26265: (QA follow-up) Remove g option from regex, add few dirs
[koha-equinox.git] / serials / serials-edit.pl
index 749e126..6277791 100755 (executable)
@@ -268,7 +268,12 @@ if ( $op and $op eq 'serialchangestatus' ) {
                     my $subscriptioninfos = GetSubscription($subscriptionids[$i]);
 
                     # Changing the status to "available" and the itemtype according to the previousitemtype db field
-                    ModItem({notforloan => 0, itype => $subscriptioninfos->{'previousitemtype'} }, undef, $itemnumber);
+                    $serialitem->set(
+                        {
+                            notforloan => 0,
+                            itype => $subscriptioninfos->{'previousitemtype'}
+                        }
+                    )->store;
                 }
             }
         }
@@ -289,7 +294,7 @@ if ( $op and $op eq 'serialchangestatus' ) {
         #Rebuilding ALL the data for items into a hash
         # parting them on $itemid.
         my %itemhash;
-        my $countdistinct;
+        my $countdistinct = 0;
         my $range = scalar(@itemid);
         for ( my $i = 0 ; $i < $range ; $i++ ) {
             unless ( $itemhash{ $itemid[$i] } ) {
@@ -303,6 +308,7 @@ if ( $op and $op eq 'serialchangestatus' ) {
                     $itemhash{ $itemid[$i] }->{'serial'} = $newserial;
                 }
                 $itemhash{ $itemid[$i] }->{'bibnum'} = $bibnums[$countdistinct];
+                $itemhash{ $itemid[$i] }->{'num_copies'} = $num_copies[$countdistinct];
                 $countdistinct++;
             }
             push @{ $itemhash{ $itemid[$i] }->{'tags'} },      $tags[$i];
@@ -311,7 +317,6 @@ if ( $op and $op eq 'serialchangestatus' ) {
               $field_values[$i];
             push @{ $itemhash{ $itemid[$i] }->{'ind_tag'} },   $ind_tag[$i];
             push @{ $itemhash{ $itemid[$i] }->{'indicator'} }, $indicator[$i];
-            push @{ $itemhash{ $itemid[$i] }->{'num_copies'} }, $num_copies[$i];
         }
         foreach my $item ( keys %itemhash ) {
 
@@ -341,7 +346,7 @@ if ( $op and $op eq 'serialchangestatus' ) {
 
                 $itemhash{$item}->{'num_copies'} //= 1;
 
-                for (my $copy = 0; $copy < $itemhash{$item}->{'num_copies'}[$index];){
+                for (my $copy = 0; $copy < $itemhash{$item}->{'num_copies'};){
 
                 # New Item
 
@@ -399,7 +404,7 @@ if ( $op and $op eq 'serialchangestatus' ) {
                     $copy++;
                 }
 
-                } # num_copies for loop
+                } # if ( $item =~ /^N/ ) {
 
                 else {