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 (-64 / +34 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
      "bProcessing": true,
33
      "bServerSide": true,
34
      "sAjaxSource": 'batch_records_ajax.pl',
35
      "sPaginationType": "full_numbers",
36
      "fnServerData": function ( sSource, aoData, fnCallback ) {
37
          aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
38
39
          $.getJSON( sSource, aoData, function (json) { 
40
              fnCallback(json)
41
          } );
42
      },
43
      "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
44
        $('td:eq(1)', nRow).html( '<a rel="gb_page_center[600,500]" href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData[0] + '">' + aData[1] + '</a>' );
45
        $('td:eq(5)', nRow).html( '<a target="_blank" href="http://staff.kohadev/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + aData[5] + '">' + aData[5] + '</a>' );
46
      },
47
  });
44
});
48
});
45
//]]>
49
//]]>
46
</script>
50
</script>
Lines 317-369 Page Link Here
317
[% END %]
321
[% END %]
318
322
319
[% IF ( record_list ) %]
323
[% IF ( record_list ) %]
320
  [% IF ( pages ) %]
324
<table id="records-table">
321
<div class="pages">
325
    <thead>
322
Page 
326
        <tr>
323
    [% FOREACH page IN pages %]
327
            <th>#</th>
324
      [% IF ( page.current_page ) %]
328
            <th>Citation</th>
325
      <span class="current">[% page.page_number %]</span>
329
            <th>Status</th>
326
      [% ELSE %]
330
            <th>Match?</th>
327
      <a class="nav" href="[% page.script_name %]?import_batch_id=[% import_batch_id %]&amp;offset=[% page.offset %]">[% page.page_number %]</a>
331
            <th>&nbsp;</th>
328
      [% END %]
332
            <th>Record</th>
329
    [% END %]
333
        </tr>
330
</div>
334
    </thead>
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
335
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>
336
</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 %]
337
[% ELSE %]
368
  [% IF ( batch_info ) %]
338
  [% IF ( batch_info ) %]
369
    <div class="dialog alert">There are no records in this batch to import.
339
    <div class="dialog alert">There are no records in this batch to import.
(-)a/tools/batch_records_ajax.pl (+122 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
use Log::Trivial;
40
my $logger = Log::Trivial->new( log_file => "/tmp/file.log" );
41
42
my @sort_columns = qw/import_record_id title status overlay_status overlay_status/;
43
44
my $import_batch_id   = $input->param('import_batch_id');
45
my $offset            = $input->param('iDisplayStart');
46
my $results_per_page  = $input->param('iDisplayLength');
47
my $sorting_column    = $sort_columns[ $input->param('iSortCol_0') ];
48
my $sorting_direction = $input->param('sSortDir_0');
49
50
$logger->write(
51
    comment => "
52
    import_batch_id => $import_batch_id
53
    offset => $offset
54
    results_per_page => $results_per_page
55
    sorting_column => $sorting_column
56
    sorting_direction => $sorting_direction
57
"
58
);
59
60
binmode STDOUT, ":encoding(UTF-8)";
61
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
62
63
my ( $auth_status, $sessionID ) =
64
  check_cookie_auth( $input->cookie('CGISESSID'), { editcatalogue => '*' } );
65
if ( $auth_status ne "ok" ) {
66
    exit 0;
67
}
68
69
my $batch = GetImportBatch($import_batch_id);
70
my $records =
71
  GetImportRecordsRange( $import_batch_id, $offset, $results_per_page, undef, { order_by => $sorting_column, order_by_direction => $sorting_direction } );
72
my @list = ();
73
foreach my $record (@$records) {
74
    my $citation = $record->{'title'} || $record->{'authorized_heading'};
75
    $citation .= " $record->{'author'}" if $record->{'author'};
76
    $citation .= " (" if $record->{'issn'} or $record->{'isbn'};
77
    $citation .= $record->{'isbn'} if $record->{'isbn'};
78
    $citation .= ", " if $record->{'issn'} and $record->{'isbn'};
79
    $citation .= $record->{'issn'} if $record->{'issn'};
80
    $citation .= ")" if $record->{'issn'} or $record->{'isbn'};
81
82
    my $match = GetImportRecordMatches( $record->{'import_record_id'}, 1 );
83
    my $match_citation = '';
84
    my $match_id;
85
    if ( $#$match > -1 ) {
86
        if ( $match->[0]->{'record_type'} eq 'biblio' ) {
87
            $match_citation .= $match->[0]->{'title'}
88
              if defined( $match->[0]->{'title'} );
89
            $match_citation .= ' ' . $match->[0]->{'author'}
90
              if defined( $match->[0]->{'author'} );
91
            $match_id = $match->[0]->{'biblionumber'};
92
        }
93
        elsif ( $match->[0]->{'record_type'} eq 'auth' ) {
94
            if ( defined( $match->[0]->{'authorized_heading'} ) ) {
95
                $match_citation .= $match->[0]->{'authorized_heading'};
96
                $match_id = $match->[0]->{'candidate_match_id'};
97
            }
98
        }
99
    }
100
    push @list,
101
      {
102
        DT_RowId => $record->{'import_record_id'},
103
        0        => $record->{'import_record_id'},
104
        1        => $citation,
105
        2        => $record->{'status'},
106
        3        => $record->{'overlay_status'},
107
        4        => 'match data',
108
        5        => $record->{'matched_biblionumber'}
109
          || $record->{'matched_authid'}
110
          || q{},
111
      };
112
}
113
114
my $data;
115
$data->{'iTotalRecords'}        = $batch->{'num_records'};
116
$data->{'iTotalDisplayRecords'} = @list;
117
$data->{'sEcho'}                = $input->param('sEcho') || undef;
118
$data->{'aaData'}               = \@list;
119
120
$logger->write( comment => Data::Dumper::Dumper($data) );
121
122
print to_json($data);
(-)a/tools/manage-marc-import.pl (-2 / +1 lines)
Lines 352-358 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
- 

Return to bug 10558