-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrule_list.php
207 lines (193 loc) · 6.21 KB
/
rule_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
<?php
/********************************
* File Name: rule_list.php *
* Author: Ammar S.A.A *
* Output: Rules & 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 tblrulesandregulations 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 * FROM tblrulesandregulations
#ORDER BY id DESC";
if(isset($_POST['search']) && !empty($_POST['search'])){
$search = trim($_POST['search']);
$sql="SELECT * FROM tblrulesandregulations
WHERE rule LIKE '%{$search}%'
OR rule_urdu LIKE '%{$search}%'
OR creation_date LIKE '%{$search}%'
OR updation_date LIKE '%{$search}%'
";
}
$result = $conn->query($sql);
if (isset($msg))
{
echo $msg;
}
$row='';
$read_more = '';
if (isset($_GET['read_more'])) {
$read_more = $_GET['read_more'];
$id= $_GET['read_more'];
$sql= "SELECT * FROM tblrulesandregulations WHERE id={$id}";
$result = $conn->query($sql);
if ($result && $result->num_rows > 0) {
$row = $result->fetch_assoc();
$id = $row['id'];
$rule = $row['rule'];
$rule_urdu = $row['rule_urdu'];
$creation_date = $row['creation_date'];
}
}
?>
<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="rule_list.php">Rules & Regulations</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-->
<?php if (!IfIsUser($conn)) { ?>
<a class="btn btn-outline-primary" href="rule_add.php" role="button"> Add New </a>
<?php } ?>
</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">Rule</th>
<th class="urdu text-nowrap">اصول</th>
<th class="text-nowrap">Creation Date</th>
<th class="text-nowrap">Updation Date</th>
<?php
if (IfIsUser($conn)) {
echo "";
}else{
echo "<th colspan='2' class='text-nowrap'>Action</th>";
?>
<?php
}
?>
</tr>
</thead>
<tbody>
<?php
if ($result){
foreach ($result as $row) {
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td class="text-truncate">
<?php
if (isset($_GET['read_more'])) {
echo $row['rule'];
}else{
echo substr($row['rule'],0,50)."...";
?>
<a href="<?php echo WEBSITE_URL.'rule_list.php?read_more='.$row['id'] ?>">Read More</a>
<?php } ?>
</td>
<td class="urdu text-truncate">
<?php
if (isset($_GET['read_more'])) {
echo $row['rule_urdu'];
}else{
echo substr($row['rule_urdu'],0,100)."......";
?>
<a href="<?php echo WEBSITE_URL.'rule_list.php?read_more='.$row['id'] ?>">مزید پڑھیں</a>
<?php } ?>
</td>
<?php
if (IfIsUser($conn)) {
echo "";
}else{
?>
<td><?php echo $row['creation_date'] ?></td>
<td><?php echo $row['updation_date'] ?></td>
<td>
<button role="button" class="btn btn-warning btn-sm">
<a href="<?php echo WEBSITE_URL. 'rule_add.php?id='.$row['id']; ?> ">
<i class="display-5 glyphicon glyphicon-edit"></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='11'><p>No record found for <b>{$search}</b></p></td></tr>";
}
?>
</tbody>
<tfoot class="tfoot tfoot-light">
<td colspan="11">
<?php
if (isset($search)) {
GetTotalSearchResult($conn,$result,$search);
}else{
$total_rules = GetTotal($conn, TBLRULESANDREGULATIONS);
echo "Showing total <b>".$total_rules."</b> of <b>".$total_rules."</b> ";
if ($total_rules > 1) {
echo "results.";
}else{ echo "result.";}
}
?>
</td>
</tfoot>
</table>
</div>
</div>
<br />
</div>
</div>
</section>
</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. 'rule_list.php?action=delete&id=' ?>"+id;
}
}
</script>
<?php
include(WEBSITE_PATH.'./includes/footer.php');
?>