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 (+283 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 $help;
56
my $outfile;
57
58
# maps to convert I-tiva terms to Koha terms
59
my $type_module_map = { 'PREOVERDUE'  => 'circulation',
60
                        'OVERDUE' => 'circulation',
61
                        'RESERVE'    => 'reserves',
62
                      };
63
64
my $type_notice_map = { 'PREOVERDUE'  => 'PREDUE_PHONE',
65
                        'OVERDUE' => 'OVERDUE_PHONE',
66
                        'RESERVE'    => 'HOLD_PHONE',
67
                      };
68
69
GetOptions(
70
  'o|output:s' => \$outfile,
71
  'v' => \$verbose,
72
  'lang:s' => \$language,
73
  'type:s' => \@types,
74
  'w|waiting-hold-day:s' => \@holds_waiting_days_to_call,
75
  'help|h'   => \$help,
76
);
77
78
$language = uc($language);
79
80
pod2usage( -verbose => 1 ) if $help;
81
82
# output log or STDOUT
83
if (defined $outfile) {
84
   open (OUT, ">$outfile") || die ("Cannot open output file");
85
} else {
86
   print "No output file defined; printing to STDOUT\n" if (defined $verbose);
87
   open(OUT, ">&STDOUT") || die ("Couldn't duplicate STDOUT: $!");
88
}
89
90
my $format = 'V'; # format for phone notifications
91
92
foreach my $type (@types) {
93
   $type = uc($type); #just in case lower or mixed-case was supplied
94
   my $module = $type_module_map->{$type}; #since the module is required to get the letter
95
   my $code = $type_notice_map->{$type}; #to get the Koha name of the notice
96
97
   my @loop;
98
   if ($type eq 'OVERDUE') {
99
     @loop = GetOverdueIssues();
100
   } elsif ($type eq 'PREOVERDUE') {
101
     @loop = GetPredueIssues();
102
   } elsif ($type eq 'RESERVE') {
103
     @loop = GetWaitingHolds();
104
   } else {
105
      print "Unknown or unsupported message type $type; skipping...\n" if (defined $verbose);
106
      next;
107
   }
108
109
   foreach my $issues (@loop) {
110
      my $date = C4::Dates->new($issues->{'date_due'}, 'iso');
111
      my $due_date = $date->output('metric');
112
113
      # gets the placeholder message, and enqueues the letter
114
      my $letter = getletter($module, $code);
115
      die "No letter found for type $type!... dying\n" unless $letter;
116
      # covers basic variable parsing in letter
117
      $letter = C4::Letters::parseletter($letter, 'borrowers', $issues->{'borrowernumber'});
118
      $letter = C4::Letters::parseletter($letter, 'biblio', $issues->{'biblionumber'});
119
      $letter = C4::Letters::parseletter($letter, 'biblioitems', $issues->{'biblionumber'});
120
121
      my $message_id = 0;
122
      if ($outfile) {
123
         $message_id = C4::Letters::EnqueueLetter( {  letter => $letter,
124
                                                      borrowernumber => $issues->{'borrowernumber'},
125
                                                      message_transport_type => 'phone',
126
                                                   });
127
      }
128
         
129
      print OUT "\"$format\",\"$language\",\"$type\",\"$issues->{level}\",\"$issues->{cardnumber}\",\"$issues->{patron_title}\",\"$issues->{firstname}\",";
130
      print OUT "\"$issues->{surname}\",\"$issues->{phone}\",\"$issues->{email}\",\"$issues->{branchcode}\",";
131
      print OUT "\"$issues->{site}\",\"$issues->{site_name}\",\"$issues->{barcode}\",\"$due_date\",\"$issues->{title}\",\"$message_id\"\n";
132
   }
133
}
134
135
136
=head1 NAME
137
138
TalkingTech_itiva_outbound.pl
139
140
=head1 SYNOPSIS
141
142
  TalkingTech_itiva_outbound.pl
143
  TalkingTech_itiva_outbound.pl --type=OVERDUE -w 0 -w 2 -w 6 --output=/tmp/talkingtech/outbound.csv
144
  TalkingTech_itiva_outbound.pl --type=RESERVE --type=PREOVERDUE --lang=FR
145
146
147
Script to generate Spec C outbound notifications file for Talking Tech i-tiva
148
phone notification system.
149
150
=item B<--help> B<-h>
151
152
Prints this help
153
154
=item B<-v>
155
156
Provide verbose log information.
157
158
=item B<--output> B<-o>
159
160
Destination for outbound notifications file (CSV format).  If no value is specified,
161
output is dumped to screen.
162
163
=item B<--lang>
164
165
Sets the language for all outbound messages.  Currently supported values are EN, FR and ES.
166
If no value is specified, EN will be used by default.
167
168
=item B<--type>
169
170
REQUIRED. Sets which messaging types are to be used.  Can be given multiple times, to 
171
specify multiple types in a single output file.  Currently supported values are RESERVE, PREOVERDUE
172
and OVERDUE.  If no value is given, this script will not produce any outbound notifications.
173
174
=item B<--waiting-hold-day> B<-w>
175
176
OPTIONAL for --type=RESERVE. Sets the days after a hold has been set to waiting on which to call. Use
177
switch as many times as desired. For example, passing "-w 0 -w 2 -w 6" will cause calls to be placed
178
on the day the hold was set to waiting, 2 days after the waiting date, and 6 days after. See example above.
179
If this switch is not used with --type=RESERVE, calls will be placed every day until the waiting reserve
180
is picked up or canceled.
181
182
=cut
183
184
sub GetOverdueIssues {
185
   my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname,
186
                borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due,
187
                max(overduerules.branchcode) as rulebranch, TO_DAYS(NOW())-TO_DAYS(date_due) as daysoverdue, delay1, delay2, delay3,
188
                issues.branchcode as site, branches.branchname as site_name
189
                FROM borrowers JOIN issues USING (borrowernumber)
190
                JOIN items USING (itemnumber)
191
                JOIN biblio USING (biblionumber)
192
                JOIN branches ON (issues.branchcode = branches.branchcode)
193
                JOIN overduerules USING (categorycode)
194
                WHERE ( overduerules.branchcode = borrowers.branchcode or overduerules.branchcode = '')
195
                AND ( (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay1
196
                  OR  (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay2
197
                  OR  (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay3 )
198
                GROUP BY items.itemnumber
199
                ";
200
   my $sth = $dbh->prepare($query);
201
   $sth->execute();
202
   my @results;
203
   while( my $issue = $sth->fetchrow_hashref() ) {
204
      if ( $issue->{'daysoverdue'} == $issue->{'delay1'} ) {
205
         $issue->{'level'} = 1;
206
      } elsif ( $issue->{'daysoverdue'} == $issue->{'delay2'} ) {
207
         $issue->{'level'} = 2;
208
      } elsif ( $issue->{'daysoverdue'} == $issue->{'delay3'} ) {
209
         $issue->{'level'} = 3;
210
      } else { 
211
      # this shouldn't ever happen, based our SQL criteria
212
      }
213
      push @results, $issue;
214
   }
215
   return @results;
216
}
217
218
sub GetPredueIssues {
219
   my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname,
220
                borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due,
221
                issues.branchcode as site, branches.branchname as site_name
222
                FROM borrowers JOIN issues USING (borrowernumber)
223
                JOIN items USING (itemnumber)
224
                JOIN biblio USING (biblionumber)
225
                JOIN branches ON (issues.branchcode = branches.branchcode)
226
                JOIN borrower_message_preferences USING (borrowernumber)
227
                JOIN borrower_message_transport_preferences USING (borrower_message_preference_id)
228
                JOIN message_attributes USING (message_attribute_id)
229
                WHERE ( TO_DAYS( date_due ) - TO_DAYS( NOW() ) ) = days_in_advance
230
                AND message_transport_type = 'phone'
231
                AND message_name = 'Advance_Notice'
232
                ";
233
   my $sth = $dbh->prepare($query);
234
   $sth->execute();
235
   my @results;
236
   while( my $issue = $sth->fetchrow_hashref() ) {
237
      $issue->{'level'} = 1; # only one level for Predue notifications
238
      push @results, $issue;
239
   }
240
   return @results;
241
}
242
243
sub GetWaitingHolds {
244
   my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname,
245
                borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, reserves.waitingdate,
246
                reserves.branchcode AS site, branches.branchname AS site_name,
247
                TO_DAYS(NOW())-TO_DAYS(reserves.waitingdate) AS days_since_waiting
248
                FROM borrowers JOIN reserves USING (borrowernumber)
249
                JOIN items USING (itemnumber)
250
                JOIN biblio ON (biblio.biblionumber = items.biblionumber)
251
                JOIN branches ON (reserves.branchcode = branches.branchcode)
252
                JOIN borrower_message_preferences USING (borrowernumber)
253
                JOIN borrower_message_transport_preferences USING (borrower_message_preference_id)
254
                JOIN message_attributes USING (message_attribute_id)
255
                WHERE ( reserves.found = 'W' )
256
                AND message_transport_type = 'phone'
257
                AND message_name = 'Hold_Filled'
258
                ";
259
   my $pickupdelay = C4::Context->preference("ReservesMaxPickUpDelay");
260
   my $sth = $dbh->prepare($query);
261
   $sth->execute();
262
   my @results;
263
   while( my $issue = $sth->fetchrow_hashref() ) {
264
      my @waitingdate = split( /-/, $issue->{'waitingdate'} );
265
      my @date_due = Add_Delta_Days( $waitingdate[0], $waitingdate[1], $waitingdate[2], $pickupdelay );
266
      $issue->{'date_due'} = sprintf( "%04d-%02d-%02d", $date_due[0], $date_due[1], $date_due[2] );
267
      $issue->{'level'} = 1; # only one level for Hold Waiting notifications
268
269
      my $days_to_subtract = 0;
270
      my $calendar = C4::Calendar->new( branchcode => $issue->{'site'} );
271
      while( $calendar->isHoliday( reverse( Add_Delta_Days( $waitingdate[0], $waitingdate[1], $waitingdate[2], $days_to_subtract ) ) ) ) {
272
        $days_to_subtract++;
273
      }
274
      $issue->{'days_since_waiting'} = $issue->{'days_since_waiting'} - $days_to_subtract;
275
      
276
      if ( ( grep $_ eq $issue->{'days_since_waiting'}, @holds_waiting_days_to_call ) || !scalar( @holds_waiting_days_to_call ) ) {
277
          push @results, $issue;
278
      }
279
   }
280
   return @results;
281
282
283
}
(-)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