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

(-)a/C4/ImportBatch.pm (-2 / +5 lines)
Lines 990-996 starting at the given offset. Link Here
990
=cut
990
=cut
991
991
992
sub GetImportRecordsRange {
992
sub GetImportRecordsRange {
993
    my ($batch_id, $offset, $results_per_group, $status) = @_;
993
    my ( $batch_id, $offset, $results_per_group, $status, $parameters ) = @_;
994
995
    my $order_by = $parameters->{order_by} || 'import_record_id';
996
    my $order_by_direction = $parameters->{order_by_direction} || 'ASC';
994
997
995
    my $dbh = C4::Context->dbh;
998
    my $dbh = C4::Context->dbh;
996
    my $query = "SELECT title, author, isbn, issn, authorized_heading, import_records.import_record_id,
999
    my $query = "SELECT title, author, isbn, issn, authorized_heading, import_records.import_record_id,
Lines 1006-1012 sub GetImportRecordsRange { Link Here
1006
        $query .= " AND status=?";
1009
        $query .= " AND status=?";
1007
        push(@params,$status);
1010
        push(@params,$status);
1008
    }
1011
    }
1009
    $query.=" ORDER BY import_record_id";
1012
    $query.=" ORDER BY $order_by $order_by_direction";
1010
1013
1011
    if($results_per_group){
1014
    if($results_per_group){
1012
        $query .= " LIMIT ?";
1015
        $query .= " LIMIT ?";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (-72 / +64 lines)
Lines 1-22 Link Here
1
[% BLOCK final_match_link %]
2
    [% IF ( record.record_type == 'biblio' ) %]
3
        <a target="_blank" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record.final_match_id %]">[% record.final_match_id %]</a>
4
    [% ELSIF ( record.record_type == 'auth' ) %]
5
        <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record.final_match_id %]">[% record.final_match_id %]</a>
6
    [% END %]
7
[% END %]
8
[% BLOCK match_link %]
9
    [% IF ( record_lis.match_id ) %]
10
        <tr>
11
            <td />
12
            [% IF ( record.record_type == 'biblio' ) %]
13
                <td class="highlight" colspan="4">Matches biblio [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td>
14
            [% ELSIF ( record.record_type == 'auth' ) %]
15
                <td class="highlight" colspan="4">Matches authority [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td>
16
            [% END %]
17
        </tr>
18
    [% END %]
19
[% END %]
20
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
21
<title>Koha &rsaquo; Tools &rsaquo; Manage staged MARC records
2
<title>Koha &rsaquo; Tools &rsaquo; Manage staged MARC records
22
[% IF ( import_batch_id ) %]
3
[% IF ( import_batch_id ) %]
Lines 26-31 Link Here
26
[% INCLUDE 'greybox.inc' %]
7
[% INCLUDE 'greybox.inc' %]
27
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'doc-head-close.inc' %]
28
<script type="text/javascript" src="[% themelang %]/js/background-job-progressbar.js"></script>
9
<script type="text/javascript" src="[% themelang %]/js/background-job-progressbar.js"></script>
10
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
11
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
12
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
13
[% INCLUDE 'datatables-strings.inc' %]
14
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
29
<script type="text/JavaScript" language="JavaScript">
15
<script type="text/JavaScript" language="JavaScript">
30
//<![CDATA[
16
//<![CDATA[
31
var MSG_CONFIRM_CLEAN = _("Clear all reservoir records staged in this batch?  This cannot be undone.");
17
var MSG_CONFIRM_CLEAN = _("Clear all reservoir records staged in this batch?  This cannot be undone.");
Lines 41-46 $(document).ready(function(){ Link Here
41
      $("#"+str+" option[selected='selected']").attr("selected","selected");
27
      $("#"+str+" option[selected='selected']").attr("selected","selected");
42
      $(this).parent().hide();
28
      $(this).parent().hide();
43
  });
29
  });
30
31
  $("#records-table").dataTable({
32
      "aLengthMenu": [[10, 15, 20, 25, 50, 100], [10, 15, 20, 25, 50, 100]],
33
      "iDisplayLength" : 20,
34
      "bAutoWidth": false,
35
      "bFilter": false,
36
      "bProcessing": true,
37
      "bServerSide": true,
38
      "sAjaxSource": 'batch_records_ajax.pl',
39
      "sPaginationType": "full_numbers",
40
      "aoColumns": [
41
          { "mDataProp": "import_record_id" },
42
          { "mDataProp": "citation" },
43
          { "mDataProp": "status" },
44
          { "mDataProp": "overlay_status" },
45
          { "mDataProp": "match_citation" },
46
          { "mDataProp": "matched" },
47
      ],
48
      "fnServerData": function ( sSource, aoData, fnCallback ) {
49
          aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
50
51
          $.getJSON( sSource, aoData, function (json) { 
52
              fnCallback(json)
53
          } );
54
      },
55
      "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
56
        $('td:eq(1)', nRow).html(
57
            '<a rel="gb_page_center[600,500]" href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' 
58
            + aData['import_record_id'] + '">' + aData['citation'] + '</a>' 
59
        );
60
61
        if ( aData['match_id'] ) {
62
            $('td:eq(4)', nRow).html( 
63
                _('Matches biblio ') 
64
                + aData['match_id'] 
65
                + ' (' + _('score') + '=' 
66
                + aData['score'] 
67
                + '):' + '<a target="_blank" href="http://staff.kohadev/cgi-bin/koha/catalogue/detail.pl?biblionumber=' 
68
                + aData['match_id'] + '">' + aData['match_citation'] + '</a>' 
69
            );
70
        }
71
72
        $('td:eq(5)', nRow).html(
73
            '<a target="_blank" href="http://staff.kohadev/cgi-bin/koha/catalogue/detail.pl?biblionumber=' 
74
            + aData['matched'] + '">' + aData['matched'] + '</a>' 
75
        );
76
      },
77
  });
44
});
78
});
45
//]]>
79
//]]>
46
</script>
80
</script>
Lines 316-376 Page Link Here
316
  [% END %]
350
  [% END %]
317
[% END %]
351
[% END %]
318
352
319
[% IF ( record_list ) %]
353
<table id="records-table">
320
  [% IF ( pages ) %]
354
    <thead>
321
<div class="pages">
355
        <tr>
322
Page 
356
            <th>#</th>
323
    [% FOREACH page IN pages %]
357
            <th>Citation</th>
324
      [% IF ( page.current_page ) %]
358
            <th>Status</th>
325
      <span class="current">[% page.page_number %]</span>
359
            <th>Match?</th>
326
      [% ELSE %]
360
            <th>&nbsp;</th>
327
      <a class="nav" href="[% page.script_name %]?import_batch_id=[% import_batch_id %]&amp;offset=[% page.offset %]">[% page.page_number %]</a>
361
            <th>Record</th>
328
      [% END %]
362
        </tr>
329
    [% END %]
363
    </thead>
330
</div>
331
  [% END %]
332
<table>
333
  <tr>
334
    <th>#</th>
335
    <th>Citation</th>
336
    <th>Status</th>
337
    <th>Match?</th>
338
    <th>Record</th>
339
364
340
  </tr>
341
  [% FOREACH record_lis IN record_list %]
342
  [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
343
    <td>[% record_lis.record_sequence %]</td>
344
    <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% record_lis.import_record_id %]" rel="gb_page_center[600,500]">[% record_lis.citation %]</a></td>
345
    <td>[% record_lis.status %]</td>
346
    <td>[% record_lis.overlay_status %]</td>
347
    <td>[% IF ( record_lis.final_match_id ) %]
348
        [% PROCESS final_match_link record=record_lis %]
349
        [% END %]
350
    </td>
351
  </tr>
352
    [% PROCESS match_link record=record_lis %]
353
  [% END %]
354
</table>
365
</table>
355
  [% IF ( pages ) %]
356
<div class="pages">
357
Page 
358
    [% FOREACH page IN pages %]
359
      [% IF ( page.current_page ) %]
360
      <span class="current">[% page.page_number %]</span>
361
      [% ELSE %]
362
      <a class="nav" href="[% page.script_name %]?import_batch_id=[% import_batch_id %]&amp;offset=[% page.offset %]">[% page.page_number %]</a>
363
      [% END %]
364
    [% END %]
365
</div>
366
  [% END %]
367
[% ELSE %]
368
  [% IF ( batch_info ) %]
369
    <div class="dialog alert">There are no records in this batch to import.
370
    <a href="/cgi-bin/koha/tools/manage-marc-import.pl">Manage staged MARC records</a>.</div>
371
372
  [% END %]
373
[% END %]
374
366
375
</div>
367
</div>
376
</div>
368
</div>
(-)a/tools/batch_records_ajax.pl (+112 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
4
5
# Copyright 2007 Tamil s.a.r.l.
6
#
7
# This file is part of Koha.
8
#
9
# 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
11
# Foundation; either version 2 of the License, or (at your option) any later
12
# version.
13
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License along
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
=head1 ysearch.pl
23
24
25
=cut
26
27
use Modern::Perl;
28
29
use CGI;
30
use JSON qw/ to_json /;
31
32
use C4::Context;
33
use C4::Charset;
34
use C4::Auth qw/check_cookie_auth/;
35
use C4::ImportBatch;
36
37
my $input = new CGI;
38
39
my @sort_columns =
40
  qw/import_record_id title status overlay_status overlay_status/;
41
42
my $import_batch_id   = $input->param('import_batch_id');
43
my $offset            = $input->param('iDisplayStart');
44
my $results_per_page  = $input->param('iDisplayLength');
45
my $sorting_column    = $sort_columns[ $input->param('iSortCol_0') ];
46
my $sorting_direction = $input->param('sSortDir_0');
47
48
binmode STDOUT, ":encoding(UTF-8)";
49
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
50
51
my ( $auth_status, $sessionID ) =
52
  check_cookie_auth( $input->cookie('CGISESSID'), { editcatalogue => '*' } );
53
if ( $auth_status ne "ok" ) {
54
    exit 0;
55
}
56
57
my $batch = GetImportBatch($import_batch_id);
58
my $records =
59
  GetImportRecordsRange( $import_batch_id, $offset, $results_per_page, undef,
60
    { order_by => $sorting_column, order_by_direction => $sorting_direction } );
61
my @list = ();
62
foreach my $record (@$records) {
63
    my $citation = $record->{'title'} || $record->{'authorized_heading'};
64
    $citation .= " $record->{'author'}" if $record->{'author'};
65
    $citation .= " (" if $record->{'issn'} or $record->{'isbn'};
66
    $citation .= $record->{'isbn'} if $record->{'isbn'};
67
    $citation .= ", " if $record->{'issn'} and $record->{'isbn'};
68
    $citation .= $record->{'issn'} if $record->{'issn'};
69
    $citation .= ")" if $record->{'issn'} or $record->{'isbn'};
70
71
    my $match = GetImportRecordMatches( $record->{'import_record_id'}, 1 );
72
    my $match_citation = '';
73
    my $match_id;
74
    if ( $#$match > -1 ) {
75
        if ( $match->[0]->{'record_type'} eq 'biblio' ) {
76
            $match_citation .= $match->[0]->{'title'}
77
              if defined( $match->[0]->{'title'} );
78
            $match_citation .= ' ' . $match->[0]->{'author'}
79
              if defined( $match->[0]->{'author'} );
80
            $match_id = $match->[0]->{'biblionumber'};
81
        }
82
        elsif ( $match->[0]->{'record_type'} eq 'auth' ) {
83
            if ( defined( $match->[0]->{'authorized_heading'} ) ) {
84
                $match_citation .= $match->[0]->{'authorized_heading'};
85
                $match_id = $match->[0]->{'candidate_match_id'};
86
            }
87
        }
88
    }
89
90
    push @list,
91
      {
92
        DT_RowId        => $record->{'import_record_id'},
93
        import_record_id => $record->{'import_record_id'},
94
        citation        => $citation,
95
        status          => $record->{'status'},
96
        overlay_status  => $record->{'overlay_status'},
97
        match_citation  => $match_citation,
98
        matched         => $record->{'matched_biblionumber'}
99
          || $record->{'matched_authid'}
100
          || q{},
101
        score => $#$match > -1 ? $match->[0]->{'score'} : 0,
102
        match_id => $match_id,
103
      };
104
}
105
106
my $data;
107
$data->{'iTotalRecords'}        = $batch->{'num_records'};
108
$data->{'iTotalDisplayRecords'} = $batch->{'num_records'};
109
$data->{'sEcho'}                = $input->param('sEcho') || undef;
110
$data->{'aaData'}               = \@list;
111
112
print to_json($data);
(-)a/tools/manage-marc-import.pl (-50 / +49 lines)
Lines 352-406 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, $offset, $results_per_page);
355
#    my $records = GetImportRecordsRange($import_batch_id);
356
    my @list = ();
356
#    my @list = ();
357
    foreach my $record (@$records) {
357
#    foreach my $record (@$records) {
358
        my $citation = $record->{'title'} || $record->{'authorized_heading'};
358
#        my $citation = $record->{'title'} || $record->{'authorized_heading'};
359
        $citation .= " $record->{'author'}" if $record->{'author'};
359
#        $citation .= " $record->{'author'}" if $record->{'author'};
360
        $citation .= " (" if $record->{'issn'} or $record->{'isbn'};
360
#        $citation .= " (" if $record->{'issn'} or $record->{'isbn'};
361
        $citation .= $record->{'isbn'} if $record->{'isbn'};
361
#        $citation .= $record->{'isbn'} if $record->{'isbn'};
362
        $citation .= ", " if $record->{'issn'} and $record->{'isbn'};
362
#        $citation .= ", " if $record->{'issn'} and $record->{'isbn'};
363
        $citation .= $record->{'issn'} if $record->{'issn'};
363
#        $citation .= $record->{'issn'} if $record->{'issn'};
364
        $citation .= ")" if $record->{'issn'} or $record->{'isbn'};
364
#        $citation .= ")" if $record->{'issn'} or $record->{'isbn'};
365
365
#
366
        my $match = GetImportRecordMatches($record->{'import_record_id'}, 1);
366
#        my $match = GetImportRecordMatches($record->{'import_record_id'}, 1);
367
        my $match_citation = '';
367
#        my $match_citation = '';
368
        my $match_id;
368
#        my $match_id;
369
        if ($#$match > -1) {
369
#        if ($#$match > -1) {
370
            if ($match->[0]->{'record_type'} eq 'biblio') {
370
#            if ($match->[0]->{'record_type'} eq 'biblio') {
371
                $match_citation .= $match->[0]->{'title'} if defined($match->[0]->{'title'});
371
#                $match_citation .= $match->[0]->{'title'} if defined($match->[0]->{'title'});
372
                $match_citation .= ' ' . $match->[0]->{'author'} if defined($match->[0]->{'author'});
372
#                $match_citation .= ' ' . $match->[0]->{'author'} if defined($match->[0]->{'author'});
373
                $match_id = $match->[0]->{'biblionumber'};
373
#                $match_id = $match->[0]->{'biblionumber'};
374
            } elsif ($match->[0]->{'record_type'} eq 'auth') {
374
#            } elsif ($match->[0]->{'record_type'} eq 'auth') {
375
                if (defined($match->[0]->{'authorized_heading'})) {
375
#                if (defined($match->[0]->{'authorized_heading'})) {
376
                    $match_citation .= $match->[0]->{'authorized_heading'};
376
#                    $match_citation .= $match->[0]->{'authorized_heading'};
377
                    $match_id = $match->[0]->{'candidate_match_id'};
377
#                    $match_id = $match->[0]->{'candidate_match_id'};
378
                }
378
#                }
379
            }
379
#            }
380
        }
380
#        }
381
381
#
382
        push @list,
382
#        push @list,
383
          { import_record_id         => $record->{'import_record_id'},
383
#          { import_record_id         => $record->{'import_record_id'},
384
            final_match_id           => $record->{'matched_biblionumber'} || $record->{'matched_authid'},
384
#            final_match_id           => $record->{'matched_biblionumber'} || $record->{'matched_authid'},
385
            citation                 => $citation,
385
#            citation                 => $citation,
386
            status                   => $record->{'status'},
386
#            status                   => $record->{'status'},
387
            record_sequence          => $record->{'record_sequence'},
387
#            record_sequence          => $record->{'record_sequence'},
388
            overlay_status           => $record->{'overlay_status'},
388
#            overlay_status           => $record->{'overlay_status'},
389
            # Sorry about the match_id being from the "biblionumber" field;
389
#            # Sorry about the match_id being from the "biblionumber" field;
390
            # as it turns out, any match id will go in biblionumber
390
#            # as it turns out, any match id will go in biblionumber
391
            match_id                 => $match_id,
391
#            match_id                 => $match_id,
392
            match_citation           => $match_citation,
392
#            match_citation           => $match_citation,
393
            match_score              => $#$match > -1 ? $match->[0]->{'score'} : 0,
393
#            match_score              => $#$match > -1 ? $match->[0]->{'score'} : 0,
394
            record_type              => $record->{'record_type'},
394
#            record_type              => $record->{'record_type'},
395
          };
395
#          };
396
    }
396
#    }
397
    my $num_records = $batch->{'num_records'};
397
#    my $num_records = $batch->{'num_records'};
398
    $template->param(record_list => \@list);
398
#    $template->param(record_list => \@list);
399
    add_page_numbers($template, $offset, $results_per_page, $num_records);
399
#    add_page_numbers($template, $offset, $results_per_page, $num_records);
400
    $template->param(offset => $offset);
400
#    $template->param(offset => $offset);
401
    $template->param(range_top => $offset + $results_per_page - 1);
401
#    $template->param(range_top => $offset + $results_per_page - 1);
402
    $template->param(num_results => $num_records);
402
#    $template->param(num_results => $num_records);
403
    $template->param(results_per_page => $results_per_page);
403
#    $template->param(results_per_page => $results_per_page);
404
    $template->param(import_batch_id => $import_batch_id);
404
    $template->param(import_batch_id => $import_batch_id);
405
    my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
405
    my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
406
    $template->param("overlay_action_${overlay_action}" => 1);
406
    $template->param("overlay_action_${overlay_action}" => 1);
407
- 

Return to bug 10558