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 (+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 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 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 IGNORE 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/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 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'),
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 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'),
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/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 / +15 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
                        <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 merge-items"><i class="fa fa-compress"></i> Merge selected</button></div>
49
                            <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 %]
50
                        [% 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>
188
                                                    <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>
189
                                                    <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 ) %]
190
                                                    [% 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>
191
                                                        [% IF breeding_loo.file == "Draft record" %]
192
                                                            <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>
193
                                                        [% ELSE %]
194
                                                            <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id | uri %]"><i class="fa fa-plus"></i> Add biblio</a></li>
195
                                                        [% END %]
191
                                                    [% END %]
196
                                                    [% END %]
192
                                                </ul>
197
                                                </ul>
193
                                            </div>
198
                                            </div>
Lines 227-232 Link Here
227
            //Set focus to cataloging search
232
            //Set focus to cataloging search
228
            $("input[name=q]:eq(0)").focus();
233
            $("input[name=q]:eq(0)").focus();
229
234
235
            $("#filteraction_off").hide();
236
            $("#filters").hide();
237
238
            $("#filteraction_off, #filteraction_on").on('click', function(e) {
239
                e.preventDefault();
240
                $('#filters').toggle();
241
                $('.filteraction').toggle();
242
            });
243
230
            $("#z3950search").click(function(){
244
            $("#z3950search").click(function(){
231
                PopupZ3950("Default");
245
                PopupZ3950("Default");
232
                return false;
246
                return false;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/draftrecords.tt (+145 lines)
Line 0 Link Here
1
[% USE raw %]
2
[% SET footerjs = 1 %]
3
[% USE Asset %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Cataloging &rsaquo; Draft records</title>
6
[% INCLUDE 'doc-head-close.inc' %]
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
[% Asset.css("css/datatables.css") %]
12
</head>
13
<body class="cat">
14
    [% INCLUDE 'header.inc' %]
15
16
    <div id="breadcrumbs">
17
        <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
18
        <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>  &rsaquo; View draft records
19
    </div>
20
21
    <div class="main container-fluid">
22
        <div class="row">
23
            <div class="col-md-10 col-md-offset-1">
24
           [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
25
            <div id="toolbar" class="btn-toolbar">
26
                [% IF Koha.Preference( 'EnableAdvancedCatalogingEditor' ) == 1 %]
27
                    <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>
28
                [% END %]
29
                <div class="btn-group">
30
                    <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>
31
                    <ul class="dropdown-menu">
32
                         <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=">Default framework</a></li>
33
                         [% FOREACH framework IN frameworks %]
34
                             <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=[% framework.frameworkcode %]">[% framework.frameworktext %]</a></li>
35
                         [% END %]
36
                    </ul>
37
                </div>
38
                [% IF servers.count > 0 %]
39
                   <div class="btn-group">
40
                        <button class="btn btn-default btn-sm" id="z3950search"><i class="fa fa-search"></i> New from Z39.50/SRU</button>
41
                        <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
42
                           <span class="caret"></span>
43
                        </button>
44
                        <ul class="dropdown-menu">
45
                             <li id="" class="z3950searchFw"><a href="#">Default framework</a></li>
46
                             [% FOREACH framework IN frameworks %]
47
                                 <li id="[% framework.frameworkcode %]" class="z3950searchFw"><a href="#">[% framework.frameworktext %]</a></li>
48
                             [% END %]
49
                        </ul>
50
                   </div>
51
                [% END %]
52
                <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>
53
                [% IF ( total ) %]
54
                    <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>
55
                [% END %]
56
            </div>
57
            [% END %]
58
            <h1>View draft records</h1>
59
                <div id="draftrecords">
60
                   <p> To edit or save these draft records click the 'Edit' link beside the appropriate record.
61
                   <form action="/cgi-bin/koha/cataloguing/draftrecords.pl" method="post">
62
                       <input type="hidden" name="op" id="delete_all_drafts" value='delete_all'/>
63
                       <button type="submit">Delete all drafts from reservoir</button>
64
                   </form>
65
                   </p>
66
                   <table id="records-table">
67
                     <thead>
68
                        <tr>
69
                           <th>#</th>
70
                           <th>Citation</th>
71
                           <th>Status</th>
72
                           <th>Edit record</th>
73
                           <th>Delete record</th>
74
                        </tr>
75
                     </thead>
76
                   </table>
77
                </div>
78
          </div>
79
     </div>
80
  </div>
81
</body>
82
[% MACRO jsinclude BLOCK %]
83
[% Asset.js("js/tools-menu.js") %]
84
[% Asset.js("js/background-job-progressbar.js") %]
85
[% INCLUDE 'datatables.inc' %]
86
<script type="text/javascript">
87
    $(document).ready(function(){
88
       $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
89
          "bSort": true,
90
          "order": [0, "desc"],
91
          "bAutoWidth": false,
92
          "bFilter": false,
93
          "bProcessing": true,
94
          "bServerSide": true,
95
          "sAjaxSource": 'batch_records_ajax.pl',
96
          "sPaginationType": "full_numbers",
97
          "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
98
          "aoColumns": [
99
             { "mDataProp": "import_record_id" },
100
             { "mDataProp": "citation" },
101
             { "mDataProp": "status" },
102
             { "mDataProp": "catalog_link" },
103
             { "mDataProp": "delete_link" }
104
          ],
105
           "fnServerData": function ( sSource, aoData, fnCallback ) {
106
              aoData.push( { "name": "import_batch_id", "value": 1 } );
107
                 $.ajax({
108
                      'dataType': 'json',
109
                      'type': 'POST',
110
                      'url': sSource,
111
                      'data': aoData,
112
                      'success': function(json){
113
                        fnCallback(json);
114
                      }
115
                 });
116
             },
117
            "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
118
               [% IF ( record_type == 'auth' ) %]
119
                  var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
120
               [% ELSE %]
121
                  var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
122
               [% END %]
123
               $('td:eq(1)', nRow).html(
124
                  '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
125
               );
126
               $('td:eq(2)', nRow).html(
127
                  aData['status'] == 'staged'   ? _("Draft")   :
128
                  aData['status']
129
               );
130
               if (aData['catalog_link']){
131
                  $('td:eq(3)', nRow).html(
132
                      '<a href="' + aData['catalog_link'] + '">' + "Edit" + '</a>'
133
                  );
134
               }
135
               if (aData['delete_link']){
136
                  $('td:eq(4)', nRow).html(
137
                      '<a href="' + aData['delete_link'] + '">' + "Delete" + '</a>'
138
                  );
139
               }
140
            },
141
        }));
142
    });
143
</script>
144
[% END %]
145
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/t/db_dependent/ImportBatch.t (-1 / +6 lines)
Lines 4-9 use Modern::Perl; Link Here
4
use Test::More tests => 15;
4
use Test::More tests => 15;
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