-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsurvey_widget.php
More file actions
84 lines (83 loc) · 2.79 KB
/
survey_widget.php
File metadata and controls
84 lines (83 loc) · 2.79 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
<?php include 'db_connect.php' ?>
<?php
$answers = $conn->query("SELECT distinct(survey_id) from answers where user_id ={$_SESSION['login_id']}");
$ans = array();
while($row=$answers->fetch_assoc()){
$ans[$row['survey_id']] = 1;
}
?>
<div class="col-lg-12">
<div class="d-flex w-100 justify-content-center align-items-center mb-2">
<label for="" class="control-label">Find Survey</label>
<div class="input-group input-group-sm col-sm-5">
<input type="text" class="form-control" id="filter" placeholder="Enter keyword...">
<span class="input-group-append">
<button type="button" class="btn btn-primary btn-flat" id="search">Searh</button>
</span>
</div>
</div>
<div class=" w-100" id='ns' style="display: none"><center><b>No Result.</b></center></div>
<div class="row">
<?php
$survey = $conn->query("SELECT * FROM survey_set where '".date('Y-m-d')."' between date(start_date) and date(end_date) order by rand() ");
while($row=$survey->fetch_assoc()):
?>
<div class="col-md-3 py-1 px-1 survey-item">
<div class="card card-outline card-primary">
<div class="card-header">
<h3 class="card-title"><?php echo ucwords($row['title']) ?></h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse">
<i class="fas fa-minus"></i>
</button>
</div>
</div>
<div class="card-body" style="display: block;">
<?php echo $row['description'] ?>
<div class="row">
<hr class="border-primary">
<div class="d-flex justify-content-center w-100 text-center">
<?php if(!isset($ans[$row['id']])): ?>
<a href="index.php?page=answer_survey&id=<?php echo $row['id'] ?>" class="btn btn-sm bg-gradient-primary"><i class="fa fa-pen-square"></i> Take Survey</a>
<?php else: ?>
<p class="text-primary border-top border-primary">Done</p>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
<script>
function find_survey(){
start_load()
var filter = $('#filter').val()
filter = filter.toLowerCase()
console.log(filter)
$('.survey-item').each(function(){
var txt = $(this).text()
if((txt.toLowerCase()).includes(filter) == true){
$(this).toggle(true)
}else{
$(this).toggle(false)
}
if($('.survey-item:visible').length <= 0){
$('#ns').show()
}else{
$('#ns').hide()
}
})
end_load()
}
$('#search').click(function(){
find_survey()
})
$('#filter').keypress(function(e){
if(e.which == 13){
find_survey()
return false;
}
})
</script>