-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbookRoom.php
More file actions
80 lines (64 loc) · 1.42 KB
/
bookRoom.php
File metadata and controls
80 lines (64 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
require_once('lib/nusoap.php');
$cell_number = $_GET['MSISDN'];
$session_id = $_GET['SESSION_ID'];
$service_code = $_GET['SERVICE_CODE'];
$ussd_string = $_GET['USSD_STRING'];
//set default level to zero
$level = 0;
$ussd_string = str_replace("#","*",$ussd_string);
$ussd_string_exploded = explode("*",$ussd_string);
$ussd_string_exploded2 = array_shift($ussd_string_exploded);
//get level id from ussd_string reply
$level = count($ussd_string_exploded);
$phone = $cell_number;
if($level == 0)
{
display_menu();
}
if($level > 0)
{
switch($ussd_string_exploded[0])
{
case 1:
register($ussd_string_exploded,$phone);
break;
case 2:
viewRooms($ussd_string_exploded,$phone);
break;
case 3:
bookRoom($ussd_string_exploded,$phone);
break;
}
}
function display_menu()
{
$ussd_text = "1. Register\n2. View rooms\n3. Book a room";
ussd_proceed($ussd_text);
}
function register($details,$phone)
{
if(count($details) == 1)
{
$ussd_text = "Please enter your name";
ussd_proceed($ussd_text);
}
if(count($details) == 2)
{
$param = array('name'=>$details[1],'phone'=>$phone);
$client = new nusoap_client('http://127.0.0.1/soaptest/server.php');
$response = $client->call('registerCustomer', $param);
ussd_stop("Thank you. Your registration is being processed.");
}
}
function ussd_proceed($ussd_text)
{
echo "CON $ussd_text";
exit(0);
}
function ussd_stop($ussd_text)
{
echo "END $ussd_text";
exit(0);
}
?>