Track Voicemail Message Success/Failure in CDR

Track whether or not a message was actually left in the voicemail box. Previously we only knew that voicemail answered, now we know whether the caller left a message.
Callers who didn't leave a message now show up in the "Cancelled" call filter in xml_cdr.php

Bonus: Fixed a bug with the originating_leg_uuid that was breaking extension summary from a previous commit and some other minor bugs/typos.
This commit is contained in:
demonspork
2021-02-21 21:09:37 -06:00
parent 0ef2551698
commit c11589b1c3
5 changed files with 53 additions and 13 deletions

View File

@@ -587,7 +587,7 @@
--if the recording is below the minimal length then re-record the message
if (message_length > 2) then
--continue
session:setVariable("voicemail_message_seconds", message_length);
else
if (session:ready()) then
--your recording is below the minimal acceptable length, please try again

View File

@@ -564,6 +564,12 @@
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Save the last application data.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "voicemail_message";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "boolean";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "missed_call";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "boolean";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";

View File

@@ -150,6 +150,7 @@ if (!class_exists('xml_cdr')) {
$this->fields[] = "rtp_audio_in_mos";
$this->fields[] = "last_app";
$this->fields[] = "last_arg";
$this->fields[] = "voicemail_message";
$this->fields[] = "cc_side";
$this->fields[] = "cc_member_uuid";
$this->fields[] = "cc_queue_joined_epoch";
@@ -391,6 +392,14 @@ if (!class_exists('xml_cdr')) {
$this->array[$key]['last_app'] = urldecode($xml->variables->last_app);
$this->array[$key]['last_arg'] = urldecode($xml->variables->last_arg);
//voicemail message success
if ($xml->variables->voicemail_action == "save" && $xml->variables->voicemail_message_seconds > 0){
$this->array[$key]['voicemail_message'] = "true";
}
else { //if ($xml->variables->voicemail_action == "save") {
$this->array[$key]['voicemail_message'] = "false";
}
//conference
$this->array[$key]['conference_name'] = urldecode($xml->variables->conference_name);
$this->array[$key]['conference_uuid'] = urldecode($xml->variables->conference_uuid);
@@ -922,13 +931,13 @@ if (!class_exists('xml_cdr')) {
if (strlen($this->start_stamp_begin) > 0 || strlen($this->start_stamp_end) > 0) {
unset($this->quick_select);
if (strlen($this->start_stamp_begin) > 0 && strlen($this->start_stamp_end) > 0) {
$sql_date_range .= " and start_stamp between :start_stamp_begin and :start_stamp_end \n";
$sql_date_range = " and start_stamp between :start_stamp_begin and :start_stamp_end \n";
$parameters['start_stamp_begin'] = $this->start_stamp_begin.':00.000';
$parameters['start_stamp_end'] = $this->start_stamp_end.':59.999';
}
else {
if (strlen($this->start_stamp_begin) > 0) {
$sql_date_range .= "and start_stamp >= :start_stamp_begin \n";
$sql_date_range = "and start_stamp >= :start_stamp_begin \n";
$parameters['start_stamp_begin'] = $this->start_stamp_begin.':00.000';
}
if (strlen($this->start_stamp_end) > 0) {
@@ -939,13 +948,13 @@ if (!class_exists('xml_cdr')) {
}
else {
switch ($this->quick_select) {
case 1: $sql_date_range .= "and start_stamp >= '".date('Y-m-d H:i:s.000', strtotime("-1 week"))."' \n"; break; //last 7 days
case 2: $sql_date_range .= "and start_stamp >= '".date('Y-m-d H:i:s.000', strtotime("-1 hour"))."' \n"; break; //last hour
case 3: $sql_date_range .= "and start_stamp >= '".date('Y-m-d')." "."00:00:00.000' \n"; break; //today
case 4: $sql_date_range .= "and start_stamp between '".date('Y-m-d',strtotime("-1 day"))." "."00:00:00.000' and '".date('Y-m-d',strtotime("-1 day"))." "."23:59:59.999' \n"; break; //yesterday
case 5: $sql_date_range .= "and start_stamp >= '".date('Y-m-d',strtotime("this week"))." "."00:00:00.000' \n"; break; //this week
case 6: $sql_date_range .= "and start_stamp >= '".date('Y-m-')."01 "."00:00:00.000' \n"; break; //this month
case 7: $sql_date_range .= "and start_stamp >= '".date('Y-')."01-01 "."00:00:00.000' \n"; break; //this year
case 1: $sql_date_range = "and start_stamp >= '".date('Y-m-d H:i:s.000', strtotime("-1 week"))."' \n"; break; //last 7 days
case 2: $sql_date_range = "and start_stamp >= '".date('Y-m-d H:i:s.000', strtotime("-1 hour"))."' \n"; break; //last hour
case 3: $sql_date_range = "and start_stamp >= '".date('Y-m-d')." "."00:00:00.000' \n"; break; //today
case 4: $sql_date_range = "and start_stamp between '".date('Y-m-d',strtotime("-1 day"))." "."00:00:00.000' and '".date('Y-m-d',strtotime("-1 day"))." "."23:59:59.999' \n"; break; //yesterday
case 5: $sql_date_range = "and start_stamp >= '".date('Y-m-d',strtotime("this week"))." "."00:00:00.000' \n"; break; //this week
case 6: $sql_date_range = "and start_stamp >= '".date('Y-m-')."01 "."00:00:00.000' \n"; break; //this month
case 7: $sql_date_range = "and start_stamp >= '".date('Y-')."01-01 "."00:00:00.000' \n"; break; //this year
}
}
@@ -1086,6 +1095,7 @@ if (!class_exists('xml_cdr')) {
$sql .= " direction, \n";
$sql .= " start_stamp, \n";
$sql .= " hangup_cause, \n";
$sql .= " originating_leg_uuid, \n";
$sql .= " billsec \n";
$sql .= " from v_xml_cdr \n";
if (!($_GET['show'] === 'all' && permission_exists('xml_cdr_all'))) {

View File

@@ -198,6 +198,14 @@
$database->fields['last_app'] = urldecode($xml->variables->last_app);
$database->fields['last_arg'] = urldecode($xml->variables->last_arg);
//voicemail message success
if ($xml->variables->voicemail_action == "save" && $xml->variables->voicemail_message_seconds > 0){
$database->fields['voicemail_message'] = "true";
}
elseif ($xml->variables->voicemail_action == "save") {
$database->fields['voicemail_message'] = "false";
}
//conference
$database->fields['conference_name'] = urldecode($xml->variables->conference_name);
$database->fields['conference_uuid'] = urldecode($xml->variables->conference_uuid);

View File

@@ -417,7 +417,7 @@
$sql .= "and hangup_cause like :hangup_cause ";
$parameters['hangup_cause'] = '%'.$hangup_cause.'%';
}
elseif (!permission_exists('xml_cdr_lose_race') && permission_exists('xml_cdr_enterprise_leg')) {
elseif (!permission_exists('xml_cdr_lose_race') && !permission_exists('xml_cdr_enterprise_leg')) {
$sql .= "and hangup_cause != 'LOSE_RACE' ";
}
//exclude enterprise ring group legs
@@ -437,10 +437,20 @@
break;
case 'cancelled':
if ($direction == 'inbound' || $direction == 'local' || $call_result == 'missed') {
$sql = "and (answer_stamp is null and bridge_uuid is null and sip_hangup_disposition <> 'send_refuse') ";
$sql .= "
and ((
answer_stamp is null
and bridge_uuid is null
and sip_hangup_disposition <> 'send_refuse'
)
or (
answer_stamp is not null
and bridge_uuid is null
and voicemail_message = false
))";
}
else if ($direction == 'outbound') {
$sql = "and (answer_stamp is null and bridge_uuid is not null) ";
$sql .= "and (answer_stamp is null and bridge_uuid is not null) ";
}
else {
$sql .= "
@@ -454,6 +464,12 @@
direction = 'outbound'
and answer_stamp is null
and bridge_uuid is not null
)
or (
(direction = 'inbound' or direction = 'local')
and answer_stamp is not null
and bridge_uuid is null
and voicemail_message = false
))";
}
break;