From 70615317bc8b490abc9d30dd0c5c740582af6714 Mon Sep 17 00:00:00 2001 From: Joseph Sikowitz Date: Sat, 23 May 2020 17:45:51 -0400 Subject: [PATCH 2/2] Bug 25606: Remove all reserve items button Adds button to course records to remove all attached reserve items. A warning dialog box will appear before executed. Test plan 1. Install patch 2. Log in as user with permission to delete reserves 3. View a course reserve record with multiple items attached 4. There should now be a button that says "- Batch remove reserves" 5. When you click the button a dialog box should appear with a warning 6. Click "Ok" 7. All course reserves should be removed from the record 8. Add an item to more than course record 9. Redo 3-7 10. Items should have been removed from that course but remain on all other courses 11. Log in as a user without delete reserves permission 12. You should not see the batch remove option --- course_reserves/course-details.pl | 10 +++++++++- .../prog/en/modules/course_reserves/course-details.tt | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/course_reserves/course-details.pl b/course_reserves/course-details.pl index af1eb62..7604e23 100755 --- a/course_reserves/course-details.pl +++ b/course_reserves/course-details.pl @@ -34,7 +34,7 @@ my $action = $cgi->param('action') || ''; my $course_id = $cgi->param('course_id'); my $flagsrequired; -$flagsrequired->{coursereserves} = 'delete_reserves' if ( $action eq 'del_reserve' ); +$flagsrequired->{coursereserves} = 'delete_reserves' if ( $action eq 'del_reserve' or $action eq 'rm_all' ); my $tmpl = ($course_id) ? "course-details.tt" : "invalid-course.tt"; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -49,6 +49,14 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( if ( $action eq 'del_reserve' ) { DelCourseReserve( cr_id => scalar $cgi->param('cr_id') ); } +elsif ( $action eq 'rm_all' ) { + my $course_res = GetCourseReserves(course_id => $course_id); + foreach my $cr (@$course_res) { + if(exists $cr->{'cr_id'}) { + DelCourseReserve(cr_id => $cr->{cr_id}); + } + } +} my $course = GetCourse($course_id); my $course_reserves = GetCourseReserves( diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt index a1e04a9..421940a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt @@ -36,6 +36,9 @@ Add reserves Batch add reserves [% END %] + [% IF CAN_user_coursereserves_delete_reserves %] + Remove all reserves + [% END %] [% IF ( CAN_user_coursereserves_manage_courses ) %] Edit course [% END %] @@ -263,6 +266,10 @@ return confirmDelete(_("Are you sure you want to remove this item from the course?")); }); + $("#rm_items").click(function(){ + return confirmDelete(_("Are you sure you want to remove all items from the course?")); + }); + $("#delete_course").click(function(){ [% SET count = course_reserves.size || 0 %] [% IF count == 1 %] -- 2.7.4