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

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

Return to bug 20699