Skip to content

Commit fc9b22d

Browse files
author
Shreya Sharma
committed
Created switch for canteen status
connected to db for past orders and ongoing orders for canteen-side modified update.php
1 parent c74fc20 commit fc9b22d

10 files changed

+289
-117
lines changed

JS/addtocart.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -139,24 +139,27 @@ var shoppingCart = (function() {
139139

140140
$("#order-now").click(function() {
141141
var cartArray = shoppingCart.listCart();
142+
console.log(cartArray);
142143
$.ajax({
143144
type: "post",
144145
url: "../php/ordersummary.php",
145146
data: {
146-
cartArray,
147-
},
147+
cartArray
148+
},
148149
success: function(response) {
149150
if (response==true) {
150151
alert("Order Succesfully Placed");
151152
clearCart();
152153
window.location.replace("../html/userhomepage.php");
153154

154-
} else {
155+
} else if(response==false) {
155156
alert("Connection Error");
157+
} else {
158+
alert("Hello");
156159
}
157160
}
158-
});
159-
});
161+
})
162+
})
160163

161164
$('.show-cart').on("click", ".delete-item", function(event) {
162165
var name = $(this).data('name')

css/canteenhomepage.css

+36-35
Original file line numberDiff line numberDiff line change
@@ -170,58 +170,59 @@ div.content {
170170

171171

172172
@import url(https://fonts.googleapis.com/css?family=Ubuntu);
173-
h1{
173+
174+
h1 {
174175
font-family: 'Ubuntu', sans-serif;
175176
color: #fff;
176177
font-size: 40px;
177178
font-weight: normal;
178179
margin-bottom: 50px;
179180
}
180-
.toggle-btn{
181+
182+
.togglebutton {
181183
width: 80px;
182184
height: 40px;
183185
margin: 10px;
184186
border-radius: 50px;
185187
display: inline-block;
186188
position: relative;
187-
background : url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAyklEQVQ4T42TaxHCQAyENw5wAhLACVUAUkABOCkSwEkdhNmbpHNckzv689L98toIAKjqGcAFwElEFr5ln6ruAMwA7iLyFBM/TPDuQSrxwf6fCKBoX2UMIYGYkg8BLOnVg2RiAEexGaQQq4w9e9klcxGLLAUwgDAcihlYAR1IvZA1sz/+AAaQjXhTQQVoe2Yo3E7UQiT2ijeQdojRtClOfVKvMVyVpU594kZK9zzySWTlcNqZY9tjCsUds00+A57z1e35xzlzJjee8xf0HYp+cOZQUQAAAABJRU5ErkJggg==') no-repeat 50px center #e74c3c;
189+
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAyklEQVQ4T42TaxHCQAyENw5wAhLACVUAUkABOCkSwEkdhNmbpHNckzv689L98toIAKjqGcAFwElEFr5ln6ruAMwA7iLyFBM/TPDuQSrxwf6fCKBoX2UMIYGYkg8BLOnVg2RiAEexGaQQq4w9e9klcxGLLAUwgDAcihlYAR1IvZA1sz/+AAaQjXhTQQVoe2Yo3E7UQiT2ijeQdojRtClOfVKvMVyVpU594kZK9zzySWTlcNqZY9tjCsUds00+A57z1e35xzlzJjee8xf0HYp+cOZQUQAAAABJRU5ErkJggg==") no-repeat 50px center #e74c3c;
188190
cursor: pointer;
189191
-webkit-transition: background-color .40s ease-in-out;
190192
-moz-transition: background-color .40s ease-in-out;
191193
-o-transition: background-color .40s ease-in-out;
192194
transition: background-color .40s ease-in-out;
193-
cursor:pointer; }
194-
/* &.active{
195-
background : url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAmUlEQVQ4T6WT0RWDMAhFeZs4ipu0mawZpaO4yevBc6hUIWLNd+4NeQDk5sE/PMkZwFvZywKSTxF5iUgH0C4JHGyF97IggFVSqyCFga0CvQSg70Mdwd8QSSr4sGBMcgavAgdvwQCtApvA2uKr1x7Pu++06ItrF5LXPB/CP4M0kKTwYRIDyRAOR9lJTuF0F0hOAJbKopVHOZN9ACS0UgowIx8ZAAAAAElFTkSuQmCC') no-repeat 10px center #2ecc71;
196-
.round-btn{
197-
left: 45px;
198-
}
199-
}
200-
.round-btn{
201-
width: 30px;
202-
height: 30px;
203-
background-color: #fff;
204-
border-radius: 50%;
205-
display: inline-block;
206-
position: absolute;
207-
left: 5px;
208-
top: 50%;
209-
margin-top: -15px;
210-
-webkit-transition: all .30s ease-in-out;
195+
cursor: pointer;
196+
}
197+
.togglebutton.active {
198+
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAmUlEQVQ4T6WT0RWDMAhFeZs4ipu0mawZpaO4yevBc6hUIWLNd+4NeQDk5sE/PMkZwFvZywKSTxF5iUgH0C4JHGyF97IggFVSqyCFga0CvQSg70Mdwd8QSSr4sGBMcgavAgdvwQCtApvA2uKr1x7Pu++06ItrF5LXPB/CP4M0kKTwYRIDyRAOR9lJTuF0F0hOAJbKopVHOZN9ACS0UgowIx8ZAAAAAElFTkSuQmCC") no-repeat 10px center #2ecc71;
199+
}
200+
.togglebutton.active .sliderround {
201+
left: 45px;
202+
}
203+
.togglebutton .sliderround {
204+
width: 30px;
205+
height: 30px;
206+
background-color: #fff;
207+
border-radius: 50%;
208+
display: inline-block;
209+
position: absolute;
210+
left: 5px;
211+
top: 50%;
212+
margin-top: -15px;
213+
-webkit-transition: all .30s ease-in-out;
211214
-moz-transition: all .30s ease-in-out;
212215
-o-transition: all .30s ease-in-out;
213216
transition: all .30s ease-in-out;
214-
}
215-
.updatebutton{
216-
position: absolute;
217-
left:0;
218-
right:0;
219-
width: 100%;
220-
height: 100%;
221-
opacity: 0;
222-
z-index: 9;
223-
cursor:pointer;
224-
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
225-
}
226-
} */
227-
217+
}
218+
.togglebutton .togglebtn {
219+
position: absolute;
220+
left: 0;
221+
right: 0;
222+
width: 100%;
223+
height: 100%;
224+
opacity: 0;
225+
z-index: 9;
226+
cursor: pointer;
227+
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
228+
}

html/allorder.php

+53-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
session_start();
3-
if (!(isset($_SESSION['username'])))
4-
{
3+
if (!(isset($_SESSION['username']))) {
54
header("Location: ../html/login.html");
65
}
76
?>
@@ -20,20 +19,60 @@
2019

2120
<div class="body">
2221
<div class="sidebar">
23-
<div class="header">Rassasy<br></div>
24-
<u>
25-
<?php
26-
session_start();
27-
echo "Hey, " . $_SESSION['username'];
28-
?> </u>
29-
<hr>
30-
<a href="canteenhomepage.php">Pending Orders</a>
31-
<a href="allorder.php">All Orders</a>
32-
<a href="menu.php">Menu</a>
33-
<a href="update.php">Update</a>
34-
<a href="../php/logout.php">Logout</a>
22+
<div class="header">Rassasy<br></div>
23+
<u>
24+
<?php
25+
session_start();
26+
echo "Hey, " . $_SESSION['username'];
27+
?> </u>
28+
<hr>
29+
<a href="canteenhomepage.php">Pending Orders</a>
30+
<a href="allorder.php">All Orders</a>
31+
<a href="menu.php">Menu</a>
32+
<a href="update.php">Update</a>
33+
<a href="../php/logout.php">Logout</a>
3534
</div>
3635
<div class="allorder"> All orders are displayed here.</div>
36+
<?php
37+
include('../php/conn.php');
38+
$canteenname = $_SESSION['username'];
39+
$sql = "select * from order_$canteenname group by orderid; ";
40+
$result = $conn->query($sql);
41+
if ($result->num_rows > 0) {
42+
echo "
43+
<table id='ordertable' border='1'>
44+
<thead>
45+
<tr>
46+
<td>Item No</td>
47+
<td>Item Name</td>
48+
<td>Quantity</td>
49+
<td>Price</td>
50+
<td>Total</td>
51+
<td>Student Name</td>
52+
<td>Student Mobile</td>
53+
<td>Status</td>
54+
</tr>
55+
</thead>
56+
<tbody>
57+
";
58+
while ($r = $result->fetch_assoc()) {
59+
echo $r['orderid'];
60+
echo " <tr class='table_entry'>
61+
<td class='table_data'>$r[itemno]</td>
62+
<td class='table_data'>$r[itemname]</td>
63+
<td class='table_data'>$r[count]</td>
64+
<td class='table_data'>$r[price]</td>
65+
<td class='table_data'>$r[total]</td>
66+
<td class='table_data'>$r[student_name]</td>
67+
<td class='table_data'>$r[student_mobile]</td>
68+
<td class='table_data'>$r[status]</td>
69+
</tr> ";
70+
}
71+
} else
72+
echo " No past orders";
73+
echo "</tbody>
74+
</table> " ;
75+
?>
3776
</div>
3877
</body>
3978

html/canteenhomepage.php

+106-24
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
Rassasy
1313
</title>
1414
<link rel="stylesheet" href="../css/canteenhomepage.css">
15+
<script type="text/javascript" src="../JS/jquery-3.4.1.min.js"></script>
16+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
1517

1618
</head>
1719

@@ -34,37 +36,117 @@
3436
</div>
3537
<div class="orders">
3638
<div class="switch">Are you ready to open the shop?
37-
<label class="switch">
38-
<input type="checkbox" class="switch">
39-
<span class="slider round"></span>
40-
</label>
39+
<div class="togglebutton">
40+
<input type="checkbox" class="togglebtn" id="togglebtn">
41+
<span class="sliderround"></span>
42+
</div>
43+
</div>
44+
<div class="ongoingorders">
45+
<?php
46+
include('../php/conn.php');
47+
$canteenname = $_SESSION['username'];
48+
$sql = "select * from order_$canteenname where status = 0 group by orderid; ";
49+
$result = $conn->query($sql);
50+
if ($result->num_rows > 0) {
51+
echo "
52+
<table id='ordertable' border='1'>
53+
<thead>
54+
<tr>
55+
<td>Item No</td>
56+
<td>Item Name</td>
57+
<td>Quantity</td>
58+
<td>Price</td>
59+
<td>Total</td>
60+
<td>Student Name</td>
61+
<td>Student Mobile</td>
62+
<td>Status</td>
63+
<td>Update Status</td>
64+
</tr>
65+
</thead>
66+
<tbody>
67+
";
68+
while ($r = $result->fetch_assoc()) {
69+
echo $r['orderid'];
70+
echo " <tr class='table_entry'>
71+
<td class='table_data'>$r[itemno]</td>
72+
<td class='table_data'>$r[itemname]</td>
73+
<td class='table_data'>$r[count]</td>
74+
<td class='table_data'>$r[price]</td>
75+
<td class='table_data'>$r[total]</td>
76+
<td class='table_data'>$r[student_name]</td>
77+
<td class='table_data'>$r[student_mobile]</td>
78+
<td class='table_data'>$r[status]</td>
79+
<td class='table_data'><div class='togglebutton'>
80+
<input type='checkbox' class='updateorderstatus' data-id='$r[id]'>
81+
<span class='sliderround'></span></div></td>
82+
</tr> ";
83+
}
84+
}
85+
else
86+
echo " No pending orders";
87+
echo "</tbody>
88+
</table> " ;
89+
?>
4190
</div>
4291
</div>
4392
</div>
4493
<script>
45-
$("#switch").click(function(event) {
46-
if ($(mainParent).find('input.switch').is(':checked')) {
47-
status = 1;
48-
$(mainParent).addClass('active');
49-
} else {
50-
status = 0;
51-
$(mainParent).removeClass('active');
52-
}
94+
$('.togglebtn').click(function(event) {
95+
var status;
96+
var mainParent = $(this).parent('.togglebutton');
97+
if ($(mainParent).find('input.togglebtn').is(':checked')) {
98+
status = 1;
99+
$(mainParent).addClass('active');
100+
} else {
101+
status = 0;
102+
$(mainParent).removeClass('active');
103+
}
104+
console.log(status);
53105

54-
$.ajax({
55-
type: "post",
56-
url: "../php/canteenopen.php",
57-
data: {
58-
'status': status,
59-
},
60-
success: function(response) {
61-
if (response == true) {
62-
alert("Updated");
63-
} else {
64-
alert("Connection Error");
106+
$.ajax({
107+
type: "post",
108+
url: "../php/canteenopen.php",
109+
data: {
110+
'status': status,
111+
},
112+
success: function(response) {
113+
if (response == true) {
114+
alert("Updated");
115+
} else {
116+
alert("Connection Error");
117+
}
65118
}
66-
}
119+
});
67120
});
121+
122+
$('.updateorderstatus').click(function(event) {
123+
var status;
124+
var orderupdateid = $(this).data('id');
125+
var mainParent = $(this).parent('.togglebutton');
126+
if ($(mainParent).find('input.updateorderstatus').is(':checked')) {
127+
status = 1;
128+
$(mainParent).addClass('active');
129+
} else {
130+
status = 0;
131+
$(mainParent).removeClass('active');
132+
}
133+
console.log(status);
134+
135+
$.ajax({
136+
type: "post",
137+
url: "../php/canteenopen.php",
138+
data: {
139+
'status': status,
140+
'orderupdateid': orderupdateid
141+
},
142+
success: function(response) {
143+
if (response == true) {
144+
alert("Updated");
145+
} else {
146+
alert("Connection Error");
147+
}
148+
}
149+
});
68150
});
69151
</script>
70152
</body>

html/menu.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function updateRow(row, i, reset) {
121121
add_menu_data
122122
},
123123
success: function(response) {
124-
if (response) {
124+
if (response==true) {
125125
alert("Saved to Menu");
126126
inp1.value = inp2.value = inp3.value = '';
127127
} else {

0 commit comments

Comments
 (0)