/
displayfeedback.php
executable file
·155 lines (146 loc) · 4.99 KB
/
displayfeedback.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
<?php
session_start();
require('functions.php');
function display_feedback($title){
if(!check('SA') and !check('BA') ) header("location:./?sub");
else{
include 'config/globals.php';
$pg = $_SERVER['QUERY_STRING'];
$page='/^[\d]+$/';
if(preg_match($page,$pg)){
include 'config/db.php';
include 'config/settings.php';
$dbname = $branchyear.'_Logs';
$table = $branchyear.'_Feedback';
//if(!mysql_select_db($dbname)) die(mysql_error());
echo "<!DOCTYPE html>\n<html>\n";
display_headers($title);
echo "<body>\n";
menu();
echo <<< display
<br><div class="container" style="margin-top:-15px;">
<div class="row">
<div class="span9">
<div class="well well-large" style="background:#FFF;">
<div class="row">
<div id="step1" class="span4">
<h5>Feedback</h5>
<h6>     -   Listing all complaints and suggestions </h6>
</div>
<div id="page1" class="span4">
<a class="pull-right"><h6>Page $pg</h6></a>
</div>
</div>
display;
//if(!mysql_select_db($dbname)) die(mysql_error());
$query="SELECT * From ".$table." ORDER BY SNo DESC;";
$exe=mysql_query($query) or die(mysql_error());
$page=$pg;
$prev=$page-1;
$next=$page+1;
$per_page=10;
$slimit=($page-1)*10;
$total = mysql_num_rows($exe);
$lastpage = ceil($total/$per_page);
$query1 = "SELECT * FROM ".$table." ORDER BY SNo DESC LIMIT $slimit,$per_page;";
$exe1 = mysql_query($query1) or die(mysql_error());
if($total > 0){
echo <<< table
<div id='$globalbranch' >
<table class="table table-hover table-bordered " style="padding:0px;">
<thead>
<tr>
<th style="text-align:center;" class="span1">Date</th>
<th style="text-align:center;" class="span4">Subject</th>
<th style="text-align:center;" class="span1">Sender</th>
</tr>
</thead>
<tbody>
table;
for($i=0;$i<mysql_num_rows($exe1);$i++){
$record = mysql_fetch_array($exe1);
$datetime=explode(' ',$record['DateTime']);
$date=$datetime[0];
echo <<< feedback
<tr data-toggle='modal' href="#Note$record[0]" style="cursor:pointer;" >
<td style="text-align:center;">$date</td>
<td >$record[2]</td>
<td style="text-align:center;"> $record[4] </td>
</tr>
feedback;
}
echo <<< feedback
</tbody>
</table>
</div>
feedback;
$query2 = "SELECT * FROM ".$table." ORDER BY SNo DESC LIMIT $slimit,$per_page;";
$exe2 = mysql_query($query2) or die(mysql_error());
for($i=0;$i<mysql_num_rows($exe1);$i++){
$record = mysql_fetch_array($exe2);
$datetime=explode(' ',$record['DateTime']);
$date=$datetime[0];
if(preg_match("/<br>/",$record[3]))
$record[3]=str_replace("<br>","<br>",$record[3]);
echo <<< feedback
<div id="Note$record[0]" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="useridlabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h5>$record[2]</h5>
</div>
<div class="modal-body">
<p>$record[3]</p>
</div>
<div class="modal-footer">
<h6 class="pull-left">$record[1] sent by<i> $record[4] </i> @ $record[5] </h6>
</div>
</div>
feedback;
}
echo <<< page
<div class="pagination pagination-centered">
<ul>
page;
if($page < ($total/10)+1) {
if($page != 1)
echo "<li><a href='?$prev'>← Prev</a></li>";
else {echo "<li class='disabled'><a>← Prevt</a></li>";}
if($lastpage<=10){
for($i=1;$i<=$lastpage;$i++){
if($page == $i ) echo "<li class='active'><a href='?$i'><b class='text-error'> $i</b></a></li>";
else echo "<li><a href='?$i'>$i</a></li>";
}
}
else{
$init1 = ($page%10 == 0)?((floor($page/10)-1)*10+1):((floor($page/10)*10)+1) ;
// total no of records total pages pages range
//echo $page/10; echo $lastpage/10;
$end1 = (floor(($page-1)/10) == floor($lastpage/10))?$lastpage:((ceil($page/10))*10);
for($i=$init1;$i<=$end1;$i++){
if($page == $i ) echo "<li class='active'><a href='?$i'><b class='text-error'> $i</b></a></li>";
else echo "<li><a href='?$i'>$i</a></li>";
}
}
if($page != $lastpage)
echo "<li><a href='?$next'>Next →</a></li>";
else {echo "<li class='disabled'><a>Next →</a></li>";}
}
else echo "<script>show_error('No notifications found');</script>";
echo <<< next
</ul>
</div>
next;
}
else echo "<center><p>No complaints/suggestions found.</p></center>";
echo "</div></div><div class='span3'>";
go_home();
sidepanel();
echo "</div></div>";
display_footer();
echo "\n</body>\n</html>";
}
else echo "<script type='text/javascript'>document.location.href='404.php';</script>";
}
}
display_feedback("Admin - Feedback");
?>