-
Notifications
You must be signed in to change notification settings - Fork 1
/
feedback_list.php
308 lines (280 loc) · 9.45 KB
/
feedback_list.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<?php
/********************************
* File Name: feedback_list.php *
* Author: Ammar S.A.A *
* Output: feedbacks & Regulations *
********************************/
require('config.php');
require(WEBSITE_PATH.'./includes/db_connection.php');
require(WEBSITE_PATH.'./includes/session.php');
include(WEBSITE_PATH.'./includes/header.php');
include(WEBSITE_PATH.'./includes/logo.php');
include(WEBSITE_PATH.'./includes/menu.php');
if(isset($_GET['action']) && isset($_GET['id']))
{
$id = $_GET['id'];
$sql = "DELETE FROM tblfeedback WHERE id={$id}";
$result = $conn->query($sql);
if($result)
{
$msg = "<div class='alert alert-success'>Record Deleted Successfully.</div>";
}
else{
$msg = "<div class='alert alert-danger'>Record Not Deleted Successfully.</div>";
}
}
$sql="SELECT
tblfeedback.id,
tblfeedback.feedback,
tblfeedback.feedback_urdu,
tblfeedback.feedback_reply,
tblfeedback.rating,
admin.user_name,
tblusers.full_name,
tblusers.email_id,
tblfeedback.creation_date,
tblfeedback.reply_date
FROM
tblfeedback
INNER JOIN tblusers ON tblfeedback.user_id = tblusers.id
INNER JOIN admin ON tblfeedback.reply_id = admin.id
ORDER BY id DESC";
if(isset($_POST['search']) && !empty($_POST['search'])){
$search = trim($_POST['search']);
$sql= "SELECT
tblfeedback.id,
tblfeedback.feedback,
tblfeedback.feedback_urdu,
tblfeedback.feedback_reply,
tblfeedback.rating,
admin.user_name,
tblusers.full_name,
tblusers.email_id,
tblfeedback.creation_date,
tblfeedback.reply_date
FROM
tblfeedback
INNER JOIN tblusers ON tblfeedback.user_id = tblusers.id
INNER JOIN admin ON tblfeedback.reply_id = admin.id
WHERE feedback LIKE '%{$search}%'
OR feedback_urdu LIKE '%{$search}%'
OR rating LIKE '%{$search}%'
OR tblusers.full_name LIKE '%{$search}%'
OR tblusers.email_id LIKE '%{$search}%'
OR admin.user_name LIKE '%{$search}%'
OR creation_date LIKE '%{$search}%'
OR reply_date LIKE '%{$search}%'
";
}
$result = $conn->query($sql);
if (isset($msg))
{
echo $msg;
}
$row='';
$read_more = '';
if (isset($_GET['read_more'])) {
$id = $_GET['read_more'];
$sql= "SELECT
tblfeedback.id,
tblfeedback.feedback,
tblfeedback.feedback_urdu,
tblfeedback.feedback_reply,
tblfeedback.rating,
admin.user_name,
tblusers.full_name,
tblusers.email_id,
tblfeedback.creation_date,
tblfeedback.reply_date
FROM
tblfeedback
INNER JOIN tblusers ON tblfeedback.user_id = tblusers.id
INNER JOIN admin ON tblfeedback.reply_id = admin.id
#ORDER BY id DESC
WHERE tblfeedback.id={$id}";
$result = $conn->query($sql);
if ($result && $result->num_rows > 0) {
$row = $result->fetch_assoc();
$id = $row['id'];
$feedback = $row['feedback'];
$feedback_urdu = $row['feedback_urdu'];
$rating = $row['rating'];
$replied_by = $row['user_name'];
$reply = $row['feedback_reply'];
$admin_name = $row['user_name'];
$user_name = $row['full_name'];
$user_email = $row['email_id'];
$creation_date = $row['creation_date'];
$reply_date = $row['reply_date'];
};
}
?>
<?php
if (!IfIsUser($conn) && $_SESSION['user_name']) {
?>
<section id="content">
<div class="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<!--Search Nav Start-->
<nav class="navbar navbar-light default-color bg-transparent nav justify-content-between">
<a class="navbar-brand" href="feedback_list.php">Feedbacks' List</a>
<!--Search Form Start-->
<form class="form-inline form-responsive my-0 form-inline bg-transparent" method="POST">
<div class="md-form form-sm my-0">
<input type="text" class="form-control" name="search" placeholder="Search..." />
<button class="btn btn-sm my-0 btn-transparent" type="submit">
<i class="material-icons">search</i>
</button>
</div>
</form>
<!--Search Form End-->
</nav>
<!--Search Nav End-->
</div>
</div>
<div class="row">
<div class="table-responsive">
<table class="table table-borderless table-condensed table-hover table-striped">
<thead class="thead thead-light">
<tr>
<th class="text-nowrap">ID</th>
<th class="text-nowrap">Feedback</th>
<th class="text-nowrap urdu">رائے</th>
<th class="text-nowrap">Reply</th>
<th class="text-nowrap">Stars</th>
<th class="text-nowrap">Full Name</th>
<th class="text-nowrap">Email ID</th>
<th class="text-nowrap">Creation Date</th>
<th class="text-nowrap">Reply Date</th>
<th class="text-nowrap">Replied By</th>
<th colspan="2" class="text-nowrap">Action</th>
</tr>
</thead>
<tbody>
<?php
if ($result){
foreach ($result as $row) {
?>
<tr>
<td><?php echo $row['id']; ?></td>
<!--Feedback-->
<td class="text-truncate">
<?php
if (isset($_GET['read_more'])) {
echo $row['feedback'];
}else{
echo substr($row['feedback'],0,20);
if(!empty($row['feedback'])){
?>
<a href="<?php echo WEBSITE_URL.'feedback_list.php?read_more='.$row['id']; ?>">...Read More</a>
<?php }} ?>
</td>
<!--Feedback Urdu-->
<td class="urdu text-truncate">
<?php
if (isset($_GET['read_more'])) {
echo $row['feedback_urdu'];
}else{
echo substr($row['feedback_urdu'],0,10);
if(!empty($row['feedback_urdu'])){
?>
<a href="<?php echo WEBSITE_URL.'feedback_list.php?read_more='.$row['id']; ?>">...مزید پڑھیں</a>
<?php }} ?>
</td>
<!--Reply-->
<td class="text-truncate">
<?php
if (isset($_GET['read_more'])) {
echo $row['feedback_reply'];
}else{
echo substr($row['feedback_reply'],0,20);
if(!empty($row['feedback_reply'])){
?>
<a href="<?php echo WEBSITE_URL.'feedback_list.php?read_more='.$row['id']; ?>">...Read More</a>
<?php }} ?>
</td>
<td>
<?php
if (isset($row['rating'])) {
GetStars($row['rating']);
}else{ echo "Not Rated!";}?>
</td>
<td><?php echo $row['full_name']; ?></td>
<!--email ID-->
<td class="text-truncate">
<?php
if (isset($_GET['read_more'])) {
echo $row['email_id'];
}else{
echo substr($row['email_id'],0,8);
if(!empty($row['email_id'])){
?>
<a href="<?php echo WEBSITE_URL.'feedback_list.php?read_more='.$row['id']; ?>">...</a>
<?php }} ?>
</td>
<td><?php echo $row['creation_date']; ?></td>
<td><?php echo $row['reply_date']; ?></td>
<td><?php echo $row['user_name']; ?></td>
<td>
<button role="button" class="btn btn-info btn-sm">
<a class="" href="<?php echo WEBSITE_URL.'feedback.php?action=relpy&id='.$row['id']; ?>">
<i class="fa fa-envelope-o fa-lg"></i>
</a>
</button>
</td>
<td>
<button class="btn btn-danger btn-sm" onclick="delete_confirm(<?php echo $row["id"]; ?>)" >
<i class="display-5 glyphicon glyphicon-trash"></i>
</button>
</td>
</tr>
<?php }
}else{
echo "<tr><td colspan='12'><p>No record found for <b>{$search}</b></p></td></tr>";
}
?>
</tbody>
<tfoot class="tfoot tfoot-light">
<tr>
<td colspan="12">
<?php
if (isset($search)) {
GetTotalSearchResult($conn,$result,$search);
}else{
$total_feedbacks = GetTotal($conn, TBLFEEDBACK);
echo "Showing total <b>".$total_feedbacks."</b> of <b>".$total_feedbacks."</b> ";
if ($total_feedbacks > 1) {
echo "results.";
}else{ echo "result.";}
}
?>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<br />
</div>
</div>
</section>
<?php
}else{ echo "<div class='alert alert-danger'>Access Denied!</div>"; }
?>
</div>
</div>
<br />
<script>
function delete_confirm(id)
{
var txt;
if (confirm("Are you sure? you want to delete this record.")) {
window.location.href = "<?php echo WEBSITE_URL. 'feedback_list.php?action=delete&id=' ?>"+id;
}
}
</script>
<?php
include(WEBSITE_PATH.'./includes/footer.php');
?>