-
Notifications
You must be signed in to change notification settings - Fork 1
/
rating.php
185 lines (171 loc) · 11.1 KB
/
rating.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
include 'callback/rating.php';
include 'includes/header.php';
?>
<div class="col-md-4">
<form action="" method="post">
<button type='submit' name='logout' class='btn btn-danger'>Logout</button>
</form>
</div>
<div class="d-flex align-items-center" style="height:100vh;">
<div class="card col-md-6 m-auto">
<div class="card-header">
<h1 class="m-auto text-center mx-5 h1">Rate the Dishes</h1>
</div>
<div class="card-body ">
<form action="" method="post">
<?php
if($currentTime >= '8:00' && $currentTime <= '12:00'){
$query = "SELECT * FROM `menu` WHERE meal_id = 1 AND date = '$date'";
$result = $db->select($query);
if ($result) {
$i = 1;
while ($row = $result->fetch_assoc()) {
$item_id = $row['item_id'];
$q2 = "SELECT * FROM `items` WHERE id = $item_id";
$r2 = $db->select($q2);
if ($r2) {
foreach ($r2 as $row2) {
$item_name = $row2['name'];
}
$check = "SELECT * FROM `ratings` WHERE user_id = '$userid' AND item_id = '$item_id' AND meal_id = '$meal'";
$check_result = $db->select($check);
if($check_result){
echo "<div class='input-group color-danger mb-3'><span class='input-group-text col-md-3' id='basic-addon1'>";
echo $item_name. "</span>";
$i++;}
else{
echo "<div class='input-group mb-3'><span class='input-group-text col-md-3' id='basic-addon1'>";
echo $item_name. "</span>";
echo "<div class='rating border border-start-0 rounded col-md-9' >
<input type='hidden' name='item_id".$i."' value='".$item_id."'>
<input type='radio' id='star5".$i."' name='rating".$i."' value='5' /><label for='star5".$i."'></label>
<input type='radio' id='star4".$i."' name='rating".$i."' value='4' /><label for='star4".$i."'></label>
<input type='radio' id='star3".$i."' name='rating".$i."' value='3' /><label for='star3".$i."'></label>
<input type='radio' id='star2".$i."' name='rating".$i."' value='2' /><label for='star2".$i."'></label>
<input type='radio' id='star1".$i."' name='rating".$i."' value='1' /><label for='star1".$i."'></label>
</div></div>";
$i++;
} }
}
}
}elseif($currentTime >= '12:00' && $currentTime <= '16:00'){
$query = "SELECT * FROM `menu` WHERE meal_id = 2 AND date = '$date'";
$result = $db->select($query);
if ($result) {
$i = 1;
while ($row = $result->fetch_assoc()) {
$item_id = $row['item_id'];
$q2 = "SELECT * FROM `items` WHERE id = $item_id";
$r2 = $db->select($q2);
if ($r2) {
foreach ($r2 as $row2) {
$item_name = $row2['name'];
}
$check = "SELECT * FROM `ratings` WHERE user_id = '$userid' AND item_id = '$item_id' AND meal_id = '$meal'";
$check_result = $db->select($check);
if($check_result){
echo "<div class='input-group color-danger mb-3'><span class='input-group-text col-md-3' id='basic-addon1'>";
echo $item_name. "</span>";
$i++;}
else{
echo "<div class='input-group mb-3'><span class='input-group-text col-md-3' id='basic-addon1'>";
echo $item_name. "</span>";
echo "<div class='rating border border-start-0 rounded col-md-9' >
<input type='hidden' name='item_id".$i."' value='".$item_id."'>
<input type='radio' id='star5".$i."' name='rating".$i."' value='5' /><label for='star5".$i."'></label>
<input type='radio' id='star4".$i."' name='rating".$i."' value='4' /><label for='star4".$i."'></label>
<input type='radio' id='star3".$i."' name='rating".$i."' value='3' /><label for='star3".$i."'></label>
<input type='radio' id='star2".$i."' name='rating".$i."' value='2' /><label for='star2".$i."'></label>
<input type='radio' id='star1".$i."' name='rating".$i."' value='1' /><label for='star1".$i."'></label>
</div></div>";
$i++;
}
}}
}
}elseif($currentTime >= '16:00' && $currentTime <= '20:00'){
$query = "SELECT * FROM `menu` WHERE meal_id = 3 AND date = '$date'";
$result = $db->select($query);
if ($result) {
$i = 1;
while ($row = $result->fetch_assoc()) {
$item_id = $row['item_id'];
$q2 = "SELECT * FROM `items` WHERE id = $item_id";
$r2 = $db->select($q2);
if ($r2) {
foreach ($r2 as $row2) {
$item_name = $row2['name'];
}
$check = "SELECT * FROM `ratings` WHERE user_id = '$userid' AND item_id = '$item_id' AND meal_id = '$meal' and date = '$date'";
$check_result = $db->select($check);
if($check_result){
echo "<div class='input-group mb-3'><span class='input-group-text text-danger col-md-3' id='basic-addon1'>";
echo $item_name. "</span>
<div class='text-danger border text-center border-start-0 rounded col-md-9' >
You have already rated this item.</div>
</div>";
}
else{
echo "<div class='input-group mb-3'><span class='input-group-text col-md-3' id='basic-addon1'>";
echo $item_name. "</span>";
echo "<div class='rating border border-start-0 rounded col-md-9' >
<input type='hidden' name='item_id".$i."' value='".$item_id."'>
<input type='radio' id='star5".$i."' name='rating".$i."' value='5' /><label for='star5".$i."'></label>
<input type='radio' id='star4".$i."' name='rating".$i."' value='4' /><label for='star4".$i."'></label>
<input type='radio' id='star3".$i."' name='rating".$i."' value='3' /><label for='star3".$i."'></label>
<input type='radio' id='star2".$i."' name='rating".$i."' value='2' /><label for='star2".$i."'></label>
<input type='radio' id='star1".$i."' name='rating".$i."' value='1' /><label for='star1".$i."'></label>
</div></div>";
$i++;
}
}}
}
}elseif($currentTime >= '20:00' && $currentTime <= '23:59'){
$query = "SELECT * FROM `menu` WHERE meal_id = 4 AND date = '$date'";
$result = $db->select($query);
if ($result) {
$i = 1;
while ($row = $result->fetch_assoc()) {
$item_id = $row['item_id'];
$q2 = "SELECT * FROM `items` WHERE id = $item_id";
$r2 = $db->select($q2);
if ($r2) {
foreach ($r2 as $row2) {
$item_name = $row2['name'];
}
$check = "SELECT * FROM `ratings` WHERE user_id = '$userid' AND item_id = '$item_id' AND meal_id = '$meal'";
$check_result = $db->select($check);
if($check_result){
echo "<div class='input-group color-danger mb-3'><span class='input-group-text col-md-3' id='basic-addon1'>";
echo $item_name. "</span>";
$i++;}
else{
echo "<div class='input-group mb-3'><span class='input-group-text col-md-3' id='basic-addon1'>";
echo $item_name. "</span>";
echo "<div class='rating border border-start-0 rounded col-md-9' >
<input type='hidden' name='item_id".$i."' value='".$item_id."'>
<input type='radio' id='star5".$i."' name='rating".$i."' value='5' /><label for='star5".$i."'></label>
<input type='radio' id='star4".$i."' name='rating".$i."' value='4' /><label for='star4".$i."'></label>
<input type='radio' id='star3".$i."' name='rating".$i."' value='3' /><label for='star3".$i."'></label>
<input type='radio' id='star2".$i."' name='rating".$i."' value='2' /><label for='star2".$i."'></label>
<input type='radio' id='star1".$i."' name='rating".$i."' value='1' /><label for='star1".$i."'></label>
</div></div>";
$i++;
}}}}
}
?>
<div class="d-grid">
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
<script>
if (window.history.replaceState) {
window.history.replaceState(null, null, window.location.href);
}
</script>
<?php
include "includes/footer.php";
?>