|
Lines 93-99
$template->param(LETTERLOOP => \@letterloop);
Link Here
|
| 93 |
|
93 |
|
| 94 |
=cut |
94 |
=cut |
| 95 |
|
95 |
|
| 96 |
sub GetLetters (;$) { |
96 |
sub GetLetters { |
| 97 |
|
97 |
|
| 98 |
# returns a reference to a hash of references to ALL letters... |
98 |
# returns a reference to a hash of references to ALL letters... |
| 99 |
my $cat = shift; |
99 |
my $cat = shift; |
|
Lines 117-123
sub GetLetters (;$) {
Link Here
|
| 117 |
} |
117 |
} |
| 118 |
|
118 |
|
| 119 |
my %letter; |
119 |
my %letter; |
| 120 |
sub getletter ($$$) { |
120 |
sub getletter { |
| 121 |
my ( $module, $code, $branchcode ) = @_; |
121 |
my ( $module, $code, $branchcode ) = @_; |
| 122 |
|
122 |
|
| 123 |
if (C4::Context->preference('IndependantBranches') && $branchcode){ |
123 |
if (C4::Context->preference('IndependantBranches') && $branchcode){ |
|
Lines 149-155
sub getletter ($$$) {
Link Here
|
| 149 |
|
149 |
|
| 150 |
=cut |
150 |
=cut |
| 151 |
|
151 |
|
| 152 |
sub addalert ($$$) { |
152 |
sub addalert { |
| 153 |
my ( $borrowernumber, $type, $externalid ) = @_; |
153 |
my ( $borrowernumber, $type, $externalid ) = @_; |
| 154 |
my $dbh = C4::Context->dbh; |
154 |
my $dbh = C4::Context->dbh; |
| 155 |
my $sth = |
155 |
my $sth = |
|
Lines 170-176
sub addalert ($$$) {
Link Here
|
| 170 |
|
170 |
|
| 171 |
=cut |
171 |
=cut |
| 172 |
|
172 |
|
| 173 |
sub delalert ($) { |
173 |
sub delalert { |
| 174 |
my $alertid = shift or die "delalert() called without valid argument (alertid)"; # it's gonna die anyway. |
174 |
my $alertid = shift or die "delalert() called without valid argument (alertid)"; # it's gonna die anyway. |
| 175 |
$debug and warn "delalert: deleting alertid $alertid"; |
175 |
$debug and warn "delalert: deleting alertid $alertid"; |
| 176 |
my $sth = C4::Context->dbh->prepare("delete from alert where alertid=?"); |
176 |
my $sth = C4::Context->dbh->prepare("delete from alert where alertid=?"); |
|
Lines 187-193
sub delalert ($) {
Link Here
|
| 187 |
|
187 |
|
| 188 |
=cut |
188 |
=cut |
| 189 |
|
189 |
|
| 190 |
sub getalert (;$$$) { |
190 |
sub getalert { |
| 191 |
my ( $borrowernumber, $type, $externalid ) = @_; |
191 |
my ( $borrowernumber, $type, $externalid ) = @_; |
| 192 |
my $dbh = C4::Context->dbh; |
192 |
my $dbh = C4::Context->dbh; |
| 193 |
my $query = "SELECT a.*, b.branchcode FROM alert a JOIN borrowers b USING(borrowernumber) WHERE"; |
193 |
my $query = "SELECT a.*, b.branchcode FROM alert a JOIN borrowers b USING(borrowernumber) WHERE"; |
|
Lines 224-239
sub getalert (;$$$) {
Link Here
|
| 224 |
# outmoded POD: |
224 |
# outmoded POD: |
| 225 |
# When type=virtual, the id is related to a virtual shelf and this sub returns the name of the sub |
225 |
# When type=virtual, the id is related to a virtual shelf and this sub returns the name of the sub |
| 226 |
|
226 |
|
| 227 |
sub findrelatedto ($$) { |
227 |
sub findrelatedto { |
| 228 |
my $type = shift or return undef; |
228 |
my $type = shift or return ; |
| 229 |
my $externalid = shift or return undef; |
229 |
my $externalid = shift or return ; |
| 230 |
my $q = ($type eq 'issue' ) ? |
230 |
my $q = ($type eq 'issue' ) ? |
| 231 |
"select title as result from subscription left join biblio on subscription.biblionumber=biblio.biblionumber where subscriptionid=?" : |
231 |
"select title as result from subscription left join biblio on subscription.biblionumber=biblio.biblionumber where subscriptionid=?" : |
| 232 |
($type eq 'borrower') ? |
232 |
($type eq 'borrower') ? |
| 233 |
"select concat(firstname,' ',surname) from borrowers where borrowernumber=?" : undef; |
233 |
"select concat(firstname,' ',surname) from borrowers where borrowernumber=?" : undef; |
| 234 |
unless ($q) { |
234 |
unless ($q) { |
| 235 |
warn "findrelatedto(): Illegal type '$type'"; |
235 |
warn "findrelatedto(): Illegal type '$type'"; |
| 236 |
return undef; |
236 |
return; |
| 237 |
} |
237 |
} |
| 238 |
my $sth = C4::Context->dbh->prepare($q); |
238 |
my $sth = C4::Context->dbh->prepare($q); |
| 239 |
$sth->execute($externalid); |
239 |
$sth->execute($externalid); |
|
Lines 665-676
return message_id on success
Link Here
|
| 665 |
|
665 |
|
| 666 |
=cut |
666 |
=cut |
| 667 |
|
667 |
|
| 668 |
sub EnqueueLetter ($) { |
668 |
sub EnqueueLetter { |
| 669 |
my $params = shift or return undef; |
669 |
my $params = shift or return; |
| 670 |
|
670 |
|
| 671 |
return unless exists $params->{'letter'}; |
671 |
return exists $params->{'letter'}; |
| 672 |
return unless exists $params->{'borrowernumber'}; |
672 |
return exists $params->{'borrowernumber'}; |
| 673 |
return unless exists $params->{'message_transport_type'}; |
673 |
return exists $params->{'message_transport_type'}; |
| 674 |
|
674 |
|
| 675 |
# If we have any attachments we should encode then into the body. |
675 |
# If we have any attachments we should encode then into the body. |
| 676 |
if ( $params->{'attachments'} ) { |
676 |
if ( $params->{'attachments'} ) { |
|
Lines 716-722
returns number of messages sent.
Link Here
|
| 716 |
|
716 |
|
| 717 |
=cut |
717 |
=cut |
| 718 |
|
718 |
|
| 719 |
sub SendQueuedMessages (;$) { |
719 |
sub SendQueuedMessages { |
| 720 |
my $params = shift; |
720 |
my $params = shift; |
| 721 |
|
721 |
|
| 722 |
my $unsent_messages = _get_unsent_messages(); |
722 |
my $unsent_messages = _get_unsent_messages(); |
|
Lines 861-867
sub _add_attachments {
Link Here
|
| 861 |
|
861 |
|
| 862 |
} |
862 |
} |
| 863 |
|
863 |
|
| 864 |
sub _get_unsent_messages (;$) { |
864 |
sub _get_unsent_messages { |
| 865 |
my $params = shift; |
865 |
my $params = shift; |
| 866 |
|
866 |
|
| 867 |
my $dbh = C4::Context->dbh(); |
867 |
my $dbh = C4::Context->dbh(); |
|
Lines 893-899
ENDSQL
Link Here
|
| 893 |
return $sth->fetchall_arrayref({}); |
893 |
return $sth->fetchall_arrayref({}); |
| 894 |
} |
894 |
} |
| 895 |
|
895 |
|
| 896 |
sub _send_message_by_email ($;$$$) { |
896 |
sub _send_message_by_email { |
| 897 |
my $message = shift or return; |
897 |
my $message = shift or return; |
| 898 |
my ($username, $password, $method) = @_; |
898 |
my ($username, $password, $method) = @_; |
| 899 |
|
899 |
|
|
Lines 975-982
$content
Link Here
|
| 975 |
EOS |
975 |
EOS |
| 976 |
} |
976 |
} |
| 977 |
|
977 |
|
| 978 |
sub _send_message_by_sms ($) { |
978 |
sub _send_message_by_sms { |
| 979 |
my $message = shift or return undef; |
979 |
my $message = shift or return; |
| 980 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
980 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
| 981 |
return unless $member->{'smsalertnumber'}; |
981 |
return unless $member->{'smsalertnumber'}; |
| 982 |
|
982 |
|
|
Lines 994-1004
sub _update_message_to_address {
Link Here
|
| 994 |
$dbh->do('UPDATE message_queue SET to_address=? WHERE message_id=?',undef,($to,$id)); |
994 |
$dbh->do('UPDATE message_queue SET to_address=? WHERE message_id=?',undef,($to,$id)); |
| 995 |
} |
995 |
} |
| 996 |
|
996 |
|
| 997 |
sub _set_message_status ($) { |
997 |
sub _set_message_status { |
| 998 |
my $params = shift or return undef; |
998 |
my $params = shift or return; |
| 999 |
|
999 |
|
| 1000 |
foreach my $required_parameter ( qw( message_id status ) ) { |
1000 |
foreach my $required_parameter ( qw( message_id status ) ) { |
| 1001 |
return undef unless exists $params->{ $required_parameter }; |
1001 |
return unless exists $params->{ $required_parameter }; |
| 1002 |
} |
1002 |
} |
| 1003 |
|
1003 |
|
| 1004 |
my $dbh = C4::Context->dbh(); |
1004 |
my $dbh = C4::Context->dbh(); |
| 1005 |
- |
|
|