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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (+174 lines)
Lines 9-14 Link Here
9
</title>
9
</title>
10
[% INCLUDE 'doc-head-close.inc' %]
10
[% INCLUDE 'doc-head-close.inc' %]
11
[% Asset.css("css/datatables.css") | $raw %]
11
[% Asset.css("css/datatables.css") | $raw %]
12
<script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar.js"></script>
13
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
14
[% INCLUDE 'datatables.inc' %]
15
<script type="text/javascript">
16
//<![CDATA[
17
$(document).ready(function(){
18
  $("#staged-record-matching-rules select").change(function(){
19
      var str = $(this).attr("id");
20
      $("#reset_"+str).parent().show();
21
  });
22
  $("a.reset").click(function(){
23
      var str = $(this).attr("id");
24
      str = str.replace("reset_","")
25
      $("#"+str+" option[selected='selected']").attr("selected","selected");
26
      $(this).parent().hide();
27
  });
28
29
  [% IF import_batch_id %]
30
      var checkedRecords = {};
31
      $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
32
          "bAutoWidth": false,
33
          "bFilter": false,
34
          "bProcessing": true,
35
          "bServerSide": true,
36
          "sAjaxSource": 'batch_records_ajax.pl',
37
          "sPaginationType": "full_numbers",
38
          "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
39
          "aaSorting": [ [ 1, 'asc' ] ],
40
          "aoColumns": [
41
              {
42
                  "bSortable": false,
43
                  "mDataProp": null,
44
                  "sDefaultContent": ''
45
              },
46
              { "mDataProp": "import_record_id" },
47
              { "mDataProp": "citation" },
48
              { "mDataProp": "status" },
49
              { "mDataProp": "overlay_status" },
50
              { "mDataProp": "match_citation" },
51
              { "mDataProp": "diff_url" },
52
              { "mDataProp": "matched" },
53
              {
54
                  "bSortable": false,
55
                  "mDataProp": null,
56
                  "sDefaultContent": ''
57
              }
58
          ],
59
          "fnServerData": function ( sSource, aoData, fnCallback ) {
60
              aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
61
62
              $.ajax({
63
                  'dataType': 'json',
64
                  'type': 'POST',
65
                  'url': sSource,
66
                  'data': aoData,
67
                  'success': function(json){
68
                      fnCallback(json);
69
                  }
70
              });
71
          },
72
          "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
73
            [% IF ( record_type == 'auth' ) %]
74
                var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
75
            [% ELSE %]
76
                var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
77
            [% END %]
78
79
            var record_id = aData['import_record_id'];
80
            var $checkbox = $('<input type="checkbox"></input>');
81
            $('td:eq(0)', nRow).append($checkbox);
82
            $checkbox.prop( 'checked', checkedRecords[record_id] );
83
            $checkbox.change( function() {
84
                if ( this.checked ) {
85
                    checkedRecords[record_id] = true;
86
                } else {
87
                    delete checkedRecords[record_id];
88
                }
89
            } );
90
91
            $('td:eq(2)', nRow).html(
92
                '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '" class="previewMARC">' + aData['citation'] + '</a>'
93
            );
94
95
            $('td:eq(3)', nRow).html(
96
                aData['status'] == 'imported' ? _("Imported") :
97
                aData['status'] == 'ignored'  ? _("Ignored")  :
98
                aData['status'] == 'reverted' ? _("Reverted") :
99
                aData['status'] == 'staged'   ? _("Staged")   :
100
                aData['status'] == 'error'    ? _("Error")    :
101
                aData['status']
102
            );
103
104
            $('td:eq(4)', nRow).html(
105
                aData['overlay_status'] == 'no_match'      ? _("No match")       :
106
                aData['overlay_status'] == 'match_applied' ? _("Match applied")  :
107
                aData['overlay_status'] == 'auto_match'    ? _("Match found")    :
108
                aData['overlay_status']
109
            );
110
111
            if ( aData['match_id'] ) {
112
                [% IF ( record_type == 'auth' ) -%]
113
                var matching_msg = _("Matches authority %s (score=%s):%s");
114
                [%- ELSE -%]
115
                var matching_msg = _("Matches biblio %s (score=%s):%s");
116
                [%- END %]
117
                $('td:eq(4)', nRow).html(
118
                    matching_msg.format(aData['match_id'], aData['score'],
119
                    '<a target="_blank" href="' + record_details_url
120
                    + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
121
                );
122
            }
123
            if (aData['diff_url']){
124
                $('td:eq(6)', nRow).html(
125
                    '<a rel="gb_page_center[960,600]" href="'+aData['diff_url']+'">View</a>'
126
                );
127
            }
128
            $('td:eq(7)', nRow).html(
129
                '<a target="_blank" href="' + record_details_url
130
                    + aData['matched'] + '">' + aData['matched'] + '</a>'
131
            );
132
            $('td:eq(8)', nRow).html(
133
                '<a target="_blank" href="/cgi-bin/koha/cataloguing/editor.pl#batch:[% import_batch_id %]/' + record_id
134
                    + '">' + _("Edit") + '</a>'
135
            );
136
          },
137
      }));
138
        $("#import_batch_form").on("submit",function(){
139
            return submitBackgroundJob( document.getElementById("import_batch_form") );
140
        });
141
        $("#revert_batch_form").on("submit",function(){
142
            return confirm( _("Are you sure you want to undo the import of this batch into the catalog?") ) &&   submitBackgroundJob( document.getElementById("revert_batch_form") );
143
        });
144
      $('#export-selected').click( function() {
145
          var options = {
146
              import_record_id: $.map( checkedRecords, function( undef, key ) { return key; } ).join('|'),
147
          };
148
149
          if ( options.import_record_id.length == 0 ) return false;_
150
151
          window.open( '/cgi-bin/koha/svc/cataloguing/import_batches/' + [% import_batch_id %] + '?download=1&' + $.param( options ) );
152
          return false;
153
      });
154
    [% END %]
155
    $("body").on("click",".previewMARC", function(e){
156
        e.preventDefault();
157
        var ltitle = $(this).text();
158
        var page = $(this).attr("href");
159
        $("#marcPreviewLabel").text(ltitle);
160
        $("#marcPreview .modal-body").load(page + " table");
161
        $('#marcPreview').modal({show:true});
162
    });
163
    $("#marcPreview").on("hidden", function(){
164
        $("#marcPreviewLabel").html("");
165
        $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
166
    });
167
    $(".batch_form").on("submit",function(){
168
        if( $(this).hasClass("batch_delete") ){
169
            return confirm( _("Are you sure you want to permanently delete this batch?") );
170
        } else {
171
            return confirm( _("Clear all reservoir records staged in this batch?  This cannot be undone.") );
172
        }
173
    });
174
});
175
176
//]]>
177
</script>
12
<style type="text/css">
178
<style type="text/css">
13
    #jobpanel,#jobstatus,#jobfailed { display : none; }
179
    #jobpanel,#jobstatus,#jobfailed { display : none; }
14
    span.change-status { font-style:italic; color:#666; display:none; }
180
    span.change-status { font-style:italic; color:#666; display:none; }
Lines 39-44 Link Here
39
 &rsaquo; Batch [% import_batch_id | html %]
205
 &rsaquo; Batch [% import_batch_id | html %]
40
[% END %]
206
[% END %]
41
</h1>
207
</h1>
208
42
[% IF ( label_batch_msg ) %]
209
[% IF ( label_batch_msg ) %]
43
[% IF ( alert ) %]
210
[% IF ( alert ) %]
44
<div class="alert">
211
<div class="alert">
Lines 342-350 Link Here
342
[% END %]
509
[% END %]
343
510
344
[% IF import_batch_id %]
511
[% IF import_batch_id %]
512
    <div id="toolbar" class="btn-toolbar">
513
        <!--<button class="btn btn-small" id="import-additional" title="Import extra records into this batch"><i class="icon-plus"></i> <span>Import additional records</span></button>-->
514
        <button class="btn btn-small" id="export-selected" title="Import extra records into this batch"><i class="fa fa-hdd-o"></i> <span>Export selected records</span></button>
515
    </div>
516
345
    <table id="records-table">
517
    <table id="records-table">
346
        <thead>
518
        <thead>
347
            <tr>
519
            <tr>
520
                <th>&nbsp;</th>
348
                <th>#</th>
521
                <th>#</th>
349
                <th>Citation</th>
522
                <th>Citation</th>
350
                <th>Status</th>
523
                <th>Status</th>
Lines 352-357 Link Here
352
                <th>Match details</th>
525
                <th>Match details</th>
353
                <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
526
                <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
354
                <th>Record</th>
527
                <th>Record</th>
528
                <th>Action</th>
355
            </tr>
529
            </tr>
356
        </thead>
530
        </thead>
357
    </table>
531
    </table>
(-)a/svc/cataloguing/import_batches (-1 / +6 lines)
Lines 85-90 sub download_batch { Link Here
85
        };
85
        };
86
    }
86
    }
87
87
88
    my $import_record_ids = $query->param( 'import_record_id' );
89
90
    if ( $import_record_ids ) {
91
        $extra_conditions{'import_record.import_record_id'} = { -in => [ split /\|/, $import_record_ids ] };
92
    }
93
88
    my $records = $schema->resultset('ImportBiblio')->search(
94
    my $records = $schema->resultset('ImportBiblio')->search(
89
        {
95
        {
90
            'import_record.import_batch_id' => $batch_id,
96
            'import_record.import_batch_id' => $batch_id,
91
- 

Return to bug 19265