From 17e78f85940050b62bd0645cff27a9a37877fdbf 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. Signed-off-by: Emily Lamancusa --- .../bootstrap/en/modules/opac-memberentry.tt | 34 ++++++++++++++++++- opac/opac-memberentry.pl | 10 +++++- 2 files changed, 42 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 89a9e841e0..99d3efe87a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -214,7 +214,7 @@
- [% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' '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' ] %] + [% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' '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' 'smsalertnumber' 'sms_provider_id' ] %] [% IF mandatory.defined( field ) %] [% SET required.$field = 'required' %] [% END %] @@ -902,7 +902,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 action == 'edit' || hidden.defined('password') %]
diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index d18e5f542b..7ded651ff8 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::Token; use Koha::AuthorisedValues; +use Koha::SMS::Providers; my $cgi = CGI->new; my $dbh = C4::Context->dbh; @@ -98,6 +99,13 @@ if ( defined $min ) { my $defaultCategory = Koha::Patron::Categories->find(C4::Context->preference('PatronSelfRegistrationDefaultCategory')); +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( action => $action, hidden => GetHiddenFields( $mandatory, $action ), @@ -562,7 +570,7 @@ sub ParseCgiForBorrower { $borrower{gdpr_proc_consent} = dt_from_string if $borrower{gdpr_proc_consent} && $borrower{gdpr_proc_consent} eq 'agreed'; delete $borrower{$_} for qw/borrowernumber date_renewed debarred debarredcomment flags privacy privacy_guarantor_fines privacy_guarantor_checkouts checkprevcheckout updated_on lastseen lang login_attempts overdrive_auth_token anonymized/; # See also members/memberentry.pl - delete $borrower{$_} for qw/dateenrolled dateexpiry borrowernotes opacnote sort1 sort2 sms_provider_id autorenew_checkouts gonenoaddress lost relationship/; # On OPAC only + delete $borrower{$_} for 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{} ); return %borrower; -- 2.34.1