-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
100 lines (97 loc) · 3.24 KB
/
index.php
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With");
header('P3P: CP="CAO PSA OUR"');
header("Content-Type: application/json; charset=utf-8");
include 'DatabaseConnection.php';
include 'messageFunctions.php';
include 'productInServiceFunctions.php';
include 'adminFunctions.php';
$postdata = file_get_contents("php://input");
$request = json_decode($postdata,TRUE);
$entity = $request["entity"];
if($entity=="message")
{
$messageFunctionsC = new messageFunctions();
$process=$request["process"];
if($process=="select")
{
$output = $messageFunctionsC->selectMessage();
echo "$output";
}
else if($process=="insert")
{
$newMessage = new message();
$newMessage->senderName=$request["senderName"];
$newMessage->email=$request["email"];
$newMessage->subject=$request["subject"];
$newMessage->content=$request["content"];
$output = $messageFunctionsC->insertMessage($newMessage);
}
}
else if($entity=="productInService")
{
$productInServiceFunctionsC = new productInServiceFunctions();
$process=$request["process"];
if($process=="select")
{
$output = $productInServiceFunctionsC->selectProductInService();
echo "$output";
}
else if($process=="insert")
{
$newProductInService = new productInService();
$newProductInService->serialNo=$request['serialNo'];
$newProductInService->status=$request['status'];
$newProductInService->modelCode=$request['modelCode'];
$newProductInService->ownerAddress=$request['ownerAddress'];
$newProductInService->ownerEmail=$request['ownerEmail'];
$newProductInService->ownerPhone=$request['ownerPhone'];
$output = $productInServiceFunctionsC->insertProductInService($newProductInService);
}
else if($process=="update")
{
$newProductInService = new productInService();
$newProductInService->serialNo=$request['serialNo'];
$newProductInService->status=$request['status'];
$newProductInService->ownerAddress=$request['ownerAddress'];
$newProductInService->ownerEmail=$request['ownerEmail'];
$newProductInService->ownerPhone=$request['ownerPhone'];
$newProductInService->dateOfReturn=$request['dateOfReturn'];
$output = $productInServiceFunctionsC->updateProductInService($newProductInService);
}
else if($process=="search")
{
$serialNo=$request["serialNo"];
$output = $productInServiceFunctionsC->searchProductInService($serialNo);
}
}
if($entity=="admin")
{
$adminFunctionsC = new adminFunctions();
$process=$request["process"];
if($process=="login")
{
$userName=$request["userName"];
$password=$request["password"];
$output = $adminFunctionsC->selectAdminLogin($userName,$password);
echo "$output";
}
else if($process=="insert")
{
$newAdmin = new admin();
$newAdmin->userName=$request["userName"];
$newAdmin->password=$request["password"];
$output = $adminFunctionsC->insertAdmin($newAdmin);
}
else if($process=="delete")
{
$newAdmin = new admin();
$newAdmin->userName=$request["userName"];
$newAdmin->password=$request["password"];
$output = $adminFunctionsC->deleteAdmin($newAdmin);
}
}
?>