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 296-301 sub AddBiblioToBatch { Link Here
296
    return $import_record_id;
297
    return $import_record_id;
297
}
298
}
298
299
300
=head2 DeleteBiblioInBatch
301
    DeleteBiblioInBatch( $import_record_id );
302
=cut
303
304
sub DeleteBiblioInBatch {
305
    my ($subroutine, $import_record_id) = @_;
306
    _delete_import_record_marc($import_record_id);
307
}
308
299
=head2 ModBiblioInBatch
309
=head2 ModBiblioInBatch
300
310
301
  ModBiblioInBatch($import_record_id, $marc_record);
311
  ModBiblioInBatch($import_record_id, $marc_record);
Lines 1614-1619 sub _update_import_record_marc { Link Here
1614
    $sth->finish();
1624
    $sth->finish();
1615
}
1625
}
1616
1626
1627
sub _delete_import_record_marc {
1628
    my ($import_record_id, $subroutine) = @_;
1629
    my $dbh = C4::Context->dbh;
1630
    my $sth = $dbh->prepare("DELETE FROM import_records WHERE import_record_id = ?");
1631
    $sth->execute($import_record_id);
1632
    $sth->finish();
1633
}
1634
1617
sub _add_auth_fields {
1635
sub _add_auth_fields {
1618
    my ($import_record_id, $marc_record) = @_;
1636
    my ($import_record_id, $marc_record) = @_;
1619
1637
(-)a/cataloguing/addbiblio.pl (-2 / +10 lines)
Lines 698-704 my $fa_barcode = $input->param('barcode'); Link Here
698
my $fa_branch             = $input->param('branch');
698
my $fa_branch             = $input->param('branch');
699
my $fa_stickyduedate      = $input->param('stickyduedate');
699
my $fa_stickyduedate      = $input->param('stickyduedate');
700
my $fa_duedatespec        = $input->param('duedatespec');
700
my $fa_duedatespec        = $input->param('duedatespec');
701
701
my $previewrecord = $input->param('preview');
702
my $userflags = 'edit_catalogue';
702
my $userflags = 'edit_catalogue';
703
703
704
my $changed_framework = $input->param('changed_framework') // q{};
704
my $changed_framework = $input->param('changed_framework') // q{};
Lines 840-846 if ( $op eq "addbiblio" ) { Link Here
840
            ModBiblio( $record, $biblionumber, $frameworkcode );
840
            ModBiblio( $record, $biblionumber, $frameworkcode );
841
        }
841
        }
842
        else {
842
        else {
843
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
843
            if ($previewrecord) {
844
                AddBiblioToBatch(1, 0, $record, 'biblio', int(rand(99999)), 1);
845
                print $input->redirect('/cgi-bin/koha/cataloguing/addbooks.pl');
846
            } else {
847
                if ($breedingid) {
848
                    C4::ImportBatch->DeleteBiblioInBatch($breedingid);
849
                }
850
                ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
851
            }
844
        }
852
        }
845
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){
853
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){
846
	    if ($frameworkcode eq 'FA'){
854
	    if ($frameworkcode eq 'FA'){
(-)a/cataloguing/addbooks.pl (-11 / +37 lines)
Lines 46-51 my $success = $input->param('biblioitem'); Link Here
46
my $query   = $input->param('q');
46
my $query   = $input->param('q');
47
my @value   = $input->multi_param('value');
47
my @value   = $input->multi_param('value');
48
my $page    = $input->param('page') || 1;
48
my $page    = $input->param('page') || 1;
49
my $drafts_only = $input->param('drafts_only');
49
my $results_per_page = 20;
50
my $results_per_page = 20;
50
my $lang = C4::Languages::getlanguage($input);
51
my $lang = C4::Languages::getlanguage($input);
51
52
Lines 61-68 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
61
    }
62
    }
62
);
63
);
63
64
64
# Searching the catalog.
65
# Searching the catalog unless 'drafts_only' has been selected
65
if ($query) {
66
if (($query) && !($drafts_only)) {
66
67
67
    # build query
68
    # build query
68
    my @operands = $query;
69
    my @operands = $query;
Lines 128-143 if ($query) { Link Here
128
    ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );
129
    ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );
129
}
130
}
130
my $breeding_loop = [];
131
my $breeding_loop = [];
132
my $count;
133
131
for my $resultsbr (@resultsbr) {
134
for my $resultsbr (@resultsbr) {
132
    push @{$breeding_loop}, {
135
133
        id               => $resultsbr->{import_record_id},
136
    #Only return records associated with 'Draft record' file_name if drafts_only has been set
134
        isbn             => $resultsbr->{isbn},
137
    if ($drafts_only) {
135
        copyrightdate    => $resultsbr->{copyrightdate},
138
        if ($resultsbr->{file_name} eq "Draft record") {
136
        editionstatement => $resultsbr->{editionstatement},
139
            push @{$breeding_loop}, {
137
        file             => $resultsbr->{file_name},
140
                id               => $resultsbr->{import_record_id},
138
        title            => $resultsbr->{title},
141
                isbn             => $resultsbr->{isbn},
139
        author           => $resultsbr->{author},
142
                copyrightdate    => $resultsbr->{copyrightdate},
140
    };
143
                editionstatement => $resultsbr->{editionstatement},
144
                file             => $resultsbr->{file_name},
145
                title            => $resultsbr->{title},
146
                author           => $resultsbr->{author},
147
            };
148
            $count++;
149
        }
150
    } else {
151
        push @{$breeding_loop}, {
152
                id               => $resultsbr->{import_record_id},
153
                isbn             => $resultsbr->{isbn},
154
                copyrightdate    => $resultsbr->{copyrightdate},
155
                editionstatement => $resultsbr->{editionstatement},
156
                file             => $resultsbr->{file_name},
157
                title            => $resultsbr->{title},
158
                author           => $resultsbr->{author},
159
        };
160
    }
161
}
162
163
#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
164
if ($drafts_only) {
165
    $countbr = $count;
166
    $template->param( query => $query, drafts_only => $drafts_only );
141
}
167
}
142
168
143
my $servers = Koha::Z3950Servers->search(
169
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 164-169 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
164
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
164
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
165
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
165
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
166
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
166
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
167
('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'),
167
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
168
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
168
('EnableSearchHistory','0','','Enable or disable search history','YesNo'),
169
('EnableSearchHistory','0','','Enable or disable search history','YesNo'),
169
('EnhancedMessagingPreferences','1','','If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'),
170
('EnhancedMessagingPreferences','1','','If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (-3 / +2 lines)
Lines 1-8 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
[% INCLUDE 'blocking_errors.inc' %]
2
<div id="toolbar" class="btn-toolbar">
2
<div id="toolbar" class="btn-toolbar">
3
3
4
[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items ||
4
[% IF CAN_user_editcatalogue_commit_MARC_records_to_catalog && (CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_serials_create_subscription) %]
5
CAN_user_serials_create_subscription ) %]
6
    <div class="btn-group">
5
    <div class="btn-group">
7
    <button class="btn btn-default 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 (+4 lines)
Lines 291-296 Link Here
291
            Fast cataloging
291
            Fast cataloging
292
        </span>
292
        </span>
293
        <span class="permissioncode">([% name | html %])</span>
293
        <span class="permissioncode">([% name | html %])</span>
294
    [%- CASE 'commit_MARC_records_to_catalog' -%]
295
        <span class="sub_permission commit_MARC_records_to_catalog">
296
            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
297
        </span>
294
    [%- CASE 'remaining_permissions' -%]
298
    [%- CASE 'remaining_permissions' -%]
295
        <span class="sub_permission remaining_permissions_subpermission">
299
        <span class="sub_permission remaining_permissions_subpermission">
296
            Remaining permissions for managing fines and fees
300
            Remaining permissions for managing fines and fees
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +2 lines)
Lines 213-219 Link Here
213
                [% IF ( hostrecords ) %]<th>Host records</th>[% END %]
213
                [% IF ( hostrecords ) %]<th>Host records</th>[% END %]
214
                [% IF ( analyze ) %]<th>Used in</th><th></th>[% END %]
214
                [% IF ( analyze ) %]<th>Used in</th><th></th>[% END %]
215
                [% IF ( ShowCourseReserves ) %]<th>Course Reserves</th>[% END %]
215
                [% IF ( ShowCourseReserves ) %]<th>Course Reserves</th>[% END %]
216
                [% IF ( CAN_user_editcatalogue_edit_items ) %]<th class="NoSort">&nbsp;</th>[% END %]
216
                [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_items ) %]<th class="NoSort">&nbsp;</th>[% END %]
217
            </tr>
217
            </tr>
218
        </thead>
218
        </thead>
219
        <tbody>
219
        <tbody>
Lines 400-406 Link Here
400
                       [% END %]
400
                       [% END %]
401
                    </td>
401
                    </td>
402
                [% END %]
402
                [% END %]
403
                [% IF CAN_user_editcatalogue_edit_items %]
403
                [% IF CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_items %]
404
                    <td class="actions">
404
                    <td class="actions">
405
                        [% UNLESS item.cannot_be_edited %]
405
                        [% UNLESS item.cannot_be_edited %]
406
                            <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>
406
                            <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>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (-2 / +2 lines)
Lines 439-448 Link Here
439
                                                        | <a id="requst_article_[% SEARCH_RESULT.biblionumber | html %]" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]">Request article</a>
439
                                                        | <a id="requst_article_[% SEARCH_RESULT.biblionumber | html %]" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]">Request article</a>
440
                                                    [% END %]
440
                                                    [% END %]
441
441
442
                                                    [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
442
                                                    [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_catalogue ) %]
443
                                                        | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Edit record</a>
443
                                                        | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Edit record</a>
444
                                                    [% END %]
444
                                                    [% END %]
445
                                                    [% IF ( CAN_user_editcatalogue_edit_items ) %]
445
                                                    [% IF ( CAN_user_editcatalogue_commit_MARC_records_to_catalog && CAN_user_editcatalogue_edit_items ) %]
446
                                                        | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Edit items</a>
446
                                                        | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">Edit items</a>
447
                                                    [% END %]
447
                                                    [% END %]
448
448
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-3 / +13 lines)
Lines 92-97 Link Here
92
            return false;
92
            return false;
93
        });
93
        });
94
94
95
        $("#previewrecord").click(function(){
96
            $(".btn-group").removeClass("open");
97
            document.getElementById('preview').value = 1;
98
            onOption();
99
            return false;
100
        });
101
95
        $("#saveandview").click(function(){
102
        $("#saveandview").click(function(){
96
            $(".btn-group").removeClass("open");
103
            $(".btn-group").removeClass("open");
97
            redirect("view");
104
            redirect("view");
Lines 524-532 Link Here
524
                                <span class="caret"></span>
531
                                <span class="caret"></span>
525
                                </button>
532
                                </button>
526
                                <ul class="dropdown-menu">
533
                                <ul class="dropdown-menu">
527
                                    <li><a id="saveandview" href="#">Save and view record</a></li>
534
                                    [% IF CAN_user_editcatalogue_commit_MARC_records_to_catalog %]
528
                                    <li><a id="saveanditems" href="#">Save and edit items</a></li>
535
                                        <li><a id="saveandview" href="#">Save and view record</a></li>
529
                                    <li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
536
                                        <li><a id="saveanditems" href="#">Save and edit items</a></li>
537
                                        <li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
538
                                    [% END %]
539
                                    <li><a id="previewrecord" name="previewrecord" href="#">Save as draft</a></li>
530
                                </ul>
540
                                </ul>
531
                            </div>
541
                            </div>
532
                        [% END %]
542
                        [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt (-1 / +32 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 155-162 Link Here
155
                [% END # /IF total %]
156
                [% END # /IF total %]
156
157
157
                [% IF ( query ) %]
158
                [% IF ( query ) %]
159
                    [% IF (drafts_only) %]
160
                        <div>
161
                            <a href="#searchresult-breeding">[% breeding_count %] result(s) found in reservoir</a>
162
                        </div>
163
                    [% END %]
158
                    <div id="searchresult-breeding">
164
                    <div id="searchresult-breeding">
165
                    [% IF (drafts_only) %]
166
                        <h3>Draft records in reservoir</h3>
167
                    [% ELSE %]
159
                        <h3>Biblios in reservoir</h3>
168
                        <h3>Biblios in reservoir</h3>
169
                    [% END %]
170
160
                        [% IF ( breeding_loop ) %]
171
                        [% IF ( breeding_loop ) %]
161
                            <table>
172
                            <table>
162
                                <tr>
173
                                <tr>
Lines 178-183 Link Here
178
                                        <td>[% breeding_loo.edition | html %]</td>
189
                                        <td>[% breeding_loo.edition | html %]</td>
179
                                        <td>[% breeding_loo.file | html %]</td>
190
                                        <td>[% breeding_loo.file | html %]</td>
180
                                        <td>
191
                                        <td>
192
                                            [% IF breeding_loo.file == "Draft record" %]
193
                                                Draft record
194
                                            [% ELSE %]
195
                                                [% breeding_loo.file %]
196
                                            [% END %]
197
                                        </td>
198
                                        <td>
181
                                            <div class="dropup">
199
                                            <div class="dropup">
182
                                                <a class="btn btn-default btn-xs dropdown-toggle" id="reservoirsearchactions[% breeding_loo.id | html %]" role="button" data-toggle="dropdown" href="#">
200
                                                <a class="btn btn-default btn-xs dropdown-toggle" id="reservoirsearchactions[% breeding_loo.id | html %]" role="button" data-toggle="dropdown" href="#">
183
                                                    Actions <b class="caret"></b>
201
                                                    Actions <b class="caret"></b>
Lines 186-192 Link Here
186
                                                    <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>
204
                                                    <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>
187
                                                    <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>
205
                                                    <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>
188
                                                    [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
206
                                                    [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
189
                                                        <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id | uri %]"><i class="fa fa-plus"></i> Add biblio</a></li>
207
                                                        [% IF breeding_loo.file == "Draft record" %]
208
                                                            <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Continue editing draft record</a></li>
209
                                                        [% ELSE %]
210
                                                            <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Add biblio</a></li>
211
                                                        [% END %]
190
                                                    [% END %]
212
                                                    [% END %]
191
                                                </ul>
213
                                                </ul>
192
                                            </div>
214
                                            </div>
Lines 226-231 Link Here
226
            //Set focus to cataloging search
248
            //Set focus to cataloging search
227
            $("input[name=q]:eq(0)").focus();
249
            $("input[name=q]:eq(0)").focus();
228
250
251
            $("#filteraction_off").hide();
252
            $("#filters").hide();
253
254
            $("#filteraction_off, #filteraction_on").on('click', function(e) {
255
                e.preventDefault();
256
                $('#filters').toggle();
257
                $('.filteraction').toggle();
258
            });
259
229
            $("#z3950search").click(function(){
260
            $("#z3950search").click(function(){
230
                PopupZ3950("");
261
                PopupZ3950("");
231
                return false;
262
                return false;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/draftrecords.tt (+139 lines)
Line 0 Link Here
1
[% SET footerjs = 1 %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Cataloging &rsaquo; Draft records</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'browser-strings.inc' %]
6
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
7
<style type="text/css">
8
    #jobpanel,#jobstatus,#jobfailed { display : none; }
9
    span.change-status { font-style:italic; color:#666; display:none; }
10
</style>
11
</head>
12
<body class="cat">
13
    [% INCLUDE 'header.inc' %]
14
    <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloguing</a> &rsaquo; View draft records</div>
15
    <div id="doc" class="yui-t2">
16
       <div id="bd">
17
          <div id="yui-main">
18
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
19
            <div id="toolbar" class="btn-toolbar">
20
                [% IF Koha.Preference( 'EnableAdvancedCatalogingEditor' ) == 1 %]
21
                    <a id="useadvanced" href="/cgi-bin/koha/cataloguing/editor.pl" class="btn btn-default btn-sm"><i class="fa fa-pencil"></i> Advanced editor</a>
22
                [% END %]
23
                <div class="btn-group">
24
                    <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New record <span class="caret"></span></button>
25
                    <ul class="dropdown-menu">
26
                         <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=">Default framework</a></li>
27
                         [% FOREACH framework IN frameworks %]
28
                             <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=[% framework.frameworkcode %]">[% framework.frameworktext %]</a></li>
29
                         [% END %]
30
                    </ul>
31
                </div>
32
                [% IF servers.count > 0 %]
33
                   <div class="btn-group">
34
                        <button class="btn btn-default btn-sm" id="z3950search"><i class="fa fa-search"></i> New from Z39.50/SRU</button>
35
                        <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
36
                           <span class="caret"></span>
37
                        </button>
38
                        <ul class="dropdown-menu">
39
                             <li id="" class="z3950searchFw"><a href="#">Default framework</a></li>
40
                             [% FOREACH framework IN frameworks %]
41
                                 <li id="[% framework.frameworkcode %]" class="z3950searchFw"><a href="#">[% framework.frameworktext %]</a></li>
42
                             [% END %]
43
                        </ul>
44
                   </div>
45
                [% END %]
46
                <a class="btn btn-default btn-sm" href="/cgi-bin/koha/cataloguing/draftrecords.pl"><i class="fa fa-eye" aria-hidden="true"></i> View draft records</a></button>
47
                [% IF ( total ) %]
48
                    <div class="btn-group"><button type="submit" class="btn btn-default btn-sm merge-items"><i class="fa fa-compress"></i> Merge selected</button></div>
49
                [% END %]
50
            </div>
51
            [% END %]
52
            <h1>View draft records</h1>
53
                <div id="draftrecords">
54
                   <p> To edit or save these draft records click the 'Edit' link beside the appropriate record.
55
                   <form action="/cgi-bin/koha/cataloguing/draftrecords.pl" method="post">
56
                       <input type="hidden" name="op" id="delete_all_drafts" value='delete_all'/>
57
                       <button type="submit">Delete all drafts from reservoir</button>
58
                   </form>
59
                   </p>
60
                   <table id="records-table">
61
                     <thead>
62
                        <tr>
63
                           <th>#</th>
64
                           <th>Citation</th>
65
                           <th>Status</th>
66
                           <th>Edit record</th>
67
                           <th>Delete record</th>
68
                        </tr>
69
                     </thead>
70
                   </table>
71
                </div>
72
          </div>
73
     </div>
74
  </div>
75
</body>
76
[% MACRO jsinclude BLOCK %]
77
<script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu_[% KOHA_VERSION %].js"></script>
78
<script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar_[% KOHA_VERSION %].js"></script>
79
[% INCLUDE 'datatables.inc' %]
80
<script type="text/javascript">
81
    $(document).ready(function(){
82
       $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
83
          "bSort": true,
84
          "order": [0, "desc"],
85
          "bAutoWidth": false,
86
          "bFilter": false,
87
          "bProcessing": true,
88
          "bServerSide": true,
89
          "sAjaxSource": 'batch_records_ajax.pl',
90
          "sPaginationType": "full_numbers",
91
          "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
92
          "aoColumns": [
93
             { "mDataProp": "import_record_id" },
94
             { "mDataProp": "citation" },
95
             { "mDataProp": "status" },
96
             { "mDataProp": "catalog_link" },
97
             { "mDataProp": "delete_link" }
98
          ],
99
           "fnServerData": function ( sSource, aoData, fnCallback ) {
100
              aoData.push( { "name": "import_batch_id", "value": 1 } );
101
                 $.ajax({
102
                      'dataType': 'json',
103
                      'type': 'POST',
104
                      'url': sSource,
105
                      'data': aoData,
106
                      'success': function(json){
107
                        fnCallback(json);
108
                      }
109
                 });
110
             },
111
            "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
112
               [% IF ( record_type == 'auth' ) %]
113
                  var record_details_url = "/cgi-bin/koha/authorities/detail.pl?authid=";
114
               [% ELSE %]
115
                  var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
116
               [% END %]
117
               $('td:eq(1)', nRow).html(
118
                  '<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData['import_record_id'] + '&viewas=html" class="previewMARC">' + aData['citation'] + '</a>'
119
               );
120
               $('td:eq(2)', nRow).html(
121
                  aData['status'] == 'staged'   ? _("Draft")   :
122
                  aData['status']
123
               );
124
               if (aData['catalog_link']){
125
                  $('td:eq(3)', nRow).html(
126
                      '<a href="' + aData['catalog_link'] + '">' + "Edit" + '</a>'
127
                  );
128
               }
129
               if (aData['delete_link']){
130
                  $('td:eq(4)', nRow).html(
131
                      '<a href="' + aData['delete_link'] + '">' + "Delete" + '</a>'
132
                  );
133
               }
134
            },
135
        }));
136
    });
137
</script>
138
[% END %]
139
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/t/db_dependent/ImportBatch.t (-2 / +7 lines)
Lines 1-8 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::More tests => 14;
4
use Test::More tests => 15;
5
use File::Basename;
5
use File::Basename;
6
use Cwd qw(abs_path);
6
use File::Temp qw/tempfile/;
7
use File::Temp qw/tempfile/;
7
8
8
use t::lib::Mocks;
9
use t::lib::Mocks;
Lines 143-148 $dbh->do( "DELETE FROM items WHERE itemnumber=?", undef, $itemno ); Link Here
143
is( @a, 0, 'No item numbers expected since we deleted the item' );
144
is( @a, 0, 'No item numbers expected since we deleted the item' );
144
$dbh->do( $sql, undef, undef, $import_record_id ); # remove link again
145
$dbh->do( $sql, undef, undef, $import_record_id ); # remove link again
145
146
147
#Test DeleteBiblioInBatch
148
my @a = DeleteBiblioInBatch( $import_record_id); #Remove the MARC record from import_biblios and import_records tables
149
my $biblio_in_import_records = $dbh->do('SELECT * FROM import_records WHERE import_batch_id = "$import_record_id"');
150
is( $biblio_in_import_records, "0E0", 'No biblio expected since we deleted the biblio from the batch' );
151
146
# fresh data
152
# fresh data
147
my $sample_import_batch3 = {
153
my $sample_import_batch3 = {
148
    matcher_id => 3,
154
    matcher_id => 3,
149
- 

Return to bug 20678