-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_response.php
51 lines (50 loc) · 1.61 KB
/
view_response.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
<?php
extract($_GET);
?>
<script src="./js/form-builder.js"></script>
<div class="row">
<div class="col-lg-12">
<div class="card bg-primary text-white">
<div class="card-body">
<h3><b>Response</b></h3>
</div>
</div>
</div>
</div>
<hr class="border-dark">
<?php
include "./forms/".$code.".html";
$responses = $db->conn->query("SELECT * FROM `responses` where rl_id = $id");
$data = array();
while($row = $responses->fetch_assoc()){
$data[$row['meta_field']]['value'] = $row['meta_value'];
$data[$row['meta_field']]['type'] = "text";
if(is_file("./uploads/".$row['meta_value'])){
$data[$row['meta_field']]['type'] = "file";
}
}
?>
<script>
$('#form-buidler-action').remove()
$('.question-item .card-footer, .item-move,[name="choice"],.add_chk, .add_radio,.rem-on-display').remove()
$('[contenteditable]').each(function() {
$(this).removeAttr('contenteditable')
})
$('.question-item .choice-field').html('')
var data = $.parseJSON('<?php echo json_encode($data) ?>');
$(function(){
$('.question-item').each(function(){
var item = $(this).attr('data-item')
if(!!data[item] && data[item]['type'] == 'file'){
var el = $("<a download>")
el.attr({
href:"./uploads/"+data[item]['value']
})
el.text(data[item]['value'])
$(this).find('.choice-field').append(el)
}else{
$(this).find('.choice-field').append(data[item]['value'])
}
})
})
</script>