-
Notifications
You must be signed in to change notification settings - Fork 0
/
survey_widget.php
155 lines (114 loc) · 3.67 KB
/
survey_widget.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
<?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="d-flex w-100 justify-content-center align-items-center mb-2">
</div>
<div class="d-flex w-100 justify-content-center align-items-center mb-2">
</div>
<div class="d-flex w-100 justify-content-center align-items-center mb-2">
</div>
<div class="d-flex w-100 justify-content-center align-items-center mb-2">
</div>
<div class="d-flex w-100 justify-content-center align-items-center mb-2">
</div>
<div class="d-flex w-100 justify-content-center align-items-center mb-2">
</div>
<div class="col-lg-12">
<div class="d-flex w-100 justify-content-center align-items-center mb-2">
</div>
</div>
<div class="row">
<?php
$mail = $_SESSION['login_email'];
$survey = $conn->query("SELECT s.id, s.title, s.description, s.start_date, s.end_date FROM survey_set AS s, users as u WHERE FIND_IN_SET(s.title,u.serv) and u.email = '" . $mail . "' ");
while ($row = $survey->fetch_assoc()) :
?>
<div class="col-sm py-1 px-1 survey-item">
<div class="card card-outline card-primary">
<div class="card-header">
<h3 class="card-title" style="text-align:center;"><?php echo ucwords($row['title']) ?></h3>
<h6 style="text-align:center;">
<?php echo ucwords($row['description']) ?>
</h6>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse">
</button>
</div>
</div>
<div class="card-body" style="display: block;">
<div class="row">
<hr class="border-primary">
<br>
<br />
</div>
<?php
$usid = $_SESSION['login_id'];
?>
<div style="text-align:center;">
<i class="fas fa-fw fa-window-restore"></i> <a href="http://localhost/mxp/app.php?page=answer_survey&id=<?php echo $row['id'] ?>&usid=<?php echo $usid ?>" onclick="copyURI(event)" id="myInput">Copier Le lien</a>
</div>
<!-- The button used to copy the text -->
<div style="text-align:center;">
<i class="fas fa-fw fa-window-restore"></i> <a href="http://localhost/mxp/app.php?page=qr&id=<?php echo $row['id'] ?>&usid=<?php echo $usid ?>" onclick="fun()" id="myInput">QR Code</a>
<script src="https://cdn.rawgit.com/davidshimjs/qrcodejs/gh-pages/qrcode.min.js"></script>
</div>
<div id="qrcode"></div>
<script>
function fun() {
window.location.replace("http://localhost/mxp/");
}
</script>
<script>
function copyURI(evt) {
evt.preventDefault();
navigator.clipboard.writeText(evt.target.getAttribute('href')).then(() => {
/* clipboard successfully set */
}, alert_toast("copied.", 'success'), () => {
/* clipboard write failed */
});
}
</script>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
<script src="pj/assets/js/vendor.min.js"></script>
<script src="pj/assets/js/app.min.js"></script>
<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>