Update xml_cdr.php (#2942)

Add check for duplicate call records. Duplicate records will cause the entire db insert to fail. I have tested this with the /app/xml_cdr/xml_cdr_import.php method for cdr insertion.
This commit is contained in:
konradSC 2018-01-09 13:01:10 -05:00 committed by FusionPBX
parent e8b8f559c3
commit 0170979401
1 changed files with 329 additions and 304 deletions

View File

@ -236,6 +236,30 @@ if (!class_exists('xml_cdr')) {
//$this->log("\nfail loadxml: " . $e->getMessage() . "\n");
}
//Check for duplicate call uuid's
$duplicate_uuid = false;
$uuid = check_str(urldecode($xml->variables->uuid));
if($uuid != null) {
//Check in the database
$database = new database;
$database->table = "v_xml_cdr";
$where[1]["name"] = "uuid";
$where[1]["operator"] = "=";
$where[1]["value"] = "$uuid";
$database->where = $where;
$result = $database->count();
if ($result > 0) {
$duplicate_uuid = true;
}
unset($where,$result,$database);
//Check in the array
if (isset($this->array)) foreach ($this->array as $row) {
if (in_array($uuid,$row,true))
$duplicate_uuid = true;
}
}
if ($duplicate_uuid == false) {
//get the destination number
if ($xml->variables->current_application == "bridge") {
$current_application_data = urldecode($xml->variables->current_application_data);
@ -574,6 +598,7 @@ if (!class_exists('xml_cdr')) {
}
unset($sql);
}
}
/**
* get xml from the filesystem and save it to the database