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

(-)a/C4/ImportBatch.pm (-2 / +9 lines)
Lines 990-998 starting at the given offset. Link Here
990
=cut
990
=cut
991
991
992
sub GetImportRecordsRange {
992
sub GetImportRecordsRange {
993
    my ($batch_id, $offset, $results_per_group, $status) = @_;
993
    my ( $batch_id, $offset, $results_per_group, $status, $parameters ) = @_;
994
994
995
    my $dbh = C4::Context->dbh;
995
    my $dbh = C4::Context->dbh;
996
997
    my $order_by =
998
      $dbh->quote_identifier( $parameters->{order_by} || 'import_record_id' );
999
    my $order_by_direction =
1000
      uc( $parameters->{order_by_direction} ) eq 'DESC' ? 'DESC' : 'ASC';
1001
996
    my $query = "SELECT title, author, isbn, issn, authorized_heading, import_records.import_record_id,
1002
    my $query = "SELECT title, author, isbn, issn, authorized_heading, import_records.import_record_id,
997
                                           record_sequence, status, overlay_status,
1003
                                           record_sequence, status, overlay_status,
998
                                           matched_biblionumber, matched_authid, record_type
1004
                                           matched_biblionumber, matched_authid, record_type
Lines 1006-1012 sub GetImportRecordsRange { Link Here
1006
        $query .= " AND status=?";
1012
        $query .= " AND status=?";
1007
        push(@params,$status);
1013
        push(@params,$status);
1008
    }
1014
    }
1009
    $query.=" ORDER BY import_record_id";
1015
1016
    $query.=" ORDER BY $order_by $order_by_direction";
1010
1017
1011
    if($results_per_group){
1018
    if($results_per_group){
1012
        $query .= " LIMIT ?";
1019
        $query .= " LIMIT ?";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (-98 / +81 lines)
Lines 1-31 Link Here
1
[% BLOCK final_match_link %]
2
    [% IF ( record.record_type == 'biblio' ) %]
3
        <a target="_blank" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record.final_match_id %]">[% record.final_match_id %]</a>
4
    [% ELSIF ( record.record_type == 'auth' ) %]
5
        <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record.final_match_id %]">[% record.final_match_id %]</a>
6
    [% END %]
7
[% END %]
8
[% BLOCK match_link %]
9
    [% IF ( record_lis.match_id ) %]
10
        <tr>
11
            <td />
12
            [% IF ( record.record_type == 'biblio' ) %]
13
                <td class="highlight" colspan="4">Matches biblio [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td>
14
            [% ELSIF ( record.record_type == 'auth' ) %]
15
                <td class="highlight" colspan="4">Matches authority [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td>
16
            [% END %]
17
        </tr>
18
    [% END %]
19
[% END %]
20
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
21
<title>Koha &rsaquo; Tools &rsaquo; Manage staged MARC records
2
<title>Koha &rsaquo; Tools &rsaquo; Manage staged MARC records
22
[% IF ( import_batch_id ) %]
3
[% IF ( import_batch_id ) %]
23
 &rsaquo; Batch [% import_batch_id %]
4
 &rsaquo; Batch [% import_batch_id %]
24
[% END %]
5
[% END %]
25
</title>
6
</title>
26
[% INCLUDE 'greybox.inc' %]
27
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
28
<script type="text/javascript" src="[% themelang %]/js/background-job-progressbar.js"></script>
8
<script type="text/javascript" src="[% themelang %]/js/background-job-progressbar.js"></script>
9
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
10
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
11
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
12
[% INCLUDE 'datatables-strings.inc' %]
13
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
29
<script type="text/JavaScript" language="JavaScript">
14
<script type="text/JavaScript" language="JavaScript">
30
//<![CDATA[
15
//<![CDATA[
31
var MSG_CONFIRM_CLEAN = _("Clear all reservoir records staged in this batch?  This cannot be undone.");
16
var MSG_CONFIRM_CLEAN = _("Clear all reservoir records staged in this batch?  This cannot be undone.");
Lines 41-47 $(document).ready(function(){ Link Here
41
      $("#"+str+" option[selected='selected']").attr("selected","selected");
26
      $("#"+str+" option[selected='selected']").attr("selected","selected");
42
      $(this).parent().hide();
27
      $(this).parent().hide();
43
  });
28
  });
29
30
  $("#records-table").dataTable({
31
      "aLengthMenu": [[10, 15, 20, 25, 50, 100], [10, 15, 20, 25, 50, 100]],
32
      "iDisplayLength" : 20,
33
      "bAutoWidth": false,
34
      "bFilter": false,
35
      "bProcessing": true,
36
      "bServerSide": true,
37
      "sAjaxSource": 'batch_records_ajax.pl',
38
      "sPaginationType": "full_numbers",
39
      "aoColumns": [
40
          { "mDataProp": "import_record_id" },
41
          { "mDataProp": "citation" },
42
          { "mDataProp": "status" },
43
          { "mDataProp": "overlay_status" },
44
          { "mDataProp": "match_citation" },
45
          { "mDataProp": "matched" },
46
      ],
47
      "fnServerData": function ( sSource, aoData, fnCallback ) {
48
          aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
49
50
          $.getJSON( sSource, aoData, function (json) {
51
              fnCallback(json)
52
          } );
53
      },
54
      "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
55
        $('td:eq(1)', nRow).html(
56
            '<a href="javascript:void()" onclick="show_marc('
57
            + aData['import_record_id']
58
            + ')">' + aData['citation'] + '</a>'
59
        );
60
61
        if ( aData['match_id'] ) {
62
            $('td:eq(4)', nRow).html(
63
                _("Matches biblio ")
64
                + aData['match_id']
65
                + " (" + _("score") + "="
66
                + aData['score']
67
                + '):' + '<a target="_blank" href="http://staff.kohadev/cgi-bin/koha/catalogue/detail.pl?biblionumber='
68
                + aData['match_id'] + '">' + aData['match_citation'] + '</a>'
69
            );
70
        }
71
72
        $('td:eq(5)', nRow).html(
73
            '<a target="_blank" href="http://staff.kohadev/cgi-bin/koha/catalogue/detail.pl?biblionumber='
74
            + aData['matched'] + '">' + aData['matched'] + '</a>'
75
        );
76
      },
77
  });
44
});
78
});
79
80
function show_marc( id ) {
81
    var page = "/cgi-bin/koha/catalogue/showmarc.pl?importid=" + id;
82
83
    var $dialog = $('<div></div>')
84
        .html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"></iframe>')
85
        .dialog({
86
            autoOpen: false,
87
            modal: true,
88
            height: 625,
89
            width: 500,
90
            title: _("MARC Preview")
91
        });
92
93
    $dialog.dialog('open');
94
}
45
//]]>
95
//]]>
46
</script>
96
</script>
47
<style type="text/css">
97
<style type="text/css">
Lines 360-444 Page Link Here
360
  [% END %]
410
  [% END %]
361
[% END %]
411
[% END %]
362
412
363
[% IF ( record_list ) %]
413
<table id="records-table">
364
  [% IF ( pages ) %]
414
    <thead>
365
<div class="pages">
415
        <tr>
366
Page 
416
            <th>#</th>
367
    [% FOREACH page IN pages %]
417
            <th>Citation</th>
368
      [% IF ( page.current_page ) %]
418
            <th>Status</th>
369
      <span class="current">[% page.page_number %]</span>
419
            <th>Match?</th>
370
      [% ELSE %]
420
            <th>&nbsp;</th>
371
      <a class="nav" href="[% page.script_name %]?import_batch_id=[% import_batch_id %]&amp;offset=[% page.offset %]">[% page.page_number %]</a>
421
            <th>Record</th>
372
      [% END %]
422
        </tr>
373
    [% END %]
423
    </thead>
374
</div>
375
  [% END %]
376
<table>
377
  <tr>
378
    <th>#</th>
379
    <th>Citation</th>
380
    <th>Status</th>
381
    <th>Match?</th>
382
    <th>Record</th>
383
384
  </tr>
385
  [% FOREACH record_lis IN record_list %]
386
  [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
387
    <td>[% record_lis.record_sequence %]</td>
388
    <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% record_lis.import_record_id %]" rel="gb_page_center[600,500]">[% record_lis.citation %]</a></td>
389
    <td>
390
        [% IF ( record_lis.status == 'imported' ) %]
391
            Imported
392
        [% ELSIF ( record_lis.status == 'ignored' ) %]
393
            Ignored
394
        [% ELSIF ( record_lis.status == 'reverted' ) %]
395
            Reverted
396
        [% ELSIF ( record_lis.status == 'staged' ) %]
397
            Staged
398
        [% ELSIF ( record_lis.status == 'error' ) %]
399
            Error
400
        [% ELSE %]
401
          [% record_lis.status %]
402
        [% END %]
403
    </td>
404
    <td>
405
        [% IF ( record_lis.overlay_status == 'no_match' ) %]
406
            No match
407
        [% ELSIF ( record_lis.overlay_status == 'match_applied' ) %]
408
            Match applied
409
        [% ELSIF ( record_lis.overlay_status == 'auto_match' ) %]
410
            Match found
411
        [% ELSE %]
412
            [% record_lis.overlay_status %]
413
        [% END %]
414
    </td>
415
    <td>[% IF ( record_lis.final_match_id ) %]
416
        [% PROCESS final_match_link record=record_lis %]
417
        [% END %]
418
    </td>
419
  </tr>
420
    [% PROCESS match_link record=record_lis %]
421
  [% END %]
422
</table>
424
</table>
423
  [% IF ( pages ) %]
424
<div class="pages">
425
Page 
426
    [% FOREACH page IN pages %]
427
      [% IF ( page.current_page ) %]
428
      <span class="current">[% page.page_number %]</span>
429
      [% ELSE %]
430
      <a class="nav" href="[% page.script_name %]?import_batch_id=[% import_batch_id %]&amp;offset=[% page.offset %]">[% page.page_number %]</a>
431
      [% END %]
432
    [% END %]
433
</div>
434
  [% END %]
435
[% ELSE %]
436
  [% IF ( batch_info ) %]
437
    <div class="dialog alert">There are no records in this batch to import.
438
    <a href="/cgi-bin/koha/tools/manage-marc-import.pl">Manage staged MARC records</a>.</div>
439
440
  [% END %]
441
[% END %]
442
425
443
</div>
426
</div>
444
</div>
427
</div>
(-)a/tools/batch_records_ajax.pl (+112 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
4
5
# Copyright 2007 Tamil s.a.r.l.
6
#
7
# This file is part of Koha.
8
#
9
# Koha is free software; you can redistribute it and/or modify it under the
10
# terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
12
# version.
13
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License along
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
=head1 ysearch.pl
23
24
25
=cut
26
27
use Modern::Perl;
28
29
use CGI;
30
use JSON qw/ to_json /;
31
32
use C4::Context;
33
use C4::Charset;
34
use C4::Auth qw/check_cookie_auth/;
35
use C4::ImportBatch;
36
37
my $input = new CGI;
38
39
my @sort_columns =
40
  qw/import_record_id title status overlay_status overlay_status/;
41
42
my $import_batch_id   = $input->param('import_batch_id');
43
my $offset            = $input->param('iDisplayStart');
44
my $results_per_page  = $input->param('iDisplayLength');
45
my $sorting_column    = $sort_columns[ $input->param('iSortCol_0') ];
46
my $sorting_direction = $input->param('sSortDir_0');
47
48
binmode STDOUT, ":encoding(UTF-8)";
49
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
50
51
my ( $auth_status, $sessionID ) =
52
  check_cookie_auth( $input->cookie('CGISESSID'), { editcatalogue => '*' } );
53
if ( $auth_status ne "ok" ) {
54
    exit 0;
55
}
56
57
my $batch = GetImportBatch($import_batch_id);
58
my $records =
59
  GetImportRecordsRange( $import_batch_id, $offset, $results_per_page, undef,
60
    { order_by => $sorting_column, order_by_direction => $sorting_direction } );
61
my @list = ();
62
foreach my $record (@$records) {
63
    my $citation = $record->{'title'} || $record->{'authorized_heading'};
64
    $citation .= " $record->{'author'}" if $record->{'author'};
65
    $citation .= " (" if $record->{'issn'} or $record->{'isbn'};
66
    $citation .= $record->{'isbn'} if $record->{'isbn'};
67
    $citation .= ", " if $record->{'issn'} and $record->{'isbn'};
68
    $citation .= $record->{'issn'} if $record->{'issn'};
69
    $citation .= ")" if $record->{'issn'} or $record->{'isbn'};
70
71
    my $match = GetImportRecordMatches( $record->{'import_record_id'}, 1 );
72
    my $match_citation = '';
73
    my $match_id;
74
    if ( $#$match > -1 ) {
75
        if ( $match->[0]->{'record_type'} eq 'biblio' ) {
76
            $match_citation .= $match->[0]->{'title'}
77
              if defined( $match->[0]->{'title'} );
78
            $match_citation .= ' ' . $match->[0]->{'author'}
79
              if defined( $match->[0]->{'author'} );
80
            $match_id = $match->[0]->{'biblionumber'};
81
        }
82
        elsif ( $match->[0]->{'record_type'} eq 'auth' ) {
83
            if ( defined( $match->[0]->{'authorized_heading'} ) ) {
84
                $match_citation .= $match->[0]->{'authorized_heading'};
85
                $match_id = $match->[0]->{'candidate_match_id'};
86
            }
87
        }
88
    }
89
90
    push @list,
91
      {
92
        DT_RowId        => $record->{'import_record_id'},
93
        import_record_id => $record->{'import_record_id'},
94
        citation        => $citation,
95
        status          => $record->{'status'},
96
        overlay_status  => $record->{'overlay_status'},
97
        match_citation  => $match_citation,
98
        matched         => $record->{'matched_biblionumber'}
99
          || $record->{'matched_authid'}
100
          || q{},
101
        score => $#$match > -1 ? $match->[0]->{'score'} : 0,
102
        match_id => $match_id,
103
      };
104
}
105
106
my $data;
107
$data->{'iTotalRecords'}        = $batch->{'num_records'};
108
$data->{'iTotalDisplayRecords'} = $batch->{'num_records'};
109
$data->{'sEcho'}                = $input->param('sEcho') || undef;
110
$data->{'aaData'}               = \@list;
111
112
print to_json($data);
(-)a/tools/manage-marc-import.pl (-50 / +49 lines)
Lines 351-405 sub import_records_list { Link Here
351
    my ($template, $import_batch_id, $offset, $results_per_page) = @_;
351
    my ($template, $import_batch_id, $offset, $results_per_page) = @_;
352
352
353
    my $batch = GetImportBatch($import_batch_id);
353
    my $batch = GetImportBatch($import_batch_id);
354
    my $records = GetImportRecordsRange($import_batch_id, $offset, $results_per_page);
354
#    my $records = GetImportRecordsRange($import_batch_id);
355
    my @list = ();
355
#    my @list = ();
356
    foreach my $record (@$records) {
356
#    foreach my $record (@$records) {
357
        my $citation = $record->{'title'} || $record->{'authorized_heading'};
357
#        my $citation = $record->{'title'} || $record->{'authorized_heading'};
358
        $citation .= " $record->{'author'}" if $record->{'author'};
358
#        $citation .= " $record->{'author'}" if $record->{'author'};
359
        $citation .= " (" if $record->{'issn'} or $record->{'isbn'};
359
#        $citation .= " (" if $record->{'issn'} or $record->{'isbn'};
360
        $citation .= $record->{'isbn'} if $record->{'isbn'};
360
#        $citation .= $record->{'isbn'} if $record->{'isbn'};
361
        $citation .= ", " if $record->{'issn'} and $record->{'isbn'};
361
#        $citation .= ", " if $record->{'issn'} and $record->{'isbn'};
362
        $citation .= $record->{'issn'} if $record->{'issn'};
362
#        $citation .= $record->{'issn'} if $record->{'issn'};
363
        $citation .= ")" if $record->{'issn'} or $record->{'isbn'};
363
#        $citation .= ")" if $record->{'issn'} or $record->{'isbn'};
364
364
#
365
        my $match = GetImportRecordMatches($record->{'import_record_id'}, 1);
365
#        my $match = GetImportRecordMatches($record->{'import_record_id'}, 1);
366
        my $match_citation = '';
366
#        my $match_citation = '';
367
        my $match_id;
367
#        my $match_id;
368
        if ($#$match > -1) {
368
#        if ($#$match > -1) {
369
            if ($match->[0]->{'record_type'} eq 'biblio') {
369
#            if ($match->[0]->{'record_type'} eq 'biblio') {
370
                $match_citation .= $match->[0]->{'title'} if defined($match->[0]->{'title'});
370
#                $match_citation .= $match->[0]->{'title'} if defined($match->[0]->{'title'});
371
                $match_citation .= ' ' . $match->[0]->{'author'} if defined($match->[0]->{'author'});
371
#                $match_citation .= ' ' . $match->[0]->{'author'} if defined($match->[0]->{'author'});
372
                $match_id = $match->[0]->{'biblionumber'};
372
#                $match_id = $match->[0]->{'biblionumber'};
373
            } elsif ($match->[0]->{'record_type'} eq 'auth') {
373
#            } elsif ($match->[0]->{'record_type'} eq 'auth') {
374
                if (defined($match->[0]->{'authorized_heading'})) {
374
#                if (defined($match->[0]->{'authorized_heading'})) {
375
                    $match_citation .= $match->[0]->{'authorized_heading'};
375
#                    $match_citation .= $match->[0]->{'authorized_heading'};
376
                    $match_id = $match->[0]->{'candidate_match_id'};
376
#                    $match_id = $match->[0]->{'candidate_match_id'};
377
                }
377
#                }
378
            }
378
#            }
379
        }
379
#        }
380
380
#
381
        push @list,
381
#        push @list,
382
          { import_record_id         => $record->{'import_record_id'},
382
#          { import_record_id         => $record->{'import_record_id'},
383
            final_match_id           => $record->{'matched_biblionumber'} || $record->{'matched_authid'},
383
#            final_match_id           => $record->{'matched_biblionumber'} || $record->{'matched_authid'},
384
            citation                 => $citation,
384
#            citation                 => $citation,
385
            status                   => $record->{'status'},
385
#            status                   => $record->{'status'},
386
            record_sequence          => $record->{'record_sequence'},
386
#            record_sequence          => $record->{'record_sequence'},
387
            overlay_status           => $record->{'overlay_status'},
387
#            overlay_status           => $record->{'overlay_status'},
388
            # Sorry about the match_id being from the "biblionumber" field;
388
#            # Sorry about the match_id being from the "biblionumber" field;
389
            # as it turns out, any match id will go in biblionumber
389
#            # as it turns out, any match id will go in biblionumber
390
            match_id                 => $match_id,
390
#            match_id                 => $match_id,
391
            match_citation           => $match_citation,
391
#            match_citation           => $match_citation,
392
            match_score              => $#$match > -1 ? $match->[0]->{'score'} : 0,
392
#            match_score              => $#$match > -1 ? $match->[0]->{'score'} : 0,
393
            record_type              => $record->{'record_type'},
393
#            record_type              => $record->{'record_type'},
394
          };
394
#          };
395
    }
395
#    }
396
    my $num_records = $batch->{'num_records'};
396
#    my $num_records = $batch->{'num_records'};
397
    $template->param(record_list => \@list);
397
#    $template->param(record_list => \@list);
398
    add_page_numbers($template, $offset, $results_per_page, $num_records);
398
#    add_page_numbers($template, $offset, $results_per_page, $num_records);
399
    $template->param(offset => $offset);
399
#    $template->param(offset => $offset);
400
    $template->param(range_top => $offset + $results_per_page - 1);
400
#    $template->param(range_top => $offset + $results_per_page - 1);
401
    $template->param(num_results => $num_records);
401
#    $template->param(num_results => $num_records);
402
    $template->param(results_per_page => $results_per_page);
402
#    $template->param(results_per_page => $results_per_page);
403
    $template->param(import_batch_id => $import_batch_id);
403
    $template->param(import_batch_id => $import_batch_id);
404
    my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
404
    my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
405
    $template->param("overlay_action_${overlay_action}" => 1);
405
    $template->param("overlay_action_${overlay_action}" => 1);
406
- 

Return to bug 10558