adding SMS stuff so we don't forget about it
[wip/koha-chris_n.git] / sms / sms.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use CGI;
5 use C4::SMS;
6 use C4::Output;
7 use C4::Auth;
8 my ($res,$ua);
9 my %commands;
10 my $query = new CGI;
11 my $message=$query->param('message');
12 my $phone=$query->param('phone');
13 my $operation=$query->param('operation');
14 my $result;
15 my $errorcode;
16 my ($template, $loggedinuser, $cookie)
17     = get_template_and_user({template_name => "sms/sms-home.tmpl",
18                              query => $query,
19                              type => "intranet",
20                              authnotrequired => 0,
21                              flagsrequired => {circulate => 1},
22                              debug => 1,
23                              });
24 if ($operation eq"sendsms"){
25  $phone=parse_phone($phone);
26   if ($phone>0){
27 ##write to a queue and exit
28 my $me=C4::Context->userenv;
29 my $card=$me->{cardnumber};
30          $result=write_sms($card,$message,$phone);
31
32   }else{
33   $errorcode=-1104;
34  }
35 }
36 my $error=error_codes($errorcode);
37 $template->param(error=>$error);
38 output_html_with_http_headers $query, $cookie, $template->output;
39
40
41
42
43