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

(-)a/acqui/addorderiso2709.pl (-13 / +13 lines)
Lines 135-141 if ($op eq ""){ Link Here
135
135
136
    # retrieve the file you want to import
136
    # retrieve the file you want to import
137
    my $import_batch_id = $cgiparams->{'import_batch_id'};
137
    my $import_batch_id = $cgiparams->{'import_batch_id'};
138
    my $biblios = GetImportRecordsRange($import_batch_id);
138
    my $import_records = Koha::Import::Records->search({
139
        import_batch_id => $import_batch_id,
140
    });
139
    my $duplinbatch;
141
    my $duplinbatch;
140
    my $imported = 0;
142
    my $imported = 0;
141
    my @import_record_id_selected = $input->multi_param("import_record_id");
143
    my @import_record_id_selected = $input->multi_param("import_record_id");
Lines 149-162 if ($op eq ""){ Link Here
149
    my $matcher_id = $input->param('matcher_id');
151
    my $matcher_id = $input->param('matcher_id');
150
    my $active_currency = Koha::Acquisition::Currencies->get_active;
152
    my $active_currency = Koha::Acquisition::Currencies->get_active;
151
    my $biblio_count = 0;
153
    my $biblio_count = 0;
152
    for my $biblio (@$biblios){
154
    while( my $import_record = $import_records->next ){
153
        $biblio_count++;
155
        $biblio_count++;
154
        my $duplifound = 0;
156
        my $duplifound = 0;
155
        # Check if this import_record_id was selected
157
        # Check if this import_record_id was selected
156
        next if not grep { $_ eq $$biblio{import_record_id} } @import_record_id_selected;
158
        next if not grep { $_ eq $import_record->import_record_id } @import_record_id_selected;
157
        my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} );
159
        my $marcrecord = $import_record->get_marc_record || die "couldn't translate marc information";
158
        my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information";
160
        my $match = GetImportRecordMatches( $import_record->import_record_id, 1 );
159
        my $match = GetImportRecordMatches( $biblio->{'import_record_id'}, 1 );
160
        my $biblionumber=$#$match > -1?$match->[0]->{'biblionumber'}:0;
161
        my $biblionumber=$#$match > -1?$match->[0]->{'biblionumber'}:0;
161
        my $c_quantity = shift( @quantities ) || GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour') ) || 1;
162
        my $c_quantity = shift( @quantities ) || GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour') ) || 1;
162
        my $c_budget_id = shift( @budgets_id ) || $input->param('all_budget_id') || $budget_id;
163
        my $c_budget_id = shift( @budgets_id ) || $input->param('all_budget_id') || $budget_id;
Lines 196-207 if ($op eq ""){ Link Here
196
                }
197
                }
197
            }
198
            }
198
            ( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $cgiparams->{'frameworkcode'} || '' );
199
            ( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $cgiparams->{'frameworkcode'} || '' );
199
            SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' );
200
            $import_record->status('imported')->store;
200
        } else {
201
        } else {
201
            SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' );
202
            $import_record->status('imported')->store;
202
        }
203
        }
203
204
204
        SetMatchedBiblionumber( $biblio->{import_record_id}, $biblionumber );
205
        $import_record->import_biblio->matched_biblionumber($biblionumber)->store;
205
206
206
        # Add items from MarcItemFieldsToOrder
207
        # Add items from MarcItemFieldsToOrder
207
        my @homebranches = $input->multi_param('homebranch_' . $biblio_count);
208
        my @homebranches = $input->multi_param('homebranch_' . $biblio_count);
Lines 358-364 if ($op eq ""){ Link Here
358
                $order->add_item( $itemnumber );
359
                $order->add_item( $itemnumber );
359
                }
360
                }
360
            } else {
361
            } else {
361
                SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' );
362
                $import_record->status( 'imported' )->store;
362
            }
363
            }
363
        }
364
        }
364
        $imported++;
365
        $imported++;
Lines 366-373 if ($op eq ""){ Link Here
366
367
367
    # If all bibliographic records from the batch have been imported we modifying the status of the batch accordingly
368
    # If all bibliographic records from the batch have been imported we modifying the status of the batch accordingly
368
    SetImportBatchStatus( $import_batch_id, 'imported' )
369
    SetImportBatchStatus( $import_batch_id, 'imported' )
369
        if    @{ GetImportRecordsRange( $import_batch_id, undef, undef, 'imported' )}
370
        if Koha::Import::Records->search({import_batch_id => $import_batch_id, status => 'imported' })->count
370
           == @{ GetImportRecordsRange( $import_batch_id )};
371
           == Koha::Import::Records->search({import_batch_id => $import_batch_id})->count;
371
372
372
    # go to basket page
373
    # go to basket page
373
    if ( $imported ) {
374
    if ( $imported ) {
374
- 

Return to bug 31569