-
Notifications
You must be signed in to change notification settings - Fork 0
/
managefoodcatagories.php
162 lines (131 loc) · 4.82 KB
/
managefoodcatagories.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
<?php include("./inc/req_functions.php") ?>
<?php include("./inc/connection.php") ?>
<?php session_start() ?>
<?php
if (!isset($_SESSION["first_name"])) {
header("Location: signin.php?access=false");
}
if (!($_SESSION["usertype"] == "SystemAdmin")) {
header("Location: signin.php?access=false");
}
if (isset($_POST['searchsubmit'])) {
$searchval = $_POST['searchval'];
$query = "SELECT * FROM categories WHERE catagory_id LIKE '%{$searchval}%' OR catagory_description LIKE '%{$searchval}%'
OR catagory_name LIKE '%{$searchval}%'";
$result = mysqli_query($conn, $query);
query_check($result);
$table = "";
if (mysqli_num_rows($result) >= 1) {
while ($row = mysqli_fetch_assoc($result)) {
$table .= "<tr>";
$table .= "<td>{$row['catagory_id']}</td>";
$table .= "<td>{$row['catagory_name']}</td>";
$table .= "<td>{$row['catagory_description']}</td>";
$table .= "<td><a href=\"updatefoodcatagory.php?catagory_id={$row['catagory_id']}\">" . "<span class=\"badge bg-warning\">Update</span>" . "</a></td>";
$table .= "<td><a href=\"deletefoodcatagories.php?catagory_id={$row['catagory_id']}\">" . "<span class=\"badge bg-danger\">Delete</span>" . "</a></td>";
$table .= "</td>";
}
} else {
header("Location: managefoodcatagories.php?data=notfound");
}
} else {
$query = "SELECT * FROM categories WHERE is_deleted=0";
$result = mysqli_query($conn, $query);
query_check($result);
$table = "";
while ($row = mysqli_fetch_assoc($result)) {
$table .= "<tr>";
$table .= "<td>{$row['catagory_id']}</td>";
$table .= "<td>{$row['catagory_name']}</td>";
$table .= "<td>{$row['catagory_description']}</td>";
$table .= "<td><a href=\"updatefoodcatagory.php?catagory_id={$row['catagory_id']}\">" . "<span class=\"badge bg-warning\">" . "<span class=\"badge bg-warning\">Update</span>" . "</span>" . "</a></td>";
$table .= "<td><a onclick=\"confirm('are you sure?')\" href=\"deletefoodcatagories.php?catagory_id={$row['catagory_id']}\">" . "<span class=\"badge bg-danger\">Delete</span>" . "</a></td>";
$table .= "</td>";
}
}
?>
<a href=""></a>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manage Users</title>
</head>
<?php
if ($_SESSION['usertype'] == "normaluser") {
include("./inc/mainheader.php");
} else if ($_SESSION['usertype'] == "SystemAdmin") {
include("./inc/adminheader.php");
} else if ($_SESSION['usertype'] == "operational") {
include("./inc/opheader.php");
}
?>
<style>
.search-bar {
border-radius: 10px;
border: 1px black solid;
padding: 5px;
background-color: white;
}
.search-bar input {
padding-right: 100px;
background-color: white;
border: none;
}
.search-bar input:active {
border: none;
padding: none;
background-color: none;
}
.search-bar button {
/* background-color: aqua; */
padding-left: 10px;
border: none;
}
</style>
<body>
<div class="container">
<form action="managefoodcatagories.php" method="post">
<div class="row mt-3">
<div class="col-5" style="color:red">
<?php if (isset($_GET['data'])) {
if ($_GET['data'] == "notfound") {
echo "Data Not Fonud!";
}
} ?>
</div>
</div>
<div class="row">
<div class="col-5">
<h2>Manage Users <span><a href="./addfoodcatagory.php">+Add Catagory</a></span> </h2>
</div>
</div>
<div class="d-flex search-bar flex-row align-items-center mt-3 mb-3">
<div class="flex-grow-1">
<input type="text" class="form-control col-10" name="searchval" placeholder="Search Users Here">
</div>
<div class="bt">
<button type="submit" class="btn form-control" name="searchsubmit"> <i class="fas fa-search"></i></button>
</div>
</div>
</form>
<table class="table">
<thead class="">
<th scope="col">Catagory ID</th>
<th scope="col">Catagory Name</th>
<th scope="col">Catagory Description</th>
<th scope="col">Update</th>
<th scope="col">Delete</th>
</thead>
<tbody>
<?php
if (isset($table)) {
echo $table;
}
?>
</tbody>
</table>
</div>
</body>
</html>