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

(-)a/C4/ImportBatch.pm (+18 lines)
Lines 45-50 BEGIN { Link Here
45
    GetImportBatch
45
    GetImportBatch
46
    AddAuthToBatch
46
    AddAuthToBatch
47
    AddBiblioToBatch
47
    AddBiblioToBatch
48
    DeleteBiblioInBatch
48
    AddItemsToImportBiblio
49
    AddItemsToImportBiblio
49
    ModAuthorityInBatch
50
    ModAuthorityInBatch
50
    ModBiblioInBatch
51
    ModBiblioInBatch
Lines 294-299 sub AddBiblioToBatch { Link Here
294
    return $import_record_id;
295
    return $import_record_id;
295
}
296
}
296
297
298
=head2 DeleteBiblioInBatch
299
    DeleteBiblioInBatch( $import_record_id );
300
=cut
301
302
sub DeleteBiblioInBatch {
303
    my ($subroutine, $import_record_id) = @_;
304
    _delete_import_record_marc($import_record_id);
305
}
306
297
=head2 ModBiblioInBatch
307
=head2 ModBiblioInBatch
298
308
299
  ModBiblioInBatch($import_record_id, $marc_record);
309
  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 703-709 my $fa_barcode = $input->param('barcode'); Link Here
703
my $fa_branch             = $input->param('branch');
703
my $fa_branch             = $input->param('branch');
704
my $fa_stickyduedate      = $input->param('stickyduedate');
704
my $fa_stickyduedate      = $input->param('stickyduedate');
705
my $fa_duedatespec        = $input->param('duedatespec');
705
my $fa_duedatespec        = $input->param('duedatespec');
706
706
my $previewrecord = $input->param('preview');
707
my $userflags = 'edit_catalogue';
707
my $userflags = 'edit_catalogue';
708
708
709
my $changed_framework = $input->param('changed_framework') // q{};
709
my $changed_framework = $input->param('changed_framework') // q{};
Lines 845-851 if ( $op eq "addbiblio" ) { Link Here
845
            ModBiblio( $record, $biblionumber, $frameworkcode );
845
            ModBiblio( $record, $biblionumber, $frameworkcode );
846
        }
846
        }
847
        else {
847
        else {
848
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
848
            if ($previewrecord) {
849
                AddBiblioToBatch(1, 0, $record, 'biblio', int(rand(99999)), 1);
850
                print $input->redirect('/cgi-bin/koha/cataloguing/addbooks.pl');
851
            } else {
852
                if ($breedingid) {
853
                    C4::ImportBatch->DeleteBiblioInBatch($breedingid);
854
                }
855
                ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
856
            }
849
        }
857
        }
850
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){
858
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){
851
	    if ($frameworkcode eq 'FA'){
859
	    if ($frameworkcode eq 'FA'){
(-)a/cataloguing/addbooks.pl (-11 / +37 lines)
Lines 47-52 my $success = $input->param('biblioitem'); Link Here
47
my $query   = $input->param('q');
47
my $query   = $input->param('q');
48
my @value   = $input->multi_param('value');
48
my @value   = $input->multi_param('value');
49
my $page    = $input->param('page') || 1;
49
my $page    = $input->param('page') || 1;
50
my $drafts_only = $input->param('drafts_only');
50
my $results_per_page = 20;
51
my $results_per_page = 20;
51
my $lang = C4::Languages::getlanguage($input);
52
my $lang = C4::Languages::getlanguage($input);
52
53
Lines 62-69 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
62
    }
63
    }
63
);
64
);
64
65
65
# Searching the catalog.
66
# Searching the catalog unless 'drafts_only' has been selected
66
if ($query) {
67
if (($query) && !($drafts_only)) {
67
68
68
    # build query
69
    # build query
69
    my @operands = $query;
70
    my @operands = $query;
Lines 127-142 if ($query) { Link Here
127
    ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );
128
    ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );
128
}
129
}
129
my $breeding_loop = [];
130
my $breeding_loop = [];
131
my $count;
132
130
for my $resultsbr (@resultsbr) {
133
for my $resultsbr (@resultsbr) {
131
    push @{$breeding_loop}, {
134
132
        id               => $resultsbr->{import_record_id},
135
    #Only return records associated with 'Draft record' file_name if drafts_only has been set
133
        isbn             => $resultsbr->{isbn},
136
    if ($drafts_only) {
134
        copyrightdate    => $resultsbr->{copyrightdate},
137
        if ($resultsbr->{file_name} eq "Draft record") {
135
        editionstatement => $resultsbr->{editionstatement},
138
            push @{$breeding_loop}, {
136
        file             => $resultsbr->{file_name},
139
                id               => $resultsbr->{import_record_id},
137
        title            => $resultsbr->{title},
140
                isbn             => $resultsbr->{isbn},
138
        author           => $resultsbr->{author},
141
                copyrightdate    => $resultsbr->{copyrightdate},
139
    };
142
                editionstatement => $resultsbr->{editionstatement},
143
                file             => $resultsbr->{file_name},
144
                title            => $resultsbr->{title},
145
                author           => $resultsbr->{author},
146
            };
147
            $count++;
148
        }
149
    } else {
150
        push @{$breeding_loop}, {
151
                id               => $resultsbr->{import_record_id},
152
                isbn             => $resultsbr->{isbn},
153
                copyrightdate    => $resultsbr->{copyrightdate},
154
                editionstatement => $resultsbr->{editionstatement},
155
                file             => $resultsbr->{file_name},
156
                title            => $resultsbr->{title},
157
                author           => $resultsbr->{author},
158
        };
159
    }
160
}
161
162
#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
163
if ($drafts_only) {
164
    $countbr = $count;
165
    $template->param( query => $query, drafts_only => $drafts_only );
140
}
166
}
141
167
142
my $servers = Koha::Z3950Servers->search(
168
my $servers = Koha::Z3950Servers->search(
(-)a/cataloguing/batch_records_ajax.pl (+121 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
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
=head1 NAME
21
22
batch_records_ajax.pl - A script for searching batch imported records via ajax
23
24
=head1 SYNOPSIS
25
26
This script is to be used as a data source for DataTables that load and display
27
the records from an import batch.
28
29
=cut
30
31
use Modern::Perl;
32
33
use CGI qw ( -utf8 );
34
use JSON qw/ to_json /;
35
36
use C4::Context;
37
use C4::Charset;
38
use C4::Auth qw/check_cookie_auth/;
39
use C4::ImportBatch;
40
41
my $input = new CGI;
42
43
my @sort_columns =
44
  qw/import_record_id title status overlay_status overlay_status/;
45
46
my $import_batch_id   = $input->param('import_batch_id');
47
my $offset            = $input->param('iDisplayStart');
48
my $results_per_page  = $input->param('iDisplayLength');
49
my $sorting_column    = $sort_columns[ $input->param('iSortCol_0') // 0 ];
50
my $sorting_direction = $input->param('sSortDir_0');
51
52
$results_per_page = undef if $results_per_page && $results_per_page == -1;
53
54
binmode STDOUT, ":encoding(UTF-8)";
55
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
56
57
my ( $auth_status, $sessionID ) =
58
  check_cookie_auth( $input->cookie('CGISESSID'), { tools => 'manage_staged_marc' } );
59
if ( $auth_status ne "ok" ) {
60
    exit 0;
61
}
62
63
my $batch = GetImportBatch($import_batch_id);
64
my $records =
65
  GetImportRecordsRange( $import_batch_id, $offset, $results_per_page, undef,
66
    { order_by => $sorting_column, order_by_direction => $sorting_direction } );
67
my @list = ();
68
foreach my $record (@$records) {
69
    my $citation = $record->{'title'} || $record->{'authorized_heading'};
70
    $citation .= " $record->{'author'}" if $record->{'author'};
71
    $citation .= " (" if $record->{'issn'} or $record->{'isbn'};
72
    $citation .= $record->{'isbn'} if $record->{'isbn'};
73
    $citation .= ", " if $record->{'issn'} and $record->{'isbn'};
74
    $citation .= $record->{'issn'} if $record->{'issn'};
75
    $citation .= ")" if $record->{'issn'} or $record->{'isbn'};
76
77
    my $match = GetImportRecordMatches( $record->{'import_record_id'}, 1 );
78
    my $match_citation = '';
79
    my $match_id;
80
    if ( $#$match > -1 ) {
81
        if ( $match->[0]->{'record_type'} eq 'biblio' ) {
82
            $match_citation .= $match->[0]->{'title'}
83
              if defined( $match->[0]->{'title'} );
84
            $match_citation .= ' ' . $match->[0]->{'author'}
85
              if defined( $match->[0]->{'author'} );
86
            $match_id = $match->[0]->{'biblionumber'};
87
        }
88
        elsif ( $match->[0]->{'record_type'} eq 'auth' ) {
89
            if ( defined( $match->[0]->{'authorized_heading'} ) ) {
90
                $match_citation .= $match->[0]->{'authorized_heading'};
91
                $match_id = $match->[0]->{'candidate_match_id'};
92
            }
93
        }
94
    }
95
96
    push @list,
97
      {
98
        DT_RowId        => $record->{'import_record_id'},
99
        import_record_id => $record->{'import_record_id'},
100
        citation        => $citation,
101
        status          => $record->{'status'},
102
        overlay_status  => $record->{'overlay_status'},
103
        match_citation  => $match_citation,
104
        matched         => $record->{'matched_biblionumber'}
105
          || $record->{'matched_authid'}
106
          || q{},
107
        score => $#$match > -1 ? $match->[0]->{'score'} : 0,
108
        match_id => $match_id,
109
        diff_url => $match_id ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id" : undef,
110
        catalog_link => "/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=$record->{import_record_id}",
111
        delete_link =>"/cgi-bin/koha/cataloguing/draftrecords.pl?biblionumber=$record->{import_record_id}&op=delete_record",
112
      };
113
}
114
115
my $data;
116
$data->{'iTotalRecords'}        = $batch->{'num_records'};
117
$data->{'iTotalDisplayRecords'} = $batch->{'num_records'};
118
$data->{'sEcho'}                = $input->param('sEcho') || undef;
119
$data->{'aaData'}               = \@list;
120
121
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 IGNORE 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 IGNORE INTO permissions (module_bit, code, description) VALUES (9, 'commit_MARC_records_to_catalog', 'Commit bibliographic records to the catalog. Once committed they will be visible in OPAC search results.');
3
INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('EnableDraftRecords', 1, NULL, 'If enabled staff will be able to save records to the reservoir as a draft record, which will not be visible in OPAC search results.', 'YesNo');
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 178-183 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
178
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
178
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
179
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
179
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
180
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
180
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
181
('EnableDraftRecords','1', NULL, 'If enabled staff will be able to save records to the reservoir as a draft record, which will not be visible in OPAC search results.', 'YesNo'),
181
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
182
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
182
('EnablePointOfSale','0',NULL,'Enable the point of sale feature to allow anonymous transactions with the accounting system. (Requires UseCashRegisters)','YesNo'),
183
('EnablePointOfSale','0',NULL,'Enable the point of sale feature to allow anonymous transactions with the accounting system. (Requires UseCashRegisters)','YesNo'),
183
('EnableSearchHistory','0','','Enable or disable search history','YesNo'),
184
('EnableSearchHistory','0','','Enable or disable search history','YesNo'),
(-)a/installer/data/mysql/userpermissions.sql (+1 lines)
Lines 46-51 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
46
   ( 9, 'edit_items', 'Edit items'),
46
   ( 9, 'edit_items', 'Edit items'),
47
   ( 9, 'edit_items_restricted', 'Limit item modification to subfields defined in the SubfieldsToAllowForRestrictedEditing preference (please note that edit_item is still required)'),
47
   ( 9, 'edit_items_restricted', 'Limit item modification to subfields defined in the SubfieldsToAllowForRestrictedEditing preference (please note that edit_item is still required)'),
48
   ( 9, 'delete_all_items', 'Delete all items at once'),
48
   ( 9, 'delete_all_items', 'Delete all items at once'),
49
   ( 9, 'commit_MARC_records_to_catalog', 'Commit bibliographic records to the catalog. Once committed they will be visible in OPAC search results.'),
49
   (10, 'payout', 'Perform account payout action'),
50
   (10, 'payout', 'Perform account payout action'),
50
   (10, 'refund', 'Perform account refund action'),
51
   (10, 'refund', 'Perform account refund action'),
51
   (10, 'discount', 'Perform account discount action'),
52
   (10, 'discount', 'Perform account discount action'),
(-)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 dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New <span class="caret"></span></button>
6
    <button class="btn btn-default 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 dropdown-toggle" data-toggle="dropdown"><i class="fa fa-pencil"></i> Edit <span class="caret"></span></button>
31
    <button class="btn btn-default 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 / +4 lines)
Lines 314-320 Link Here
314
        <span class="sub_permission fast_cataloging_subpermission">
314
        <span class="sub_permission fast_cataloging_subpermission">
315
            Fast cataloging
315
            Fast cataloging
316
        </span>
316
        </span>
317
        <span class="permissioncode">([% name | html %])</span>
317
    [%- CASE 'commit_MARC_records_to_catalog' -%]
318
        <span>Commit MARC records to the catalog.
319
            If not enabled then a patron will only be able to create draft records if other editcatalogue subpermissions are enabled
320
        </span>
318
    [%- CASE 'remaining_permissions' -%]
321
    [%- CASE 'remaining_permissions' -%]
319
        <span class="sub_permission remaining_permissions_subpermission">
322
        <span class="sub_permission remaining_permissions_subpermission">
320
            Remaining permissions for managing fines and fees
323
            Remaining permissions for managing fines and fees
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (-1 / +6 lines)
Lines 27-32 Cataloging: Link Here
27
            - the advanced cataloging editor.
27
            - the advanced cataloging editor.
28
            - "<br/> NOTE:"
28
            - "<br/> NOTE:"
29
            - Currently does not include support for UNIMARC or NORMARC fixed fields.
29
            - Currently does not include support for UNIMARC or NORMARC fixed fields.
30
        -
31
            - pref: EnableDraftRecords
32
              choices:
33
                  yes: Enable
34
                  no: "Don't enable"
35
            - staff and catalogers to save records to the reservoir as a draft rather than to the catalogue. Draft records will not appear in OPAC or general staff client searches.
30
    Spine labels:
36
    Spine labels:
31
        -
37
        -
32
            - When using the quick spine label printer,
38
            - When using the quick spine label printer,
Lines 46-52 Cataloging: Link Here
46
                  yes: Display
52
                  yes: Display
47
                  no:  "Don't display"
53
                  no:  "Don't display"
48
            - buttons on the bib details page to print item spine labels.
54
            - buttons on the bib details page to print item spine labels.
49
        -
50
    Record structure:
55
    Record structure:
51
        -
56
        -
52
            - Fill in the default language for field 008 Range 35-37 of MARC21 records (e.g. eng, nor, ger, see <a href="http://www.loc.gov/marc/languages/language_code.html">MARC Code List for Languages</a>)
57
            - Fill in the default language for field 008 Range 35-37 of MARC21 records (e.g. eng, nor, ger, see <a href="http://www.loc.gov/marc/languages/language_code.html">MARC Code List for Languages</a>)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-5 / +2 lines)
Lines 253-259 Link Here
253
                [% IF ( analyze ) %]<th id="[% tab | html %]_usedin" data-colname="[% tab | html %]_usedin">Used in</th><th></th>[% END %]
253
                [% IF ( analyze ) %]<th id="[% tab | html %]_usedin" data-colname="[% tab | html %]_usedin">Used in</th><th></th>[% END %]
254
                [% IF ( ShowCourseReserves ) %]<th id="[% tab | html %]_course_reserves" data-colname="[% tab | html %]_course_reserves">Course reserves</th>[% END %]
254
                [% IF ( ShowCourseReserves ) %]<th id="[% tab | html %]_course_reserves" data-colname="[% tab | html %]_course_reserves">Course reserves</th>[% END %]
255
                [% IF ( SpineLabelShowPrintOnBibDetails ) %]<th id="[% tab | html %]_spinelabel" data-colname="[% tab | html %]_spinelabel" class="NoSort">Spine label</th>[% END %]
255
                [% IF ( SpineLabelShowPrintOnBibDetails ) %]<th id="[% tab | html %]_spinelabel" data-colname="[% tab | html %]_spinelabel" class="NoSort">Spine label</th>[% END %]
256
                [% IF ( CAN_user_editcatalogue_edit_items ) %]<th id="[% tab | html %]_actions" data-colname="[% tab | html %]_actions"class="NoSort">&nbsp;</th>[% END %]
256
                [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_items ) %]<th class="NoSort">&nbsp;</th>[% END %]
257
            </tr>
257
            </tr>
258
        </thead>
258
        </thead>
259
        <tbody>
259
        <tbody>
Lines 466-476 Note that permanent location is a code, and location may be an authval. Link Here
466
                    </td>
466
                    </td>
467
                [% END %]
467
                [% END %]
468
468
469
                [% IF ( SpineLabelShowPrintOnBibDetails ) %]
470
                    <td><a class="btn btn-default btn-xs print-label" href="/cgi-bin/koha/labels/spinelabel-print.pl?barcode=[% item.barcode | uri %]"><i class="fa fa-print"></i> Print label</a></td>
469
                    <td><a class="btn btn-default btn-xs print-label" href="/cgi-bin/koha/labels/spinelabel-print.pl?barcode=[% item.barcode | uri %]"><i class="fa fa-print"></i> Print label</a></td>
471
                [% END %]
470
                [% END %]
472
471
473
                [% IF CAN_user_editcatalogue_edit_items %]
472
                [% IF CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_items %]
474
                    <td class="actions">
473
                    <td class="actions">
475
                        [% UNLESS item.cannot_be_edited %]
474
                        [% UNLESS item.cannot_be_edited %]
476
                            <a class="btn btn-default btn-xs" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=[% item.biblionumber | html %]&itemnumber=[% item.itemnumber | html %]#edititem"><i class="fa fa-pencil"></i> Edit</a>
475
                            <a class="btn btn-default btn-xs" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=[% item.biblionumber | html %]&itemnumber=[% item.itemnumber | html %]#edititem"><i class="fa fa-pencil"></i> Edit</a>
Lines 897-904 Note that permanent location is a code, and location may be an authval. Link Here
897
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
896
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
898
     </div> <!-- /.row -->
897
     </div> <!-- /.row -->
899
898
900
[% END %]
901
902
[% MACRO jsinclude BLOCK %]
899
[% MACRO jsinclude BLOCK %]
903
    [% INCLUDE 'catalog-strings.inc' %]
900
    [% INCLUDE 'catalog-strings.inc' %]
904
    [% Asset.js("js/catalog.js") | $raw %]
901
    [% Asset.js("js/catalog.js") | $raw %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (-2 / +2 lines)
Lines 500-509 Link Here
500
                                                        | <a id="requst_article_[% SEARCH_RESULT.biblionumber | html %]" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]">Request article</a>
500
                                                        | <a id="requst_article_[% SEARCH_RESULT.biblionumber | html %]" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]">Request article</a>
501
                                                    [% END %]
501
                                                    [% END %]
502
502
503
                                                    [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
503
                                                    [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_catalogue ) %]
504
                                                        | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Edit record</a>
504
                                                        | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Edit record</a>
505
                                                    [% END %]
505
                                                    [% END %]
506
                                                    [% IF ( CAN_user_editcatalogue_edit_items ) %]
506
                                                    [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_catalogue ) %]
507
                                                        | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Edit items</a>
507
                                                        | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Edit items</a>
508
                                                    [% END %]
508
                                                    [% END %]
509
509
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-3 / +14 lines)
Lines 93-98 Link Here
93
            return false;
93
            return false;
94
        });
94
        });
95
95
96
        $("#previewrecord").click(function(){
97
            $(".btn-group").removeClass("open");
98
            document.getElementById('preview').value = 1;
99
            onOption();
100
            return false;
101
        });
102
96
        $("#saveandview").click(function(){
103
        $("#saveandview").click(function(){
97
            $(".btn-group").removeClass("open");
104
            $(".btn-group").removeClass("open");
98
            redirect("view");
105
            redirect("view");
Lines 568-576 Link Here
568
                                <span class="caret"></span>
575
                                <span class="caret"></span>
569
                                </button>
576
                                </button>
570
                                <ul class="dropdown-menu">
577
                                <ul class="dropdown-menu">
571
                                    <li><a id="saveandview" href="#">Save and view record</a></li>
578
                                    [% IF CAN_user_editcatalogue_commit_MARC_records_to_catalog %]
572
                                    <li><a id="saveanditems" href="#">Save and edit items</a></li>
579
                                        <li><a id="saveandview" href="#">Save and view record</a></li>
573
                                    <li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
580
                                        <li><a id="saveanditems" href="#">Save and edit items</a></li>
581
                                        <li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
582
                                    [% END %]
583
                                    <li><a id="previewrecord" name="previewrecord" href="#">Save as draft</a></li>
574
                                </ul>
584
                                </ul>
575
                            </div>
585
                            </div>
576
                        [% END %]
586
                        [% END %]
Lines 688-693 Link Here
688
                        <input type="hidden" name="mode" value="popup" />
698
                        <input type="hidden" name="mode" value="popup" />
689
                [% END %]
699
                [% END %]
690
                <input type="hidden" name="op" value="addbiblio" />
700
                <input type="hidden" name="op" value="addbiblio" />
701
                <input type="hidden" id="preview" name="preview" />
691
                <input type="hidden" id="frameworkcode" name="frameworkcode" value="[% frameworkcode | html %]" />
702
                <input type="hidden" id="frameworkcode" name="frameworkcode" value="[% frameworkcode | html %]" />
692
                <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
703
                <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
693
                <input type="hidden" name="breedingid" value="[% breedingid | html %]" />
704
                <input type="hidden" name="breedingid" value="[% breedingid | html %]" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt (-1 / +17 lines)
Lines 44-49 Link Here
44
                                </ul>
44
                                </ul>
45
                            </div>
45
                            </div>
46
                        [% END # /IF servers.count %]
46
                        [% END # /IF servers.count %]
47
                        [% IF Koha.Preference('EnableDraftRecords') %]
48
                            <a class="btn btn-default" href="/cgi-bin/koha/cataloguing/draftrecords.pl"><i class="fa fa-eye" aria-hidden="true"></i> View draft records</a></button>
49
                        [% END %]
47
                        [% IF ( total ) %]
50
                        [% IF ( total ) %]
48
                            <div class="btn-group"><button type="submit" class="btn btn-default merge-items"><i class="fa fa-compress"></i> Merge selected</button></div>
51
                            <div class="btn-group"><button type="submit" class="btn btn-default merge-items"><i class="fa fa-compress"></i> Merge selected</button></div>
49
                        [% END %]
52
                        [% END %]
Lines 187-193 Link Here
187
                                                    <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.id | uri %]" class="previewData"><i class="fa fa-eye"></i> MARC preview</a></li>
190
                                                    <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.id | uri %]" class="previewData"><i class="fa fa-eye"></i> MARC preview</a></li>
188
                                                    <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.id | uri %]" class="previewData"><i class="fa fa-eye"></i> Card preview</a></li>
191
                                                    <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.id | uri %]" class="previewData"><i class="fa fa-eye"></i> Card preview</a></li>
189
                                                    [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
192
                                                    [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
190
                                                        <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id | uri %]"><i class="fa fa-plus"></i> Add biblio</a></li>
193
                                                        [% IF breeding_loo.file == "Draft record" %]
194
                                                            <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id | uri %]"><i class="fa fa-plus"></i> Continue editing draft record</a></li>
195
                                                        [% ELSE %]
196
                                                            <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id | uri %]"><i class="fa fa-plus"></i> Add biblio</a></li>
197
                                                        [% END %]
191
                                                    [% END %]
198
                                                    [% END %]
192
                                                </ul>
199
                                                </ul>
193
                                            </div>
200
                                            </div>
Lines 227-232 Link Here
227
            //Set focus to cataloging search
234
            //Set focus to cataloging search
228
            $("input[name=q]:eq(0)").focus();
235
            $("input[name=q]:eq(0)").focus();
229
236
237
            $("#filteraction_off").hide();
238
            $("#filters").hide();
239
240
            $("#filteraction_off, #filteraction_on").on('click', function(e) {
241
                e.preventDefault();
242
                $('#filters').toggle();
243
                $('.filteraction').toggle();
244
            });
245
230
            $("#z3950search").click(function(){
246
            $("#z3950search").click(function(){
231
                PopupZ3950("Default");
247
                PopupZ3950("Default");
232
                return false;
248
                return false;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/draftrecords.tt (+148 lines)
Line 0 Link Here
1
[% USE raw %]
2
[% USE Koha %]
3
[% SET footerjs = 1 %]
4
[% USE Asset %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Cataloging &rsaquo; Draft records</title>
7
[% INCLUDE 'doc-head-close.inc' %]
8
<style type="text/css">
9
    #jobpanel,#jobstatus,#jobfailed { display : none; }
10
    span.change-status { font-style:italic; color:#666; display:none; }
11
</style>
12
[% Asset.css("css/datatables.css") | $raw %]
13
</head>
14
<body id="cat_adddrafts" class="cat">
15
    [% INCLUDE 'header.inc' %]
16
17
    <div id="breadcrumbs">
18
        <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
19
        <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>  &rsaquo; View draft records
20
    </div>
21
22
    <div class="main container-fluid">
23
        <div class="row">
24
            <div class="col-md-10 col-md-offset-1">
25
           [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
26
            <div id="toolbar" class="btn-toolbar">
27
                [% IF Koha.Preference( 'EnableAdvancedCatalogingEditor' ) == 1 %]
28
                    <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>
29
                [% END %]
30
                <div class="btn-group">
31
                    <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>
32
                    <ul class="dropdown-menu">
33
                         <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=">Default framework</a></li>
34
                         [% FOREACH framework IN frameworks %]
35
                             <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=[% framework.frameworkcode | uri %]">[% framework.frameworktext | html %]</a></li>
36
                         [% END %]
37
                    </ul>
38
                </div>
39
                [% IF servers.count > 0 %]
40
                   <div class="btn-group">
41
                        <button class="btn btn-default btn-sm" id="z3950search"><i class="fa fa-search"></i> New from Z39.50/SRU</button>
42
                        <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
43
                           <span class="caret"></span>
44
                        </button>
45
                        <ul class="dropdown-menu">
46
                             <li id="" class="z3950searchFw"><a href="#">Default framework</a></li>
47
                             [% FOREACH framework IN frameworks %]
48
                                 <li id="[% framework.frameworkcode | html %]" class="z3950searchFw"><a href="#">[% framework.frameworktext | html %]</a></li>
49
                             [% END %]
50
                        </ul>
51
                   </div>
52
                [% END %]
53
                [% IF Koha.Preference('EnableDraftRecords') %]
54
                    <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>
55
                 [% END %]
56
                [% IF ( total ) %]
57
                    <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>
58
                [% END %]
59
            </div>
60
            [% END %]
61
            <h1>View draft records</h1>
62
                <div id="draftrecords">
63
                   <p> To edit or save these draft records click the 'Edit' link beside the appropriate record.
64
                   <form action="/cgi-bin/koha/cataloguing/draftrecords.pl" method="post">
65
                       <input type="hidden" name="op" id="delete_all_drafts" value='delete_all'/>
66
                       <button type="submit">Delete all drafts from reservoir</button>
67
                   </form>
68
                   </p>
69
                   <table id="records-table">
70
                     <thead>
71
                        <tr>
72
                           <th>#</th>
73
                           <th>Citation</th>
74
                           <th>Status</th>
75
                           <th>Edit record</th>
76
                           <th>Delete record</th>
77
                        </tr>
78
                     </thead>
79
                   </table>
80
                </div>
81
          </div>
82
     </div>
83
  </div>
84
</body>
85
[% MACRO jsinclude BLOCK %]
86
[% Asset.js("js/tools-menu.js") | $raw %]
87
[% Asset.js("js/background-job-progressbar.js") | $raw %]
88
[% INCLUDE 'datatables.inc' %]
89
<script type="text/javascript">
90
    $(document).ready(function(){
91
       $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
92
          "bSort": true,
93
          "order": [0, "desc"],
94
          "bAutoWidth": false,
95
          "bFilter": false,
96
          "bProcessing": true,
97
          "bServerSide": true,
98
          "sAjaxSource": 'batch_records_ajax.pl',
99
          "sPaginationType": "full_numbers",
100
          "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
101
          "aoColumns": [
102
             { "mDataProp": "import_record_id" },
103
             { "mDataProp": "citation" },
104
             { "mDataProp": "status" },
105
             { "mDataProp": "catalog_link" },
106
             { "mDataProp": "delete_link" }
107
          ],
108
           "fnServerData": function ( sSource, aoData, fnCallback ) {
109
              aoData.push( { "name": "import_batch_id", "value": 1 } );
110
                 $.ajax({
111
                      'dataType': 'json',
112
                      'type': 'POST',
113
                      'url': sSource,
114
                      'data': aoData,
115
                      'success': function(json){
116
                        fnCallback(json);
117
                      }
118
                 });
119
             },
120
            "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
121
               [% IF ( record_type == 'auth' ) %]
122
                  var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
123
               [% ELSE %]
124
                  var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
125
               [% END %]
126
               $('td:eq(1)', nRow).html(
127
                  '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
128
               );
129
               $('td:eq(2)', nRow).html(
130
                  aData['status'] == 'staged'   ? _("Draft")   :
131
                  aData['status']
132
               );
133
               if (aData['catalog_link']){
134
                  $('td:eq(3)', nRow).html(
135
                      '<a href="' + aData['catalog_link'] + '">' + "Edit" + '</a>'
136
                  );
137
               }
138
               if (aData['delete_link']){
139
                  $('td:eq(4)', nRow).html(
140
                      '<a href="' + aData['delete_link'] + '">' + "Delete" + '</a>'
141
                  );
142
               }
143
            },
144
        }));
145
    });
146
</script>
147
[% END %]
148
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/t/db_dependent/ImportBatch.t (-2 / +7 lines)
Lines 1-9 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 => 15;
4
use Test::More tests => 16;
5
use utf8;
5
use utf8;
6
use File::Basename;
6
use File::Basename;
7
use Cwd qw(abs_path);
7
use File::Temp qw/tempfile/;
8
use File::Temp qw/tempfile/;
8
9
9
use t::lib::Mocks;
10
use t::lib::Mocks;
Lines 146-151 $dbh->do( "DELETE FROM items WHERE itemnumber=?", undef, $itemno ); Link Here
146
is( @a, 0, 'No item numbers expected since we deleted the item' );
147
is( @a, 0, 'No item numbers expected since we deleted the item' );
147
$dbh->do( $sql, undef, undef, $import_record_id ); # remove link again
148
$dbh->do( $sql, undef, undef, $import_record_id ); # remove link again
148
149
150
#Test DeleteBiblioInBatch
151
my @a = DeleteBiblioInBatch( $import_record_id); #Remove the MARC record from import_biblios and import_records tables
152
my $biblio_in_import_records = $dbh->do('SELECT * FROM import_records WHERE import_batch_id = "$import_record_id"');
153
is( $biblio_in_import_records, "0E0", 'No biblio expected since we deleted the biblio from the batch' );
154
149
# fresh data
155
# fresh data
150
my $sample_import_batch3 = {
156
my $sample_import_batch3 = {
151
    matcher_id => 3,
157
    matcher_id => 3,
152
- 

Return to bug 20678