forked from Bkoech/gbvis
-
Notifications
You must be signed in to change notification settings - Fork 1
/
indicators.php
executable file
·202 lines (159 loc) · 6.71 KB
/
indicators.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
<?php
/*********************************************************************
* Author: Benard Koech
* Email: [email protected].
* Gender Base violence Information system
***********************************************************************/
//users_accounts.php
$page_title = "indicators| GBV";
$current_page = "indicators";
require_once 'includes/global.inc.php';
// Same as error_reporting(E_ALL);
ini_set("error_reporting", E_ALL);
//check to see if they're logged in
if(isset($_SESSION['logged_in'])) {
//get the user object from the session
$user = unserialize($_SESSION['user']);
//initialize php variables used in the form
$id = "";
$indicator = "";
$survey= "";
$sector = "";
$error = "";
//check to see that the form has been submitted
//include "includes/Dash_header.php";include "includes/topbar.php"; //TA:60:1
include "includes/Dash_header.php";
include "includes/topbar.php"; //TA:60:1
include_once('includes/connection.php');
include_once('includes/functions.php');
?>
<div id="sidebar">
<center><h3 style="text-size:18px; font-family: TStar-Bol"></h3></center>
<div class="sidebar-nav">
<?php
include "includes/sidebar.php";
?>
</div>
</div>
<div id="main-content_with_side_bar">
<div id="bread-crumbs">
<!--breadcrumbs-->
</div>
<div id="content-body">
<h3 class="page-title">Indicators</h3>
<br clear="all">
<div class="" align="left">
<section class="" style="width:85%;">
<form action="#">
<input type="text" name="search" value="" id="id_search" placeholder="Filter records here" autofocus />
<a class="link-btn" href="add_indicator.php">New Indicator</a>
<a class="link-btn" href="export_indicatorCsv.php">Export to csv</a>
<a class="link-btn" href="export_indicatorsExcel.php">Export to excel</a>
</form>
</section>
<hr size="1" color="#CCCCCC">
<div class="profile-data" align="left">
<?php
if (isset($_GET['id'])) {
$query = "DELETE FROM indicators WHERE indicator_id= '$_GET[id]'";
mysql_query($query) or die(mysql_error());
}
?>
<table width="100%" border="0" align="center" cellspacing="1" class="table-hover">
<thead>
<th align="left" width="20px"><b>ID</b></th>
<th align="left"><b>Indicator</b></th>
<th align="left"><b>Sector </b></th>
<th align="left"><b>Date</b></th>
<th align="left"><b><center>View</center></b></th>
<th align="left"><b><center>Edit</center></b></th>
<th align="left"><b><center>Delete</center></b></th>
</thead>
<?php
$page = (int)(!isset($_GET["page"]) ? 1 : $_GET["page"]);
if ($page <= 0) $page = 1;
$per_page = 10; // Set how many records do you want to display per page.
$startpoint = ($page * $per_page) - $per_page;
$statement = "`indicators` ORDER BY indicator_id ASC"; // Change `records` according to your table name.
//$where ="'sector_id'= $user_sector_name";
$results = mysqli_query($conDB,"SELECT * FROM {$statement} LIMIT {$startpoint} , {$per_page}");
if (mysqli_num_rows($results)!= 0) {
// displaying records.
while ($row = mysqli_fetch_array($results)) {
$id= $row['indicator_id'];
$indicator = $row['indicator'];
$sector = $row['sector_id'];
$date =$row['date_recorded'];
?>
<tr bgcolor="#FFFFFF" style="border-bottom: 1px solid #B4B5B0;">
<td><?php echo $id; ?></td>
<td><?php echo $indicator ?></td>
<?php
$sectors_results = $db->selectData("sectors"," sector_id = $sector");
foreach ($sectors_results as $urows)
{
$sector = $urows['sector_id'];
$sector_name = $urows['sector'];
}
?>
<td><?php echo $sector_name ?></td>
<td><?php echo $date ?></td>
<td align="center"><a href='view_indicators.php?id=<?php echo $id;?>'><img src="UI/images/icons/view2.png" height="20px"/><a></td>
<td align="center"><a href='edit_indicator.php?id=<?php echo $id;?>'><img src="UI/images/icons/edit2.png" height="20px"/></a></td>
<td align="center"><a href="javascript:void(0)" onclick='show_confirm(<?php echo $id; ?>);'><img src="UI/images/icons/delete.png" height="20px"/></a></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td colspan="8"><?php echo "No records are found.";?></td>
</tr>
<?php }
// displaying paginaiton.
?>
<tr>
<td colspan="8"><?php echo pagination($statement,$per_page,$page,$url='?');?></td>
</tr>
</table>
<br clear="all"><br clear="all"><br clear="all">
</div><br clear="all">
</div>
</div>
</div>
<br clear="all">
<!--Pop up starts here -->
<div id="light" class="white_content"><div class="popup-area"><div class="popup-top-menu"><section style="float:left;"></section><section style="float:right;"><a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></section></div>
<div class="popup-Content">This is the lightbox content.
</div>
</div>
<!--Pop up ends here -->
<!--filter includes-->
<script type="text/javascript" src="css/filter-as-you-type/jquery.min.js"></script>
<script type="text/javascript" src="css/filter-as-you-type/jquery.quicksearch.js"></script>
<script type="text/javascript">
$(function() {
$('input#id_search').quicksearch('table tbody tr');
});
</script>
<script>
function show_confirm(id) {
if (confirm("Are you Sure you want to delete?")) {
location.replace('indicators.php?id=' + id);
} else {
return false;
}
}
</script>
</div>
<?php
include "includes/footer.php";
}
else
{
//Redirect user back to login page if there is no valid session created
header("location: login.php");
}
?>