-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcommunications.php
More file actions
96 lines (95 loc) · 3.06 KB
/
communications.php
File metadata and controls
96 lines (95 loc) · 3.06 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
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* @file
* Communications table
*
* Show the latest calls and texts in the $comms variable.
*
*/
?>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>when</th>
<th>from</th>
<th>to</th>
<th>content</th>
<th>type</th>
<th>response</th>
</tr>
</thead>
<tbody>
<?php
// is the number to dial from specified?
$from_url = !empty($from) ? ("&from=" . urlencode($from)) : '';
foreach ($comms as $comm) {
$not_responded = !$comm['responded'] && array_key_exists($comm['phone_to'], $HOTLINES) &&
($comm['status'] == 'text' || $comm['status'] == 'voicemail') &&
strtolower($comm['body']) != 'off' && strtolower($comm['body']) != 'on';
?>
<tr <?php if ($not_responded) echo 'class="warning"' ?>>
<td><?php echo date("m/d/y h:i a", strtotime($comm['communication_time'])); ?></td>
<td><?php
// the "from" number
echo '<a href="contact.php?ph=' . urlencode($comm['phone_from']) . $from_url . '">' . $comm['phone_from'] . '</a>';
if ($comm['from_contact']) {
echo " ({$comm['from_contact']})";
}
?></td>
<td><?php
// the "to" number
echo '<a href="contact.php?ph=' . urlencode($comm['phone_to']) . $from_url . '">' . $comm['phone_to'] . '</a>';
if ($comm['to_contact']) {
echo " ({$comm['to_contact']})";
}
?></td>
<td><?php
// the text body, voicemail link or other information
if (substr($comm['body'], 0, 22) == 'https://api.twilio.com') {
echo 'Voicemail: <a href="' . $comm['body'] . '">[listen]</a>';
} else {
echo $comm['body'];
}
// media
if ($comm['media_urls']) {
// display media received
echo "<br />Media: ";
$items = explode("\n", $comm['media_urls']);
foreach ($items as $item) {
if (!trim($item)) {
// skip blank lines
continue;
}
$detail = explode("\t", $item);
echo '<a href="'.$detail[0].'">['.$detail[1].']</a> ';
}
}
?></td>
<td><?php echo $comm['status']; ?></td>
<td>
<?php
if ($comm['responded']) {
$unmark_url = $_SERVER['PHP_SELF'] . "?ph=".urlencode($ph)."&s={$start}&unmark={$comm['id']}";
$responded_time = date("m/d/y h:i a", strtotime($comm['responded']));
?>
<a href="<?php echo $unmark_url ?>" title="Click to mark as not responded"><?php echo $responded_time ?></a>
<?php
} else if ($not_responded) {
$mark_url = $_SERVER['PHP_SELF'] . "?ph=".urlencode($ph)."&s={$start}&mark={$comm['id']}";
?>
<a class="btn btn-warning" title="Click to mark as responded" href="<?php echo $mark_url ?>" role="button">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
<span class="sr-only">Mark responded</span>
</a>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>