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

(-)a/cataloguing/addbooks.pl (-12 / +39 lines)
Lines 33-38 use C4::Breeding; Link Here
33
use C4::Output;
33
use C4::Output;
34
use C4::Koha;
34
use C4::Koha;
35
use C4::Search;
35
use C4::Search;
36
use Data::Dumper;
36
37
37
use Koha::BiblioFrameworks;
38
use Koha::BiblioFrameworks;
38
use Koha::SearchEngine::Search;
39
use Koha::SearchEngine::Search;
Lines 44-52 my $success = $input->param('biblioitem'); Link Here
44
my $query   = $input->param('q');
45
my $query   = $input->param('q');
45
my @value   = $input->multi_param('value');
46
my @value   = $input->multi_param('value');
46
my $page    = $input->param('page') || 1;
47
my $page    = $input->param('page') || 1;
48
my $drafts_only = $input->param('drafts_only');
47
my $results_per_page = 20;
49
my $results_per_page = 20;
48
50
49
50
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
51
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
51
    {
52
    {
52
        template_name   => "cataloguing/addbooks.tt",
53
        template_name   => "cataloguing/addbooks.tt",
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 90-95 if ($query) { Link Here
90
    # SimpleSearch() give the results per page we want, so 0 offet here
91
    # SimpleSearch() give the results per page we want, so 0 offet here
91
    my $total = @{$marcresults};
92
    my $total = @{$marcresults};
92
    my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, $marcresults );
93
    my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, $marcresults );
94
93
    $template->param(
95
    $template->param(
94
        total          => $total_hits,
96
        total          => $total_hits,
95
        query          => $query,
97
        query          => $query,
Lines 121-136 if ($query) { Link Here
121
    ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );
123
    ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );
122
}
124
}
123
my $breeding_loop = [];
125
my $breeding_loop = [];
126
127
my $count;
124
for my $resultsbr (@resultsbr) {
128
for my $resultsbr (@resultsbr) {
125
    push @{$breeding_loop}, {
129
126
        id               => $resultsbr->{import_record_id},
130
    #Only return records associated with 'Draft record' file_name if drafts_only has been set
127
        isbn             => $resultsbr->{isbn},
131
    if ($drafts_only) {
128
        copyrightdate    => $resultsbr->{copyrightdate},
132
        if ($resultsbr->{file_name} eq "Draft record") {
129
        editionstatement => $resultsbr->{editionstatement},
133
            push @{$breeding_loop}, {
130
        file             => $resultsbr->{file_name},
134
                id               => $resultsbr->{import_record_id},
131
        title            => $resultsbr->{title},
135
                isbn             => $resultsbr->{isbn},
132
        author           => $resultsbr->{author},
136
                copyrightdate    => $resultsbr->{copyrightdate},
133
    };
137
                editionstatement => $resultsbr->{editionstatement},
138
                file             => $resultsbr->{file_name},
139
                title            => $resultsbr->{title},
140
                author           => $resultsbr->{author},
141
            };
142
            $count++;
143
        }
144
    } else {
145
        push @{$breeding_loop}, {
146
            id               => $resultsbr->{import_record_id},
147
            isbn             => $resultsbr->{isbn},
148
            copyrightdate    => $resultsbr->{copyrightdate},
149
            editionstatement => $resultsbr->{editionstatement},
150
            file             => $resultsbr->{file_name},
151
            title            => $resultsbr->{title},
152
            author           => $resultsbr->{author},
153
        };
154
    }
155
}
156
157
#If drafts_only has been set then query, drafts_only need to be returned to template and $countbr must be based on number of drafts in reservoir
158
if ($drafts_only) {
159
    $countbr = $count;
160
    $template->param( query => $query, drafts_only => $drafts_only );
134
}
161
}
135
162
136
my $schema = Koha::Database->new()->schema();
163
my $schema = Koha::Database->new()->schema();
(-)a/installer/data/mysql/atomicupdate/add_draft_record_batch.sql (-1 / +1 lines)
Line 1 Link Here
1
INSERT INTO import_batches (import_batch_id,record_type,file_name,comments) VALUES (1, 'biblio', 'draft_marc_records.mrc', 'MARC file containing draft MARC records created in the addbiblio.pl file but not saved to the Koha catalog');
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');
(-)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/modules/cataloguing/addbooks.tt (-4 / +32 lines)
Lines 44-49 Link Here
44
            </ul>
44
            </ul>
45
        </div>
45
        </div>
46
        [% END %]
46
        [% END %]
47
         <a class="btn btn-default btn-sm" href="/cgi-bin/koha/cataloguing/draftrecords.pl">View Draft records</a></button>
47
    [% IF ( total ) %]
48
    [% IF ( total ) %]
48
        <div class="btn-group"><button type="submit" class="btn btn-default btn-sm merge-items"><i class="fa fa-compress"></i> Merge selected</button></div>
49
        <div class="btn-group"><button type="submit" class="btn btn-default btn-sm merge-items"><i class="fa fa-compress"></i> Merge selected</button></div>
49
    [% END %]
50
    [% END %]
Lines 142-148 Link Here
142
    </table>
143
    </table>
143
</div>
144
</div>
144
[% ELSE %]
145
[% ELSE %]
145
    [% IF ( query ) %]
146
    [% IF ( (query) && !(drafts_only) ) %]
146
        [% IF ( error ) %]<div class="dialog alert">[% END %]<b>No results found</b>
147
        [% IF ( error ) %]<div class="dialog alert">[% END %]<b>No results found</b>
147
        [% IF ( error ) %]
148
        [% IF ( error ) %]
148
            Error: <span class="error">[% error %]</span></div>
149
            Error: <span class="error">[% error %]</span></div>
Lines 151-158 Link Here
151
[% END %]
152
[% END %]
152
153
153
[% IF ( query ) %]
154
[% IF ( query ) %]
155
    [% IF ( drafts_only ) %]
156
        <div>
157
            <a href="#searchresult-breeding">[% breeding_count %] result(s) found in reservoir</a>
158
        </div>
159
    [% END %]
154
<div id="searchresult-breeding">
160
<div id="searchresult-breeding">
155
    <h3>Biblios in reservoir</h3>
161
    [% IF (drafts_only) %]
162
        <h3>Draft records in reservoir</h3>
163
    [% ELSE %]
164
        <h3>Biblios in reservoir</h3>
165
    [% END %]
156
    [% IF ( breeding_loop ) %]
166
    [% IF ( breeding_loop ) %]
157
        <table>
167
        <table>
158
            <tr>
168
            <tr>
Lines 170-176 Link Here
170
                <td>[% breeding_loo.isbn %]</td>
180
                <td>[% breeding_loo.isbn %]</td>
171
                <td>[% breeding_loo.copyrightdate %]</td>
181
                <td>[% breeding_loo.copyrightdate %]</td>
172
                <td>[% breeding_loo.edition %]</td>
182
                <td>[% breeding_loo.edition %]</td>
173
                <td>[% breeding_loo.file %]</td>
183
                <td>
184
                    [% IF breeding_loo.file == "Draft record" %]
185
                        Draft record
186
                    [% ELSE %]
187
                        [% breeding_loo.file %]
188
                    [% END %]
189
                </td>
174
                <td>
190
                <td>
175
                  <div class="dropup">
191
                  <div class="dropup">
176
                    <a class="btn btn-default btn-xs dropdown-toggle" id="reservoirsearchactions[% breeding_loo.id %]" role="button" data-toggle="dropdown" href="#">
192
                    <a class="btn btn-default btn-xs dropdown-toggle" id="reservoirsearchactions[% breeding_loo.id %]" role="button" data-toggle="dropdown" href="#">
Lines 180-186 Link Here
180
                      <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.id %]" class="previewData"><i class="fa fa-eye"></i> MARC preview</a></li>
196
                      <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.id %]" class="previewData"><i class="fa fa-eye"></i> MARC preview</a></li>
181
                      <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.id %]" class="previewData"><i class="fa fa-eye"></i> Card preview</a></li>
197
                      <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.id %]" class="previewData"><i class="fa fa-eye"></i> Card preview</a></li>
182
                      [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
198
                      [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
183
                        <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Continue editing draft record</a></li>
199
                        [% IF breeding_loo.file == "Draft record" %]
200
                            <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Continue editing draft record</a></li>
201
                        [% ELSE %]
202
                            <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Add biblio</a></li>
203
                        [% END %]
184
                      [% END %]
204
                      [% END %]
185
                    </ul>
205
                    </ul>
186
                  </div>
206
                  </div>
Lines 220-225 Link Here
220
         $(document).ready(function() {
240
         $(document).ready(function() {
221
            //Set focus to cataloging search
241
            //Set focus to cataloging search
222
            $("input[name=q]:eq(0)").focus();
242
            $("input[name=q]:eq(0)").focus();
243
            $("#filteraction_off").hide();
244
            $("#filters").hide();
245
246
            $("#filteraction_off, #filteraction_on").on('click', function(e) {
247
                e.preventDefault();
248
                $('#filters').toggle();
249
                $('.filteraction').toggle();
250
            });
223
251
224
            $("#z3950search").click(function(){
252
            $("#z3950search").click(function(){
225
                PopupZ3950("");
253
                PopupZ3950("");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (-79 / +14 lines)
Lines 270-283 Link Here
270
    [% END %]
270
    [% END %]
271
</div>
271
</div>
272
  [% END %]
272
  [% END %]
273
<div class="statictabs">
274
  <ul>
275
    <li><a id="marcfileslink">Marc files</a></li>
276
    <li><a id="draftrecordslink" name="draft_record_to_display" value="1">Draft records</a></li>
277
  </ul>
278
279
  <div class="tabs-container">
280
<div id="marcfiles">
281
<table>
273
<table>
282
  <tr>
274
  <tr>
283
    <th>#</th>
275
    <th>#</th>
Lines 334-361 Link Here
334
  </tr>
326
  </tr>
335
  [% END %]
327
  [% END %]
336
</table>
328
</table>
337
</div>
338
339
<div id="draftrecords" onload="document.getElementById("draftrecords").style.display ='none';">
340
    <p> To edit or save these draft records click the 'Edit' link beside the appropriate record. </p>
341
    <table id="records-table">
342
        <thead>
343
           <tr>
344
             <th>#</th>
345
             <th>Citation</th>
346
             <th>Status</th>
347
             <th>Match type</th>
348
             <th>Match details</th>
349
             <th><abbr title="Differences between the original biblio and the imported">Diff</abbr></th>
350
             <th>Record</th>
351
             <th>Catalog link</th>
352
           </tr>
353
         </thead>
354
    </table>
355
</div>
356
</div>
357
</div>
358
359
  [% IF ( pages ) %]
329
  [% IF ( pages ) %]
360
<div class="pages">
330
<div class="pages">
361
    [% FOREACH page IN pages %]
331
    [% FOREACH page IN pages %]
Lines 426-461 Link Here
426
                $(this).parent().hide();
396
                $(this).parent().hide();
427
            });
397
            });
428
398
429
            [% IF !(import_batch_id) %]
399
            [% IF import_batch_id %]
430
                document.getElementById('draftrecords').style.display = 'none';
431
                var marcfileslink = document.getElementById("marcfileslink");
432
                marcfileslink.style.backgroundColor = "#FFF";
433
            [% END %]
434
435
            var marcfiles = document.getElementById("marcfiles");
436
            var draftrecords = document.getElementById("draftrecords");
437
            var draftrecordslink = document.getElementById("draftrecordslink");
438
            var marcfileslink = document.getElementById("marcfileslink");
439
440
            $("#draftrecordslink").click(function(e){
441
                draftrecords.style.display = "block";
442
                draftrecordslink.style.backgroundColor = "#FFF";
443
                marcfileslink.style.backgroundColor= "#e6f0f2";
444
                marcfiles.style.display = "none";
445
                if (document.getElementById("draftrecords").style.display === 'block') {
446
                    [% draft_record_to_display = 1 %]
447
                }
448
            });
449
450
            $("#marcfileslink").click(function(e){
451
                draftrecords.style.display = "none";
452
                marcfiles.style.display = "block";
453
                draftrecordslink.style.backgroundColor = "#e6f0f2";
454
                marcfileslink.style.backgroundColor= "#FFF";
455
            });
456
457
            [% IF (import_batch_id || draft_record_to_display) %]
458
                $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
400
                $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, {
401
                    "bSort": true,
402
                    "order": [0, "desc"],
459
                    "bAutoWidth": false,
403
                    "bAutoWidth": false,
460
                    "bFilter": false,
404
                    "bFilter": false,
461
                    "bProcessing": true,
405
                    "bProcessing": true,
Lines 471-485 Link Here
471
                        { "mDataProp": "match_citation" },
415
                        { "mDataProp": "match_citation" },
472
                        { "mDataProp": "diff_url" },
416
                        { "mDataProp": "diff_url" },
473
                        { "mDataProp": "matched" },
417
                        { "mDataProp": "matched" },
474
                        [% IF !(import_batch_id) %] { "mDataProp": "catalog_link" } [% END %]
475
                    ],
418
                    ],
476
                    [% IF (import_batch_id) %]
419
                    "fnServerData": function ( sSource, aoData, fnCallback ) {
477
                        "fnServerData": function ( sSource, aoData, fnCallback ) {
420
                        aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
478
                            aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } );
479
                    [% ELSE %]
480
                        "fnServerData": function ( sSource, aoData, fnCallback ) {
481
                            aoData.push( { "name": "import_batch_id", "value": [% draft_record_to_display %] } );
482
                    [% END %]
483
                        $.ajax({
421
                        $.ajax({
484
                            'dataType': 'json',
422
                            'dataType': 'json',
485
                            'type': 'POST',
423
                            'type': 'POST',
Lines 502-514 Link Here
502
                      );
440
                      );
503
441
504
                      $('td:eq(2)', nRow).html(
442
                      $('td:eq(2)', nRow).html(
505
                          aData['status'] == 'imported' ? _("Imported") :
443
                          aData['status'] == 'staged'   ? _("Draft")   :
506
                          aData['status'] == 'ignored'  ? _("Ignored")  :
507
                          aData['status'] == 'reverted' ? _("Reverted") :
508
                          aData['status'] == 'staged'   ? _("Staged")   :
509
                          aData['status'] == 'error'    ? _("Error")    :
510
                          aData['status']
444
                          aData['status']
511
                      );
445
                      );
446
                      $('td:eq(2)', nRow).html(
447
                            aData['status'] == 'imported' ? _("Imported") :
448
                            aData['status'] == 'ignored'  ? _("Ignored")  :
449
                            aData['status'] == 'reverted' ? _("Reverted") :
450
                            aData['status'] == 'staged'   ? _("Staged")   :
451
                            aData['status'] == 'error'    ? _("Error")    :
452
                            aData['status']
453
                      );
512
454
513
                      $('td:eq(3)', nRow).html(
455
                      $('td:eq(3)', nRow).html(
514
                          aData['overlay_status'] == 'no_match'      ? _("No match")       :
456
                          aData['overlay_status'] == 'no_match'      ? _("No match")       :
Lines 538-550 Link Here
538
                          '<a target="_blank" href="' + record_details_url
480
                          '<a target="_blank" href="' + record_details_url
539
                              + aData['matched'] + '">' + aData['matched'] + '</a>'
481
                              + aData['matched'] + '">' + aData['matched'] + '</a>'
540
                      );
482
                      );
541
                      [% IF !(import_batch_id) %]
542
                        if (aData['catalog_link']){
543
                           $('td:eq(7)', nRow).html(
544
                              '<a href="' + aData['catalog_link'] + '">' + "Edit" + '</a>'
545
                            );
546
                         }
547
                      [% END %]
548
                    },
483
                    },
549
                }));
484
                }));
550
                $("#import_batch_form").on("submit",function(){
485
                $("#import_batch_form").on("submit",function(){
(-)a/tools/manage-marc-import.pl (-12 / +13 lines)
Lines 207-223 sub import_batches_list { Link Here
207
207
208
    my @list = ();
208
    my @list = ();
209
    foreach my $batch (@$batches) {
209
    foreach my $batch (@$batches) {
210
        push @list, {
210
        if ( !($batch->{'import_batch_id'} == 1) ) {
211
            import_batch_id => $batch->{'import_batch_id'},
211
            push @list, {
212
            num_records => $batch->{'num_records'},
212
                import_batch_id => $batch->{'import_batch_id'},
213
            num_items => $batch->{'num_items'},
213
                num_records => $batch->{'num_records'},
214
            upload_timestamp => $batch->{'upload_timestamp'},
214
                num_items => $batch->{'num_items'},
215
            import_status => $batch->{'import_status'},
215
                upload_timestamp => $batch->{'upload_timestamp'},
216
            file_name => $batch->{'file_name'} || "($batch->{'batch_type'})",
216
                import_status => $batch->{'import_status'},
217
            comments => $batch->{'comments'},
217
                file_name => $batch->{'file_name'} || "($batch->{'batch_type'})",
218
            can_clean => ($batch->{'import_status'} ne 'cleaned') ? 1 : 0,
218
                comments => $batch->{'comments'},
219
            record_type => $batch->{'record_type'},
219
                can_clean => ($batch->{'import_status'} ne 'cleaned') ? 1 : 0,
220
        };
220
                record_type => $batch->{'record_type'},
221
            };
222
        }
221
    }
223
    }
222
    $template->param(batch_list => \@list); 
224
    $template->param(batch_list => \@list); 
223
    my $num_batches = GetNumberOfNonZ3950ImportBatches();
225
    my $num_batches = GetNumberOfNonZ3950ImportBatches();
224
- 

Return to bug 20678