Bugzilla – Attachment 105607 Details for
Bug 14648
Batch remove reserve items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug-14648-Batch-remove-reserve-items
Bug-14648-Batch-remove-reserve-items.patch (text/plain), 9.00 KB, created by
Joe Sikowitz
on 2020-06-06 13:27:51 UTC
(
hide
)
Description:
Bug-14648-Batch-remove-reserve-items
Filename:
MIME Type:
Creator:
Joe Sikowitz
Created:
2020-06-06 13:27:51 UTC
Size:
9.00 KB
patch
obsolete
>From ad8633e7a9fd7a954239b6a67c2ff421adfaa3f6 Mon Sep 17 00:00:00 2001 >From: Joseph Sikowitz <joe@flo.org> >Date: Sat, 6 Jun 2020 09:19:59 -0400 >Subject: [PATCH 3/3] Bug 14648: Batch remove reserve items > >Adds "Batch remove items" button to course-reserves.tt. Creates batch_rm_items.pl and batch_rm_items.tt. Allows user to enter a list of >barcode numbers so that they will be removed from all course reserves to which they are attached. A dialog box will provide a warning >before the final deletion is made. > >Test Plan >1. Log in as a user with permissions to add and delete course reserves >2. Add the same items to multiple course reserves >3. Go to the main course reserves page (i.e. /cgi-bin/koha/course_reserves/course-reserves.pl) >4. Click the "- Batch remove items" button >5. Enter the barcodes that you added to multiple reserves in step 1 >6. Click submit >7. Click Ok if you are ready to delete all of these items >8. Check each course reserve that you added the items to in step 1 to make sure the items you entered were deleted but nothing else >9. Log out >10. Log in as a user without permission to delete course reserves >11. Go to the main course reserves page (i.e. /cgi-bin/koha/course_reserves/course-reserves.pl) >12. You should not longer see the "- Batch remove items" button >--- > course_reserves/batch_rm_items.pl | 80 ++++++++++++++++++++++ > .../en/modules/course_reserves/batch_rm_items.tt | 80 ++++++++++++++++++++++ > .../en/modules/course_reserves/course-reserves.tt | 5 +- > 3 files changed, 164 insertions(+), 1 deletion(-) > create mode 100755 course_reserves/batch_rm_items.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_rm_items.tt > >diff --git a/course_reserves/batch_rm_items.pl b/course_reserves/batch_rm_items.pl >new file mode 100755 >index 0000000..b66ab1a >--- /dev/null >+++ b/course_reserves/batch_rm_items.pl >@@ -0,0 +1,80 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright (C) 2020 Fenway Library Organization >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI qw( -utf8 ); >+use List::MoreUtils qw( uniq ); >+ >+use C4::Auth; >+use C4::Output; >+use C4::CourseReserves qw(GetItemCourseReservesInfo DelCourseReserve); >+ >+use Koha::Items; >+ >+my $cgi = new CGI; >+ >+my $action = $cgi->param('action') || q{}; >+my $barcodes = $cgi->param('barcodes') || q{}; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "course_reserves/batch_rm_items.tt", >+ query => $cgi, >+ type => "intranet", >+ flagsrequired => { coursereserves => 'delete_reserves' }, >+ } >+); >+ >+if ( !$action ) { >+ $template->param( action => 'display_form' ); >+} >+ >+elsif ( $action eq 'batch_rm' ) { >+ my @barcodes = uniq( split (/\s\n/, $barcodes ) ); >+ >+ my @items; >+ my @invalid_barcodes; >+ foreach my $bar (@barcodes) { >+ my $item = Koha::Items->find( { barcode => $bar } ); >+ >+ if($item) { >+ #takes each course item and finds the courses they are attached to >+ push( @items, $item ); >+ my $res_info = GetItemCourseReservesInfo(itemnumber => $item->id); >+ foreach my $cr (@$res_info) { >+ if($cr->{cr_id}) { >+ DelCourseReserve('cr_id' => $cr->{cr_id}); >+ } >+ } >+ } >+ else { >+ push( @invalid_barcodes, $bar ); >+ } >+ >+ } >+ >+ $template->param( >+ action => 'display_results', >+ items_deleted => \@items, >+ invalid_barcodes => \@invalid_barcodes, >+ ); >+} >+ >+output_html_with_http_headers $cgi, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_rm_items.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_rm_items.tt >new file mode 100644 >index 0000000..529965f >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_rm_items.tt >@@ -0,0 +1,80 @@ >+[% SET footerjs = 1 %] >+ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Course reserves › Remove items</title> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+<body id="courses_rm_items" class="course"> >+ >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a> › Batch remove reserves</div> >+ >+<div class="main container-fluid"> >+ <div class="row"> >+ <div class="col-md-8 col-md-offset-2"> >+ [% IF action == 'display_form' %] >+ <form method="post" action="/cgi-bin/koha/course_reserves/batch_rm_items.pl"> >+ <input type="hidden" name="action" value="batch_rm" /> >+ <fieldset class="rows"> >+ <legend>Remove items: scan barcodes</legend> >+ <ol> >+ <li> >+ <label class="required" for="barcodes">Item barcodes:</label> >+ <textarea rows="20" cols="50" id="barcodes" name="barcodes" class="focus"></textarea> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <p>All course reserve items will be deleted from <i>all</i> courses to which they are attached.</p> >+ <input type="submit" value="Submit" class="submit" id="batch_rm_btn" /> >+ <a href="/cgi-bin/koha/course_reserves/course-reserves.pl" class="cancel">Cancel</a> >+ </fieldset> >+ </form> >+ [% END %] >+ >+ [% IF action == 'display_results' %] >+ <h1>Results</h1> >+ >+ <h3>Items deleted</h3> >+ [% IF items_deleted.size > 0 %] >+ <p>The following items were removed from all courses:</p> >+ <ul> >+ [% FOREACH i IN items_deleted %] >+ <li>[% i.biblio.title | html %] ( [% i.barcode | html %] )</li> >+ [% END %] >+ </ul> >+ [% ELSE %] >+ No valid item barcodes found. >+ [% END %] >+ >+ >+ [% IF invalid_barcodes.size > 0 %] >+ <h3>Invalid barcodes</h3> >+ <p>The following invalid barcodes were skipped:</p> >+ <ul> >+ [% FOREACH b IN invalid_barcodes %] >+ <li>[% b | html %]</li> >+ [% END %] >+ </ul> >+ [% END %] >+ >+ <p> >+ <a class='btn btn-default' href="/cgi-bin/koha/course_reserves/course-reserves.pl">Return</a> >+ </p> >+ [% END %] >+ </div> >+</div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script> >+ $(document).ready(function() { >+ $("#batch_rm_btn").click(function(){ >+ return confirmDelete(_("Are you sure you want to remove these items from all courses?")); >+ }); >+ }); >+ </script> >+[% END %] >+ >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt >index 7b1d4cd..7e6c4aa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt >@@ -20,11 +20,14 @@ > <div class="row"> > <div class="col-md-10 col-md-offset-1"> > >- [% IF CAN_user_coursereserves_add_reserves OR CAN_user_coursereserves_manage_courses OR CAN_user_coursereserves_manage_courses %] >+ [% IF CAN_user_coursereserves_add_reserves OR CAN_user_coursereserves_manage_courses OR CAN_user_coursereserves_manage_courses OR CAN_user_coursereserves_delete_reserves %] > <div id="toolbar"> > [% IF ( CAN_user_coursereserves_manage_courses ) %] > <a class="btn btn-default" id="new_course" href="/cgi-bin/koha/course_reserves/course.pl"><i class="fa fa-plus"></i> New course</a> > [% END %] >+ [% IF ( CAN_user_coursereserves_delete_reserves ) %] >+ <a class="btn btn-default" id="batch_rm" href="/cgi-bin/koha/course_reserves/batch_rm_items.pl"><i class="fa fa-minus"></i> Batch remove items</a> >+ [% END %] > </div><!-- /toolbar --> > [% END %] > >-- >2.7.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14648
:
105190
|
105607
|
105609
|
105610
|
107043
|
110228
|
110293
|
110294
|
110295
|
110988