-
Notifications
You must be signed in to change notification settings - Fork 1
/
task.php
214 lines (159 loc) · 5.26 KB
/
task.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
<?php
ob_start();
session_start();
//error_reporting( E_ALL & ~E_DEPRECATED & ~E_NOTICE );
require_once 'connect.php';
// if session is not set this will redirect to login page
if( !isset($_SESSION['userName']) ) {
header("Location: login.php");
exit;
}else $userName = $_SESSION['userName'];
$id = htmlentities($_GET['id']);
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tasks</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="assets/css/font-awesome.min.css" type="text/css" />
<link rel="stylesheet" href="style.css" type="text/css" />
<style>
.btn-floating-container {
right: 80px;
bottom: 80px;
position: fixed;
z-index: 99;
}
.btn-floating {
width: 50px;
height: 50px;
border-radius: 50%;
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.2), 0 1px 1px 0 rgba(0, 0, 0, 0.2);
border: 1px solid rgba(245, 245, 245, 0.075);
text-align: center;
padding: 0px;
font-size: 24px;
background-color: green;
}
@media (max-width: 768px) {
.btn-floating-container {
right: 40px;
bottom: 40px;
}
}
</style>
</head>
<body>
<a href="logout.php?logout">Sign Out</a></li>
<a href="users.php">Users</a></li>
<div id="wrapper">
<div class="container">
<div class="btn-floating-container">
<button class="btn-floating btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm"><i class="fa fa-plus " aria-hidden="true"></i></button>
</div>
<?php
$result = mysqli_query($link, "SELECT `name`, `pirce` FROM `topics` WHERE `id`='".$id."'");
$row = $result->fetch_assoc();
echo "<h3>".$row['name']."</h3>";
$pirce = $row['pirce'];
echo "<h4>Rs".$pirce."</h5>";
?>
<div id="amt"></div>
<div style="width: 40%" >
<table class="table table-condensed table-bordered table-hover table-striped">
<thead>
<tr>
<th>#id</th>
<th>name</th>
<th>payment</th>
</tr>
</thead>
<tbody>
<?php
// $sql = "SELECT "
// . " users.id, users.name, task_reg.payment"
// . " FROM "
// . " task_reg "
// . " JOIN users ON users.id = task_reg.use_id "
// . " JOIN topics ON topics.id = task_reg.top_id "
// . " WHERE "
// . " topics.id=". $id;
$sql = "SELECT users.id, users.name, IFNULL(task_reg.payment, 0) AS payment "
. "FROM users "
. "LEFT JOIN task_reg ON users.id = task_reg.use_id "
. "LEFT JOIN topics ON topics.id = task_reg.top_id AND topics.id =". $id ." "
. "ORDER BY `users`.`name` ASC ";
echo($sql);
$result = mysqli_query($link, $sql);
$num_rows = mysqli_num_rows($result);
if($result)if ($result->num_rows ) {
while($row = $result->fetch_array()) {
$checkbox = ($row['payment']=='1') ? "checked" : "" ;
echo "<tr>";
echo "<td>" . $row["id"] . "</td>";
echo "<td>" . $row["name"] . "</td>";
echo "<td><input type='checkbox' class='cbx' usrid='".$row['id']."' topid='".$id."' ".$checkbox."></td>";
echo "</tr>";
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<form class="form-horizontal" action="users-ins.php" method="POST">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel2">New</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
function status() {
var n = $("input:checked").length;
var amt = '<?php echo $pirce;?>';
var str = amt+'x'+n+'='+'<b>'+(amt*n)+'</b>';
$("#amt").html(str);
}
status();
$(".cbx").click(function(){
var usr_id = $(this).attr('usrid');
var top_id = $(this).attr('topid');
var cbstat = $(this).is(':checked') ? 'ON' : 'OFF';
//console.log(ckb);
status();// move to on sucss inside ajax
$.post("process.php",{
usrid: usr_id,
topid: top_id,
cstat: cbstat
},
function(data) {
//alert(data);
//$('#form')[0].reset(); //To reset form fields after submission
$('#alert').fadeTo(2000,500).slideUp(500,function(){ //fade out
$('#alert').addClass('hiden'); //adds a class .hidden
});
});
});
});
</script>
</body>
</html>