-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfacade.php
More file actions
146 lines (108 loc) · 4.17 KB
/
Copy pathfacade.php
File metadata and controls
146 lines (108 loc) · 4.17 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
function redirect(){
header("location:admin.php",true,302);
die();
}
function direct(){
header("location:admin.php",true,302);
die();
}
class Technical_layer{
function add_bs_ToDB($d_time, $starting_loc, array $route, $vehicleNumber, $vehicleType ) {
$conn = mysqli_connect('localhost', 'root', '', 'bus');
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$route_string = implode(",", $route);
$sql = "INSERT INTO vehicle (vehicleNO, vehicleType)
VALUES ('$vehicleNumber', '$vehicleType')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = "INSERT INTO location (pickUpLocation, dropOffLocation) VALUES ('$starting_loc', '$route_string')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
// Insert the data into the table
$sql = "INSERT INTO vehicle_schedule (departureTime,vehicleID,locID)VALUES ('$d_time',LAST_INSERT_ID(),LAST_INSERT_ID())";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
// Close the connection
// mysqli_close($conn);
redirect();
}
function add_requisition_ToDB($d_time, $starting_loc,array $route, $a_time, $date, $req)
{
/////////////////////////////// addd query
echo $d_time ;
echo $starting_loc;
echo $route[0] ;
echo $a_time;
echo $date;
echo $req;
$conn = mysqli_connect('localhost', 'root', '', 'bus');
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$r_string = implode("", $route);
$sql = "INSERT INTO location (pickUpLocation, dropOffLocation) VALUES ('$starting_loc', '$r_string')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = "INSERT INTO requisition (request, departure_time,reqDate,arrivalTime,locID)
VALUES ('$d_time', '$a_time','$req','$date',LAST_INSERT_ID())";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
// Insert the data into the tabl
}
function add_user_ToDB($id, $password, $designation )
{
///////////////////////////// addd query
//
$conn = mysqli_connect('localhost', 'root', '', 'bus');
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "INSERT INTO user (username, designation,password) VALUES ('$id', '$designation','$password')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
direct();
}
// function add_complaint_ToDB($cID, $complaint )
// {
// /////////////////////////////// addd query
// // echo $cID;
// // echo $user_ID;
// // echo $complaint;
// $conn = mysqli_connect('localhost', 'root', '', 'bus');
// // Check connection
// if (!$conn) {
// die("Connection failed: " . mysqli_connect_error());
// }
// $sql = "INSERT INTO complaints (complaintIDuser, complaint) VALUES ('$cID', '$complaint')";
// if (mysqli_query($conn, $sql)) {
// echo "New record created successfully";
// } else {
// echo "Error: " . $sql . "<br>" . mysqli_error($conn);
// }
// }
}
?>