Bug 33221

Summary: Send WELCOME notices by SMS
Product: Koha Reporter: Julian Maurice <julian.maurice>
Component: PatronsAssignee: Julian Maurice <julian.maurice>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: gmcharlt, kyle.m.hall, kyle, lucas
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 33221: Send WELCOME notices by sms too
Bug 33221: Send WELCOME notices by sms too
Bug 33221: Send WELCOME notices by sms too
Bug 33221: Send WELCOME notices by sms too
Bug 33221: Send WELCOME notices by sms too
Bug 33221: Send WELCOME notices by sms too
Bug 33221: Send WELCOME notices by sms too
Bug 33221: (QA follow-up) Tidy code
Bug 33221: (QA follow-up) Fix up unit tests

Description Julian Maurice 2023-03-14 07:08:13 UTC
WELCOME notices are sent only by email. This will make it possible to send them by sms too.
Comment 1 Julian Maurice 2023-03-14 07:10:23 UTC
Created attachment 148152 [details] [review]
Bug 33221: Send WELCOME notices by sms too

This affects patron creation from staff and OPAC interfaces, and also
when patrons are imported by misc/import_patrons.pl

Since it's not possible at the moment to provide an SMS number when
creating an account from OPAC, the changes at OPAC will only be useful
once that possibility is added (see bug 20859)

Test plan:
1. Enable system preference AutoEmailNewUser
2. Set system preference SMSSendDriver to 'Test'
3. Verify in "About" page that SMS::Send is installed
4. In "Notices and Slips" tool, edit the 'WELCOME' letter and verify
   that both email and sms parts are filled. Use a different title
   and body for the sms part
5. Create a new borrower with an email address and an SMS number
6. Verify in the "Notices" tab that two notices are pending, one for
   email, one for sms
7. Click on "Send welcome email" in the "More" menu
8. Verify that two new notices have been queued (like in step 6)
9. Create a 'borrowers.csv' file with the following content:

cardnumber,surname,categorycode,branchcode,email,smsalertnumber
foo,Foo,PT,CPL,foo@example.com,+33123456789

10. Import it with the following command

misc/import_patrons.pl -v -c -m cardnumber -f borrowers.csv --email-new

11. Verify that the patron has been imported and that two new notices
    have been queued (like in step 6)
12. Enable system preference PatronSelfRegistration and disable system
    preference PatronSelfRegistrationVerifyByEmail
13. Go to OPAC and register a new account with an email address
14. Verify that the email notice was queued
15. Enable PatronSelfRegistrationVerifyByEmail
16. Go to OPAC and register a new account with an email address. Go
    through the verification process
17. Verify that the email notice was queued

Sponsored-by: Médiathèque de Montauban
Comment 2 Lucas Gass (lukeg) 2023-03-15 19:01:11 UTC
There seems to be some errors in memberentry.pl and opac-memberentry.pl:

 FAIL	members/memberentry.pl
   FAIL	  valid
		Missing right curly or square bracket
		syntax error
		members/memberentry.pl had compilation errors.

 FAIL	opac/opac-memberentry.pl
   FAIL	  valid
		"my" variable $cgi masks earlier declaration in same statement
		"my" variable %borrower masks earlier declaration in same scope
		"my" variable @empty_mandatory_fields masks earlier declaration in same scope
		"my" variable $invalidformfields masks earlier declaration in same scope
		syntax error
		Can't redeclare "my" in "my"
		Type of arg 1 to List::MoreUtils::XS::any must be block or sub {} (not reference constructor)
		Type of arg 1 to List::MoreUtils::XS::any must be block or sub {} (not reference constructor)
		Type of arg 1 to List::MoreUtils::XS::any must be block or sub {} (not reference constructor)
		Missing right curly or square bracket
		opac/opac-memberentry.pl had compilation errors.

 FAIL	opac/opac-registration-verify.pl
   FAIL	  valid
		Missing right curly or square bracket
		syntax error
		opac/opac-registration-verify.pl had compilation errors.
Comment 3 Julian Maurice 2023-03-16 08:14:24 UTC
Created attachment 148251 [details] [review]
Bug 33221: Send WELCOME notices by sms too

This affects patron creation from staff and OPAC interfaces, and also
when patrons are imported by misc/import_patrons.pl

Since it's not possible at the moment to provide an SMS number when
creating an account from OPAC, the changes at OPAC will only be useful
once that possibility is added (see bug 20859)

Test plan:
1. Enable system preference AutoEmailNewUser
2. Set system preference SMSSendDriver to 'Test'
3. Verify in "About" page that SMS::Send is installed
4. In "Notices and Slips" tool, edit the 'WELCOME' letter and verify
   that both email and sms parts are filled. Use a different title
   and body for the sms part
5. Create a new borrower with an email address and an SMS number
6. Verify in the "Notices" tab that two notices are pending, one for
   email, one for sms
7. Click on "Send welcome email" in the "More" menu
8. Verify that two new notices have been queued (like in step 6)
9. Create a 'borrowers.csv' file with the following content:

cardnumber,surname,categorycode,branchcode,email,smsalertnumber
foo,Foo,PT,CPL,foo@example.com,+33123456789

10. Import it with the following command

misc/import_patrons.pl -v -c -m cardnumber -f borrowers.csv --email-new

11. Verify that the patron has been imported and that two new notices
    have been queued (like in step 6)
12. Enable system preference PatronSelfRegistration and disable system
    preference PatronSelfRegistrationVerifyByEmail
13. Go to OPAC and register a new account with an email address
14. Verify that the email notice was queued
15. Enable PatronSelfRegistrationVerifyByEmail
16. Go to OPAC and register a new account with an email address. Go
    through the verification process
17. Verify that the email notice was queued

Sponsored-by: Médiathèque de Montauban
Comment 4 Julian Maurice 2023-03-16 08:15:18 UTC
(In reply to Lucas Gass from comment #2)
> There seems to be some errors in memberentry.pl and opac-memberentry.pl:

Bad conflict resolution... Sorry for that.
All fixed in the latest patch.
Comment 5 Lucas Gass (lukeg) 2023-03-16 12:33:09 UTC
I am only able to get the SMS WELCOME notice to generate when I create a new patron in the staff interface. 

When using the 'Send WELCOME notice' button, or when I import a patron I am only seeing the email WELCOME notice.
Comment 6 Lucas Gass (lukeg) 2023-11-02 21:33:59 UTC
Looks like this one needs to be rebased.
Comment 7 Kyle M Hall (khall) 2024-09-19 11:24:48 UTC
Created attachment 171712 [details] [review]
Bug 33221: Send WELCOME notices by sms too

This affects patron creation from staff and OPAC interfaces, and also
when patrons are imported by misc/import_patrons.pl

Since it's not possible at the moment to provide an SMS number when
creating an account from OPAC, the changes at OPAC will only be useful
once that possibility is added (see bug 20859)

Test plan:
1. Enable system preference AutoEmailNewUser
2. Set system preference SMSSendDriver to 'Test'
3. Verify in "About" page that SMS::Send is installed
4. In "Notices and Slips" tool, edit the 'WELCOME' letter and verify
   that both email and sms parts are filled. Use a different title
   and body for the sms part
5. Create a new borrower with an email address and an SMS number
6. Verify in the "Notices" tab that two notices are pending, one for
   email, one for sms
7. Click on "Send welcome email" in the "More" menu
8. Verify that two new notices have been queued (like in step 6)
9. Create a 'borrowers.csv' file with the following content:

cardnumber,surname,categorycode,branchcode,email,smsalertnumber
foo,Foo,PT,CPL,foo@example.com,+33123456789

10. Import it with the following command

misc/import_patrons.pl -v -c -m cardnumber -f borrowers.csv --email-new

11. Verify that the patron has been imported and that two new notices
    have been queued (like in step 6)
12. Enable system preference PatronSelfRegistration and disable system
    preference PatronSelfRegistrationVerifyByEmail
13. Go to OPAC and register a new account with an email address
14. Verify that the email notice was queued
15. Enable PatronSelfRegistrationVerifyByEmail
16. Go to OPAC and register a new account with an email address. Go
    through the verification process
17. Verify that the email notice was queued

Sponsored-by: Médiathèque de Montauban
Comment 8 Sukhmandeep 2024-09-27 15:08:59 UTC Comment hidden (obsolete)
Comment 9 Sukhmandeep 2024-09-27 15:26:01 UTC
Created attachment 172126 [details] [review]
Bug 33221: Send WELCOME notices by sms too

This affects patron creation from staff and OPAC interfaces, and also
when patrons are imported by misc/import_patrons.pl

Since it's not possible at the moment to provide an SMS number when
creating an account from OPAC, the changes at OPAC will only be useful
once that possibility is added (see bug 20859)

Test plan:
1. Enable system preference AutoEmailNewUser
2. Set system preference SMSSendDriver to 'Test'
3. Verify in "About" page that SMS::Send is installed
4. In "Notices and Slips" tool, edit the 'WELCOME' letter and verify
   that both email and sms parts are filled. Use a different title
   and body for the sms part
5. Create a new borrower with an email address and an SMS number
6. Verify in the "Notices" tab that two notices are pending, one for
   email, one for sms
7. Click on "Send welcome email" in the "More" menu
8. Verify that two new notices have been queued (like in step 6)
9. Create a 'borrowers.csv' file with the following content:

cardnumber,surname,categorycode,branchcode,email,smsalertnumber
foo,Foo,PT,CPL,foo@example.com,+33123456789

10. Import it with the following command

misc/import_patrons.pl -v -c -m cardnumber -f borrowers.csv --email-new

11. Verify that the patron has been imported and that two new notices
    have been queued (like in step 6)
12. Enable system preference PatronSelfRegistration and disable system
    preference PatronSelfRegistrationVerifyByEmail
13. Go to OPAC and register a new account with an email address
14. Verify that the email notice was queued
15. Enable PatronSelfRegistrationVerifyByEmail
16. Go to OPAC and register a new account with an email address. Go
    through the verification process
17. Verify that the email notice was queued

Sponsored-by: Médiathèque de Montauban
Comment 10 Kyle M Hall (khall) 2024-10-03 11:26:40 UTC
Created attachment 172336 [details] [review]
Bug 33221: Send WELCOME notices by sms too

This affects patron creation from staff and OPAC interfaces, and also
when patrons are imported by misc/import_patrons.pl

Since it's not possible at the moment to provide an SMS number when
creating an account from OPAC, the changes at OPAC will only be useful
once that possibility is added (see bug 20859)

Test plan:
1. Enable system preference AutoEmailNewUser
2. Set system preference SMSSendDriver to 'Test'
3. Verify in "About" page that SMS::Send is installed
4. In "Notices and Slips" tool, edit the 'WELCOME' letter and verify
   that both email and sms parts are filled. Use a different title
   and body for the sms part
5. Create a new borrower with an email address and an SMS number
6. Verify in the "Notices" tab that two notices are pending, one for
   email, one for sms
7. Click on "Send welcome email" in the "More" menu
8. Verify that two new notices have been queued (like in step 6)
9. Create a 'borrowers.csv' file with the following content:

cardnumber,surname,categorycode,branchcode,email,smsalertnumber
foo,Foo,PT,CPL,foo@example.com,+33123456789

10. Import it with the following command

misc/import_patrons.pl -v -c -m cardnumber -f borrowers.csv --email-new

11. Verify that the patron has been imported and that two new notices
    have been queued (like in step 6)
12. Enable system preference PatronSelfRegistration and disable system
    preference PatronSelfRegistrationVerifyByEmail
13. Go to OPAC and register a new account with an email address
14. Verify that the email notice was queued
15. Enable PatronSelfRegistrationVerifyByEmail
16. Go to OPAC and register a new account with an email address. Go
    through the verification process
17. Verify that the email notice was queued

Sponsored-by: Médiathèque de Montauban
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 11 Kyle M Hall (khall) 2024-10-03 11:36:12 UTC
Created attachment 172337 [details] [review]
Bug 33221: Send WELCOME notices by sms too

This affects patron creation from staff and OPAC interfaces, and also
when patrons are imported by misc/import_patrons.pl

Since it's not possible at the moment to provide an SMS number when
creating an account from OPAC, the changes at OPAC will only be useful
once that possibility is added (see bug 20859)

Test plan:
1. Enable system preference AutoEmailNewUser
2. Set system preference SMSSendDriver to 'Test'
3. Verify in "About" page that SMS::Send is installed
4. In "Notices and Slips" tool, edit the 'WELCOME' letter and verify
   that both email and sms parts are filled. Use a different title
   and body for the sms part
5. Create a new borrower with an email address and an SMS number
6. Verify in the "Notices" tab that two notices are pending, one for
   email, one for sms
7. Click on "Send welcome email" in the "More" menu
8. Verify that two new notices have been queued (like in step 6)
9. Create a 'borrowers.csv' file with the following content:

cardnumber,surname,categorycode,branchcode,email,smsalertnumber
foo,Foo,PT,CPL,foo@example.com,+33123456789

10. Import it with the following command

misc/import_patrons.pl -v -c -m cardnumber -f borrowers.csv --email-new

11. Verify that the patron has been imported and that two new notices
    have been queued (like in step 6)
12. Enable system preference PatronSelfRegistration and disable system
    preference PatronSelfRegistrationVerifyByEmail
13. Go to OPAC and register a new account with an email address
14. Verify that the email notice was queued
15. Enable PatronSelfRegistrationVerifyByEmail
16. Go to OPAC and register a new account with an email address. Go
    through the verification process
17. Verify that the email notice was queued

Sponsored-by: Médiathèque de Montauban
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 12 Kyle M Hall (khall) 2024-10-03 11:36:19 UTC
Created attachment 172338 [details] [review]
Bug 33221: (QA follow-up) Tidy code

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 13 Kyle M Hall (khall) 2024-10-03 11:36:21 UTC
Created attachment 172339 [details] [review]
Bug 33221: (QA follow-up) Fix up unit tests

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 14 Kyle M Hall (khall) 2024-10-03 11:42:02 UTC
AutoEmailNewUser should be renamed to AutoMessageNewUser

SMS message sending could be decoupled so it does not require an email welcome notice in order to send the sms welcome notice.