@@ -, +, @@ --- C4/Letters.pm | 11 ++++++++- C4/Members.pm | 6 ++++- admin/admin-home.pl | 5 +++- installer/data/mysql/kohastructure.sql | 18 +++++++++++++- installer/data/mysql/updatedatabase.pl | 18 ++++++++++++++ .../prog/en/modules/admin/admin-home.tt | 18 ++++++++++---- .../prog/en/modules/members/memberentrygen.tt | 13 ++++++++++ .../opac-tmpl/prog/en/modules/opac-messaging.tt | 25 +++++++++++++++++++- members/memberentry.pl | 7 +++++ opac/opac-messaging.pl | 9 ++++++- 10 files changed, 119 insertions(+), 11 deletions(-) --- a/C4/Letters.pm +++ a/C4/Letters.pm @@ -30,6 +30,7 @@ use C4::Log; use C4::SMS; use C4::Debug; use Koha::DateUtils; +use Koha::SMS::Provider; use Date::Calc qw( Add_Delta_Days ); use Encode; @@ -742,7 +743,14 @@ sub SendQueuedMessages { _send_message_by_email( $message, $params->{'username'}, $params->{'password'}, $params->{'method'} ); } elsif ( lc( $message->{'message_transport_type'} ) eq 'sms' ) { - _send_message_by_sms( $message ); + if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) { + my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); + my $sms_provider = Koha::SMS::Provider->find( $member->{'sms_provider_id'} ); + $message->{to_address} .= '@' . $sms_provider->domain(); + _send_message_by_email( $message, $params->{'username'}, $params->{'password'}, $params->{'method'} ); + } else { + _send_message_by_sms( $message ); + } } } return scalar( @$unsent_messages ); @@ -955,6 +963,7 @@ sub _send_message_by_email { } _update_message_to_address($message->{'message_id'},$to_address) unless $message->{to_address}; #if initial message address was empty, coming here means that a to address was found and queue should be updated + if ( sendmail( %sendmail_params ) ) { _set_message_status( { message_id => $message->{'message_id'}, status => 'sent' } ); --- a/C4/Members.pm +++ a/C4/Members.pm @@ -722,7 +722,11 @@ sub ModMember { $data{password} = md5_base64($data{password}); } } - my $execute_success=UpdateInTable("borrowers",\%data); + + $data{'sms_provider_id'} = undef unless ( $data{'sms_provider_id'} ); + + my $execute_success=UpdateInTable("borrowers",\%data); + if ($execute_success) { # only proceed if the update was a success # ok if its an adult (type) it may have borrowers that depend on it as a guarantor # so when we update information for an adult we should check for guarantees and update the relevant part --- a/admin/admin-home.pl +++ a/admin/admin-home.pl @@ -34,6 +34,9 @@ my ($template, $loggedinuser, $cookie) debug => 1, }); -$template->param( SearchEngine => C4::Context->preference('SearchEngine') ); +$template->param( + SearchEngine => C4::Context->preference('SearchEngine'), + SMSSendDriver => C4::Context->preference('SMSSendDriver'), +); output_html_with_http_headers $query, $cookie, $template->output; --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -262,6 +262,7 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons `altcontactcountry` text default NULL, -- the country for the alternate contact for the patron/borrower `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on) + `sms_provider_id` int(11) DEFAULT NULL, -- the provider of the mobile phone number defined in smsalertnumber `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history UNIQUE KEY `cardnumber` (`cardnumber`), PRIMARY KEY `borrowernumber` (`borrowernumber`), @@ -269,8 +270,10 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons KEY `branchcode` (`branchcode`), KEY `userid` (`userid`), KEY `guarantorid` (`guarantorid`), + KEY `sms_provider_id` (`sms_provider_id`) CONSTRAINT `borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`), - CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) + CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`), + CONSTRAINT `borrowers_ibfk_3` FOREIGN KEY (`sms_provider_id`) REFERENCES `sms_providers` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -1817,6 +1820,19 @@ CREATE TABLE sessions ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- +-- Table structure for table `sms_providers` +-- + +DROP TABLE IF EXISTS sms_providers; +CREATE TABLE `sms_providers` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `domain` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -- Table structure for table `special_holidays` -- --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -6437,6 +6437,24 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.11.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do(" + CREATE TABLE sms_providers ( + id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , + name VARCHAR( 255 ) NOT NULL , + domain VARCHAR( 255 ) NOT NULL , + UNIQUE ( + name + ) + ) ENGINE = INNODB CHARACTER SET utf8; + "); + $dbh->do("ALTER TABLE borrowers ADD sms_provider_id INT( 11 ) NULL DEFAULT NULL AFTER smsalertnumber, ADD INDEX ( sms_provider_id )"); + $dbh->do("ALTER TABLE borrowers ADD FOREIGN KEY ( sms_provider_id ) REFERENCES sms_providers ( id )"); + + print "Upgrade to $DBversion done (Add SMS via Email feature)\n"; + SetVersion ($DBversion); +} =head1 FUNCTIONS --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt @@ -101,14 +101,22 @@

Additional parameters

- [% IF ( NoZebra ) %]
Stop words
-
Words ignored during search.
[% END %] - + [% IF ( NoZebra ) %]
Stop words
+
Words ignored during search.
+ [% END %] + +
Z39.50 client targets
-
Define which servers to query for MARC data in the integrated Z39.50 client.
+
Define which servers to query for MARC data in the integrated Z39.50 client.
+
Did you mean?
Choose which plugins to use to suggest searches to patrons and staff.
+ + [% IF SMSSendDriver == 'Email' %] +
SMS cellular providers
+
Define a list of cellular providers for sending SMS messages via email.
+ [% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1441,6 +1441,19 @@ [% END %]

+

+ + +

[% END %] [% END %] [% END %] --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-messaging.tt +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-messaging.tt @@ -143,8 +143,31 @@ [% END %] -[% IF ( SMSSendDriver ) %]
[% END %] + [% IF ( SMSSendDriver ) %] +
  1. Some charges for text messages may be incurred when using this service. Please check with your mobile service provider if you have questions.
+
  1. + + Please enter numbers only. (123) 456-7890 would be entered as 1234567890. +
+ [% END %] + + [% IF ( SMSSendDriver == 'Email' ) %] +
  1. + + + 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. +
+ [% END %]
--- a/members/memberentry.pl +++ a/members/memberentry.pl @@ -41,6 +41,7 @@ use C4::Log; use C4::Letters; use C4::Branch; # GetBranches use C4::Form::MessagingPreferences; +use Koha::SMS::Provider; use vars qw($debug); @@ -62,6 +63,12 @@ my ($template, $loggedinuser, $cookie) flagsrequired => {borrowers => 1}, debug => ($debug) ? 1 : 0, }); + +if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) { + my @providers = Koha::SMS::Provider->all(); + $template->param( sms_providers => \@providers ); +} + my $guarantorid = $input->param('guarantorid'); my $borrowernumber = $input->param('borrowernumber'); my $actionType = $input->param('actionType') || ''; --- a/opac/opac-messaging.pl +++ a/opac/opac-messaging.pl @@ -54,7 +54,9 @@ if ( defined $query->param('modify') && $query->param('modify') eq 'yes' ) { # If they've modified the SMS number, record it. if ( ( defined $query->param('SMSnumber') ) && ( $query->param('SMSnumber') ne $borrower->{'mobile'} ) ) { ModMember( borrowernumber => $borrowernumber, - smsalertnumber => $query->param('SMSnumber') ); + smsalertnumber => $query->param('SMSnumber'), + sms_provider_id => $query->param('sms_provider_id') + ); $borrower = GetMemberDetails( $borrowernumber ); } @@ -70,4 +72,9 @@ $template->param( BORROWER_INFO => [ $borrower ], SMSSendDriver => C4::Context->preference("SMSSendDriver"), TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification") ); +if ( C4::Context->preference("SMSSendDriver") eq 'Email' ) { + my @providers = Koha::SMS::Provider->all(); + $template->param( sms_providers => \@providers, sms_provider_id => $borrower->{'sms_provider_id'} ); +} + output_html_with_http_headers $query, $cookie, $template->output; --