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

(-)a/C4/ImportBatch.pm (+18 lines)
Lines 44-49 BEGIN { Link Here
44
    GetImportBatch
44
    GetImportBatch
45
    AddAuthToBatch
45
    AddAuthToBatch
46
    AddBiblioToBatch
46
    AddBiblioToBatch
47
    DeleteBiblioInBatch
47
    AddItemsToImportBiblio
48
    AddItemsToImportBiblio
48
    ModAuthorityInBatch
49
    ModAuthorityInBatch
49
    ModBiblioInBatch
50
    ModBiblioInBatch
Lines 296-301 sub AddBiblioToBatch { Link Here
296
    return $import_record_id;
297
    return $import_record_id;
297
}
298
}
298
299
300
=head2 DeleteBiblioInBatch
301
    DeleteBiblioInBatch( $import_record_id );
302
=cut
303
304
sub DeleteBiblioInBatch {
305
    my ($subroutine, $import_record_id) = @_;
306
    _delete_import_record_marc($import_record_id);
307
}
308
299
=head2 ModBiblioInBatch
309
=head2 ModBiblioInBatch
300
310
301
  ModBiblioInBatch($import_record_id, $marc_record);
311
  ModBiblioInBatch($import_record_id, $marc_record);
Lines 1615-1620 sub _update_import_record_marc { Link Here
1615
    $sth->finish();
1625
    $sth->finish();
1616
}
1626
}
1617
1627
1628
sub _delete_import_record_marc {
1629
    my ($import_record_id, $subroutine) = @_;
1630
    my $dbh = C4::Context->dbh;
1631
    my $sth = $dbh->prepare("DELETE FROM import_records WHERE import_record_id = ?");
1632
    $sth->execute($import_record_id);
1633
    $sth->finish();
1634
}
1635
1618
sub _add_auth_fields {
1636
sub _add_auth_fields {
1619
    my ($import_record_id, $marc_record) = @_;
1637
    my ($import_record_id, $marc_record) = @_;
1620
1638
(-)a/cataloguing/addbiblio.pl (-2 / +10 lines)
Lines 702-708 my $fa_barcode = $input->param('barcode'); Link Here
702
my $fa_branch             = $input->param('branch');
702
my $fa_branch             = $input->param('branch');
703
my $fa_stickyduedate      = $input->param('stickyduedate');
703
my $fa_stickyduedate      = $input->param('stickyduedate');
704
my $fa_duedatespec        = $input->param('duedatespec');
704
my $fa_duedatespec        = $input->param('duedatespec');
705
705
my $previewrecord = $input->param('preview');
706
my $userflags = 'edit_catalogue';
706
my $userflags = 'edit_catalogue';
707
707
708
my $changed_framework = $input->param('changed_framework') // q{};
708
my $changed_framework = $input->param('changed_framework') // q{};
Lines 843-849 if ( $op eq "addbiblio" ) { Link Here
843
            ModBiblio( $record, $biblionumber, $frameworkcode );
843
            ModBiblio( $record, $biblionumber, $frameworkcode );
844
        }
844
        }
845
        else {
845
        else {
846
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
846
            if ($previewrecord) {
847
                AddBiblioToBatch(1, 0, $record, 'biblio', int(rand(99999)), 1);
848
                print $input->redirect('/cgi-bin/koha/cataloguing/addbooks.pl');
849
            } else {
850
                if ($breedingid) {
851
                    C4::ImportBatch->DeleteBiblioInBatch($breedingid);
852
                }
853
                ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
854
            }
847
        }
855
        }
848
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){
856
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){
849
	    if ($frameworkcode eq 'FA'){
857
	    if ($frameworkcode eq 'FA'){
(-)a/cataloguing/addbooks.pl (-11 / +37 lines)
Lines 45-50 my $success = $input->param('biblioitem'); Link Here
45
my $query   = $input->param('q');
45
my $query   = $input->param('q');
46
my @value   = $input->multi_param('value');
46
my @value   = $input->multi_param('value');
47
my $page    = $input->param('page') || 1;
47
my $page    = $input->param('page') || 1;
48
my $drafts_only = $input->param('drafts_only');
48
my $results_per_page = 20;
49
my $results_per_page = 20;
49
50
50
51
Lines 59-66 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
59
    }
60
    }
60
);
61
);
61
62
62
# Searching the catalog.
63
# Searching the catalog unless 'drafts_only' has been selected
63
if ($query) {
64
if (($query) && !($drafts_only)) {
64
65
65
    # build query
66
    # build query
66
    my @operands = $query;
67
    my @operands = $query;
Lines 122-137 if ($query) { Link Here
122
    ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );
123
    ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );
123
}
124
}
124
my $breeding_loop = [];
125
my $breeding_loop = [];
126
my $count;
127
125
for my $resultsbr (@resultsbr) {
128
for my $resultsbr (@resultsbr) {
126
    push @{$breeding_loop}, {
129
127
        id               => $resultsbr->{import_record_id},
130
    #Only return records associated with 'Draft record' file_name if drafts_only has been set
128
        isbn             => $resultsbr->{isbn},
131
    if ($drafts_only) {
129
        copyrightdate    => $resultsbr->{copyrightdate},
132
        if ($resultsbr->{file_name} eq "Draft record") {
130
        editionstatement => $resultsbr->{editionstatement},
133
            push @{$breeding_loop}, {
131
        file             => $resultsbr->{file_name},
134
                id               => $resultsbr->{import_record_id},
132
        title            => $resultsbr->{title},
135
                isbn             => $resultsbr->{isbn},
133
        author           => $resultsbr->{author},
136
                copyrightdate    => $resultsbr->{copyrightdate},
134
    };
137
                editionstatement => $resultsbr->{editionstatement},
138
                file             => $resultsbr->{file_name},
139
                title            => $resultsbr->{title},
140
                author           => $resultsbr->{author},
141
            };
142
            $count++;
143
        }
144
    } else {
145
        push @{$breeding_loop}, {
146
                id               => $resultsbr->{import_record_id},
147
                isbn             => $resultsbr->{isbn},
148
                copyrightdate    => $resultsbr->{copyrightdate},
149
                editionstatement => $resultsbr->{editionstatement},
150
                file             => $resultsbr->{file_name},
151
                title            => $resultsbr->{title},
152
                author           => $resultsbr->{author},
153
        };
154
    }
155
}
156
157
#If drafts_only has been set then only draft records will be returned to the template. $countbr must be based on the number of drafts in the reservoir
158
if ($drafts_only) {
159
    $countbr = $count;
160
    $template->param( query => $query, drafts_only => $drafts_only );
135
}
161
}
136
162
137
my $servers = Koha::Z3950Servers->search(
163
my $servers = Koha::Z3950Servers->search(
(-)a/cataloguing/batch_records_ajax.pl (+122 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
# Based on circ/ysearch.pl: Copyright 2007 Tamil s.a.r.l.
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 3 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
=head1 NAME
22
23
batch_records_ajax.pl - A script for searching batch imported records via ajax
24
25
=head1 SYNOPSIS
26
27
This script is to be used as a data source for DataTables that load and display
28
the records from an import batch.
29
30
=cut
31
32
use Modern::Perl;
33
34
use CGI qw ( -utf8 );
35
use JSON qw/ to_json /;
36
37
use C4::Context;
38
use C4::Charset;
39
use C4::Auth qw/check_cookie_auth/;
40
use C4::ImportBatch;
41
42
my $input = new CGI;
43
44
my @sort_columns =
45
  qw/import_record_id title status overlay_status overlay_status/;
46
47
my $import_batch_id   = $input->param('import_batch_id');
48
my $offset            = $input->param('iDisplayStart');
49
my $results_per_page  = $input->param('iDisplayLength');
50
my $sorting_column    = $sort_columns[ $input->param('iSortCol_0') // 0 ];
51
my $sorting_direction = $input->param('sSortDir_0');
52
53
$results_per_page = undef if $results_per_page && $results_per_page == -1;
54
55
binmode STDOUT, ":encoding(UTF-8)";
56
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
57
58
my ( $auth_status, $sessionID ) =
59
  check_cookie_auth( $input->cookie('CGISESSID'), { tools => 'manage_staged_marc' } );
60
if ( $auth_status ne "ok" ) {
61
    exit 0;
62
}
63
64
my $batch = GetImportBatch($import_batch_id);
65
my $records =
66
  GetImportRecordsRange( $import_batch_id, $offset, $results_per_page, undef,
67
    { order_by => $sorting_column, order_by_direction => $sorting_direction } );
68
my @list = ();
69
foreach my $record (@$records) {
70
    my $citation = $record->{'title'} || $record->{'authorized_heading'};
71
    $citation .= " $record->{'author'}" if $record->{'author'};
72
    $citation .= " (" if $record->{'issn'} or $record->{'isbn'};
73
    $citation .= $record->{'isbn'} if $record->{'isbn'};
74
    $citation .= ", " if $record->{'issn'} and $record->{'isbn'};
75
    $citation .= $record->{'issn'} if $record->{'issn'};
76
    $citation .= ")" if $record->{'issn'} or $record->{'isbn'};
77
78
    my $match = GetImportRecordMatches( $record->{'import_record_id'}, 1 );
79
    my $match_citation = '';
80
    my $match_id;
81
    if ( $#$match > -1 ) {
82
        if ( $match->[0]->{'record_type'} eq 'biblio' ) {
83
            $match_citation .= $match->[0]->{'title'}
84
              if defined( $match->[0]->{'title'} );
85
            $match_citation .= ' ' . $match->[0]->{'author'}
86
              if defined( $match->[0]->{'author'} );
87
            $match_id = $match->[0]->{'biblionumber'};
88
        }
89
        elsif ( $match->[0]->{'record_type'} eq 'auth' ) {
90
            if ( defined( $match->[0]->{'authorized_heading'} ) ) {
91
                $match_citation .= $match->[0]->{'authorized_heading'};
92
                $match_id = $match->[0]->{'candidate_match_id'};
93
            }
94
        }
95
    }
96
97
    push @list,
98
      {
99
        DT_RowId        => $record->{'import_record_id'},
100
        import_record_id => $record->{'import_record_id'},
101
        citation        => $citation,
102
        status          => $record->{'status'},
103
        overlay_status  => $record->{'overlay_status'},
104
        match_citation  => $match_citation,
105
        matched         => $record->{'matched_biblionumber'}
106
          || $record->{'matched_authid'}
107
          || q{},
108
        score => $#$match > -1 ? $match->[0]->{'score'} : 0,
109
        match_id => $match_id,
110
        diff_url => $match_id ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id" : undef,
111
        catalog_link => "/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=$record->{import_record_id}",
112
        delete_link =>"/cgi-bin/koha/cataloguing/draftrecords.pl?biblionumber=$record->{import_record_id}&op=delete_record",
113
      };
114
}
115
116
my $data;
117
$data->{'iTotalRecords'}        = $batch->{'num_records'};
118
$data->{'iTotalDisplayRecords'} = $batch->{'num_records'};
119
$data->{'sEcho'}                = $input->param('sEcho') || undef;
120
$data->{'aaData'}               = \@list;
121
122
print to_json($data);
(-)a/cataloguing/draftrecords.pl (+125 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2018 Catalyst IT
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
=head1 cataloguing:draftrecords.pl
21
22
	TODO
23
24
=cut
25
26
use strict;
27
use warnings;
28
use CGI qw ( -utf8 );
29
use C4::Auth;
30
use C4::Biblio;
31
use C4::Breeding;
32
use C4::Output;
33
use C4::Koha;
34
use C4::Search;
35
use C4::ImportBatch;
36
37
use Koha::BiblioFrameworks;
38
use Koha::SearchEngine::Search;
39
use Koha::SearchEngine::QueryBuilder;
40
41
my $input = new CGI;
42
43
my $success = $input->param('biblioitem');
44
my $query   = $input->param('q');
45
my @value   = $input->multi_param('value');
46
my $page    = $input->param('page') || 1;
47
my $biblionumber= $input->param('biblionumber');
48
my $op = $input->param('op');
49
my $results_per_page = 20;
50
51
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
52
    {
53
        template_name   => "cataloguing/draftrecords.tt",
54
        query           => $input,
55
        type            => "intranet",
56
        authnotrequired => 0,
57
        flagsrequired   => { editcatalogue => '*' },
58
        debug           => 1,
59
    }
60
);
61
62
# fill with books in breeding farm
63
64
my $countbr = 0;
65
my @resultsbr;
66
if ($query) {
67
# fill isbn or title, depending on what has been entered
68
#u must do check on isbn because u can find number in beginning of title
69
#check is on isbn legnth 13 for new isbn and 10 for old isbn
70
    my ( $title, $isbn );
71
    if ($query=~/\d/) {
72
        my $clean_query = $query;
73
        $clean_query =~ s/-//g; # remove hyphens
74
        my $querylength = length $clean_query;
75
        if ( $querylength == 13 || $querylength == 10 ) {
76
            $isbn = $query;
77
        }
78
    }
79
    if (!$isbn) {
80
        $title = $query;
81
    }
82
    ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );
83
}
84
85
if ($op && $op eq 'delete_record') {
86
    C4::ImportBatch->DeleteBiblioInBatch($biblionumber);
87
} elsif ($op && $op eq 'delete_all') {
88
    CleanBatch(1);
89
}
90
91
92
my $breeding_loop = [];
93
for my $resultsbr (@resultsbr) {
94
    push @{$breeding_loop}, {
95
        id               => $resultsbr->{import_record_id},
96
        isbn             => $resultsbr->{isbn},
97
        copyrightdate    => $resultsbr->{copyrightdate},
98
        editionstatement => $resultsbr->{editionstatement},
99
        file             => $resultsbr->{file_name},
100
        title            => $resultsbr->{title},
101
        author           => $resultsbr->{author},
102
    };
103
}
104
105
my $schema = Koha::Database->new()->schema();
106
my $servers = $schema->resultset('Z3950server')->search(
107
        {
108
            recordtype => 'biblio',
109
            servertype => ['zed', 'sru'],
110
        },
111
        {   result_class => 'DBIx::Class::ResultClass::HashRefInflator',
112
            order_by     => ['rank', 'servername'],
113
        },
114
);
115
116
my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
117
$template->param(
118
    servers           => $servers,
119
    frameworks        => $frameworks,
120
    breeding_count    => $countbr,
121
    breeding_loop     => $breeding_loop,
122
    z3950_search_params => C4::Search::z3950_search_args($query),
123
);
124
125
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/installer/data/mysql/atomicupdate/bug_20678_save_draft_records.sql (+3 lines)
Line 0 Link Here
1
INSERT INTO import_batches (import_batch_id,record_type,file_name,comments) VALUES (1, 'biblio', 'Draft record', 'Draft MARC records created in the addbiblio.pl file but not saved to the Koha catalog');
2
INSERT INTO permissions (module_bit, code, description) VALUES (9, 'commit_MARC_records_to_catalog', 'Commit MARC records to the catalog. If not enabled then a patron will only be able to create draft records if other editcatalogue subpermissions are enabled');
3
INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('EnableDraftRecords', 1, NULL, 'If enabled staff and catalogers will be able to save records to the reservoir as a draft rather than to the catalog. Also the link to the draft records interface in the Cataloguing module will be visible', 'YesNo');
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (-3 / +2 lines)
Lines 1-8 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
[% INCLUDE 'blocking_errors.inc' %]
2
<div id="toolbar" class="btn-toolbar">
2
<div id="toolbar" class="btn-toolbar">
3
3
4
[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items ||
4
[% IF CAN_user_editcatalogue_commit_MARC_records_to_catalog && (CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_serials_create_subscription) %]
5
CAN_user_serials_create_subscription ) %]
6
    <div class="btn-group">
5
    <div class="btn-group">
7
    <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New <span class="caret"></span></button>
6
    <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New <span class="caret"></span></button>
8
        <ul class="dropdown-menu">
7
        <ul class="dropdown-menu">
Lines 27-33 CAN_user_serials_create_subscription ) %] Link Here
27
    </div>
26
    </div>
28
[% END %]
27
[% END %]
29
28
30
[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
29
[% IF ((CAN_user_editcatalogue_commit_MARC_records_to_catalog) and (( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ))) %]
31
    <div class="btn-group">
30
    <div class="btn-group">
32
    <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-pencil"></i> Edit <span class="caret"></span></button>
31
    <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-pencil"></i> Edit <span class="caret"></span></button>
33
        <ul class="dropdown-menu">
32
        <ul class="dropdown-menu">
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cataloging-search.inc (+5 lines)
Lines 6-12 Link Here
6
        <p class="tip">Search the catalog and the reservoir:</p>
6
        <p class="tip">Search the catalog and the reservoir:</p>
7
            <form name="search" action="addbooks.pl">
7
            <form name="search" action="addbooks.pl">
8
                <input class="head-searchbox" type="text" name="q" size="40" />
8
                <input class="head-searchbox" type="text" name="q" size="40" />
9
                <span class="filteraction" id="filteraction_off"> <a href="#">[-]</a></span>
10
                <span class="filteraction" id="filteraction_on">  <a href="#">[+]</a></span>
9
                <input type="submit" class="submit" value="Submit" />
11
                <input type="submit" class="submit" value="Submit" />
12
                <div id="filters">
13
                    <p><input type="checkbox" name="drafts_only" value=1>Drafts only</p>
14
                </div>
10
            </form>
15
            </form>
11
        </div>
16
        </div>
12
17
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc (+1 lines)
Lines 43-48 Link Here
43
    [%- CASE 'edit_items' -%]<span>Edit items</span>
43
    [%- CASE 'edit_items' -%]<span>Edit items</span>
44
    [%- CASE 'edit_items_restricted' -%]<span>Limit item modification to subfields defined in the SubfieldsToAllowForRestrictedEditing preference (please note that edit_item is still required)</span>
44
    [%- CASE 'edit_items_restricted' -%]<span>Limit item modification to subfields defined in the SubfieldsToAllowForRestrictedEditing preference (please note that edit_item is still required)</span>
45
    [%- CASE 'fast_cataloging' -%]<span>Fast cataloging</span>
45
    [%- CASE 'fast_cataloging' -%]<span>Fast cataloging</span>
46
    [%- CASE 'commit_MARC_records_to_catalog' -%]<span>Commit MARC records to the catalog. If not enabled then a patron will only be able to create draft records if other editcatalogue subpermissions are enabled</span>
46
    [%- CASE 'remaining_permissions' -%]<span>Remaining permissions for managing fines and fees</span>
47
    [%- CASE 'remaining_permissions' -%]<span>Remaining permissions for managing fines and fees</span>
47
    [%- CASE 'writeoff' -%]<span>Write off fines and fees</span>
48
    [%- CASE 'writeoff' -%]<span>Write off fines and fees</span>
48
    [%- CASE 'budget_add_del' -%]<span>Add and delete budgets (but can't modify budgets)</span>
49
    [%- CASE 'budget_add_del' -%]<span>Add and delete budgets (but can't modify budgets)</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +2 lines)
Lines 349-355 Link Here
349
                [% IF ( hostrecords ) %]<th>Host records</th>[% END %]
349
                [% IF ( hostrecords ) %]<th>Host records</th>[% END %]
350
                [% IF ( analyze ) %]<th>Used in</th><th></th>[% END %]
350
                [% IF ( analyze ) %]<th>Used in</th><th></th>[% END %]
351
                [% IF ( ShowCourseReserves ) %]<th>Course Reserves</th>[% END %]
351
                [% IF ( ShowCourseReserves ) %]<th>Course Reserves</th>[% END %]
352
                [% IF ( CAN_user_editcatalogue_edit_items ) %]<th class="NoSort">&nbsp;</th>[% END %]
352
                [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_items ) %]<th class="NoSort">&nbsp;</th>[% END %]
353
            </tr>
353
            </tr>
354
        </thead>
354
        </thead>
355
        <tbody>
355
        <tbody>
Lines 532-538 Link Here
532
                       [% END %]
532
                       [% END %]
533
                    </td>
533
                    </td>
534
                [% END %]
534
                [% END %]
535
                [% IF CAN_user_editcatalogue_edit_items %]
535
                [% IF CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_items %]
536
                    <td class="actions">
536
                    <td class="actions">
537
                        [% UNLESS item.cannot_be_edited %]
537
                        [% UNLESS item.cannot_be_edited %]
538
                            <a class="btn btn-default btn-xs" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=[% item.biblionumber %]&itemnumber=[% item.itemnumber %]#edititem"><i class="fa fa-pencil"></i> Edit</a>
538
                            <a class="btn btn-default btn-xs" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=[% item.biblionumber %]&itemnumber=[% item.itemnumber %]#edititem"><i class="fa fa-pencil"></i> Edit</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (-2 / +2 lines)
Lines 457-466 Link Here
457
                              | <a id="requst_article_[% SEARCH_RESULT.biblionumber %]" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Request article</a>
457
                              | <a id="requst_article_[% SEARCH_RESULT.biblionumber %]" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Request article</a>
458
                          [% END %]
458
                          [% END %]
459
459
460
                          [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
460
                          [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_catalogue ) %]
461
                          | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Edit record</a>
461
                          | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Edit record</a>
462
                          [% END %]
462
                          [% END %]
463
                          [% IF ( CAN_user_editcatalogue_edit_items ) %]
463
                          [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_items ) %]
464
                          | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Edit items</a>
464
                          | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Edit items</a>
465
                          [% END %]
465
                          [% END %]
466
466
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-3 / +14 lines)
Lines 86-91 Link Here
86
            return false;
86
            return false;
87
        });
87
        });
88
88
89
        $("#previewrecord").click(function(){
90
            $(".btn-group").removeClass("open");
91
            document.getElementById('preview').value = 1;
92
            onOption();
93
            return false;
94
        });
95
89
        $("#saveandview").click(function(){
96
        $("#saveandview").click(function(){
90
            $(".btn-group").removeClass("open");
97
            $(".btn-group").removeClass("open");
91
            redirect("view");
98
            redirect("view");
Lines 471-479 function Changefwk() { Link Here
471
                <span class="caret"></span>
478
                <span class="caret"></span>
472
                </button>
479
                </button>
473
                <ul class="dropdown-menu">
480
                <ul class="dropdown-menu">
474
                    <li><a id="saveandview" href="#">Save and view record</a></li>
481
                    [% IF CAN_user_editcatalogue_commit_MARC_records_to_catalog %]
475
                    <li><a id="saveanditems" href="#">Save and edit items</a></li>
482
                        <li><a id="saveandview" href="#">Save and view record</a></li>
476
                    <li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
483
                        <li><a id="saveanditems" href="#">Save and edit items</a></li>
484
                        <li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
485
                    [% END %]
486
                    <li><a id="previewrecord" name="previewrecord" href="#">Save without cataloging</a></li>
477
                </ul>
487
                </ul>
478
            </div>
488
            </div>
479
        [% END %]
489
        [% END %]
Lines 561-566 function Changefwk() { Link Here
561
        <input type="hidden" name="mode" value="popup" />
571
        <input type="hidden" name="mode" value="popup" />
562
[% END %]
572
[% END %]
563
        <input type="hidden" name="op" value="addbiblio" />
573
        <input type="hidden" name="op" value="addbiblio" />
574
        <input type="hidden" id="preview" name="preview" />
564
        <input type="hidden" id="frameworkcode" name="frameworkcode" value="[% frameworkcode %]" />
575
        <input type="hidden" id="frameworkcode" name="frameworkcode" value="[% frameworkcode %]" />
565
        <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
576
        <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
566
        <input type="hidden" name="breedingid" value="[% breedingid %]" />
577
        <input type="hidden" name="breedingid" value="[% breedingid %]" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt (-5 / +34 lines)
Lines 44-49 Link Here
44
            </ul>
44
            </ul>
45
        </div>
45
        </div>
46
        [% END %]
46
        [% END %]
47
        <a class="btn btn-default btn-sm" href="/cgi-bin/koha/cataloguing/draftrecords.pl"><i class="fa fa-eye" aria-hidden="true"></i> View draft records</a></button>
47
    [% IF ( total ) %]
48
    [% IF ( total ) %]
48
        <div class="btn-group"><button type="submit" class="btn btn-default btn-sm merge-items"><i class="fa fa-compress"></i> Merge selected</button></div>
49
        <div class="btn-group"><button type="submit" class="btn btn-default btn-sm merge-items"><i class="fa fa-compress"></i> Merge selected</button></div>
49
    [% END %]
50
    [% END %]
Lines 142-148 Link Here
142
    </table>
143
    </table>
143
</div>
144
</div>
144
[% ELSE %]
145
[% ELSE %]
145
    [% IF ( query ) %]
146
    [% IF (( query ) && !(drafts_only)) %]
146
        [% IF ( error ) %]<div class="dialog alert">[% END %]<b>No results found</b>
147
        [% IF ( error ) %]<div class="dialog alert">[% END %]<b>No results found</b>
147
        [% IF ( error ) %]
148
        [% IF ( error ) %]
148
            Error: <span class="error">[% error %]</span></div>
149
            Error: <span class="error">[% error %]</span></div>
Lines 151-158 Link Here
151
[% END %]
152
[% END %]
152
153
153
[% IF ( query ) %]
154
[% IF ( query ) %]
154
<div id="searchresult-breeding">
155
    [% IF (drafts_only) %]
155
    <h3>Biblios in reservoir</h3>
156
        <div>
157
            <a href="#searchresult-breeding">[% breeding_count %] result(s) found in reservoir</a>
158
        </div>
159
    [% END %]
160
    <div id="searchresult-breeding">
161
    [% IF (drafts_only) %]
162
        <h3>Draft records in reservoir</h3>
163
    [% ELSE %]
164
        <h3>Biblios in reservoir</h3>
165
    [% END %]
156
    [% IF ( breeding_loop ) %]
166
    [% IF ( breeding_loop ) %]
157
        <table>
167
        <table>
158
            <tr>
168
            <tr>
Lines 170-176 Link Here
170
                <td>[% breeding_loo.isbn %]</td>
180
                <td>[% breeding_loo.isbn %]</td>
171
                <td>[% breeding_loo.copyrightdate %]</td>
181
                <td>[% breeding_loo.copyrightdate %]</td>
172
                <td>[% breeding_loo.edition %]</td>
182
                <td>[% breeding_loo.edition %]</td>
173
                <td>[% breeding_loo.file %]</td>
183
                <td>
184
                      [% IF breeding_loo.file == "Draft record" %]
185
                           Draft record
186
                      [% ELSE %]
187
                           [% breeding_loo.file %]
188
                      [% END %]
189
                </td>
174
                <td>
190
                <td>
175
                  <div class="dropup">
191
                  <div class="dropup">
176
                    <a class="btn btn-default btn-xs dropdown-toggle" id="reservoirsearchactions[% breeding_loo.id %]" role="button" data-toggle="dropdown" href="#">
192
                    <a class="btn btn-default btn-xs dropdown-toggle" id="reservoirsearchactions[% breeding_loo.id %]" role="button" data-toggle="dropdown" href="#">
Lines 180-186 Link Here
180
                      <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.id %]" class="previewData"><i class="fa fa-eye"></i> MARC preview</a></li>
196
                      <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.id %]" class="previewData"><i class="fa fa-eye"></i> MARC preview</a></li>
181
                      <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.id %]" class="previewData"><i class="fa fa-eye"></i> Card preview</a></li>
197
                      <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.id %]" class="previewData"><i class="fa fa-eye"></i> Card preview</a></li>
182
                      [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
198
                      [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
183
                        <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Add biblio</a></li>
199
                        [% IF breeding_loo.file == "Draft record" %]
200
                            <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Continue editing draft record</a></li>
201
                        [% ELSE %]
202
                            <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Add biblio</a></li>
203
                        [% END %]
184
                      [% END %]
204
                      [% END %]
185
                    </ul>
205
                    </ul>
186
                  </div>
206
                  </div>
Lines 221-226 Link Here
221
            //Set focus to cataloging search
241
            //Set focus to cataloging search
222
            $("input[name=q]:eq(0)").focus();
242
            $("input[name=q]:eq(0)").focus();
223
243
244
            $("#filteraction_off").hide();
245
            $("#filters").hide();
246
247
            $("#filteraction_off, #filteraction_on").on('click', function(e) {
248
                e.preventDefault();
249
                $('#filters').toggle();
250
                $('.filteraction').toggle();
251
            });
252
224
            $("#z3950search").click(function(){
253
            $("#z3950search").click(function(){
225
                PopupZ3950("");
254
                PopupZ3950("");
226
                return false;
255
                return false;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/draftrecords.tt (+139 lines)
Line 0 Link Here
1
[% SET footerjs = 1 %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Cataloging &rsaquo; Draft records</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'browser-strings.inc' %]
6
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
7
<style type="text/css">
8
    #jobpanel,#jobstatus,#jobfailed { display : none; }
9
    span.change-status { font-style:italic; color:#666; display:none; }
10
</style>
11
</head>
12
<body class="cat">
13
    [% INCLUDE 'header.inc' %]
14
    <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloguing</a> &rsaquo; View draft records</div>
15
    <div id="doc" class="yui-t2">
16
       <div id="bd">
17
          <div id="yui-main">
18
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
19
            <div id="toolbar" class="btn-toolbar">
20
                [% IF Koha.Preference( 'EnableAdvancedCatalogingEditor' ) == 1 %]
21
                    <a id="useadvanced" href="/cgi-bin/koha/cataloguing/editor.pl" class="btn btn-default btn-sm"><i class="fa fa-pencil"></i> Advanced editor</a>
22
                [% END %]
23
                <div class="btn-group">
24
                    <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New record <span class="caret"></span></button>
25
                    <ul class="dropdown-menu">
26
                         <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=">Default framework</a></li>
27
                         [% FOREACH framework IN frameworks %]
28
                             <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=[% framework.frameworkcode %]">[% framework.frameworktext %]</a></li>
29
                         [% END %]
30
                    </ul>
31
                </div>
32
                [% IF servers.count > 0 %]
33
                   <div class="btn-group">
34
                        <button class="btn btn-default btn-sm" id="z3950search"><i class="fa fa-search"></i> New from Z39.50/SRU</button>
35
                        <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
36
                           <span class="caret"></span>
37
                        </button>
38
                        <ul class="dropdown-menu">
39
                             <li id="" class="z3950searchFw"><a href="#">Default framework</a></li>
40
                             [% FOREACH framework IN frameworks %]
41
                                 <li id="[% framework.frameworkcode %]" class="z3950searchFw"><a href="#">[% framework.frameworktext %]</a></li>
42
                             [% END %]
43
                        </ul>
44
                   </div>
45
                [% END %]
46
                <a class="btn btn-default btn-sm" href="/cgi-bin/koha/cataloguing/draftrecords.pl"><i class="fa fa-eye" aria-hidden="true"></i> View draft records</a></button>
47
                [% IF ( total ) %]
48
                    <div class="btn-group"><button type="submit" class="btn btn-default btn-sm merge-items"><i class="fa fa-compress"></i> Merge selected</button></div>
49
                [% END %]
50
            </div>
51
            [% END %]
52
            <h1>View draft records</h1>
53
                <div id="draftrecords">
54
                   <p> To edit or save these draft records click the 'Edit' link beside the appropriate record.
55
                   <form action="/cgi-bin/koha/cataloguing/draftrecords.pl" method="post">
56
                       <input type="hidden" name="op" id="delete_all_drafts" value='delete_all'/>
57
                       <button type="submit">Delete all drafts from reservoir</button>
58
                   </form>
59
                   </p>
60
                   <table id="records-table">
61
                     <thead>
62
                        <tr>
63
                           <th>#</th>
64
                           <th>Citation</th>
65
                           <th>Status</th>
66
                           <th>Edit record</th>
67
                           <th>Delete record</th>
68
                        </tr>
69
                     </thead>
70
                   </table>
71
                </div>
72
          </div>
73
     </div>
74
  </div>
75
</body>
76
[% MACRO jsinclude BLOCK %]
77
<script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu_[% KOHA_VERSION %].js"></script>
78
<script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar_[% KOHA_VERSION %].js"></script>
79
[% INCLUDE 'datatables.inc' %]
80
<script type="text/javascript">
81
    $(document).ready(function(){
82
       $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
83
          "bSort": true,
84
          "order": [0, "desc"],
85
          "bAutoWidth": false,
86
          "bFilter": false,
87
          "bProcessing": true,
88
          "bServerSide": true,
89
          "sAjaxSource": 'batch_records_ajax.pl',
90
          "sPaginationType": "full_numbers",
91
          "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
92
          "aoColumns": [
93
             { "mDataProp": "import_record_id" },
94
             { "mDataProp": "citation" },
95
             { "mDataProp": "status" },
96
             { "mDataProp": "catalog_link" },
97
             { "mDataProp": "delete_link" }
98
          ],
99
           "fnServerData": function ( sSource, aoData, fnCallback ) {
100
              aoData.push( { "name": "import_batch_id", "value": 1 } );
101
                 $.ajax({
102
                      'dataType': 'json',
103
                      'type': 'POST',
104
                      'url': sSource,
105
                      'data': aoData,
106
                      'success': function(json){
107
                        fnCallback(json);
108
                      }
109
                 });
110
             },
111
            "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
112
               [% IF ( record_type == 'auth' ) %]
113
                  var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
114
               [% ELSE %]
115
                  var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
116
               [% END %]
117
               $('td:eq(1)', nRow).html(
118
                  '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
119
               );
120
               $('td:eq(2)', nRow).html(
121
                  aData['status'] == 'staged'   ? _("Draft")   :
122
                  aData['status']
123
               );
124
               if (aData['catalog_link']){
125
                  $('td:eq(3)', nRow).html(
126
                      '<a href="' + aData['catalog_link'] + '">' + "Edit" + '</a>'
127
                  );
128
               }
129
               if (aData['delete_link']){
130
                  $('td:eq(4)', nRow).html(
131
                      '<a href="' + aData['delete_link'] + '">' + "Delete" + '</a>'
132
                  );
133
               }
134
            },
135
        }));
136
    });
137
</script>
138
[% END %]
139
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/t/db_dependent/ImportBatch.t (-2 / +6 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::More tests => 14;
4
use Test::More tests => 15;
5
use Cwd qw(abs_path);
5
use Cwd qw(abs_path);
6
use File::Temp qw/tempfile/;
6
use File::Temp qw/tempfile/;
7
7
Lines 144-149 $dbh->do( "DELETE FROM items WHERE itemnumber=?", undef, $itemno ); Link Here
144
is( @a, 0, 'No item numbers expected since we deleted the item' );
144
is( @a, 0, 'No item numbers expected since we deleted the item' );
145
$dbh->do( $sql, undef, undef, $import_record_id ); # remove link again
145
$dbh->do( $sql, undef, undef, $import_record_id ); # remove link again
146
146
147
#Test DeleteBiblioInBatch
148
my @a = DeleteBiblioInBatch( $import_record_id); #Remove the MARC record from import_biblios and import_records tables
149
my $biblio_in_import_records = $dbh->do('SELECT * FROM import_records WHERE import_batch_id = "$import_record_id"');
150
is( $biblio_in_import_records, "0E0", 'No biblio expected since we deleted the biblio from the batch' );
151
147
# fresh data
152
# fresh data
148
my $sample_import_batch3 = {
153
my $sample_import_batch3 = {
149
    matcher_id => 3,
154
    matcher_id => 3,
150
- 

Return to bug 20678