-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.php
93 lines (79 loc) · 2.62 KB
/
view.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
<?php
define('VIEW_MODE', TRUE);
include('include/header.php');
if(get('id'))
{
if(get('send') == 1)
{
sendCallToServer(get('id'), REMOTE_UPLOAD_SERVER);
}
?>
<div id="jquery_jplayer"></div>
<script type="text/javascript">
$(function(){
$("#jquery_jplayer").jPlayer();
$(".recording").click(function(e) {
$("#jquery_jplayer").jPlayer("setFile", $(this).attr("href")).jPlayer("play");
$(this).blur();
return false;
});
});
</script>
<?php
include('survey.php');
$labels = array();
foreach($questions as $q)
$data[$q['key']] = $q;
$call = db()->prepare('SELECT * FROM `calls` WHERE `id` = :id');
$call->bindParam(':id', get('id'));
$call->execute();
$call = $call->fetch(PDO::FETCH_ASSOC);
echo '<table class="callDetails">';
echo '<tr><td>Date:</td><td>' . date('F j, Y g:ia', strtotime($call['date'])) . '</td></tr>';
echo '<tr><td>Caller ID:</td><td>' . $call['callerID'] . '</td></tr>';
echo '</table>';
$query = db()->prepare('SELECT `id`, `key`, `value`, `recording` FROM `responses` WHERE `callID` = :id');
$query->bindParam(':id', get('id'));
$query->execute();
$responses = array();
while($q = $query->fetch(PDO::FETCH_ASSOC))
$responses[$q['key']] = $q;
echo '<table class="responses" cellpadding="0" cellspacing="0">';
foreach($responses as $r)
{
if(array_key_exists($r['key'], $data) && array_key_exists('lookup', $data[$r['key']]))
{
$lookup = $data[$r['key']]['lookup'];
$query = db()->prepare('SELECT ' . $lookup['value'] . ' AS val FROM ' . $lookup['table'] . ' WHERE ' . $lookup['key'] . ' = :key');
$query->bindValue(':key', $r['value']);
$query->execute();
$value = $query->fetch(PDO::FETCH_ASSOC);
$value = $value['val'];
}
else
$value = $r['value'];
echo '<tr>';
echo '<td class="key">' . (array_key_exists($r['key'], $data) && array_key_exists('name', $data[$r['key']]) ? $data[$r['key']]['name'] : $r['key']) . '</td>';
echo '<td class="value">' . $value . '</td>';
echo '<td class="listen">' . ($r['recording'] ? '<a href="recordings/' . $r['recording'] . '" id="recording_' . $r['id'] . '" class="recording">listen</a>' : '') . '</td>';
echo '</tr>';
}
echo '</table>';
}
else
{
$calls = db()->query('SELECT * FROM `calls` ORDER BY `date` DESC');
echo '<table>';
foreach($calls as $call)
{
echo '<tr>';
echo '<td><a href="?id=' . $call['id'] . '">' . $call['date'] . '</a></td>';
echo '<td>' . $call['callerID'] . '</td>';
#echo '<td>' . $call['dateFinished'] . '</td>';
#echo '<td>' . ((strtotime($call['dateFinished']) - strtotime($call['date'])) / 60) . '</td>';
echo '</tr>';
}
echo '</table>';
}
include('include/footer.php');
?>