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

(-)a/tools/batch_records_ajax.pl (-26 / +41 lines)
Lines 35-42 use CGI qw ( -utf8 ); Link Here
35
use JSON qw( to_json );
35
use JSON qw( to_json );
36
36
37
use C4::Context;
37
use C4::Context;
38
use C4::Auth        qw( check_cookie_auth );
38
use C4::Auth qw( check_cookie_auth );
39
use C4::ImportBatch qw( GetImportBatch GetImportRecordsRange GetImportRecordMatches );
39
use C4::ImportBatch qw( GetImportBatch GetImportRecordsRange GetImportRecordMathes );
40
use Koha::Import::Records;
41
use Koha::Biblios;
42
use Koha::MetadataRecord::Authority;
40
43
41
my $input = CGI->new;
44
my $input = CGI->new;
42
45
Lines 67-114 my $records = GetImportRecordsRange( Link Here
67
    { order_by => $sorting_column, order_by_direction => $sorting_direction }
70
    { order_by => $sorting_column, order_by_direction => $sorting_direction }
68
);
71
);
69
my @list = ();
72
my @list = ();
73
70
foreach my $record (@$records) {
74
foreach my $record (@$records) {
71
    my $citation = $record->{'title'} || $record->{'authorized_heading'};
75
    my $citation = $record->{'title'} || $record->{'authorized_heading'};
72
76
    my $import_record_obj = Koha::Import::Records->find($record->{'import_record_id'});
73
    my $matches = GetImportRecordMatches( $record->{'import_record_id'} );
77
    my $matches = $import_record_obj->get_import_record_matches();
74
    my $match_id;
78
    my $match_id;
75
    if ( scalar @$matches > 0 ) {
79
    my @matches_arr = ();
76
        foreach my $match (@$matches) {
80
    if ( $matches->count > 0 ) {
77
            my $match_citation = '';
81
        while ( my $match = $matches->next ){
78
            if ( $match->{'record_type'} eq 'biblio' ) {
82
        my $match_citation = '';
83
            if ( $import_record_obj->record_type eq 'biblio' ) {
84
                my $biblio = Koha::Biblios->find($match->candidate_match_id);
85
                $match = $match->unblessed;
86
                $match->{'record_type'} = 'biblio';
87
                $match->{'title'} = $biblio->title
88
                  if defined( $biblio->title );
89
                $match->{'author'} = $biblio->author
90
                  if defined( $biblio->author );
79
                $match_citation .= $match->{'title'}
91
                $match_citation .= $match->{'title'}
80
                    if defined( $match->{'title'} );
92
                    if defined( $match->{'title'} );
81
                $match_citation .= ' ' . $match->{'author'}
93
                $match_citation .= ' ' . $match->{'author'}
82
                    if defined( $match->{'author'} );
94
                    if defined( $match->{'author'} );
83
                $match->{'match_citation'} = $match_citation;
95
                $match->{'match_citation'} = $match_citation;
84
            } elsif ( $match->{'record_type'} eq 'auth' ) {
96
            }
85
                if ( defined( $match->{'authorized_heading'} ) ) {
97
            elsif ( $import_record_obj->record_type eq 'auth' ) {
98
                my $auth = Koha::MetadataRecord::Authority->get_from_authid($match->candidate_match_id);
99
                $match = $match->unblessed;
100
                $match->{'record_type'} = 'auth';
101
                if ( defined( $auth->authorized_heading ) ) {
102
                    $match->{'authorized_heading'} = $auth->authorized_heading;
86
                    $match_citation .= $match->{'authorized_heading'};
103
                    $match_citation .= $match->{'authorized_heading'};
87
                    $match->{'match_citation'} = $match_citation;
104
                    $match->{'match_citation'} = $match_citation;
88
                }
105
                }
89
            }
106
            }
107
            push @matches_arr, $match;
108
90
        }
109
        }
91
    }
110
    }
92
93
    push @list,
111
    push @list,
94
        {
112
        {
95
        DT_RowId         => $record->{'import_record_id'},
113
        DT_RowId         => $record->{'import_record_id'},
96
        import_record_id => $record->{'import_record_id'},
114
        import_record_id => $record->{'import_record_id'},
97
        citation         => $citation,
115
        citation        => $citation,
98
        author           => $record->{'author'},
116
        author          => $record->{'author'},
99
        issn             => $record->{'issn'},
117
        issn            => $record->{'issn'},
100
        isbn             => $record->{'isbn'},
118
        isbn            => $record->{'isbn'},
101
        status           => $record->{'status'},
119
        status          => $record->{'status'},
102
        overlay_status   => $record->{'overlay_status'},
120
        overlay_status  => $record->{'overlay_status'},
103
        matched          => $record->{'matched_biblionumber'}
121
        matched         => $record->{'matched_biblionumber'}
104
            || $record->{'matched_authid'}
122
          || $record->{'matched_authid'}
105
            || q{},
123
          || q{},
106
        score    => scalar @$matches > 0 ? $matches->[0]->{'score'} : 0,
124
        score    => scalar @$matches > 0 ? $matches->[0]->{'score'} : 0,
107
        matches  => $matches,
125
        matches => \@matches_arr,
108
        diff_url => $match_id
126
        diff_url => $match_id ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id&type=$record->{record_type}" : undef
109
        ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id&type=$record->{record_type}"
127
      };
110
        : undef
111
        };
112
}
128
}
113
129
114
my $data = {
130
my $data = {
115
- 

Return to bug 32055