Bug 12759: Use a list (shelf) for batch record modification and deletion

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>
This commit is contained in:
Aleisha Amohia 2017-02-15 22:52:45 +00:00 committed by root
parent 5fbe1d7105
commit 408062a2bd
4 changed files with 66 additions and 0 deletions

View file

@ -71,6 +71,21 @@
<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>
@ -190,6 +205,13 @@
<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)");

View file

@ -75,6 +75,21 @@
<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>
@ -247,6 +262,13 @@
[% 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();

View file

@ -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') );

View file

@ -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') );