Bugzilla – Attachment 145668 Details for
Bug 32730
Add patron lists tab to patron details and circulation pages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32730 - Add Patron Lists tab to patron details and circulation pages
0001-Bug-32730-Add-Patron-Lists-tab-to-patron-details-and.patch (text/plain), 23.33 KB, created by
Michael Hafen
on 2023-01-25 20:15:58 UTC
(
hide
)
Description:
Bug 32730 - Add Patron Lists tab to patron details and circulation pages
Filename:
MIME Type:
Creator:
Michael Hafen
Created:
2023-01-25 20:15:58 UTC
Size:
23.33 KB
patch
obsolete
>From f89d310701cf0aecb2f46c76c79795ba37938718 Mon Sep 17 00:00:00 2001 >From: Michael Hafen <michael.hafen@washk12.org> >Date: Wed, 25 Jan 2023 13:08:14 -0700 >Subject: [PATCH] Bug 32730 - Add Patron Lists tab to patron details and > circulation pages >Content-Type: text/plain; charset="utf-8" > >Test Plan: >1. Apply patch >2. create a patron list if there aren't any >3. search for a patron >4. observe the Patron Lists tab showing the list that the patron is not in >5. try adding the patron to the list and removing them from the list to be > sure the feature has full operation >6. click "Check Out" on the side bar menu to navigate to the circulation page > for this patron >7. observe the Patron Lists tab, and verify it operates as it did on the > patron details page >--- > Koha/List/Patron.pm | 22 ++ > circ/circulation.pl | 3 + > .../prog/en/modules/circ/circulation.tt | 21 ++ > .../prog/en/modules/members/moremember.tt | 21 ++ > .../modules/patron_lists/patron-lists-tab.tt | 197 ++++++++++++++++++ > members/moremember.pl | 3 + > patron_lists/patron-lists-tab.pl | 90 ++++++++ > 7 files changed, 357 insertions(+) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/patron-lists-tab.tt > create mode 100755 patron_lists/patron-lists-tab.pl > >diff --git a/Koha/List/Patron.pm b/Koha/List/Patron.pm >index cb91275d85..7c27659704 100644 >--- a/Koha/List/Patron.pm >+++ b/Koha/List/Patron.pm >@@ -42,6 +42,7 @@ BEGIN { > AddPatronList > ModPatronList > >+ GetListsWithPatron > AddPatronsToList > DelPatronsFromList > ); >@@ -156,6 +157,27 @@ sub ModPatronList { > return $list->update($params); > } > >+=head2 GetListsWithPatron >+ >+ GetListsWithPatron({ borrowernumber => $borrowernumber }); >+ >+=cut >+ >+sub GetListsWithPatron { >+ my ($params) = @_; >+ >+ my $borrowernumber = $params->{'borrowernumber'}; >+ >+ return unless ( $borrowernumber ); >+ >+ my @list_ids = map { $_->patron_list_id } Koha::Database->new()->schema()->resultset('PatronListPatron')->search( { borrowernumber => $borrowernumber } ); >+ my $pl_rs = Koha::Database->new()->schema()->resultset('PatronList'); >+ my $where = { patron_list_id => { 'IN' => \@list_ids } }; >+ my $order = {order_by => 'name'}; >+ >+ return $pl_rs->search( $where, $order ); >+} >+ > =head2 AddPatronsToList > > AddPatronsToList({ list => $list, cardnumbers => \@cardnumbers }); >diff --git a/circ/circulation.pl b/circ/circulation.pl >index a9a695db39..d5d10cc1ea 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -54,6 +54,7 @@ use Koha::Items; > use Koha::SearchEngine; > use Koha::SearchEngine::Search; > use Koha::Patron::Modifications; >+use Koha::List::Patron qw( GetListsWithPatron ); > use Koha::Token; > > use List::MoreUtils qw( uniq ); >@@ -631,6 +632,7 @@ if ( C4::Context->preference("ExportCircHistory") ) { > } > > my $has_modifications = Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->count; >+my $patron_lists_count = GetListsWithPatron({borrowernumber => $borrowernumber})->count(); > $template->param( > debt_confirmed => $debt_confirmed, > SpecifyDueDate => $duedatespec_allow, >@@ -639,6 +641,7 @@ $template->param( > todaysdate => dt_from_string()->set(hour => 23)->set(minute => 59), > restriction_types => scalar Koha::Patron::Restriction::Types->keyed_on_code(), > has_modifications => $has_modifications, >+ patron_lists_count => $patron_lists_count, > override_high_holds => $override_high_holds, > nopermission => scalar $query->param('nopermission'), > autoswitched => $autoswitched, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index c4c42aaea8..fc2e3dc50e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -893,6 +893,14 @@ > </a> > </li> > [% END %] >+ >+ [% IF CAN_user_tools_manage_patron_lists || patron_lists_count %] >+ <li role="presentation"> >+ <a id="pat_lists-tab-link" href="#pat_lists-tab" aria-controls="pat_lists-tab" role="tab" data-toggle="tab"> >+ Patron Lists ([% patron_lists_count | html %]) >+ </a> >+ </li> >+ [% END %] > </ul> > > <div class="tab-content"> >@@ -908,6 +916,12 @@ > </div> <!-- /#clubs-tab --> > [% END %] > >+ [% IF CAN_user_tools_manage_patron_lists || patron_lists_count %] >+ <div id="pat_lists-tab" role="tabpanel" class="tab-pane"> >+ Loading... >+ </div> >+ [% END %] >+ > [% INCLUDE borrower_debarments.inc %] > > <div id="reserves" role="tabpanel" class="tab-pane"> >@@ -1116,6 +1130,13 @@ > }); > } > >+ if ( $('#pat_lists-tab').length ) { >+ $('#pat_lists-tab-link').on('click', function() { >+ $('#pat_lists-tab').text(_("Loading...")); >+ $('#pat_lists-tab').load('/cgi-bin/koha/patron_lists/patron-lists-tab.pl?borrowernumber=[% patron.borrowernumber | html %]'); >+ }); >+ } >+ > // listen submit to trigger qslip on empty checkout > $('#mainform').bind('submit',function() { > if ($('#barcode').val() == '') { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index ef0a906c90..5f6b83cfbf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -725,6 +725,14 @@ > </a> > </li> > [% END %] >+ >+ [% IF CAN_user_tools_manage_patron_lists || patron_lists_count %] >+ <li role="presentation"> >+ <a id="pat_lists-tab-link" href="#pat_lists-tab" aria-controls="pat_lists-tab" role="tab" data-toggle="tab"> >+ Patron Lists ([% patron_lists_count | html %]) >+ </a> >+ </li> >+ [% END %] > </ul> > > <div class="tab-content"> >@@ -748,6 +756,12 @@ > </div> > [% END %] > >+ [% IF CAN_user_tools_manage_patron_lists || patron_lists_count %] >+ <div id="pat_lists-tab" role="tabpanel" class="tab-pane"> >+ Loading... >+ </div> >+ [% END %] >+ > [% INCLUDE borrower_debarments.inc %] > > [% IF ( CAN_user_circulate_circulate_remaining_permissions ) %] >@@ -902,6 +916,13 @@ > }); > } > >+ if ( $('#pat_lists-tab').length ) { >+ $('#pat_lists-tab-link').on('click', function() { >+ $('#pat_lists-tab').text(_("Loading...")); >+ $('#pat_lists-tab').load('/cgi-bin/koha/patron_lists/patron-lists-tab.pl?borrowernumber=[% patron.borrowernumber | html %]'); >+ }); >+ } >+ > $("#finesholdsissues a[data-toggle='tab']").on("shown.bs.tab", function(e){ > var oTable = $('div.dataTables_wrapper > table', $(e.target.hash) ).dataTable(); > if ( oTable.length > 0 ) { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/patron-lists-tab.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/patron-lists-tab.tt >new file mode 100644 >index 0000000000..ad5d520454 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/patron-lists-tab.tt >@@ -0,0 +1,197 @@ >+[% USE KohaDates %] >+ >+[% IF no_access_to_patron %] >+ <span class="blocker">Patron not in your library group</span> >+[% END %] >+ >+[% IF in_lists %] >+ <h4>Patron Lists currently in</h4> >+ >+ <table id="table_inlists"> >+ <thead> >+ <tr> >+ <th>Name</th> >+ <th>Patrons in list</th> >+ <th>Shared</th> >+ [% IF CAN_user_tools_manage_patron_lists %] >+ <th class="NoSort">Actions</th> >+ [% END %] >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH l IN in_lists %] >+ [% SET shared_by_other = l.owner.id != logged_in_user.id %] >+ <tr> >+ <td> >+ [% IF CAN_user_tools_manage_patron_lists %] >+ <a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% l.patron_list_id | uri %]">[% l.name | html %]</a> >+ [% ELSE %] >+ [% l.name | html %] >+ [% END %] >+ </td> >+ <td>[% l.patron_list_patrons_rs.count || 0 | html %]</td> >+ <td> >+ [% IF l.shared %] >+ [% IF shared_by_other %] >+ by <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% l.owner.id | uri %]">[% INCLUDE 'patron-title.inc' patron=l.owner %]</a> >+ [% ELSE %] >+ by you >+ [% END %] >+ [% END %] >+ </td> >+ [% IF CAN_user_tools_manage_patron_lists %] >+ <td> >+ <div class="btn-group dropup"> >+ <a class="btn btn-default btn-xs dropdown-toggle" id="listactions[% l.patron_list_id | html %]" role="button" data-toggle="dropdown" href="#"> >+ Actions <b class="caret"></b> >+ </a> >+ <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="listactions[% l.patron_list_id | html %]"> >+ <li><a onclick="removeFromList('[% l.patron_list_id | html %]','[% list_id_lookup.${l.patron_list_id} | html %]')"><i class="fa fa-remove"></i> Remove patron from list</a></li> >+ <li class="divider"></li> >+ <li><a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% l.patron_list_id | uri %]"><i class="fa fa-user"></i> Add patrons</a></li> >+ [% UNLESS shared_by_other %] >+ <li><a href="/cgi-bin/koha/patron_lists/add-modify.pl?patron_list_id=[% l.patron_list_id | uri %]"><i class="fa fa-pencil"></i> Edit list</a></li> >+ <li><a class="delete_patron" href="/cgi-bin/koha/patron_lists/delete.pl?patron_list_id=[% l.patron_list_id | html %]" data-list-name="[% l.name | html %]"><i class="fa fa-trash"></i> Delete list</a></li> >+ [% END %] >+ [% IF ( l.patron_list_patrons_rs.count ) %] >+ <li class="divider"></li> >+ <li> >+ <a class="print_cards" href="/cgi-bin/koha/patroncards/print.pl?patronlist_id=[% l.patron_list_id | html %]" data-patron_list_id="[% l.patron_list_id | html %]"><i class="fa fa-print"></i> Print patron cards</a> >+ </li> >+ [% IF CAN_user_tools_edit_patrons %] >+ <li> >+ <a href="/cgi-bin/koha/tools/modborrowers.pl?patron_list_id=[% l.patron_list_id | uri %]&op=show"> >+ <i class="fa fa-pencil"></i> Batch edit patrons >+ </a> >+ </li> >+ [% END %] >+ [% IF CAN_user_tools_delete_anonymize_patrons %] >+ <li> >+ <a href="/cgi-bin/koha/tools/cleanborrowers.pl?step=2&patron_list_id=[% l.patron_list_id | uri %]&checkbox=borrower"> >+ <i class="fa fa-trash"></i> Batch delete patrons >+ </a> >+ </li> >+ [% END %] >+ [% END %] >+ </ul> >+ </div> >+ </td> >+ [% END %] >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+[% END %] >+ >+[% IF available_lists %] >+ >+ <h4>Patron lists not in</h4> >+ >+ <table id="table_listnopatron"> >+ <thead> >+ <tr> >+ <th>Name</th> >+ <th>Patrons in list</th> >+ <th>Shared</th> >+ [% IF CAN_user_tools_manage_patron_lists %] >+ <th class="NoSort">Actions</th> >+ [% END %] >+ </tr> >+ </thead> >+ >+ <tbody> >+ [% FOREACH l IN available_lists %] >+ [% SET shared_by_other = l.owner.id != logged_in_user.id %] >+ <tr> >+ <td> >+ [% IF CAN_user_tools_manage_patron_lists %] >+ <a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% l.patron_list_id | uri %]">[% l.name | html %]</a> >+ [% ELSE %] >+ [% l.name | html %] >+ [% END %] >+ </td> >+ <td>[% l.patron_list_patrons_rs.count || 0 | html %]</td> >+ <td> >+ [% IF l.shared %] >+ [% IF shared_by_other %] >+ by <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% l.owner.id | uri %]">[% INCLUDE 'patron-title.inc' patron=l.owner %]</a> >+ [% ELSE %] >+ by you >+ [% END %] >+ [% END %] >+ </td> >+ [% IF CAN_user_tools_manage_patron_lists %] >+ <td> >+ <div class="btn-group dropup"> >+ <a class="btn btn-default btn-xs dropdown-toggle" id="listactions[% l.patron_list_id | html %]" role="button" data-toggle="dropdown" href="#"> >+ Actions <b class="caret"></b> >+ </a> >+ <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="listactions[% l.patron_list_id | html %]"> >+ <li><a onclick="addToList('[% l.patron_list_id | html %]','[% cardnumber | html %]')"><i class="fa fa-plus"></i> Add patron to list</a></li> >+ <li class="divider"></li> >+ <li><a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% l.patron_list_id | uri %]"><i class="fa fa-user"></i> Add patrons</a></li> >+ [% UNLESS shared_by_other %] >+ <li><a href="/cgi-bin/koha/patron_lists/add-modify.pl?patron_list_id=[% l.patron_list_id | uri %]"><i class="fa fa-pencil"></i> Edit list</a></li> >+ <li><a class="delete_patron" href="/cgi-bin/koha/patron_lists/delete.pl?patron_list_id=[% l.patron_list_id | html %]" data-list-name="[% l.name | html %]"><i class="fa fa-trash"></i> Delete list</a></li> >+ [% END %] >+ [% IF ( l.patron_list_patrons_rs.count ) %] >+ <li class="divider"></li> >+ <li> >+ <a class="print_cards" href="/cgi-bin/koha/patroncards/print.pl?patronlist_id=[% l.patron_list_id | html %]" data-patron_list_id="[% l.patron_list_id | html %]"><i class="fa fa-print"></i> Print patron cards</a> >+ </li> >+ [% IF CAN_user_tools_edit_patrons %] >+ <li> >+ <a href="/cgi-bin/koha/tools/modborrowers.pl?patron_list_id=[% l.patron_list_id | uri %]&op=show"> >+ <i class="fa fa-pencil"></i> Batch edit patrons >+ </a> >+ </li> >+ [% END %] >+ [% IF CAN_user_tools_delete_anonymize_patrons %] >+ <li> >+ <a href="/cgi-bin/koha/tools/cleanborrowers.pl?step=2&patron_list_id=[% l.patron_list_id | uri %]&checkbox=borrower"> >+ <i class="fa fa-trash"></i> Batch delete patrons >+ </a> >+ </li> >+ [% END %] >+ [% END %] >+ </ul> >+ </div> >+ </td> >+ [% END %] >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+[% END %] >+ >+<script> >+$("#table_listnopatron, #table_inlists").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "columnDefs": [ >+ { 'sortable': false, 'targets': [ 'NoSort' ] } >+ ], >+ paginate: true >+})); >+ >+[% IF CAN_user_tools_manage_patron_lists %] >+function addToList( list_id, cardnumber ) { >+ $('#pat_lists-tab').text(_("Loading...")); >+ $("body").css("cursor", "progress"); >+ $('#pat_lists-tab').load('/cgi-bin/koha/patron_lists/patron-lists-tab.pl?borrowernumber=[% borrowernumber | html %]&patron_list_id=' + list_id + '&patrons_to_add=' + cardnumber, function() { >+ $("body").css("cursor", "default"); >+ }); >+ >+ return false; >+} >+ >+function removeFromList( list_id, patron_list_patron_id ) { >+ $('#pat_lists-tab').text(_("Loading...")); >+ $("body").css("cursor", "progress"); >+ $('#pat_lists-tab').load('/cgi-bin/koha/patron_lists/patron-lists-tab.pl?borrowernumber=[% borrowernumber | html %]&patron_list_id=' + list_id + '&patrons_to_remove=' + patron_list_patron_id, function() { >+ $("body").css("cursor", "default"); >+ }); >+ >+ return false; >+} >+[% END %] >+</script> >diff --git a/members/moremember.pl b/members/moremember.pl >index 0523d02831..fd566d8aba 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -43,6 +43,7 @@ use Koha::CsvProfiles; > use Koha::Holds; > use Koha::Patrons; > use Koha::Patron::Files; >+use Koha::List::Patron qw( GetListsWithPatron ); > use Koha::Token; > use Koha::Checkouts; > >@@ -266,6 +267,7 @@ elsif ( $patron->is_going_to_expire ) { > > > my $has_modifications = Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->count; >+my $patron_lists_count = GetListsWithPatron({borrowernumber => $borrowernumber})->count(); > > $template->param( > patron => $patron, >@@ -283,6 +285,7 @@ $template->param( > files => Koha::Patron::Files->new( borrowernumber => $borrowernumber ) ->GetFilesInfo(), > #debarments => scalar GetDebarments({ borrowernumber => $borrowernumber }), > has_modifications => $has_modifications, >+ patron_lists_count => $patron_lists_count, > ); > > if ( C4::Context->preference('UseRecalls') ) { >diff --git a/patron_lists/patron-lists-tab.pl b/patron_lists/patron-lists-tab.pl >new file mode 100755 >index 0000000000..c3e281b140 >--- /dev/null >+++ b/patron_lists/patron-lists-tab.pl >@@ -0,0 +1,90 @@ >+#!/usr/bin/perl >+ >+# Copyright 2013 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# 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; >+ >+use C4::Auth qw( get_template_and_user ); >+use C4::Output qw( output_html_with_http_headers ); >+ >+use Koha::Patrons; >+use Koha::List::Patron qw( GetPatronLists GetListsWithPatron AddPatronsToList DelPatronsFromList ); >+ >+my $cgi = CGI->new; >+ >+my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( >+ { >+ template_name => "patron_lists/patron-lists-tab.tt", >+ query => $cgi, >+ type => "intranet", >+ flagsrequired => [ { circulate => 'circulate_remaining_permissions' }, { borrowers => '*' }, { tools => 'manage_patron_lists' } ], >+ } >+); >+ >+my $logged_in_user = Koha::Patrons->find( { borrowernumber => $loggedinuser } ); >+my $patronnumber = $cgi->param('borrowernumber'); >+my $patron = Koha::Patrons->find($patronnumber); >+my ( @in_lists, %list_id_lookup, @available_lists ); >+ >+my $list_id = $cgi->param('patron_list_id'); >+my @patrons_to_add = $cgi->multi_param('patrons_to_add'); >+my @patrons_to_remove = $cgi->multi_param('patrons_to_remove'); >+ >+if ( ! $logged_in_user->can_see_patron_infos($patron) ) { >+ $template->param('no_access_to_patron' => 1); >+} >+else { >+ if ( $list_id && ( $userflags->{'tools'} == 1 || $userflags->{'tools'}{'manage_patron_lists'} ) ) { >+ my ($list) = GetPatronLists( { patron_list_id => $list_id } ); >+ >+ if (@patrons_to_add) { >+ AddPatronsToList( { list => $list, cardnumbers => \@patrons_to_add } ); >+ } >+ >+ if (@patrons_to_remove) { >+ DelPatronsFromList( { list => $list, patron_list_patrons => \@patrons_to_remove } ); >+ } >+ } >+ >+ if ( $patron ) { >+ @in_lists = GetListsWithPatron({borrowernumber=>$patronnumber}); >+ foreach my $list ( @in_lists ) { >+ my @existing = $list->patron_list_patrons; >+ for my $plp ( @existing ) { >+ if ( $plp->borrowernumber->borrowernumber == $patronnumber ) { >+ $list_id_lookup{$list->patron_list_id} = $plp->patron_list_patron_id; >+ last; >+ } >+ } >+ } >+ } >+ @available_lists = GetPatronLists(); >+ @available_lists = grep { ! $list_id_lookup{$_->patron_list_id} } @available_lists; >+} >+ >+$template->param( >+ in_lists => \@in_lists, >+ list_id_lookup => \%list_id_lookup, >+ available_lists => \@available_lists, >+ borrowernumber => $patronnumber, >+ cardnumber => $patron->cardnumber, >+); >+ >+output_html_with_http_headers( $cgi, $cookie, $template->output ); >-- >2.34.1 >
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 32730
:
145668
|
145710
|
145744
|
145745
|
145768
|
145977
|
146039
|
147981
|
147982
|
149477
|
154672
|
155575
|
155589
|
157992
|
158209
|
158210
|
158211