SMS - widespread cleanup and moving code away from Cyprus/Turkey-specific implementat...
[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
9 my $query = new CGI;
10 my $message   = $query->param( 'message' );
11 my $phone     = $query->param(  'phone'  );
12 my $operation = $query->param('operation');
13 my $result;
14 my $errorcode;
15 my ($template, $loggedinuser, $cookie)
16     = get_template_and_user({template_name => "sms/sms-home.tmpl",
17                 query => $query,
18                 type => "intranet",
19                 authnotrequired => 0,
20                 flagsrequired => {circulate => 1},
21                 debug => 1,
22         });
23 if ($operation eq "sendsms"){
24         $phone=parse_phone($phone);
25         if ($phone){
26                 ##write to a queue and exit
27                 my $me=C4::Context->userenv;
28                 $result=write_sms($me->{cardnumber},$message,$phone);
29         } else {
30                 $errorcode=-1104;
31         }
32 }
33 my $error=error_codes($errorcode);
34 $template->param(error=>$error);
35 output_html_with_http_headers $query, $cookie, $template->output;
36