@@ -, +, @@ --- cataloguing/addbooks.pl | 51 +++++++++--- .../mysql/atomicupdate/add_draft_record_batch.sql | 2 +- .../prog/en/includes/cataloging-search.inc | 5 ++ .../prog/en/modules/cataloguing/addbooks.tt | 36 ++++++++- .../prog/en/modules/tools/manage-marc-import.tt | 93 ++++------------------ tools/manage-marc-import.pl | 24 +++--- 6 files changed, 104 insertions(+), 107 deletions(-) --- a/cataloguing/addbooks.pl +++ a/cataloguing/addbooks.pl @@ -33,6 +33,7 @@ use C4::Breeding; use C4::Output; use C4::Koha; use C4::Search; +use Data::Dumper; use Koha::BiblioFrameworks; use Koha::SearchEngine::Search; @@ -44,9 +45,9 @@ my $success = $input->param('biblioitem'); my $query = $input->param('q'); my @value = $input->multi_param('value'); my $page = $input->param('page') || 1; +my $drafts_only = $input->param('drafts_only'); my $results_per_page = 20; - my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "cataloguing/addbooks.tt", @@ -58,8 +59,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -# Searching the catalog. -if ($query) { +# Searching the catalog unless 'drafts_only' has been selected +if (($query) && !($drafts_only)) { # build query my @operands = $query; @@ -90,6 +91,7 @@ if ($query) { # SimpleSearch() give the results per page we want, so 0 offet here my $total = @{$marcresults}; my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, $marcresults ); + $template->param( total => $total_hits, query => $query, @@ -121,16 +123,41 @@ if ($query) { ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn ); } my $breeding_loop = []; + +my $count; for my $resultsbr (@resultsbr) { - push @{$breeding_loop}, { - id => $resultsbr->{import_record_id}, - isbn => $resultsbr->{isbn}, - copyrightdate => $resultsbr->{copyrightdate}, - editionstatement => $resultsbr->{editionstatement}, - file => $resultsbr->{file_name}, - title => $resultsbr->{title}, - author => $resultsbr->{author}, - }; + + #Only return records associated with 'Draft record' file_name if drafts_only has been set + if ($drafts_only) { + if ($resultsbr->{file_name} eq "Draft record") { + push @{$breeding_loop}, { + id => $resultsbr->{import_record_id}, + isbn => $resultsbr->{isbn}, + copyrightdate => $resultsbr->{copyrightdate}, + editionstatement => $resultsbr->{editionstatement}, + file => $resultsbr->{file_name}, + title => $resultsbr->{title}, + author => $resultsbr->{author}, + }; + $count++; + } + } else { + push @{$breeding_loop}, { + id => $resultsbr->{import_record_id}, + isbn => $resultsbr->{isbn}, + copyrightdate => $resultsbr->{copyrightdate}, + editionstatement => $resultsbr->{editionstatement}, + file => $resultsbr->{file_name}, + title => $resultsbr->{title}, + author => $resultsbr->{author}, + }; + } +} + +#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 +if ($drafts_only) { + $countbr = $count; + $template->param( query => $query, drafts_only => $drafts_only ); } my $schema = Koha::Database->new()->schema(); --- a/installer/data/mysql/atomicupdate/add_draft_record_batch.sql +++ a/installer/data/mysql/atomicupdate/add_draft_record_batch.sql @@ -1, +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'); +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 +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/cataloging-search.inc @@ -6,7 +6,12 @@

Search the catalog and the reservoir:

+ [-] + [+] +
+

Drafts only

+
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt @@ -44,6 +44,7 @@ [% END %] + View Draft records [% IF ( total ) %]
[% END %] @@ -142,7 +143,7 @@ [% ELSE %] - [% IF ( query ) %] + [% IF ( (query) && !(drafts_only) ) %] [% IF ( error ) %]
[% END %]No results found [% IF ( error ) %] Error: [% error %]
@@ -151,8 +152,17 @@ [% END %] [% IF ( query ) %] + [% IF ( drafts_only ) %] +
+ [% breeding_count %] result(s) found in reservoir +
+ [% END %]
-

Biblios in reservoir

+ [% IF (drafts_only) %] +

Draft records in reservoir

+ [% ELSE %] +

Biblios in reservoir

+ [% END %] [% IF ( breeding_loop ) %] @@ -170,7 +180,13 @@ - +
[% breeding_loo.isbn %] [% breeding_loo.copyrightdate %] [% breeding_loo.edition %][% breeding_loo.file %] + [% IF breeding_loo.file == "Draft record" %] + Draft record + [% ELSE %] + [% breeding_loo.file %] + [% END %] +
@@ -180,7 +196,11 @@
  • MARC preview
  • Card preview
  • [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] -
  • Continue editing draft record
  • + [% IF breeding_loo.file == "Draft record" %] +
  • Continue editing draft record
  • + [% ELSE %] +
  • Add biblio
  • + [% END %] [% END %]
    @@ -220,6 +240,14 @@ $(document).ready(function() { //Set focus to cataloging search $("input[name=q]:eq(0)").focus(); + $("#filteraction_off").hide(); + $("#filters").hide(); + + $("#filteraction_off, #filteraction_on").on('click', function(e) { + e.preventDefault(); + $('#filters').toggle(); + $('.filteraction').toggle(); + }); $("#z3950search").click(function(){ PopupZ3950(""); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt @@ -270,14 +270,6 @@ [% END %] [% END %] -
    - - -
    -
    @@ -334,28 +326,6 @@ [% END %]
    #
    -
    - -
    -

    To edit or save these draft records click the 'Edit' link beside the appropriate record.

    - - - - - - - - - - - - - -
    #CitationStatusMatch typeMatch detailsDiffRecordCatalog link
    -
    -
    -
    - [% IF ( pages ) %]
    [% FOREACH page IN pages %] @@ -426,36 +396,10 @@ $(this).parent().hide(); }); - [% IF !(import_batch_id) %] - document.getElementById('draftrecords').style.display = 'none'; - var marcfileslink = document.getElementById("marcfileslink"); - marcfileslink.style.backgroundColor = "#FFF"; - [% END %] - - var marcfiles = document.getElementById("marcfiles"); - var draftrecords = document.getElementById("draftrecords"); - var draftrecordslink = document.getElementById("draftrecordslink"); - var marcfileslink = document.getElementById("marcfileslink"); - - $("#draftrecordslink").click(function(e){ - draftrecords.style.display = "block"; - draftrecordslink.style.backgroundColor = "#FFF"; - marcfileslink.style.backgroundColor= "#e6f0f2"; - marcfiles.style.display = "none"; - if (document.getElementById("draftrecords").style.display === 'block') { - [% draft_record_to_display = 1 %] - } - }); - - $("#marcfileslink").click(function(e){ - draftrecords.style.display = "none"; - marcfiles.style.display = "block"; - draftrecordslink.style.backgroundColor = "#e6f0f2"; - marcfileslink.style.backgroundColor= "#FFF"; - }); - - [% IF (import_batch_id || draft_record_to_display) %] + [% IF import_batch_id %] $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, { + "bSort": true, + "order": [0, "desc"], "bAutoWidth": false, "bFilter": false, "bProcessing": true, @@ -471,15 +415,9 @@ { "mDataProp": "match_citation" }, { "mDataProp": "diff_url" }, { "mDataProp": "matched" }, - [% IF !(import_batch_id) %] { "mDataProp": "catalog_link" } [% END %] ], - [% IF (import_batch_id) %] - "fnServerData": function ( sSource, aoData, fnCallback ) { - aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } ); - [% ELSE %] - "fnServerData": function ( sSource, aoData, fnCallback ) { - aoData.push( { "name": "import_batch_id", "value": [% draft_record_to_display %] } ); - [% END %] + "fnServerData": function ( sSource, aoData, fnCallback ) { + aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } ); $.ajax({ 'dataType': 'json', 'type': 'POST', @@ -502,13 +440,17 @@ ); $('td:eq(2)', nRow).html( - aData['status'] == 'imported' ? _("Imported") : - aData['status'] == 'ignored' ? _("Ignored") : - aData['status'] == 'reverted' ? _("Reverted") : - aData['status'] == 'staged' ? _("Staged") : - aData['status'] == 'error' ? _("Error") : + aData['status'] == 'staged' ? _("Draft") : aData['status'] ); + $('td:eq(2)', nRow).html( + aData['status'] == 'imported' ? _("Imported") : + aData['status'] == 'ignored' ? _("Ignored") : + aData['status'] == 'reverted' ? _("Reverted") : + aData['status'] == 'staged' ? _("Staged") : + aData['status'] == 'error' ? _("Error") : + aData['status'] + ); $('td:eq(3)', nRow).html( aData['overlay_status'] == 'no_match' ? _("No match") : @@ -538,13 +480,6 @@ '' + aData['matched'] + '' ); - [% IF !(import_batch_id) %] - if (aData['catalog_link']){ - $('td:eq(7)', nRow).html( - '' + "Edit" + '' - ); - } - [% END %] }, })); $("#import_batch_form").on("submit",function(){ --- a/tools/manage-marc-import.pl +++ a/tools/manage-marc-import.pl @@ -207,17 +207,19 @@ sub import_batches_list { my @list = (); foreach my $batch (@$batches) { - push @list, { - import_batch_id => $batch->{'import_batch_id'}, - num_records => $batch->{'num_records'}, - num_items => $batch->{'num_items'}, - upload_timestamp => $batch->{'upload_timestamp'}, - import_status => $batch->{'import_status'}, - file_name => $batch->{'file_name'} || "($batch->{'batch_type'})", - comments => $batch->{'comments'}, - can_clean => ($batch->{'import_status'} ne 'cleaned') ? 1 : 0, - record_type => $batch->{'record_type'}, - }; + if ( !($batch->{'import_batch_id'} == 1) ) { + push @list, { + import_batch_id => $batch->{'import_batch_id'}, + num_records => $batch->{'num_records'}, + num_items => $batch->{'num_items'}, + upload_timestamp => $batch->{'upload_timestamp'}, + import_status => $batch->{'import_status'}, + file_name => $batch->{'file_name'} || "($batch->{'batch_type'})", + comments => $batch->{'comments'}, + can_clean => ($batch->{'import_status'} ne 'cleaned') ? 1 : 0, + record_type => $batch->{'record_type'}, + }; + } } $template->param(batch_list => \@list); my $num_batches = GetNumberOfNonZ3950ImportBatches(); --