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 (-179 / +34 lines)
Lines 9-184 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
      $('#import-additional').click( function() {
155
          window.open( '/cgi-bin/koha/tools/stage-marc-import.pl?existing_batch_id=' + [% import_batch_id %] );
156
          return false;
157
      });
158
    [% END %]
159
    $("body").on("click",".previewMARC", function(e){
160
        e.preventDefault();
161
        var ltitle = $(this).text();
162
        var page = $(this).attr("href");
163
        $("#marcPreviewLabel").text(ltitle);
164
        $("#marcPreview .modal-body").load(page + " table");
165
        $('#marcPreview').modal({show:true});
166
    });
167
    $("#marcPreview").on("hidden", function(){
168
        $("#marcPreviewLabel").html("");
169
        $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
170
    });
171
    $(".batch_form").on("submit",function(){
172
        if( $(this).hasClass("batch_delete") ){
173
            return confirm( _("Are you sure you want to permanently delete this batch?") );
174
        } else {
175
            return confirm( _("Clear all reservoir records staged in this batch?  This cannot be undone.") );
176
        }
177
    });
178
});
179
180
//]]>
181
</script>
182
<style type="text/css">
12
<style type="text/css">
183
    #jobpanel,#jobstatus,#jobfailed { display : none; }
13
    #jobpanel,#jobstatus,#jobfailed { display : none; }
184
    span.change-status { font-style:italic; color:#666; display:none; }
14
    span.change-status { font-style:italic; color:#666; display:none; }
Lines 514-521 $(document).ready(function(){ Link Here
514
344
515
[% IF import_batch_id %]
345
[% IF import_batch_id %]
516
    <div id="toolbar" class="btn-toolbar">
346
    <div id="toolbar" class="btn-toolbar">
517
        <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>
347
        <button class="btn btn-default btn-sm" id="import-additional" title="Import extra records into this batch"><i class="icon-plus"></i> <span>Import additional records</span></button>
518
        <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>
348
        <button class="btn btn-default btn-sm" id="export-selected" title="Export selected records from this batch"><i class="fa fa-hdd-o"></i> <span>Export selected records</span></button>
519
    </div>
349
    </div>
520
350
521
    <table id="records-table">
351
    <table id="records-table">
Lines 577-582 $(document).ready(function(){ Link Here
577
            });
407
            });
578
408
579
            [% IF import_batch_id %]
409
            [% IF import_batch_id %]
410
                var checkedRecords = {};
580
                $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
411
                $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
581
                    "bAutoWidth": false,
412
                    "bAutoWidth": false,
582
                    "bFilter": false,
413
                    "bFilter": false,
Lines 614-624 $(document).ready(function(){ Link Here
614
                          var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
445
                          var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
615
                      [% END %]
446
                      [% END %]
616
447
617
                      $('td:eq(1)', nRow).html(
448
                      var record_id = aData['import_record_id'];
449
                      var $checkbox = $('<input type="checkbox"></input>');
450
451
                      $('td:eq(0)', nRow).append($checkbox);
452
                      $checkbox.prop( 'checked', checkedRecords[record_id] );
453
                      $checkbox.change( function() {
454
                          if ( this.checked ) {
455
                              checkedRecords[record_id] = true;
456
                          } else {
457
                              delete checkedRecords[record_id];
458
                          }
459
                      });
460
461
                      $('td:eq(2)', nRow).html(
618
                          '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
462
                          '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
619
                      );
463
                      );
620
464
621
                      $('td:eq(2)', nRow).html(
465
                      $('td:eq(3)', nRow).html(
622
                          aData['status'] == 'imported' ? _("Imported") :
466
                          aData['status'] == 'imported' ? _("Imported") :
623
                          aData['status'] == 'ignored'  ? _("Ignored")  :
467
                          aData['status'] == 'ignored'  ? _("Ignored")  :
624
                          aData['status'] == 'reverted' ? _("Reverted") :
468
                          aData['status'] == 'reverted' ? _("Reverted") :
Lines 627-633 $(document).ready(function(){ Link Here
627
                          aData['status']
471
                          aData['status']
628
                      );
472
                      );
629
473
630
                      $('td:eq(3)', nRow).html(
474
                      $('td:eq(4)', nRow).html(
631
                          aData['overlay_status'] == 'no_match'      ? _("No match")       :
475
                          aData['overlay_status'] == 'no_match'      ? _("No match")       :
632
                          aData['overlay_status'] == 'match_applied' ? _("Match applied")  :
476
                          aData['overlay_status'] == 'match_applied' ? _("Match applied")  :
633
                          aData['overlay_status'] == 'auto_match'    ? _("Match found")    :
477
                          aData['overlay_status'] == 'auto_match'    ? _("Match found")    :
Lines 647-660 $(document).ready(function(){ Link Here
647
                          );
491
                          );
648
                      }
492
                      }
649
                      if (aData['diff_url']){
493
                      if (aData['diff_url']){
650
                          $('td:eq(5)', nRow).html(
494
                          $('td:eq(6)', nRow).html(
651
                              '<a href="'+aData['diff_url']+'">' + _("View") + '</a>'
495
                              '<a rel="gb_page_center[960,600]" href="'+aData['diff_url']+'">View</a>'
652
                          );
496
                          );
653
                      }
497
                      }
654
                      $('td:eq(6)', nRow).html(
498
                      $('td:eq(7)', nRow).html(
655
                          '<a target="_blank" href="' + record_details_url
499
                          '<a target="_blank" href="' + record_details_url
656
                              + aData['matched'] + '">' + aData['matched'] + '</a>'
500
                              + aData['matched'] + '">' + aData['matched'] + '</a>'
657
                      );
501
                      );
502
                      $('td:eq(8)', nRow).html(
503
                          '<a target="_blank" href="/cgi-bin/koha/cataloguing/editor.pl#batch:[% import_batch_id %]/' + record_id
504
                          + '">' + _("Edit") + '</a>'
505
                      );
658
                    },
506
                    },
659
                }));
507
                }));
660
                $("#import_batch_form").on("submit",function(){
508
                $("#import_batch_form").on("submit",function(){
Lines 663-668 $(document).ready(function(){ Link Here
663
                $("#revert_batch_form").on("submit",function(){
511
                $("#revert_batch_form").on("submit",function(){
664
                    return confirm( _("Are you sure you want to undo the import of this batch into the catalog?") ) &&   submitBackgroundJob( document.getElementById("revert_batch_form") );
512
                    return confirm( _("Are you sure you want to undo the import of this batch into the catalog?") ) &&   submitBackgroundJob( document.getElementById("revert_batch_form") );
665
                });
513
                });
514
                $('#export-selected').click( function() {
515
                    var options = {
516
                        import_record_id: $.map( checkedRecords, function( undef, key ) { return key; } ).join('|'),
517
                    };
518
                    if ( options.import_record_id.length == 0 ) return false;_
519
                    window.open( '/cgi-bin/koha/svc/cataloguing/import_batches/' + [% import_batch_id %] + '?download=1&' + $.param( options ) );
520
                    return false;
521
                });
666
            [% END %]
522
            [% END %]
667
            $("body").on("click",".previewMARC", function(e){
523
            $("body").on("click",".previewMARC", function(e){
668
                e.preventDefault();
524
                e.preventDefault();
669
- 

Return to bug 19265