Bug 12759: Use a list (shelf) for batch record modification and deletion
authorAleisha Amohia <aleishaamohia@hotmail.com>
Wed, 15 Feb 2017 22:52:45 +0000 (22:52 +0000)
committerroot <root@f1ebe1bec408>
Tue, 19 Feb 2019 13:52:15 +0000 (13:52 +0000)
To test:
1) Create a list, add a record to it by its barcode that you don't mind
deleting
2) Go to Tools -> Batch record modification
3) Select the record type 'Authorities'. Confirm the dropdown to select
a list disappears. Confirm selecting 'Biblios' makes the dropdown show
again.
4) Select the list from the dropdown, select a modification template,
Continue
5) Confirm all of the records in that list show on the page. Click
Modify selected records. Confirm this is successful.
6) Go to Batch record deletion
7) Select the record type 'Authorities'. Confirm the dropdown to select
a list disappears. Confirm selecting 'Biblios' makes the dropdown
show again.
8) Select the list from the dropdown and click Continue
9) Confirm all of the records in that list show on the page. Click
Delete selected records. Confirm this is successful.
10) Go back to your lists. The list should still exist but it will now be
empty.

Sponsored-by: Catalyst IT
NOTE: Rebased to work -- Mark Tompsett
Signed-off-by: Charles Farmer <charles.farmer@inLibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt
tools/batch_delete_records.pl
tools/batch_record_modification.pl

index 82d3e72..4b33b1d 100644 (file)
           <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
         </ol>
       </fieldset>
+      <fieldset class="rows" id="shelves">
+        <legend>Or select a list of records</legend>
+        <ol>
+          <li>
+            <label for="shelf_number">Use records from the following list: </label>
+            <select name="shelf_number" id="shelf_number">
+              <option value="">Select a list</option>
+                [% FOREACH list IN lists %]
+                  <option value="[% list.shelfnumber %]">[% list.shelfname %]</option>
+                [% END %]
+              </option>
+            </select>
+          </li>
+        </ol>
+      </fieldset>
       <fieldset class="rows">
         <legend>Or enter a list of record numbers</legend>
         <ol>
     <script>
         var MSG_CANNOT_BE_DELETED = _("This record cannot be deleted, at least one item is currently checked out.");
         $(document).ready(function() {
+          $("input[type='radio']").click(function(){
+            if ($(this).attr('id') == 'authority_type') {
+              $("#shelves").hide();
+            } else if ($(this).attr('id') == 'biblio_type') {
+              $("#shelves").show();
+            }
+          });
           $("#selectall").click(function(e){
             e.preventDefault();
             $(".records").checkCheckboxes(":input[type='checkbox']:not(:disabled)");
index 7928185..3bdea3a 100644 (file)
           <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
         </ol>
       </fieldset>
+      <fieldset class="rows" id="shelves">
+        <legend>Or select a list of records</legend>
+        <ol>
+          <li>
+            <label for="shelf_number">Use records from the following list: </label>
+            <select name="shelf_number" id="shelf_number">
+              <option value="">Select a list</option>
+                [% FOREACH list IN lists %]
+                  <option value="[% list.shelfnumber %]">[% list.shelfname %]</option>
+                [% END %]
+              </option>
+            </select>
+          </li>
+        </ol>
+      </fieldset>
       <fieldset class="rows">
         <legend>Or enter a list of record numbers</legend>
         <ol>
     [% Asset.js("js/background-job-progressbar.js") | $raw %]
     <script>
         $(document).ready(function() {
+          $("input[type='radio']").click(function(){
+            if ($(this).attr('id') == 'authority_type') {
+              $("#shelves").hide();
+            } else if ($(this).attr('id') == 'biblio_type') {
+              $("#shelves").show();
+            }
+          });
           $("#selectall").click(function(e){
             e.preventDefault();
             $(".records").checkCheckboxes();
index 0194c5d..c8d0566 100755 (executable)
@@ -27,6 +27,7 @@ use C4::Auth;
 use C4::Output;
 use C4::AuthoritiesMarc;
 use C4::Biblio;
+use Koha::Virtualshelves;
 
 use Koha::Authorities;
 use Koha::Biblios;
@@ -44,6 +45,9 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({
         flagsrequired => { tools => 'records_batchdel' },
 });
 
+my @lists = Koha::Virtualshelves->search({});
+$template->param( lists => \@lists );
+
 my @records;
 my @messages;
 if ( $op eq 'form' ) {
@@ -64,6 +68,13 @@ if ( $op eq 'form' ) {
             $content =~ s/[\r\n]*$//;
             push @record_ids, $content if $content;
         }
+    } elsif ( my $shelf_number = $input->param('shelf_number') ) {
+        my $shelf = Koha::Virtualshelves->find($shelf_number);
+        my $contents = $shelf->get_contents;
+        while ( my $content = $contents->next ) {
+            my $biblionumber = $content->biblionumber;
+            push @record_ids, $biblionumber;
+        }
     } else {
         # The user enters manually the list of id
         push @record_ids, split( /\s\n/, $input->param('recordnumber_list') );
index 2b76084..b6f65f3 100755 (executable)
@@ -32,6 +32,7 @@ use C4::MarcModificationTemplates qw( GetModificationTemplateActions GetModifica
 
 use Koha::Biblios;
 use Koha::MetadataRecord::Authority;
+use Koha::Virtualshelves;
 
 my $input = new CGI;
 our $dbh = C4::Context->dbh;
@@ -68,6 +69,9 @@ if ( $completedJobID ) {
     exit;
 }
 
+my @lists = Koha::Virtualshelves->search({});
+$template->param( lists => \@lists );
+
 my @templates = GetModificationTemplates( $mmtid );
 unless ( @templates ) {
     $op = 'error';
@@ -111,6 +115,13 @@ if ( $op eq 'form' ) {
             $content =~ s/[\r\n]*$//;
             push @record_ids, $content if $content;
         }
+    } elsif ( my $shelf_number = $input->param('shelf_number') ) {
+        my $shelf = Koha::Virtualshelves->find($shelf_number);
+        my $contents = $shelf->get_contents;
+        while ( my $content = $contents->next ) {
+            my $biblionumber = $content->biblionumber;
+            push @record_ids, $biblionumber;
+        }
     } else {
         # The user enters manually the list of id
         push @record_ids, split( /\s\n/, $input->param('recordnumber_list') );