View | Details | Raw Unified | Return to bug 4246
Collapse All | Expand All

(-)a/C4/Letters.pm (-2 / +2 lines)
Lines 523-529 places a letter in the message_queue database table, which will Link Here
523
eventually get processed (sent) by the process_message_queue.pl
523
eventually get processed (sent) by the process_message_queue.pl
524
cronjob when it calls SendQueuedMessages.
524
cronjob when it calls SendQueuedMessages.
525
525
526
return true on success
526
return message_id on success
527
527
528
=cut
528
=cut
529
529
Lines 565-571 ENDSQL Link Here
565
        $params->{'from_address'},                # from_address
565
        $params->{'from_address'},                # from_address
566
        $params->{'letter'}->{'content-type'},    # content_type
566
        $params->{'letter'}->{'content-type'},    # content_type
567
    );
567
    );
568
    return $result;
568
    return $dbh->last_insert_id(undef,undef,'message_queue', undef);
569
}
569
}
570
570
571
=head2 SendQueuedMessages ([$hashref]) 
571
=head2 SendQueuedMessages ([$hashref]) 
(-)a/admin/categorie.pl (-1 / +2 lines)
Lines 112-119 if ($op eq 'add_form') { Link Here
112
                                hidelostitems           => $data->{'hidelostitems'},
112
                                hidelostitems           => $data->{'hidelostitems'},
113
				category_type           => $data->{'category_type'},
113
				category_type           => $data->{'category_type'},
114
				DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
114
				DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
115
				SMSSendDriver => C4::Context->preference("SMSSendDriver"),
116
				TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"),
115
				"type_".$data->{'category_type'} => 1,
117
				"type_".$data->{'category_type'} => 1,
116
				SMSSendDriver => C4::Context->preference("SMSSendDriver")
117
				);
118
				);
118
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
119
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
119
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
120
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
(-)a/installer/data/mysql/atomicupdate/Bug-4246-Talking-Tech-itiva-phone-notifications.pl (+27 lines)
Line 0 Link Here
1
#! /usr/bin/perl
2
use strict;
3
use warnings;
4
use C4::Context;
5
my $dbh = C4::Context->dbh;
6
7
# add phone message transport type
8
$dbh->do("INSERT INTO message_transport_types (message_transport_type) VALUES ('phone')");
9
10
# adds HOLD_PHONE and PREDUE_PHONE letters (as placeholders)
11
$dbh->do("INSERT INTO letter (module, code, name, title, content) VALUES
12
          ('reserves', 'HOLD_PHONE', 'Item Available for Pick-up (phone notice)', 'Item Available for Pick-up (phone notice)', 'Your item is available for pickup'),
13
          ('circulation', 'PREDUE_PHONE', 'Advance Notice of Item Due (phone notice)', 'Advance Notice of Item Due (phone notice)', 'Your item is due soon'),
14
          ('circulation', 'OVERDUE_PHONE', 'Overdue Notice (phone notice)', 'Overdue Notice (phone notice)', 'Your item is overdue')
15
          ");
16
17
# add phone notifications to patron message preferences options
18
$dbh->do("INSERT INTO message_transports
19
         (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES
20
         (4, 'phone', 0, 'reserves', 'HOLD_PHONE'),
21
         (2, 'phone', 0, 'circulation', 'PREDUE_PHONE')
22
         ");
23
24
# add TalkingTechItivaPhoneNotification syspref
25
$dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('TalkingTechItivaPhoneNotification',0,'If ON, enables Talking Tech I-tiva phone notifications',NULL,'YesNo');");
26
27
print "Upgrade done (Support for Talking Tech i-tiva phone notification system)\n";
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc (+29 lines)
Lines 21-26 Link Here
21
    <tr><th></th>
21
    <tr><th></th>
22
        <th>Days in advance</th>
22
        <th>Days in advance</th>
23
        [% IF ( SMSSendDriver ) %]<th>SMS</th>[% END %]
23
        [% IF ( SMSSendDriver ) %]<th>SMS</th>[% END %]
24
        [% IF ( TalkingTechItivaPhone ) %]<th>Phone</th>[% END %]
24
        <th>Email</th><th>Digests only?</th>
25
        <th>Email</th><th>Digests only?</th>
25
        <!-- <th>RSS</th> -->
26
        <!-- <th>RSS</th> -->
26
        [% UNLESS ( messaging_form_inactive ) %]<th>Do not notify</th>[% END %]
27
        [% UNLESS ( messaging_form_inactive ) %]<th>Do not notify</th>[% END %]
Lines 83-88 Link Here
83
      <td>-</td>
84
      <td>-</td>
84
      [% END %]
85
      [% END %]
85
86
87
      [% IF ( TalkingTechItivaPhone ) %]<td>
88
          [% IF ( messaging_form_inactive ) %]
89
              [% IF ( messaging_preference.transports_phone ) %]
90
                 <input type="checkbox"
91
                 id="phone[% messaging_preference.message_attribute_id %]"
92
                 name="[% messaging_preference.message_attribute_id %]"
93
                 value="phone" checked="checked" disabled="disabled" />
94
              [% ELSE %]
95
                 <input type="checkbox"
96
                 id="phone[% messaging_preference.message_attribute_id %]"
97
                 name="[% messaging_preference.message_attribute_id %]"
98
                 value="phone" disabled="disabled" />
99
              [% END %]
100
          [% ELSE %]
101
              [% IF ( messaging_preference.transports_phone ) %]
102
                 <input type="checkbox"
103
                 id="phone[% messaging_preference.message_attribute_id %]"
104
                 name="[% messaging_preference.message_attribute_id %]"
105
                 value="phone" checked="checked" onclick = "$('#none'+'[% messaging_preference.message_attribute_id %]').attr('checked','');" />
106
              [% ELSE %]
107
                 <input type="checkbox"
108
                 id="phone[% messaging_preference.message_attribute_id %]"
109
                 name="[% messaging_preference.message_attribute_id %]"
110
                 value="phone" onclick = "$('#none'+'[% messaging_preference.message_attribute_id %]').attr('checked','');" />
111
              [% END %]
112
          [% END %]
113
      </td>[% END %]
114
86
      [% IF ( messaging_preference.transport_email ) %]
115
      [% IF ( messaging_preference.transport_email ) %]
87
      <td>
116
      <td>
88
          [% IF ( messaging_form_inactive ) %]
117
          [% IF ( messaging_form_inactive ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+6 lines)
Lines 120-122 Patrons: Link Here
120
           choices:
120
           choices:
121
               now: current date.
121
               now: current date.
122
               dateexpiry: current membership expiry date.
122
               dateexpiry: current membership expiry date.
123
     -
124
         - pref: TalkingTechItivaPhoneNotification
125
           choices: 
126
               yes: Enable
127
               no: Disable
128
         - patron phone notifications using Talking Tech i-tiva (overdues, predues and holds notices currently supported).
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-messaging.tt (-2 / +17 lines)
Lines 36-42 Link Here
36
  <div class="dialog message"><h3>Settings Updated</h3></div>
36
  <div class="dialog message"><h3>Settings Updated</h3></div>
37
  [% END %]
37
  [% END %]
38
  <table style="margin-right:1em;">
38
  <table style="margin-right:1em;">
39
    <tr><th>&nbsp;</th><th>Days in advance</th>[% IF ( SMSSendDriver ) %]<th>SMS</th>[% END %]<th>Email</th><th>Digests only?</th><!-- <th>RSS</th> --><th>Do not notify</th></tr>
39
    <tr><th>&nbsp;</th><th>Days in advance</th>[% IF ( SMSSendDriver ) %]<th>SMS</th>[% END %][% IF ( TalkingTechItivaPhone ) %]<th>Phone</th>[% END %]<th>Email</th><th>Digests only?</th><!-- <th>RSS</th> --><th>Do not notify</th></tr>
40
    [% FOREACH messaging_preference IN messaging_preferences %]
40
    [% FOREACH messaging_preference IN messaging_preferences %]
41
    <tr>
41
    <tr>
42
      <td>[% IF ( messaging_preference.Item_Due ) %]Item Due
42
      <td>[% IF ( messaging_preference.Item_Due ) %]Item Due
Lines 75-81 Link Here
75
        </td>
75
        </td>
76
        [% END %]
76
        [% END %]
77
      [% ELSE %]
77
      [% ELSE %]
78
        <td>-</td>
78
        <td>--</td>
79
      [% END %]
80
        [% IF ( TalkingTechItivaPhone ) %]
81
        <td>
82
          [% IF ( messaging_preference.transports_phone ) %]
83
          <input type="checkbox"
84
                     id="phone[% messaging_preference.message_attribute_id %]"
85
                     name="[% messaging_preference.message_attribute_id %]"
86
                     value="phone" checked="checked" onclick = "document.opacmessaging.none[% messaging_preference.message_attribute_id %].checked=false;" />
87
          [% ELSE %]
88
          <input type="checkbox"
89
                     id="phone[% messaging_preference.message_attribute_id %]"
90
                     name="[% messaging_preference.message_attribute_id %]"
91
                     value="phone" onclick = "document.opacmessaging.none[% messaging_preference.message_attribute_id %].checked=false;" />
92
          [% END %]
93
        </td>
79
      [% END %]
94
      [% END %]
80
95
81
      [% IF ( messaging_preference.transport_email ) %]
96
      [% IF ( messaging_preference.transport_email ) %]
(-)a/members/memberentry.pl (+1 lines)
Lines 677-682 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
677
    }
677
    }
678
    $template->param(SMSSendDriver => C4::Context->preference("SMSSendDriver"));
678
    $template->param(SMSSendDriver => C4::Context->preference("SMSSendDriver"));
679
    $template->param(SMSnumber     => defined $data{'smsalertnumber'} ? $data{'smsalertnumber'} : $data{'mobile'});
679
    $template->param(SMSnumber     => defined $data{'smsalertnumber'} ? $data{'smsalertnumber'} : $data{'mobile'});
680
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
680
}
681
}
681
682
682
$template->param( "showguarantor"  => ($category_type=~/A|I|S|X/) ? 0 : 1); # associate with step to know where you are
683
$template->param( "showguarantor"  => ($category_type=~/A|I|S|X/) ? 0 : 1); # associate with step to know where you are
(-)a/members/moremember.pl (+1 lines)
Lines 448-453 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
448
    $template->param(messaging_form_inactive => 1);
448
    $template->param(messaging_form_inactive => 1);
449
    $template->param(SMSSendDriver => C4::Context->preference("SMSSendDriver"));
449
    $template->param(SMSSendDriver => C4::Context->preference("SMSSendDriver"));
450
    $template->param(SMSnumber     => defined $data->{'smsalertnumber'} ? $data->{'smsalertnumber'} : $data->{'mobile'});
450
    $template->param(SMSnumber     => defined $data->{'smsalertnumber'} ? $data->{'smsalertnumber'} : $data->{'mobile'});
451
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
451
}
452
}
452
453
453
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
454
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
(-)a/misc/cronjobs/thirdparty/TalkingTech.README (+32 lines)
Line 0 Link Here
1
Installation and Setup instructions for Talking Tech I-tiva phone notification
2
=============================
3
4
Be sure you've run installer/data/mysql/atomicupdate/Bug-4246-Talking-Tech-itiva-phone-notifications.pl
5
to install the required data pack (new syspref, notice placeholders and messaging transport preferences)
6
7
To use, TalkingTechItivaPhoneNotification syspref must be turned on.
8
9
If you wish to process PREOVERDUE or RESERVES messages, you'll need the EnhancedMessagingPreferences 
10
system preference turned on, and patrons to have filled in a perference for receiving these notices by phone.
11
12
For OVERDUE messages, overdue notice triggers must be configured under Koha -> Tools -> Overdue Notice Triggers.
13
Either branch-specific triggers or the default level triggers may be used (script will select whichever is appropriate).
14
15
16
Sending Notices file to I-tiva:
17
=============================
18
19
1. Add the TalkingTech_itiva_outbound.pl script to your crontab 
20
2. Add an FTP/SFTP or other transport method to send the output file to the I-tiva server
21
3. If you wish, archive the sent notices file in another directory after sending
22
23
Run TalkingTech_itiva_outbound.pl --help for more information
24
25
26
Receiving Results file from I-tiva:
27
=============================
28
1. Add an FTP/SFTP or other transport method to send the Results file to a known directory on your Koha server
29
2. Add the TalkingTech_itiva_inbound.pl script to your crontab, aimed at that directory
30
3. If you wish, archive the results file in another directory after processing
31
32
Run TalkingTech_itiva_inbound.pl --help for more information
(-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_inbound.pl (+129 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
#
3
# Copyright (C) 2011 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
use warnings;
22
BEGIN {
23
    # find Koha's Perl modules
24
    # test carefully before changing this
25
    use FindBin;
26
    eval { require "$FindBin::Bin/../kohalib.pl" };
27
}
28
29
use Getopt::Long;
30
use Pod::Usage;
31
32
use C4::Context;
33
34
sub usage {
35
    pod2usage( -verbose => 2 );
36
    exit;
37
}
38
39
die "TalkingTechItivaPhoneNotification system preference not activated... dying\n" unless (C4::Context->preference("TalkingTechItivaPhoneNotification"));
40
41
# Database handle
42
my $dbh = C4::Context->dbh;
43
44
# Benchmarking
45
my $updated= 0;
46
my $total = 0;
47
48
# Options
49
my $verbose;
50
my $help;
51
my $infile;
52
53
GetOptions(
54
  'i|input:s' => \$infile,
55
  'v' => \$verbose,
56
  'help|h'   => \$help,
57
);
58
59
die pod2usage() if $help;
60
61
# initialize the input data, either file or query
62
if (defined $infile) {
63
   open(IN, $infile) || die ("Cannot open input file");
64
   print "Opening $infile\n" if (defined $verbose);
65
66
   while (<IN>) {
67
     # data should take to form "<Transaction ID>","<SUCCESS or FAIL>"
68
     s/["\n]//g; # strip quotes and newlines: they're unnecessary
69
     my @data = split(/,/);
70
     my $result = update_notice(@data);
71
     $updated += $result;
72
     $total++;
73
   }
74
} else {
75
    die pod2usage( -verbose => 1 );
76
}
77
78
print "$updated of $total results lines processed\n" if (defined $verbose);
79
80
81
=head1 NAME
82
83
TalkingTech_itiva_inbound.pl
84
85
=head1 SYNOPSIS
86
87
  TalkingTech_itiva_inbound.pl
88
  TalkingTech_itiva_inbound.pl -v --input=/tmp/talkingtech/results.csv
89
90
Script to process received Results files for Talking Tech i-tiva
91
phone notification system.
92
93
=over 8
94
95
=item B<--help> B<-h>
96
97
Prints this help
98
99
=item B<-v>
100
101
Provide verbose log information.
102
103
=item B<--input> B<-i>
104
105
REQUIRED. Path to incoming results file.
106
107
=back
108
109
=cut
110
111
sub update_notice {
112
   my $message_id = shift;
113
   my $status = shift;
114
115
   if ($status =~ m/SUCCESS/i) {
116
      $status = 'sent';
117
   } elsif ($status =~ m/FAIL/i) {
118
      $status = 'failed';
119
   } else {
120
      warn "unexpected status $status for message ID $message_id\n";
121
      return 0;
122
   }
123
124
   my $query = "UPDATE message_queue SET status = ? WHERE message_id = ? and status = 'pending'";
125
   my $sth = $dbh->prepare($query);
126
127
   my $result = $sth->execute($status,$message_id);
128
   return $result;
129
}
(-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl (+286 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
#
3
# Copyright (C) 2011 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
use warnings;
22
BEGIN {
23
    # find Koha's Perl modules
24
    # test carefully before changing this
25
    use FindBin;
26
    eval { require "$FindBin::Bin/../kohalib.pl" };
27
}
28
29
use Getopt::Long;
30
use Pod::Usage;
31
use Date::Calc qw(Add_Delta_Days);
32
33
use C4::Context;
34
use C4::Items;
35
use C4::Letters;
36
use C4::Overdues;
37
use C4::Dates;
38
use C4::Calendar;
39
40
sub usage {
41
    pod2usage( -verbose => 2 );
42
    exit;
43
}
44
45
die "TalkingTechItivaPhoneNotification system preference not activated... dying\n" unless (C4::Context->preference("TalkingTechItivaPhoneNotification"));
46
47
# Database handle
48
my $dbh = C4::Context->dbh;
49
50
# Options
51
my $verbose;
52
my $language = "EN";
53
my @types;
54
my @holds_waiting_days_to_call;
55
my $library_code;
56
my $help;
57
my $outfile;
58
59
# maps to convert I-tiva terms to Koha terms
60
my $type_module_map = { 'PREOVERDUE'  => 'circulation',
61
                        'OVERDUE' => 'circulation',
62
                        'RESERVE'    => 'reserves',
63
                      };
64
65
my $type_notice_map = { 'PREOVERDUE'  => 'PREDUE_PHONE',
66
                        'OVERDUE' => 'OVERDUE_PHONE',
67
                        'RESERVE'    => 'HOLD_PHONE',
68
                      };
69
70
GetOptions(
71
  'o|output:s' => \$outfile,
72
  'v' => \$verbose,
73
  'lang:s' => \$language,
74
  'type:s' => \@types,
75
  'w|waiting-hold-day:s' => \@holds_waiting_days_to_call,
76
  'c|code|library-code:s' => \$library_code,
77
  'help|h'   => \$help,
78
);
79
80
$language = uc($language);
81
$library_code ||= '';
82
83
pod2usage( -verbose => 1 ) if $help;
84
85
# output log or STDOUT
86
if (defined $outfile) {
87
   open (OUT, ">$outfile") || die ("Cannot open output file");
88
} else {
89
   print "No output file defined; printing to STDOUT\n" if (defined $verbose);
90
   open(OUT, ">&STDOUT") || die ("Couldn't duplicate STDOUT: $!");
91
}
92
93
my $format = 'V'; # format for phone notifications
94
95
foreach my $type (@types) {
96
   $type = uc($type); #just in case lower or mixed-case was supplied
97
   my $module = $type_module_map->{$type}; #since the module is required to get the letter
98
   my $code = $type_notice_map->{$type}; #to get the Koha name of the notice
99
100
   my @loop;
101
   if ($type eq 'OVERDUE') {
102
     @loop = GetOverdueIssues();
103
   } elsif ($type eq 'PREOVERDUE') {
104
     @loop = GetPredueIssues();
105
   } elsif ($type eq 'RESERVE') {
106
     @loop = GetWaitingHolds();
107
   } else {
108
      print "Unknown or unsupported message type $type; skipping...\n" if (defined $verbose);
109
      next;
110
   }
111
112
   foreach my $issues (@loop) {
113
      my $date = C4::Dates->new($issues->{'date_due'}, 'iso');
114
      my $due_date = $date->output('metric');
115
116
      # gets the placeholder message, and enqueues the letter
117
      my $letter = getletter($module, $code);
118
      die "No letter found for type $type!... dying\n" unless $letter;
119
      # covers basic variable parsing in letter
120
      $letter = C4::Letters::parseletter($letter, 'borrowers', $issues->{'borrowernumber'});
121
      $letter = C4::Letters::parseletter($letter, 'biblio', $issues->{'biblionumber'});
122
      $letter = C4::Letters::parseletter($letter, 'biblioitems', $issues->{'biblionumber'});
123
124
      my $message_id = 0;
125
      if ($outfile) {
126
         $message_id = C4::Letters::EnqueueLetter( {  letter => $letter,
127
                                                      borrowernumber => $issues->{'borrowernumber'},
128
                                                      message_transport_type => 'phone',
129
                                                   });
130
      }
131
         
132
      print OUT "\"$format\",\"$language\",\"$type\",\"$issues->{level}\",\"$issues->{cardnumber}\",\"$issues->{patron_title}\",\"$issues->{firstname}\",";
133
      print OUT "\"$issues->{surname}\",\"$issues->{phone}\",\"$issues->{email}\",\"$library_code\",";
134
      print OUT "\"$issues->{site}\",\"$issues->{site_name}\",\"$issues->{barcode}\",\"$due_date\",\"$issues->{title}\",\"$message_id\"\n";
135
   }
136
}
137
138
139
=head1 NAME
140
141
TalkingTech_itiva_outbound.pl
142
143
=head1 SYNOPSIS
144
145
  TalkingTech_itiva_outbound.pl
146
  TalkingTech_itiva_outbound.pl --type=OVERDUE -w 0 -w 2 -w 6 --output=/tmp/talkingtech/outbound.csv
147
  TalkingTech_itiva_outbound.pl --type=RESERVE --type=PREOVERDUE --lang=FR
148
149
150
Script to generate Spec C outbound notifications file for Talking Tech i-tiva
151
phone notification system.
152
153
=item B<--help> B<-h>
154
155
Prints this help
156
157
=item B<-v>
158
159
Provide verbose log information.
160
161
=item B<--output> B<-o>
162
163
Destination for outbound notifications file (CSV format).  If no value is specified,
164
output is dumped to screen.
165
166
=item B<--lang>
167
168
Sets the language for all outbound messages.  Currently supported values are EN, FR and ES.
169
If no value is specified, EN will be used by default.
170
171
=item B<--type>
172
173
REQUIRED. Sets which messaging types are to be used.  Can be given multiple times, to 
174
specify multiple types in a single output file.  Currently supported values are RESERVE, PREOVERDUE
175
and OVERDUE.  If no value is given, this script will not produce any outbound notifications.
176
177
=item B<--waiting-hold-day> B<-w>
178
179
OPTIONAL for --type=RESERVE. Sets the days after a hold has been set to waiting on which to call. Use
180
switch as many times as desired. For example, passing "-w 0 -w 2 -w 6" will cause calls to be placed
181
on the day the hold was set to waiting, 2 days after the waiting date, and 6 days after. See example above.
182
If this switch is not used with --type=RESERVE, calls will be placed every day until the waiting reserve
183
is picked up or canceled.
184
185
=cut
186
187
sub GetOverdueIssues {
188
   my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname,
189
                borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due,
190
                max(overduerules.branchcode) as rulebranch, TO_DAYS(NOW())-TO_DAYS(date_due) as daysoverdue, delay1, delay2, delay3,
191
                issues.branchcode as site, branches.branchname as site_name
192
                FROM borrowers JOIN issues USING (borrowernumber)
193
                JOIN items USING (itemnumber)
194
                JOIN biblio USING (biblionumber)
195
                JOIN branches ON (issues.branchcode = branches.branchcode)
196
                JOIN overduerules USING (categorycode)
197
                WHERE ( overduerules.branchcode = borrowers.branchcode or overduerules.branchcode = '')
198
                AND ( (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay1
199
                  OR  (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay2
200
                  OR  (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay3 )
201
                GROUP BY items.itemnumber
202
                ";
203
   my $sth = $dbh->prepare($query);
204
   $sth->execute();
205
   my @results;
206
   while( my $issue = $sth->fetchrow_hashref() ) {
207
      if ( $issue->{'daysoverdue'} == $issue->{'delay1'} ) {
208
         $issue->{'level'} = 1;
209
      } elsif ( $issue->{'daysoverdue'} == $issue->{'delay2'} ) {
210
         $issue->{'level'} = 2;
211
      } elsif ( $issue->{'daysoverdue'} == $issue->{'delay3'} ) {
212
         $issue->{'level'} = 3;
213
      } else { 
214
      # this shouldn't ever happen, based our SQL criteria
215
      }
216
      push @results, $issue;
217
   }
218
   return @results;
219
}
220
221
sub GetPredueIssues {
222
   my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname,
223
                borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due,
224
                issues.branchcode as site, branches.branchname as site_name
225
                FROM borrowers JOIN issues USING (borrowernumber)
226
                JOIN items USING (itemnumber)
227
                JOIN biblio USING (biblionumber)
228
                JOIN branches ON (issues.branchcode = branches.branchcode)
229
                JOIN borrower_message_preferences USING (borrowernumber)
230
                JOIN borrower_message_transport_preferences USING (borrower_message_preference_id)
231
                JOIN message_attributes USING (message_attribute_id)
232
                WHERE ( TO_DAYS( date_due ) - TO_DAYS( NOW() ) ) = days_in_advance
233
                AND message_transport_type = 'phone'
234
                AND message_name = 'Advance_Notice'
235
                ";
236
   my $sth = $dbh->prepare($query);
237
   $sth->execute();
238
   my @results;
239
   while( my $issue = $sth->fetchrow_hashref() ) {
240
      $issue->{'level'} = 1; # only one level for Predue notifications
241
      push @results, $issue;
242
   }
243
   return @results;
244
}
245
246
sub GetWaitingHolds {
247
   my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname,
248
                borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, reserves.waitingdate,
249
                reserves.branchcode AS site, branches.branchname AS site_name,
250
                TO_DAYS(NOW())-TO_DAYS(reserves.waitingdate) AS days_since_waiting
251
                FROM borrowers JOIN reserves USING (borrowernumber)
252
                JOIN items USING (itemnumber)
253
                JOIN biblio ON (biblio.biblionumber = items.biblionumber)
254
                JOIN branches ON (reserves.branchcode = branches.branchcode)
255
                JOIN borrower_message_preferences USING (borrowernumber)
256
                JOIN borrower_message_transport_preferences USING (borrower_message_preference_id)
257
                JOIN message_attributes USING (message_attribute_id)
258
                WHERE ( reserves.found = 'W' )
259
                AND message_transport_type = 'phone'
260
                AND message_name = 'Hold_Filled'
261
                ";
262
   my $pickupdelay = C4::Context->preference("ReservesMaxPickUpDelay");
263
   my $sth = $dbh->prepare($query);
264
   $sth->execute();
265
   my @results;
266
   while( my $issue = $sth->fetchrow_hashref() ) {
267
      my @waitingdate = split( /-/, $issue->{'waitingdate'} );
268
      my @date_due = Add_Delta_Days( $waitingdate[0], $waitingdate[1], $waitingdate[2], $pickupdelay );
269
      $issue->{'date_due'} = sprintf( "%04d-%02d-%02d", $date_due[0], $date_due[1], $date_due[2] );
270
      $issue->{'level'} = 1; # only one level for Hold Waiting notifications
271
272
      my $days_to_subtract = 0;
273
      my $calendar = C4::Calendar->new( branchcode => $issue->{'site'} );
274
      while( $calendar->isHoliday( reverse( Add_Delta_Days( $waitingdate[0], $waitingdate[1], $waitingdate[2], $days_to_subtract ) ) ) ) {
275
        $days_to_subtract++;
276
      }
277
      $issue->{'days_since_waiting'} = $issue->{'days_since_waiting'} - $days_to_subtract;
278
      
279
      if ( ( grep $_ eq $issue->{'days_since_waiting'}, @holds_waiting_days_to_call ) || !scalar( @holds_waiting_days_to_call ) ) {
280
          push @results, $issue;
281
      }
282
   }
283
   return @results;
284
285
286
}
(-)a/opac/opac-messaging.pl (-2 / +2 lines)
Lines 67-72 C4::Form::MessagingPreferences::set_form_values({ borrowernumber => $borrowe Link Here
67
$template->param( BORROWER_INFO         => [ $borrower ],
67
$template->param( BORROWER_INFO         => [ $borrower ],
68
                  messagingview         => 1,
68
                  messagingview         => 1,
69
                  SMSnumber => defined $borrower->{'smsalertnumber'} ? $borrower->{'smsalertnumber'} : $borrower->{'mobile'},
69
                  SMSnumber => defined $borrower->{'smsalertnumber'} ? $borrower->{'smsalertnumber'} : $borrower->{'mobile'},
70
                  SMSSendDriver                =>  C4::Context->preference("SMSSendDriver") );
70
                  SMSSendDriver                =>  C4::Context->preference("SMSSendDriver"),
71
                  TalkingTechItivaPhone        =>  C4::Context->preference("TalkingTechItivaPhoneNotification") );
71
72
72
output_html_with_http_headers $query, $cookie, $template->output;
73
output_html_with_http_headers $query, $cookie, $template->output;
73
- 

Return to bug 4246