Vicidial incoming Call Report
create an all calls report in a nice table with the phone number, date and time of call, term reason, seconds per call, and agent on the call using this code
Create call_report.php in /srv/www/htdocs
<?php
$url1=$_SERVER['REQUEST_URI'];
header("Refresh: 40; URL=$url1");
echo "<h1>Calls Past 7 Days</h1>";
echo "<h5>*Refreshes every 40s</h5>";
$servername="localhost";
$username="cron";
$password="1234";
$dbname="asterisk";
$conn=new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query="select phone_number, call_date, status, term_reason, length_in_sec, user from vicidial_log where call_date > timestampadd(day, -7, now()) ;";
$result=$conn->query($query);
if ($result->num_rows > 0) {
// output data of each row
echo '<table border=1px>';
echo '<th>Caller ID Number</th><th>Call Time</th><th>Status</th><th>Term Reason</th><th>Agent</th><th>Call Length</th>';
while($row = $result->fetch_assoc()) {
echo '<tr>';
echo "<td>" . $row["phone_number"]. "</td><td>" . $row["call_date"] . "</td><td>" . $row["status"] . "</td><td>" . $row["term_reason"] . "</td><td>" . $row["user"] . "</td><td>" . $row["length_in_sec"] . "</td></tr>";
}
} else {
echo "0 results";
}
$conn->close();
?>
Comments
Post a Comment