Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions communications.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,37 @@
* Show the latest calls and texts in the $comms variable.
*
*/

require_once 'config.php';
require_once $LIB_BASE . 'lib_sms.php';

// URL parameters
$start = (int)$_REQUEST['s'];
$mark = (int)$_REQUEST['mark'];
$unmark = (int)$_REQUEST['unmark'];

// Settings
$page = 50;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be unrelatedto what you wrote but this variable confuses me. what is page?


// Mark an item as responded, or not responded
if ($mark) {
sms_markCommunication($mark, true /* mark responded */, $error);
} else if ($unmark) {
sms_markCommunication($unmark, false /* mark not responded */, $error);
}

db_databaseConnect();
// Communications
$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 ".
"ORDER BY communication_time DESC LIMIT ".addslashes($start).",{$page}";
if (!db_db_query($sql, $comms, $error)) {
echo $error;
}


?>
<div class="table-responsive">
<table class="table table-striped">
Expand Down Expand Up @@ -94,3 +125,7 @@
</tbody>
</table>
</div>
<?php

db_databaseDisconnect();
?>
26 changes: 24 additions & 2 deletions log.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@
<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>
<?php
<!-- ?php
include 'communications.php';

?>
? -->
<div id="auto_refresh_div"></div>
<p>
<?php
// show the previous button if we are not at the beginning
Expand All @@ -67,3 +68,24 @@
include 'footer.php';

?>
<!-- Autorefresh logs -->
<script>
function auto_refresh(){
$.ajax({
url: "communications.php",
cache: false,
success: function(data){
$("#auto_refresh_div").html(data);
}
});
}

$(document).ready(function(){

auto_refresh(); //Call auto_load() function when DOM is Ready

});

//Refresh auto_refresh() function after 10000 milliseconds
setInterval(auto_refresh,10000);
</script>