forked from codeb1ooded/RTI_Automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.php
More file actions
299 lines (273 loc) · 7.34 KB
/
report.php
File metadata and controls
299 lines (273 loc) · 7.34 KB
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
<head>
<title>Report</title>
<link rel="stylesheet" href="css/background.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<script src="bootstrap/jQuery/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<meta charset="utf-8">
</head>
<body>
<div class='container'>
<h2>Generate RTI Report By :</h2><br>
<form action="report.php" method="post">
<input type="submit" name="name" class=btn value="Name">
<input type="submit" name="dept" class=btn value="Department">
<input type="submit" name="date" class=btn value="Date">
<input type="submit" name="close" class=btn value="Closed">
</form>
<?php
if(isset($_POST['name'])){
include 'config_database.php';
$query="SELECT count(name),name,id FROM add_rti group by name order by id";
$res=mysqli_query($con,$query);
echo "<table class='table table-bordered'>" ;
echo "<tr>
<th>ID</th>
<th>Applicant Name</th>
<th>No. of Applications filed</th>
</tr>";
while($r=mysqli_fetch_assoc($res))
{
echo "<tr>";
echo "<td>";
echo $r['id']."</td>";
echo "<td>";
echo $r['name'];
echo "</td>";
echo "<td>";
echo $r['count(name)'];
echo "</td></tr>";
}
echo "</table>";
}
if(isset($_POST['dept'])){
include 'config_database.php';
$query="SELECT count(map),map,id FROM t2 group by map order by id";
$res=mysqli_query($con,$query);
echo "<table class='table table-bordered'>" ;
echo "<tr>
<th>ID</th>
<th>Department Name</th>
<th>No. of Queries</th>
</tr>";
while($r=mysqli_fetch_assoc($res))
{
echo "<tr>";
echo "<td>";
echo $r['id'];
echo "</td>";
echo "<td>";
echo $r['map'];
echo "</td>";
echo "<td>";
echo $r['count(map)'];
echo "</td></tr>";
}
echo "</table>";
}
if(isset($_POST['close'])){
include 'config_database.php';
$query="SELECT * FROM add_rti WHERE archieve=1";
$res=mysqli_query($con,$query);
echo "<table class='table table-bordered'>" ;
echo "<tr>
<th>ID</th>
<th>Applicant Name</th>
<th>Reply Date</th>
</tr>";
while($r=mysqli_fetch_assoc($res))
{
echo "<tr>";
echo "<td>";
echo $r['id'];
echo "</td>";
echo "<td>";
echo $r['name'];
echo "</td>";
$que="SELECT * FROM info_about_reply WHERE id=".$r['id'].";";
$ut=mysqli_query($con,$que);
$ut1=mysqli_fetch_assoc($ut);
echo "<td>";
echo $ut1['reply_date'];
echo "</td></tr>";
}
echo "</table>";
}
if(isset($_POST['date'])){
echo "
<form method=post action='./report.php' name='report_rti'><th>Start Date</th>
<td><input type=text name=d1 placeholder=YYYY-MM-DD></td>
<th>End Date</th>
<td><input type=text name=d2 placeholder=YYYY-MM-DD></td>
<input type=submit name=enter class=btn value=Enter onclick=\"return validateDate()\">
</form>";
echo "</table>";
}
?>
<script type="text/javascript">
function validateDate(){
var bool1 = validatedate1(document.report_rti.d1);
var bool2;
if(bool1 == true){
bool2 = validatedate2(document.report_rti.d2);
}
if(bool1 == false || bool2 == false){
return false;
}
}
function validatedate1(inputText) {
var dateformat = /^(\d{4})-(\d{1,2})-(\d{1,2})/;
// Match the date format through regular expression
if(inputText.value.match(dateformat)) {
document.report_rti.d1.focus();
//Test which seperator is used '/' or '-'
var opera1 = inputText.value.split('/');
var opera2 = inputText.value.split('-');
lopera1 = opera1.length;
lopera2 = opera2.length;
// Extract the string into month, date and year
if (lopera1>1) {
var pdate = inputText.value.split('/');
} else if (lopera2>1) {
var pdate = inputText.value.split('-');
}
var dd = parseInt(pdate[2]);
var mm = parseInt(pdate[1]);
var yy = parseInt(pdate[0]);
// Create list of days of a month [assume there is no leap year by default]
var ListofDays = [31,28,31,30,31,30,31,31,30,31,30,31];
if(mm >12){
document.report_rti.d1.focus();
alert('Month should be less than twelve!!! \nInvalid date format!');
return false;
}
if (mm==1 || mm>2) {
if (dd>ListofDays[mm-1]) {
document.report_rti.d1.focus();
alert('Date exceeded!!! \nInvalid date format!');
return false;
}
else {
return true;
}
}
if (mm==2) {
var lyear = false;
if ( (!(yy % 4) && yy % 100) || !(yy % 400)) {
lyear = true;
}
if ((lyear==false) && (dd>=29)) {
alert('Date exceeded!!! \nInvalid date format!');
document.report_rti.d1.focus();
return false;
}
else if ((lyear==true) && (dd>29)) {
alert('Date exceeded!!! \nInvalid date format!');
document.report_rti.d1.focus();
return false;
}
else {
return true;
}
}
}
else {
alert("Date format is not correct!!!! \nInvalid date format!");
document.report_rti.d1.focus();
return false;
}
}
function validatedate2(inputText) {
var dateformat = /^(\d{4})-(\d{1,2})-(\d{1,2})/;
// Match the date format through regular expression
if(inputText.value.match(dateformat)) {
document.report_rti.d1.focus();
//Test which seperator is used '/' or '-'
var opera1 = inputText.value.split('/');
var opera2 = inputText.value.split('-');
lopera1 = opera1.length;
lopera2 = opera2.length;
// Extract the string into month, date and year
if (lopera1>1) {
var pdate = inputText.value.split('/');
} else if (lopera2>1) {
var pdate = inputText.value.split('-');
}
var dd = parseInt(pdate[2]);
var mm = parseInt(pdate[1]);
var yy = parseInt(pdate[0]);
// Create list of days of a month [assume there is no leap year by default]
var ListofDays = [31,28,31,30,31,30,31,31,30,31,30,31];
if(mm >12){
document.report_rti.d2.focus();
alert('Month should be less than twelve!!! \nInvalid date format!');
return false;
}
if (mm==1 || mm>2) {
if (dd>ListofDays[mm-1]) {
document.report_rti.d2.focus();
alert('Date exceeded!!! \nInvalid date format!');
return false;
}
else {
return true;
}
}
if (mm==2) {
var lyear = false;
if ( (!(yy % 4) && yy % 100) || !(yy % 400)) {
lyear = true;
}
if ((lyear==false) && (dd>=29)) {
alert('Date exceeded!!! \nInvalid date format!');
document.report_rti.d2.focus();
return false;
}
else if ((lyear==true) && (dd>29)) {
alert('Date exceeded!!! \nInvalid date format!');
document.report_rti.d2.focus();
return false;
}
else {
return true;
}
}
}
else {
alert("Date format is not correct!!!! \nInvalid date format!");
document.report_rti.d2.focus();
return false;
}
}
</script>
<?php
if(isset($_POST['enter'])){
include 'config_database.php';
$d1=$_POST['d1'];
$d2=$_POST['d2'];
// $d1=date('Y-m-d',);
//$d2=date('Y-m-d',$_POST['d2']);
$query="SELECT * FROM add_rti where (date_of_receipt_cio>='".$d1."' and date_of_receipt_cio<='".$d2."');";
$res=mysqli_query($con,$query);
echo "<table class='table table-bordered'>" ;
echo "<tr>
<th>ID</th>
<th>Applicant Name</th>
</tr>";
while($r=mysqli_fetch_assoc($res))
{
echo "<tr>";
echo "<td>";
echo $r['id'];
echo "</td>";
echo "<td>";
echo $r['name'];
echo "</td>";
}
echo "</table>";
}
?>
<br><a href=select_option.php class=btn>Back</a>
</div>
</body>
</html>