From eca9068633e03d59c89a8882072ba696c9acf5d9 Mon Sep 17 00:00:00 2001 From: jeremy breuillard Date: Fri, 22 Oct 2021 15:13:36 +0000 Subject: [PATCH] Bug 35028: Add self-registrations alert on staff interface main page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a new system preference PatronSelfRegistrationAlert to enable or disable alerts (disabled by default) Test plan: 1. Create patron category SELFREG 2. Enable PatronSelfRegistration and set PatronSelfRegistrationDefaultCategory to SELFREG and PatronSelfRegistrationAlert to "Show" 3. Go to OPAC, logout if needed, and create a new account. Remember the value you set for home library. 4. Go to staff interface, set the current library to the one you set in step 3. 5. Go to the staff interface main page. You should see at the bottom a message saying "Self-registrations from: All libraries: 1 / : 1" (numbers can vary if you already had self-registered patrons) 6. Click on both links and verify that it shows the correct patrons (or redirect to the patron detail page if there is only one) 7. Set the current library to another one (one that doesn't have self-registered patrons) 8. Go to the staff interface main page. You should see at the bottom a message saying "Self-registrations from: All libraries: 1" (numbers can vary if you already had self-registered patrons) 9. Click on the link and verify that it shows the correct patrons (or redirect to the patron detail page if there is only one) Co-authored-by: Fridolin Somers Co-authored-by: Julian Maurice Sponsored-by: Écoles nationales supérieures d'architecture (ENSA) --- installer/data/mysql/atomicupdate/bug-35028.pl | 15 +++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/opac.pref | 6 ++++++ .../prog/en/modules/intranet-main.tt | 15 ++++++++++++++- mainpage.pl | 12 ++++++++++++ members/member.pl | 15 +++++++++++---- 6 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug-35028.pl diff --git a/installer/data/mysql/atomicupdate/bug-35028.pl b/installer/data/mysql/atomicupdate/bug-35028.pl new file mode 100644 index 0000000000..87a8c5348f --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-35028.pl @@ -0,0 +1,15 @@ +use Modern::Perl; + +return { + bug_number => '35028', + description => 'Add system preference PatronSelfRegistrationAlert', + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( " + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('PatronSelfRegistrationAlert','0',NULL,'If enabled, an alter will be shown on staff interface home page when there are self-registered patrons.','YesNo') + " ); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index f49557be9c..4d47f8d411 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -612,6 +612,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('PatronSelfModificationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when a patron is editing their information via the OPAC.','free'), ('PatronSelfModificationMandatoryField','',NULL,'Define the required fields when a patron is editing their information via the OPAC','free'), ('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'), +('PatronSelfRegistrationAlert','0',NULL,'If enabled, an alter will be shown on staff interface home page when there are self-registered patrons.','YesNo'), ('PatronSelfRegistrationBorrowerMandatoryField','surname|firstname',NULL,'Choose the mandatory fields for a patron\'s account, when registering via the OPAC.','free'), ('PatronSelfRegistrationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when registering a new patron via the OPAC.','free'), ('PatronSelfRegistrationConfirmEmail', '0', NULL, 'Require users to confirm their email address by entering it twice.', 'YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 96431944a9..12f44a0e89 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -887,6 +887,12 @@ OPAC: - '
If you chooose EmailAddressForPatronRegistrations you have to enter a valid email address: ' - pref: EmailAddressForPatronRegistrations class: email + - + - pref: PatronSelfRegistrationAlert + choices: + 0: "Don't show" + 1: "Show" + - an alert on staff interface home page when there are patrons in the category defined by PatronSelfRegistrationDefaultCategory. Suggestions: - - pref: OpacSuggestionManagedBy diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index c32de6ab9b..7fe7d68754 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -180,7 +180,7 @@
[%# Following statement must be in one line for translatability %] - [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && ( pendingsuggestions || all_pendingsuggestions )) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( ( Koha.Preference('OpacCatalogConcerns') || Koha.Preference('CatalogConcerns') ) && pending_biblio_tickets && CAN_user_editcatalogue_edit_catalogue ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs || new_curbside_pickups.count || ( holds_with_cancellation_requests && CAN_user_circulate_circulate_remaining_permissions ) %] + [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && ( pendingsuggestions || all_pendingsuggestions )) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( ( Koha.Preference('OpacCatalogConcerns') || Koha.Preference('CatalogConcerns') ) && pending_biblio_tickets && CAN_user_editcatalogue_edit_catalogue ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs || new_curbside_pickups.count || ( holds_with_cancellation_requests && CAN_user_circulate_circulate_remaining_permissions ) || selfRegisteredPatrons %]
[% IF pending_article_requests %]
@@ -275,6 +275,19 @@ [% holds_with_cancellation_requests | html %]
[% END %] + + [% IF self_registered_count %] +
+ Self-registrations from: + All libraries: [% self_registered_count | html %] + + [% IF self_registered_mybranch_count %] + / + [% Branches.GetLoggedInBranchname | html %]: [% self_registered_mybranch_count | html %] + [% END %] +
+ [% END %] +
[% END %] diff --git a/mainpage.pl b/mainpage.pl index d84408538e..2b78894aaa 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -138,6 +138,18 @@ if ( C4::Context->preference('CurbsidePickup') ) { ); } +if ( C4::Context->preference('PatronSelfRegistrationAlert') ) { + my $categorycode = C4::Context->preference('PatronSelfRegistrationDefaultCategory'); + my $branchcode = C4::Context::mybranch(); + + my $rs = Koha::Patrons->search( { categorycode => $categorycode } ); + + $template->param( + self_registered_count => $rs->count, + self_registered_mybranch_count => $rs->search( { branchcode => $branchcode } )->count, + ); +} + $template->param( pendingcomments => $pendingcomments, pendingtags => $pendingtags, diff --git a/members/member.pl b/members/member.pl index 400bdf6822..42b41c0285 100755 --- a/members/member.pl +++ b/members/member.pl @@ -64,16 +64,23 @@ if ( $quicksearch and $searchmember && !$circsearch ) { } } -my $searchfieldstype = $input->param('searchfieldstype') || 'standard'; -my $searchtype = $input->param('searchtype'); +my $searchfieldstype = $input->param('searchfieldstype') || 'standard'; +my $searchtype = $input->param('searchtype'); +my $branchcode_filter = $input->param('branchcode_filter') // ''; +my $categorycode_filter = $input->param('categorycode_filter') // ''; $template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ); +my $defer_loading = $input->request_method() eq "GET" && !$circsearch ? 1 : 0; +if ($branchcode_filter ne '' || $categorycode_filter ne '') { + $defer_loading = 0; +} + $template->param( patron_lists => [ GetPatronLists() ], searchmember => $searchmember, - branchcode_filter => scalar $input->param('branchcode_filter'), - categorycode_filter => scalar $input->param('categorycode_filter'), + branchcode_filter => $branchcode_filter, + categorycode_filter => $categorycode_filter, searchtype => $searchtype, searchfieldstype => $searchfieldstype, PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20, -- 2.39.2