From fcee33a1184454fbdbf520963deb99dcacac1426 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Sun, 29 Apr 2018 13:25:08 +0000 Subject: [PATCH] Bug 20678 : Added removal of biblio from reservoir after saving to catalog Added new subroutine DeleteBiblioInBatch() and internal subroutine _delete_import_record_marc() (which is called by the DeleteBiblioInBatch() subroutine) in the C4/ImportBatches.pm file. If addbiblio.pl webpage has breedingid defined in the URL this means the biblio being edited currently exists as a draft in the reservoir. And so when a save option except for 'Save without catalog' is clicked this means the biblio is committed to the catalog and DeleteBiblioInBatch() is called to remove the biblio from the reservoir. Test plan: 1. Go to Cataloging->New record 2. After inputting the record data select 'Save without cataloging' 3. Perform a catalog search with the title of the biblio you just created 4. Notice the draft biblio you created is returned in the 'Biblios in reservoir' search results 5. Select Actions->Continue editing draft record 6. Perform the following database queries: 6a. SELECT * FROM biblio WHERE title='; - This will return a record as the biblio has been saved to the reservoir 7. Open a new tab and go to Tools->Manage staged MARC records and select the 'Draft records' tab and notice the draft biblio you just created is displayed in the table of draft records in the reservoir 8. Back in your first tab select the 'Save and view record' 9. Now perform the database queries 6a, 6b and 6c and notice the biblio record is returned for 6a as the MARC record has been committed to the catalog, and no records are returned for 6b and 6c because the biblio has been removed from the reservoir 10. In the second tab refresh the page and notice the biblio that you just committed to the catalog is not displayed in the draft records tab Sponsored-By: Toi Ohomai Institute of Technology --- C4/ImportBatch.pm | 20 +++++++++++++++++++- cataloguing/addbiblio.pl | 3 +++ .../prog/en/modules/cataloguing/addbooks.tt | 6 +----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 3727f41..45461af 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -44,6 +44,7 @@ BEGIN { GetImportBatch AddAuthToBatch AddBiblioToBatch + DeleteBiblioInBatch AddItemsToImportBiblio ModAuthorityInBatch ModBiblioInBatch @@ -296,6 +297,15 @@ sub AddBiblioToBatch { return $import_record_id; } +=head2 DeleteBiblioInBatch + DeleteBiblioInBatch( $import_record_id ); +=cut + +sub DeleteBiblioInBatch { + my ($import_record_id) = @_; + _delete_import_record_marc($import_record_id); +} + =head2 ModBiblioInBatch ModBiblioInBatch($import_record_id, $marc_record); @@ -1615,6 +1625,15 @@ sub _update_import_record_marc { $sth->finish(); } +sub _delete_import_record_marc { + my ($import_record_id) = @_; + + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("DELETE FROM import_records WHERE import_record_id = ?"); + $sth->execute($import_record_id); + $sth->finish(); +} + sub _add_auth_fields { my ($import_record_id, $marc_record) = @_; @@ -1639,7 +1658,6 @@ sub _add_biblio_fields { my $sth = $dbh->prepare("INSERT INTO import_biblios (import_record_id, title, author, isbn, issn) VALUES (?, ?, ?, ?, ?)"); $sth->execute($import_record_id, $title, $author, $isbn, $issn); $sth->finish(); - } sub _update_biblio_fields { diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 6f0f924..6d49db1 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -848,6 +848,9 @@ if ( $op eq "addbiblio" ) { AddBiblioToBatch(1, 0, $record, 'biblio', int(rand(99999)), 0); print $input->redirect('/cgi-bin/koha/cataloguing/addbooks.pl'); } else { + if ($breedingid) { + DeleteBiblioInBatch($breedingid); + } ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode ); } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt index 21d73c2..31c3659 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt @@ -180,11 +180,7 @@ <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> <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&importid=[% breeding_loo.id %]" class="previewData"><i class="fa fa-eye"></i> Card preview</a></li> [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] - [% IF breeding_loo.file == "draft_marc_records.mrc" %] - <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> - [% ELSE %] - <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?breedingid=[% breeding_loo.id %]"><i class="fa fa-plus"></i> Add biblio</a></li> - [% END %] + <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> [% END %] </ul> </div> -- 2.1.4