3 # Copyright (C) 2011 ByWater Solutions
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use Getopt::Long qw( GetOptions );
24 use Pod::Usage qw( pod2usage );
26 use Koha::Script -cron;
30 pod2usage( -verbose => 2 );
35 "TalkingTechItivaPhoneNotification system preference not activated... dying\n"
36 unless ( C4::Context->preference("TalkingTechItivaPhoneNotification") );
39 my $dbh = C4::Context->dbh;
51 'i|input:s' => \$infile,
56 die pod2usage() if $help;
58 # initialize the input data, either file or query
59 if ( defined $infile ) {
60 open( my $IN, '<', $infile ) || die("Cannot open input file");
61 print "Opening $infile\n" if ( defined $verbose );
65 # data should take to form "<Transaction ID>","<SUCCESS or FAIL>"
66 s/["\n]//g; # strip quotes and newlines: they're unnecessary
67 my @data = split(/,/);
68 my $result = update_notice(@data);
75 die pod2usage( -verbose => 1 );
78 print "$updated of $total results lines processed\n" if ( defined $verbose );
82 TalkingTech_itiva_inbound.pl
86 TalkingTech_itiva_inbound.pl
87 TalkingTech_itiva_inbound.pl -v --input=/tmp/talkingtech/results.csv
89 Script to process received Results files for Talking Tech i-tiva
90 phone notification system.
100 Provide verbose log information.
102 =item B<--input> B<-i>
104 REQUIRED. Path to incoming results file.
111 my $message_id = shift;
114 if ( $status =~ m/SUCCESS/i ) {
117 elsif ( $status =~ m/FAIL/i ) {
121 warn "unexpected status $status for message ID $message_id\n";
126 "UPDATE message_queue SET status = ? WHERE message_id = ? and status = 'pending'";
127 my $sth = $dbh->prepare($query);
129 my $result = $sth->execute( $status, $message_id );