From 660851b35f829b70dbd10c1bab0ef1714d605226 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 25 May 2023 14:39:18 +0000 Subject: [PATCH] Bug 20859: Add SMSalertnumber to OPAC registration page This patch adds the SMS number field to patron self registration. To test: 1. Apply patch. 2. Make sure an SMSSendDriver and some SMS cellular providers. 3. Go to the OPAC self registration form. 4. Notice the SMS Number and SMS provider fields now appear. 5. Use the PatronSelfRegistrationBorrowerMandatoryField and PatronSelfRegistrationBorrowerUnwantedField system preferences to ensure you can hide the fields and make them required. 6. Self register while adding a SMS number and SMS provider. Make sure that when you view the newly self-registered patron that the SMS number and SMS provider are properly populated in the staff interface. Rebased 2025-09-02 by Magnus Enger Signed-off-by: Emily Lamancusa Signed-off-by: Magnus Enger --- .../bootstrap/en/modules/opac-memberentry.tt | 35 ++++++++++++++++++- opac/opac-memberentry.pl | 10 +++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index b6621ad741..118edf3143 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -222,7 +222,7 @@
[% INCLUDE 'csrf-token.inc' %] - [% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'preferred_name' 'middle_name' 'dateofbirth' 'initials' 'pronouns' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_streetnumber' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' 'lang' ] %] + [% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'preferred_name' 'middle_name' 'dateofbirth' 'initials' 'pronouns' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_streetnumber' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' 'lang' 'smsalertnumber' 'sms_provider_id' ] %] [% IF mandatory.defined( field ) %] [% SET required.$field = 'required' %] [% END %] @@ -1169,6 +1169,39 @@ [% END %] + [% IF ( Koha.Preference('SMSSendDriver') ) && !hidden.defined('smsalertnumber') && !hidden.defined('sms_provider_id') && action != 'edit' %] +
+
+
+ SMS number +
    + [% UNLESS hidden.defined('smsalertnumber') %] +
  1. + + +
    Required
    + Please enter numbers only. Prefix the number with + or 00 if including the country code. +
  2. + [% END %] + [% UNLESS hidden.defined('sms_provider_id') %] +
  3. + + +
    Required
    + Please contact a library staff member if you are unsure of your mobile service provider, or you do not see your provider in this list. +
  4. + [% END %] +
+
+
+
+ [% END %] + [% UNLESS op == 'edit' || hidden.defined('password') %]
diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 14ec05e753..987123497d 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -45,6 +45,7 @@ use Koha::Patron::Images; use Koha::Patron::Categories; use Koha::Policy::Patrons::Cardnumber; use Koha::AuthorisedValues; +use Koha::SMS::Providers; my $cgi = CGI->new; my $dbh = C4::Context->dbh; @@ -102,6 +103,13 @@ if ( defined $min ) { my $translated_languages = C4::Languages::getTranslatedLanguages( 'opac', C4::Context->preference('opacthemes') ); +if( C4::Context->preference("SMSSendDriver") eq 'Email' ) { + my @providers = Koha::SMS::Providers->search( {}, { order_by => 'name' } )->as_list; + $template->param( + sms_providers => \@providers, + ); +} + $template->param( op => $op, hidden => GetHiddenFields( $mandatory, $op ), @@ -585,7 +593,7 @@ sub ParseCgiForBorrower { ; # See also members/memberentry.pl delete $borrower{$_} for - qw/dateenrolled dateexpiry borrowernotes opacnote sort1 sort2 sms_provider_id autorenew_checkouts gonenoaddress lost relationship/ + qw/dateenrolled dateexpiry borrowernotes opacnote sort1 sort2 autorenew_checkouts gonenoaddress lost relationship/ ; # On OPAC only delete $borrower{$_} for split( /\s*\|\s*/, C4::Context->preference('PatronSelfRegistrationBorrowerUnwantedField') || q{} ); -- 2.43.0