FreePBX | Register | Issues | Wiki | Portal | Support

Asterisk CDR Database


(Zia Afridi) #1

By default, asterisk will generate a CDR record in database for every call when hangup,
Is it possible to configure asterisk which generate CDR record in database when the call is answered by extension.
Aterisk version is 16.4(VitalPBX for GUI)


(Itzik) #2

This has nothing related to FreePBX.

Although people are asking here Asterisk questions, it’s mostly for servers that have FreePBX on top of it.

The right place to get Asterisk answers for non FreePBX products is community.asterisk.org


(Joshua C. Colp) #3

It’s not possible to configure Asterisk to do this. CDR records are for completed calls.


(Zia Afridi) #4

Dear @PitzKey,
I knew this is not place for such issue but i am stuck in this issue and try to get helps…
At asterisk 13.X and Asterisk 16.0 i was able to get Remote-Caller ID for current call from CDR using sample php file…
But After update to Asterisk 16.4, i can’t get Remote-Caller ID for current call from CDR using same php file.

Following is my php file

<?php
header('Access-Control-Allow-Origin: http://darewro.com', false);
if(!isset($_GET['extention_id'])){
	echo 0;
	exit();
	}
$extention_id = (int) $_GET['extention_id'];
if($extention_id>0){
	

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "asterisk";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "SELECT `cdr_id`, `src` FROM `cdr` WHERE `calltype`=2 AND `disposition`='ANSWERED' AND `dst`='".$extention_id."' ORDER BY `calldate` DESC LIMIT 1";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo $row["src"];
    }
} else {
    echo "No Call";
}
}else{
	echo 0;
	exit();
	}
$conn->close();
?>

(system) closed #5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.