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 (+165 lines)
Lines 8-13 Link Here
8
[% END %]
8
[% END %]
9
</title>
9
</title>
10
[% INCLUDE 'doc-head-close.inc' %]
10
[% INCLUDE 'doc-head-close.inc' %]
11
[% Asset.css("css/datatables.css") | $raw %]
11
<style>
12
<style>
12
    #jobpanel,#jobstatus,#jobfailed { display : none; }
13
    #jobpanel,#jobstatus,#jobfailed { display : none; }
13
    span.change-status { font-style:italic; color:#666; display:none; }
14
    span.change-status { font-style:italic; color:#666; display:none; }
Lines 37-42 Link Here
37
 &rsaquo; Batch [% import_batch_id | html %]
38
 &rsaquo; Batch [% import_batch_id | html %]
38
[% END %]
39
[% END %]
39
</h1>
40
</h1>
41
40
[% IF ( label_batch_msg ) %]
42
[% IF ( label_batch_msg ) %]
41
[% IF ( alert ) %]
43
[% IF ( alert ) %]
42
<div class="alert">
44
<div class="alert">
Lines 340-348 Link Here
340
[% END %]
342
[% END %]
341
343
342
[% IF import_batch_id %]
344
[% IF import_batch_id %]
345
    <div id="toolbar" class="btn-toolbar">
346
        <!--<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-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
    </div>
349
343
    <table id="records-table">
350
    <table id="records-table">
344
        <thead>
351
        <thead>
345
            <tr>
352
            <tr>
353
                <th>&nbsp;</th>
346
                <th>#</th>
354
                <th>#</th>
347
                <th>Citation</th>
355
                <th>Citation</th>
348
                <th>Status</th>
356
                <th>Status</th>
Lines 350-355 Link Here
350
                <th>Match details</th>
358
                <th>Match details</th>
351
                <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
359
                <th><abbr title="Differences between the original bibliographic record and the imported">Diff</abbr></th>
352
                <th>Record</th>
360
                <th>Record</th>
361
                <th>Action</th>
353
            </tr>
362
            </tr>
354
        </thead>
363
        </thead>
355
    </table>
364
    </table>
Lines 386-391 Link Here
386
    [% Asset.js("js/tools-menu.js") | $raw %]
395
    [% Asset.js("js/tools-menu.js") | $raw %]
387
    [% Asset.js("js/background-job-progressbar.js") | $raw %]
396
    [% Asset.js("js/background-job-progressbar.js") | $raw %]
388
    [% INCLUDE 'datatables.inc' %]
397
    [% INCLUDE 'datatables.inc' %]
398
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar.js"></script>
389
    <script>
399
    <script>
390
        $(document).ready(function(){
400
        $(document).ready(function(){
391
            $("#staged-record-matching-rules select").change(function(){
401
            $("#staged-record-matching-rules select").change(function(){
Lines 506-511 Link Here
506
                    return confirm( _("Clear all reservoir records staged in this batch?  This cannot be undone.") );
516
                    return confirm( _("Clear all reservoir records staged in this batch?  This cannot be undone.") );
507
                }
517
                }
508
            });
518
            });
519
520
            $("#staged-record-matching-rules select").change(function(){
521
                var str = $(this).attr("id");
522
                $("#reset_"+str).parent().show();
523
            });
524
            $("a.reset").click(function(){
525
                var str = $(this).attr("id");
526
                str = str.replace("reset_","")
527
                $("#"+str+" option[selected='selected']").attr("selected","selected");
528
                $(this).parent().hide();
529
            });
530
            [% IF import_batch_id %]
531
                var checkedRecords = {};
532
                $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
533
                    "bAutoWidth": false,
534
                    "bFilter": false,
535
                    "bProcessing": true,
536
                    "bServerSide": true,
537
                    "sAjaxSource": 'batch_records_ajax.pl',
538
                    "sPaginationType": "full_numbers",
539
                    "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
540
                    "aaSorting": [ [ 1, 'asc' ] ],
541
                    "aoColumns": [{
542
                        "bSortable": false,
543
                        "mDataProp": null,
544
                        "sDefaultContent": ''
545
                    },
546
                    { "mDataProp": "import_record_id" },
547
                    { "mDataProp": "citation" },
548
                    { "mDataProp": "status" },
549
                    { "mDataProp": "overlay_status" },
550
                    { "mDataProp": "match_citation" },
551
                    { "mDataProp": "diff_url" },
552
                    { "mDataProp": "matched" },
553
                    {
554
                        "bSortable": false,
555
                        "mDataProp": null,
556
                        "sDefaultContent": ''
557
                    }
558
                    ],
559
                    "fnServerData": function ( sSource, aoData, fnCallback ) {
560
                        aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
561
                        $.ajax({
562
                            'dataType': 'json',
563
                            'type': 'POST',
564
                            'url': sSource,
565
                            'data': aoData,
566
                            'success': function(json){
567
                                fnCallback(json);
568
                            }
569
                        });
570
                    },
571
                    "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
572
                        [% IF ( record_type == 'auth' ) %]
573
                            var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
574
                        [% ELSE %]
575
                            var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
576
                        [% END %]
577
578
                        var record_id = aData['import_record_id'];
579
                        var $checkbox = $('<input type="checkbox"></input>');
580
                        $('td:eq(0)', nRow).append($checkbox);
581
                        $checkbox.prop( 'checked', checkedRecords[record_id] );
582
                        $checkbox.change( function() {
583
                            if ( this.checked ) {
584
                                checkedRecords[record_id] = true;
585
                            } else {
586
                                delete checkedRecords[record_id];
587
                            }
588
                        });
589
590
                        $('td:eq(2)', nRow).html(
591
                            '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '" class="previewMARC">' + aData['citation'] + '</a>'
592
                        );
593
594
                        $('td:eq(3)', nRow).html(
595
                            aData['status'] == 'imported' ? _("Imported") :
596
                            aData['status'] == 'ignored'  ? _("Ignored")  :
597
                            aData['status'] == 'reverted' ? _("Reverted") :
598
                            aData['status'] == 'staged'   ? _("Staged")   :
599
                            aData['status'] == 'error'    ? _("Error")    :
600
                            aData['status']
601
                        );
602
603
                        $('td:eq(4)', nRow).html(
604
                            aData['overlay_status'] == 'no_match'      ? _("No match")       :
605
                            aData['overlay_status'] == 'match_applied' ? _("Match applied")  :
606
                            aData['overlay_status'] == 'auto_match'    ? _("Match found")    :
607
                            aData['overlay_status']
608
                        );
609
610
                        if ( aData['match_id'] ) {
611
                            [% IF ( record_type == 'auth' ) -%]
612
                                var matching_msg = _("Matches authority %s (score=%s):%s");
613
                            [%- ELSE -%]
614
                                var matching_msg = _("Matches biblio %s (score=%s):%s");
615
                            [%- END %]
616
                                $('td:eq(4)', nRow).html(
617
                                    matching_msg.format(aData['match_id'], aData['score'],
618
                                    '<a target="_blank" href="' + record_details_url
619
                                    + aData['match_id'] + '">' + aData['match_citation'] + '</a>')
620
                                );
621
                        }
622
                        if (aData['diff_url']){
623
                            $('td:eq(6)', nRow).html(
624
                                '<a rel="gb_page_center[960,600]" href="'+aData['diff_url']+'">View</a>'
625
                            );
626
                        }
627
                        $('td:eq(7)', nRow).html(
628
                            '<a target="_blank" href="' + record_details_url
629
                            + aData['matched'] + '">' + aData['matched'] + '</a>'
630
                        );
631
                        $('td:eq(8)', nRow).html(
632
                            '<a target="_blank" href="/cgi-bin/koha/cataloguing/editor.pl#batch:[% import_batch_id %]/' + record_id
633
                            + '">' + _("Edit") + '</a>'
634
                        );
635
                    },
636
                }));
637
                $("#import_batch_form").on("submit",function(){
638
                    return submitBackgroundJob( document.getElementById("import_batch_form") );
639
                });
640
                $("#revert_batch_form").on("submit",function(){
641
                    return confirm( _("Are you sure you want to undo the import of this batch into the catalog?") ) &&   submitBackgroundJob( document.getElementById("revert_batch_form") );
642
                });
643
                $('#export-selected').click( function() {
644
                    var options = {
645
                        import_record_id: $.map( checkedRecords, function( undef, key ) { return key; } ).join('|'),
646
                    };
647
648
                    if ( options.import_record_id.length == 0 ) return false;_
649
650
                    window.open( '/cgi-bin/koha/svc/cataloguing/import_batches/' + [% import_batch_id %] + '?download=1&' + $.param( options ) );
651
                    return false;
652
                });
653
            [% END %]
654
655
            $("body").on("click",".previewMARC", function(e){
656
                e.preventDefault();
657
                var ltitle = $(this).text();
658
                var page = $(this).attr("href");
659
                $("#marcPreviewLabel").text(ltitle);
660
                $("#marcPreview .modal-body").load(page + " table");
661
                $('#marcPreview').modal({show:true});
662
            });
663
            $("#marcPreview").on("hidden", function(){
664
                $("#marcPreviewLabel").html("");
665
                $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
666
            });
667
            $(".batch_form").on("submit",function(){
668
                if( $(this).hasClass("batch_delete") ){
669
                    return confirm( _("Are you sure you want to permanently delete this batch?") );
670
                } else {
671
                    return confirm( _("Clear all reservoir records staged in this batch?  This cannot be undone.") );
672
                }
673
            });
509
        });
674
        });
510
    </script>
675
    </script>
511
[% END %]
676
[% END %]
(-)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