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

(-)a/C4/ImportBatch.pm (-2 / +4 lines)
Lines 1032-1039 sub GetImportRecordsRange { Link Here
1032
1032
1033
    my $dbh = C4::Context->dbh;
1033
    my $dbh = C4::Context->dbh;
1034
1034
1035
    my $order_by =
1035
    my $order_by = $parameters->{order_by} || 'import_record_id';
1036
      $dbh->quote_identifier( $parameters->{order_by} || 'import_record_id' );
1036
    ( $order_by ) = grep( /^$order_by$/, qw( import_record_id title status overlay_status ) ) ? $order_by : 'import_record_id';
1037
    $order_by .= ",authorized_heading" if $order_by eq 'title';
1038
1037
    my $order_by_direction =
1039
    my $order_by_direction =
1038
      uc( $parameters->{order_by_direction} ) eq 'DESC' ? 'DESC' : 'ASC';
1040
      uc( $parameters->{order_by_direction} ) eq 'DESC' ? 'DESC' : 'ASC';
1039
1041
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (-60 / +90 lines)
Lines 7-16 Link Here
7
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
8
<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" />
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>
10
[% INCLUDE 'datatables.inc' %]
11
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.columnFilter.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>
14
<script type="text/JavaScript" language="JavaScript">
12
<script type="text/JavaScript" language="JavaScript">
15
//<![CDATA[
13
//<![CDATA[
16
var MSG_CONFIRM_CLEAN = _("Clear all reservoir records staged in this batch?  This cannot be undone.");
14
var MSG_CONFIRM_CLEAN = _("Clear all reservoir records staged in this batch?  This cannot be undone.");
Lines 27-81 $(document).ready(function(){ Link Here
27
      $(this).parent().hide();
25
      $(this).parent().hide();
28
  });
26
  });
29
27
30
  $("#records-table").dataTable({
28
  [% IF import_batch_id %]
31
      "aLengthMenu": [[10, 15, 20, 25, 50, 100], [10, 15, 20, 25, 50, 100]],
29
      $("#records-table").dataTable({
32
      "iDisplayLength" : 20,
30
          "aLengthMenu": [[10, 15, 20, 25, 50, 100, -1], [10, 15, 20, 25, 50, 100, _("All")]],
33
      "bAutoWidth": false,
31
          "iDisplayLength" : 20,
34
      "bFilter": false,
32
          "bAutoWidth": false,
35
      "bProcessing": true,
33
          "bFilter": false,
36
      "bServerSide": true,
34
          "bProcessing": true,
37
      "sAjaxSource": 'batch_records_ajax.pl',
35
          "bServerSide": true,
38
      "sPaginationType": "full_numbers",
36
          "sAjaxSource": 'batch_records_ajax.pl',
39
      "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
37
          "sPaginationType": "full_numbers",
40
      "aoColumns": [
38
          "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
41
          { "mDataProp": "import_record_id" },
39
          "aoColumns": [
42
          { "mDataProp": "citation" },
40
              { "mDataProp": "import_record_id" },
43
          { "mDataProp": "status" },
41
              { "mDataProp": "citation" },
44
          { "mDataProp": "overlay_status" },
42
              { "mDataProp": "status" },
45
          { "mDataProp": "match_citation" },
43
              { "mDataProp": "overlay_status" },
46
          { "mDataProp": "matched" },
44
              { "mDataProp": "match_citation" },
47
      ],
45
              { "mDataProp": "matched" },
48
      "fnServerData": function ( sSource, aoData, fnCallback ) {
46
          ],
49
          aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
47
          "fnServerData": function ( sSource, aoData, fnCallback ) {
48
              aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
50
49
51
          $.getJSON( sSource, aoData, function (json) {
50
              $.ajax({
52
              fnCallback(json)
51
                  'dataType': 'json',
53
          } );
52
                  'type': 'POST',
54
      },
53
                  'url': sSource,
55
      "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
54
                  'data': aoData,
56
        $('td:eq(1)', nRow).html(
55
                  'success': function(json){
57
            '<a href="javascript:void()" onclick="show_marc('
56
                      fnCallback(json);
58
            + aData['import_record_id']
57
                  }
59
            + ')">' + aData['citation'] + '</a>'
58
              });
60
        );
59
          },
60
          "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
61
            [% IF ( record_type == 'auth' ) %]
62
                var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
63
            [% ELSE %]
64
                var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
65
            [% END %]
61
66
62
        if ( aData['match_id'] ) {
67
            $('td:eq(1)', nRow).html(
63
            $('td:eq(4)', nRow).html(
68
                '<a href="javascript:void(0)" onclick="show_marc('
64
                _("Matches biblio ")
69
                + aData['import_record_id']
65
                + aData['match_id']
70
                + ')">' + aData['citation'] + '</a>'
66
                + " (" + _("score") + "="
67
                + aData['score']
68
                + '):' + '<a target="_blank" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber='
69
                + aData['match_id'] + '">' + aData['match_citation'] + '</a>'
70
            );
71
            );
71
        }
72
72
73
        $('td:eq(5)', nRow).html(
73
            $('td:eq(2)', nRow).html(
74
            '<a target="_blank" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber='
74
                aData['status'] == 'imported' ? _("Imported") :
75
            + aData['matched'] + '">' + aData['matched'] + '</a>'
75
                aData['status'] == 'ignored'  ? _("Ignored")  :
76
        );
76
                aData['status'] == 'reverted' ? _("Reverted") :
77
      },
77
                aData['status'] == 'staged'   ? _("Staged")   :
78
  });
78
                aData['status'] == 'error'    ? _("Error")    :
79
                aData['status']
80
            );
81
82
            $('td:eq(3)', nRow).html(
83
                aData['overlay_status'] == 'no_match'      ? _("No match")       :
84
                aData['overlay_status'] == 'match_applied' ? _("Match applied")  :
85
                aData['overlay_status'] == 'auto_match'    ? _("Match found")    :
86
                aData['overlay_status']
87
            );
88
89
            if ( aData['match_id'] ) {
90
                $('td:eq(4)', nRow).html(
91
                    _("Matches biblio ")
92
                    + aData['match_id']
93
                    + " (" + _("score") + "="
94
                    + aData['score']
95
                    + '):' + '<a target="_blank" href="' + record_details_url
96
                    + aData['match_id'] + '">' + aData['match_citation'] + '</a>'
97
                );
98
            }
99
100
            $('td:eq(5)', nRow).html(
101
                '<a target="_blank" href="' + record_details_url
102
                    + aData['matched'] + '">' + aData['matched'] + '</a>'
103
            );
104
          },
105
      });
106
    [% END %]
79
});
107
});
80
108
81
function show_marc( id ) {
109
function show_marc( id ) {
Lines 412-429 Page Link Here
412
  [% END %]
440
  [% END %]
413
[% END %]
441
[% END %]
414
442
415
<table id="records-table">
443
[% IF import_batch_id %]
416
    <thead>
444
    <table id="records-table">
417
        <tr>
445
        <thead>
418
            <th>#</th>
446
            <tr>
419
            <th>Citation</th>
447
                <th>#</th>
420
            <th>Status</th>
448
                <th>Citation</th>
421
            <th>Match type</th>
449
                <th>Status</th>
422
            <th>Match details</th>
450
                <th>Match type</th>
423
            <th>Record</th>
451
                <th>Match details</th>
424
        </tr>
452
                <th>Record</th>
425
    </thead>
453
            </tr>
426
</table>
454
        </thead>
455
    </table>
456
[% END %]
427
457
428
</div>
458
</div>
429
</div>
459
</div>
(-)a/tools/batch_records_ajax.pl (-6 / +13 lines)
Lines 1-14 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
3
# Copyright 2013 ByWater Solutions
4
4
# Based on circ/ysearch.pl: Copyright 2007 Tamil s.a.r.l.
5
# Copyright 2007 Tamil s.a.r.l.
6
#
5
#
7
# This file is part of Koha.
6
# This file is part of Koha.
8
#
7
#
9
# Koha is free software; you can redistribute it and/or modify it under the
8
# 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
9
# 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
10
# Foundation; either version 3 of the License, or (at your option) any later
12
# version.
11
# version.
13
#
12
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
Lines 19-26 Link Here
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
20
22
=head1 ysearch.pl
21
=head1 NAME
22
23
batch_records_ajax.pl - A script for searching batch imported records via ajax
23
24
25
=head1 SYNOPSIS
26
27
This script is to be used as a data source for DataTables that load and display
28
the records from an import batch.
24
29
25
=cut
30
=cut
26
31
Lines 45-55 my $results_per_page = $input->param('iDisplayLength'); Link Here
45
my $sorting_column    = $sort_columns[ $input->param('iSortCol_0') ];
50
my $sorting_column    = $sort_columns[ $input->param('iSortCol_0') ];
46
my $sorting_direction = $input->param('sSortDir_0');
51
my $sorting_direction = $input->param('sSortDir_0');
47
52
53
$results_per_page = undef if ( $results_per_page == -1 );
54
48
binmode STDOUT, ":encoding(UTF-8)";
55
binmode STDOUT, ":encoding(UTF-8)";
49
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
56
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
50
57
51
my ( $auth_status, $sessionID ) =
58
my ( $auth_status, $sessionID ) =
52
  check_cookie_auth( $input->cookie('CGISESSID'), { editcatalogue => '*' } );
59
  check_cookie_auth( $input->cookie('CGISESSID'), { tools => 'manage_staged_marc' } );
53
if ( $auth_status ne "ok" ) {
60
if ( $auth_status ne "ok" ) {
54
    exit 0;
61
    exit 0;
55
}
62
}
(-)a/tools/manage-marc-import.pl (-50 / +4 lines)
Lines 352-416 sub import_records_list { Link Here
352
    my ($template, $import_batch_id, $offset, $results_per_page) = @_;
352
    my ($template, $import_batch_id, $offset, $results_per_page) = @_;
353
353
354
    my $batch = GetImportBatch($import_batch_id);
354
    my $batch = GetImportBatch($import_batch_id);
355
#    my $records = GetImportRecordsRange($import_batch_id);
356
#    my @list = ();
357
#    foreach my $record (@$records) {
358
#        my $citation = $record->{'title'} || $record->{'authorized_heading'};
359
#        $citation .= " $record->{'author'}" if $record->{'author'};
360
#        $citation .= " (" if $record->{'issn'} or $record->{'isbn'};
361
#        $citation .= $record->{'isbn'} if $record->{'isbn'};
362
#        $citation .= ", " if $record->{'issn'} and $record->{'isbn'};
363
#        $citation .= $record->{'issn'} if $record->{'issn'};
364
#        $citation .= ")" if $record->{'issn'} or $record->{'isbn'};
365
#
366
#        my $match = GetImportRecordMatches($record->{'import_record_id'}, 1);
367
#        my $match_citation = '';
368
#        my $match_id;
369
#        if ($#$match > -1) {
370
#            if ($match->[0]->{'record_type'} eq 'biblio') {
371
#                $match_citation .= $match->[0]->{'title'} if defined($match->[0]->{'title'});
372
#                $match_citation .= ' ' . $match->[0]->{'author'} if defined($match->[0]->{'author'});
373
#                $match_id = $match->[0]->{'biblionumber'};
374
#            } elsif ($match->[0]->{'record_type'} eq 'auth') {
375
#                if (defined($match->[0]->{'authorized_heading'})) {
376
#                    $match_citation .= $match->[0]->{'authorized_heading'};
377
#                    $match_id = $match->[0]->{'candidate_match_id'};
378
#                }
379
#            }
380
#        }
381
#
382
#        push @list,
383
#          { import_record_id         => $record->{'import_record_id'},
384
#            final_match_id           => $record->{'matched_biblionumber'} || $record->{'matched_authid'},
385
#            citation                 => $citation,
386
#            status                   => $record->{'status'},
387
#            record_sequence          => $record->{'record_sequence'},
388
#            overlay_status           => $record->{'overlay_status'},
389
#            # Sorry about the match_id being from the "biblionumber" field;
390
#            # as it turns out, any match id will go in biblionumber
391
#            match_id                 => $match_id,
392
#            match_citation           => $match_citation,
393
#            match_score              => $#$match > -1 ? $match->[0]->{'score'} : 0,
394
#            record_type              => $record->{'record_type'},
395
#          };
396
#    }
397
#    my $num_records = $batch->{'num_records'};
398
#    $template->param(record_list => \@list);
399
#    add_page_numbers($template, $offset, $results_per_page, $num_records);
400
#    $template->param(offset => $offset);
401
#    $template->param(range_top => $offset + $results_per_page - 1);
402
#    $template->param(num_results => $num_records);
403
#    $template->param(results_per_page => $results_per_page);
404
    $template->param(import_batch_id => $import_batch_id);
355
    $template->param(import_batch_id => $import_batch_id);
356
405
    my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
357
    my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
406
    $template->param("overlay_action_${overlay_action}" => 1);
358
    $template->param("overlay_action_${overlay_action}" => 1);
407
    $template->param(overlay_action => $overlay_action);
359
    $template->param(overlay_action => $overlay_action);
360
408
    my $nomatch_action = GetImportBatchNoMatchAction($import_batch_id);
361
    my $nomatch_action = GetImportBatchNoMatchAction($import_batch_id);
409
    $template->param("nomatch_action_${nomatch_action}" => 1);
362
    $template->param("nomatch_action_${nomatch_action}" => 1);
410
    $template->param(nomatch_action => $nomatch_action);
363
    $template->param(nomatch_action => $nomatch_action);
364
411
    my $item_action = GetImportBatchItemAction($import_batch_id);
365
    my $item_action = GetImportBatchItemAction($import_batch_id);
412
    $template->param("item_action_${item_action}" => 1);
366
    $template->param("item_action_${item_action}" => 1);
413
    $template->param(item_action => $item_action);
367
    $template->param(item_action => $item_action);
368
414
    batch_info($template, $batch);
369
    batch_info($template, $batch);
415
    
370
    
416
}
371
}
417
- 

Return to bug 10558