-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlog.php
More file actions
125 lines (114 loc) · 3.89 KB
/
log.php
File metadata and controls
125 lines (114 loc) · 3.89 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
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
<?php
/**
* @file
* Communications log
*
* Show the latest calls and texts.
*
*
*/
require_once 'config.php';
require_once $LIB_BASE . 'lib_sms.php';
include 'header.php';
// URL parameters
$start = isset($_REQUEST['s']) ? (int)$_REQUEST['s'] : 0;
$mark = isset($_REQUEST['mark']) ? (int)$_REQUEST['mark'] : 0;
$unmark = isset($_REQUEST['unmark']) ? (int)$_REQUEST['unmark'] : 0;
$ph = isset($_REQUEST['ph']) ? trim($_REQUEST['ph']) : '';
// Settings
$page = 50;
// Mark an item as responded, or not responded
if ($mark) {
sms_markCommunication($mark, true /* mark responded */, $error);
} elseif ($unmark) {
sms_markCommunication($unmark, false /* mark not responded */, $error);
}
// Communications
// build the query to specify which numbers to select
$where_sql_array = array();
if (isset($BROADCAST_CALLER_IDS) && $ph == 'all_broadcast') {
// show logs for all broadcast numbers
foreach ($BROADCAST_CALLER_IDS as $number) {
$where_sql_array[] =
"communications.phone_from = '".addslashes($number)."' OR ".
"communications.phone_to = '".addslashes($number)."'";
}
} else {
// show logs just for a single number
$where_sql_array[] =
"communications.phone_from = '".addslashes($ph)."' OR ".
"communications.phone_to = '".addslashes($ph)."'";
}
$sql = "SELECT communications.*,contacts_from.contact_name AS from_contact, contacts_to.contact_name AS to_contact ".
"FROM communications ".
"LEFT JOIN contacts AS contacts_from ON contacts_from.phone = communications.phone_from ".
"LEFT JOIN contacts AS contacts_to ON contacts_to.phone = communications.phone_to ".
($ph ? ("WHERE " . implode(" OR ", $where_sql_array) . " ") : '') .
"ORDER BY communication_time DESC LIMIT ".addslashes($start).",{$page}";
if (!db_db_query($sql, $comms, $error)) {
?><div class="alert alert-danger" role="alert"><?php echo $error ?></div><?php
}
?>
<h2 class="sub-header">Log</h2>
<p>Click a phone number to view all communications with that number. Click the response button or link to mark or
unmark an item as responded to.</p>
<form id="choose_number" action="log.php" method="GET" class="form-inline">
<input type="hidden" name="s" value="<?php echo $start ?>">
<div class="form-group">
<label for="text-message">View log for:</label>
<select class="form-control" name="ph" onChange="this.form.submit()">
<option value="">(all numbers)</option>
<?php
foreach ($HOTLINES as $hotline_number => $hotline) {
?>
<option value="<?php echo $hotline_number ?>"
<?php if ($ph == $hotline_number) {
echo "selected";
} ?>><?php echo $hotline_number ?> (<?php echo $hotline['name'] ?>)</option>
<?php
}
if (isset($BROADCAST_CALLER_IDS)) {
?>
<option value="all_broadcast" <?php if ($ph == 'all_broadcast') {
echo "selected";
} ?>>(all broadcast numbers)</option>
<?php
foreach ($BROADCAST_CALLER_IDS as $broadcast_caller_id) {
?>
<option value="<?php echo $broadcast_caller_id ?>"
<?php if ($ph == $broadcast_caller_id) {
echo "selected";
} ?>><?php echo $broadcast_caller_id ?> (Broadcast)</option>
<?php
}
}
?>
</select>
</div>
<button class="btn btn-success" id="button-text">View</button>
</form>
<?php
include 'communications.php';
?>
<p>
<?php
// show the previous button if we are not at the beginning
if ($start > 0) {
?>
<a class="btn btn-success" href="log.php?s=<?php echo $start - $page ?>&ph=<?php echo urlencode($ph) ?>" role="button"><< Prev</a>
<?php
}
// show the next button if there are more to show
if (count($comms) >= $page) {
?>
<a class="btn btn-success" href="log.php?s=<?php echo $start + $page ?>&ph=<?php echo urlencode($ph) ?>" role="button">Next >></a>
<?php
}
?>
</p>
<?php
// form for exporting of data
$export['phone'] = $ph;
include 'communications_export.php';
include 'footer.php';
?>