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