-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapprovepickup.php
150 lines (104 loc) · 3.87 KB
/
approvepickup.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
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
147
148
149
150
<?php
session_start();
?>
<?php
include('project3connection.php');
$id = $_GET['id'];
$s_id = $_GET['second_id'];
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Check if the user submitted the form
$id = test_input($_POST["id"]);
if (isset($_POST['submit'])) {
$qq = "SELECT * FROM pickup WHERE s_id = '$s_id' AND approved = '1'";
$result = mysqli_query($dbc, $qq);
$num = mysqli_num_rows($result);
if ($num == 0){
echo "s_id = ".$id;
$qs = "UPDATE pickup SET approved = '1' WHERE p_id = $id";
mysqli_query($dbc, $qs);
echo" <script>";
echo 'alert("Thank you for volunteering. You will see the detail information about this pickup task under Pickup Assignment once our team has reviewed and approved it.\n You will be bring back to Check Pickup Page in 2 second.");';
echo 'setTimeout(function() { window.location.href = "assignpickup.php"; }, 0);';
echo" </script>";
}
else{
echo" <script>";
echo 'alert("Sorry you have already assign pickup to this student before. \nYou will be bring back to Check Pickup Page.");';
echo 'setTimeout(function() { window.location.href = "assignpickup.php"; }, 0);';
echo" </script>";
}
// header("Location: checkpickupneed.php");
} elseif (isset($_POST['cancel'])) {
echo" <script>";
echo 'alert("You have canceled the submission.\n You will be bring back to Check Pickup Page.");';
echo 'setTimeout(function() { window.location.href = "assignpickup.php"; }, 0);';
echo" </script>";
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<html>
<head>
<title>Confirm Pickup</title>
<style>
.box{
text-align: center;
}
input{
padding: 15px, 32px;
border-radius:12px;
font-size: 2em;
}
input:hover{
background-color: #4CAF50;
}
h3{
font-size: 2em;
}
span{
color:red;
}
</style>
</head>
<body>
<?php
include('project3connection.php');
$qs ="SELECT volunteer.first_name, volunteer.last_name,pickup.p_id, student.firstName, student.lastName, DATE_FORMAT(student.aDate, '%M %d') as aDate, student.aTime
FROM student
RIGHT JOIN pickup ON pickup.s_id = student.s_id
Join volunteer ON pickup.v_id = volunteer.v_id
ORDER BY student.aDate";
$query = mysqli_query($dbc,$qs);
$num = mysqli_num_rows($query);
if($num !=0){
while($row = mysqli_fetch_array($query)){
$v_first = $row['first_name'];
$v_last = $row['last_name'];
$s_first = $row['firstName'];
$s_last = $row['lastName'];
$date = $row['aDate'];
$time = $row['aTime'];
}
}
?>
<br><br><br><br>
<div class = "box">
<h3>Please confirm that you want to approve <br> Volunteer: <?php echo $v_first." ".$v_last ?> <br>to pickup<br>
Student: <?php echo $s_first." ".$s_last ?><br>on
<span><?php echo $date.", ".$time."</span>." ?></h3>
<form action ="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"method ="post">
<input type = "hidden" name = "id" size="20" maxlength="50" value ="<?php echo $id; ?>">
<input type = 'hidden' name = "date" value = "<?php $date ?>">
<input type = 'hidden' name = "time" value = "<?php $time ?>">
<input type = 'submit' name = "submit" value = "Confirm">
<input type = 'submit' name = "cancel" value = "Cancel">
</form>
</div>
<h1> <?php $message ?></h1>
</body>
</html>