Update call details
- Add pass objects into the constructor - details show local source and destination extensions
This commit is contained in:
parent
65aeefaea4
commit
355c0e692c
|
|
@ -33,10 +33,26 @@ if (!class_exists('xml_cdr')) {
|
|||
class xml_cdr {
|
||||
|
||||
/**
|
||||
* define variables
|
||||
* Internal array structure that is populated from the database
|
||||
* @var array Array of settings loaded from Default Settings
|
||||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* Set in the constructor. Must be a database object and cannot be null.
|
||||
* @var database Database Object
|
||||
*/
|
||||
private $database;
|
||||
|
||||
/**
|
||||
* Set in the constructor. This can be null.
|
||||
* @var destinations Object
|
||||
*/
|
||||
private $destinations;
|
||||
|
||||
/**
|
||||
* define variables
|
||||
*/
|
||||
public $array;
|
||||
public $fields;
|
||||
public $setting;
|
||||
|
|
@ -78,12 +94,26 @@ if (!class_exists('xml_cdr')) {
|
|||
/**
|
||||
* Called when the object is created
|
||||
*/
|
||||
public function __construct() {
|
||||
//connect to the database
|
||||
$this->database = new database;
|
||||
public function __construct($setting_array = []) {
|
||||
|
||||
//get the email queue settings
|
||||
$this->setting = new settings();
|
||||
//open a database connection
|
||||
if (empty($setting_array['database'])) {
|
||||
$this->database = database::new();
|
||||
} else {
|
||||
$this->database = $setting_array['database'];
|
||||
}
|
||||
|
||||
//get the settings object
|
||||
if (empty($setting_array['settings'])) {
|
||||
$this->settings = new settings();
|
||||
} else {
|
||||
$this->settings = $setting_array['settings'];
|
||||
}
|
||||
|
||||
//get the destinations object
|
||||
if (!empty($setting_array['destinations'])) {
|
||||
$this->destinations = $setting_array['destinations'];
|
||||
}
|
||||
|
||||
//assign private variables (for delete method)
|
||||
$this->app_name = 'xml_cdr';
|
||||
|
|
@ -100,23 +130,23 @@ if (!class_exists('xml_cdr')) {
|
|||
public function log($message) {
|
||||
|
||||
//save the log if enabled is true
|
||||
if ($this->setting->get('log', 'enabled', false)) {
|
||||
if ($this->settings->get('log', 'enabled', false)) {
|
||||
|
||||
//save the log to the php error log
|
||||
if ($this->setting->get('log', 'type') == 'error_log') {
|
||||
if ($this->settings->get('log', 'type') == 'error_log') {
|
||||
error_log($message);
|
||||
}
|
||||
|
||||
//save the log to the syslog server
|
||||
if ($this->setting->get('log', 'type') == 'syslog') {
|
||||
if ($this->settings->get('log', 'type') == 'syslog') {
|
||||
openlog("XML CDR", LOG_PID | LOG_PERROR, LOG_LOCAL0);
|
||||
syslog(LOG_WARNING, $message);
|
||||
closelog();
|
||||
}
|
||||
|
||||
//save the log to the file system
|
||||
if ($this->setting->get('log', 'text') == 'file') {
|
||||
$fp = fopen($this->setting->get('server', 'temp').'/xml_cdr.log', 'a+');
|
||||
if ($this->settings->get('log', 'text') == 'file') {
|
||||
$fp = fopen($this->settings->get('server', 'temp').'/xml_cdr.log', 'a+');
|
||||
if (!$fp) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -205,8 +235,8 @@ if (!class_exists('xml_cdr')) {
|
|||
$this->fields[] = "hangup_cause_q850";
|
||||
$this->fields[] = "sip_hangup_disposition";
|
||||
|
||||
if (!empty($this->setting->get('cdr', 'field'))) {
|
||||
foreach ($this->setting->get('cdr', 'field') as $field) {
|
||||
if (!empty($this->settings->get('cdr', 'field'))) {
|
||||
foreach ($this->settings->get('cdr', 'field') as $field) {
|
||||
$field_name = end(explode(',', $field));
|
||||
$this->fields[] = $field_name;
|
||||
}
|
||||
|
|
@ -226,8 +256,8 @@ if (!class_exists('xml_cdr')) {
|
|||
if (!empty($this->array)) {
|
||||
|
||||
//set the directory
|
||||
if (!empty($this->setting->get('switch', 'log'))) {
|
||||
$xml_cdr_dir = $this->setting->get('switch', 'log').'/xml_cdr';
|
||||
if (!empty($this->settings->get('switch', 'log'))) {
|
||||
$xml_cdr_dir = $this->settings->get('switch', 'log').'/xml_cdr';
|
||||
}
|
||||
|
||||
//add the temporary permission
|
||||
|
|
@ -316,8 +346,8 @@ if (!class_exists('xml_cdr')) {
|
|||
$xml = simplexml_load_string($xml_string, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
if ($xml === false) {
|
||||
//set the directory
|
||||
if (!empty($this->setting->get('switch', 'log'))) {
|
||||
$xml_cdr_dir = $this->setting->get('switch', 'log').'/xml_cdr';
|
||||
if (!empty($this->settings->get('switch', 'log'))) {
|
||||
$xml_cdr_dir = $this->settings->get('switch', 'log').'/xml_cdr';
|
||||
}
|
||||
|
||||
//failed to load the XML, move the XML file to the failed directory
|
||||
|
|
@ -335,11 +365,11 @@ if (!class_exists('xml_cdr')) {
|
|||
}
|
||||
|
||||
//skip call detail records for calls blocked by call block
|
||||
if (isset($xml->variables->call_block) && !empty($this->setting->get('call_block', 'save_call_detail_record'))) {
|
||||
if ($xml->variables->call_block == 'true' && $this->setting->get('call_block', 'save_call_detail_record') == 'false') {
|
||||
if (isset($xml->variables->call_block) && !empty($this->settings->get('call_block', 'save_call_detail_record'))) {
|
||||
if ($xml->variables->call_block == 'true' && $this->settings->get('call_block', 'save_call_detail_record') == 'false') {
|
||||
//delete the xml cdr file
|
||||
if (!empty($this->setting->get('switch', 'log'))) {
|
||||
$xml_cdr_dir = $this->setting->get('switch', 'log').'/xml_cdr';
|
||||
if (!empty($this->settings->get('switch', 'log'))) {
|
||||
$xml_cdr_dir = $this->settings->get('switch', 'log').'/xml_cdr';
|
||||
if (file_exists($xml_cdr_dir.'/'.$this->file)) {
|
||||
unlink($xml_cdr_dir.'/'.$this->file);
|
||||
}
|
||||
|
|
@ -368,8 +398,8 @@ if (!class_exists('xml_cdr')) {
|
|||
$duplicate_uuid = true;
|
||||
|
||||
//remove the file as the record already exists in the database
|
||||
if (!empty($this->setting->get('switch', 'log'))) {
|
||||
$xml_cdr_dir = $this->setting->get('switch', 'log').'/xml_cdr';
|
||||
if (!empty($this->settings->get('switch', 'log'))) {
|
||||
$xml_cdr_dir = $this->settings->get('switch', 'log').'/xml_cdr';
|
||||
if (file_exists($xml_cdr_dir.'/'.$this->file)) {
|
||||
unlink($xml_cdr_dir.'/'.$this->file);
|
||||
}
|
||||
|
|
@ -794,8 +824,8 @@ if (!class_exists('xml_cdr')) {
|
|||
}
|
||||
|
||||
//dynamic cdr fields
|
||||
if (!empty($this->setting->get('cdr', 'field'))) {
|
||||
foreach ($this->setting->get('cdr', 'field') as $field) {
|
||||
if (!empty($this->settings->get('cdr', 'field'))) {
|
||||
foreach ($this->settings->get('cdr', 'field') as $field) {
|
||||
$fields = explode(",", $field);
|
||||
$field_name = end($fields);
|
||||
$this->fields[] = $field_name;
|
||||
|
|
@ -907,7 +937,7 @@ if (!class_exists('xml_cdr')) {
|
|||
|
||||
//check to see if file exists with the default file name and path
|
||||
if (empty($record_name)) {
|
||||
$path = $this->setting->get('switch', 'recordings').'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day;
|
||||
$path = $this->settings->get('switch', 'recordings').'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day;
|
||||
if (file_exists($path.'/'.$uuid.'.wav')) {
|
||||
$record_path = $path;
|
||||
$record_name = $uuid.'.wav';
|
||||
|
|
@ -922,7 +952,7 @@ if (!class_exists('xml_cdr')) {
|
|||
//last check - check to see if file exists with the bridge_uuid for the file name and path
|
||||
if (empty($record_name)) {
|
||||
$bridge_uuid = urldecode($xml->variables->bridge_uuid) ?: $last_bridge;
|
||||
$path = $this->setting->get('switch', 'recordings').'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day;
|
||||
$path = $this->settings->get('switch', 'recordings').'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day;
|
||||
if (file_exists($path.'/'.$bridge_uuid.'.wav')) {
|
||||
$record_path = $path;
|
||||
$record_name = $bridge_uuid.'.wav';
|
||||
|
|
@ -957,7 +987,7 @@ if (!class_exists('xml_cdr')) {
|
|||
$this->json = json_encode($xml);
|
||||
|
||||
//save to the database in xml format
|
||||
if ($this->setting->get('cdr', 'format') == "xml" && $this->setting->get('cdr', 'storage') == "db") {
|
||||
if ($this->settings->get('cdr', 'format') == "xml" && $this->settings->get('cdr', 'storage') == "db") {
|
||||
$this->array[$key][0]['xml'] = $xml_string;
|
||||
}
|
||||
|
||||
|
|
@ -1009,7 +1039,7 @@ if (!class_exists('xml_cdr')) {
|
|||
$this->array[$key][0]['call_flow'] = json_encode($this->call_flow());
|
||||
|
||||
//save to the database in json format
|
||||
if ($this->setting->get('cdr', 'format') == "json" && $this->setting->get('cdr', 'storage') == "db") {
|
||||
if ($this->settings->get('cdr', 'format') == "json" && $this->settings->get('cdr', 'storage') == "db") {
|
||||
$key = 'xml_cdr_json';
|
||||
$this->array[$key][0]['xml_cdr_json_uuid'] = uuid();
|
||||
$this->array[$key][0]['xml_cdr_uuid'] = $uuid;
|
||||
|
|
@ -1018,10 +1048,10 @@ if (!class_exists('xml_cdr')) {
|
|||
}
|
||||
|
||||
//save the call log to the database
|
||||
if ($this->setting->get('cdr', 'call_log_enabled', false) && !empty($this->setting->get('switch', 'log')) && $this->setting->get('cdr', 'storage') == "db") {
|
||||
if ($this->settings->get('cdr', 'call_log_enabled', false) && !empty($this->settings->get('switch', 'log')) && $this->settings->get('cdr', 'storage') == "db") {
|
||||
//get the log content
|
||||
$log_content = '';
|
||||
$handle = @fopen($this->setting->get('switch', 'log').'/freeswitch.log', "r");
|
||||
$handle = @fopen($this->settings->get('switch', 'log').'/freeswitch.log', "r");
|
||||
if ($handle) {
|
||||
while (!feof($handle)) {
|
||||
$line = stream_get_line($handle, 0, "\n");
|
||||
|
|
@ -1044,13 +1074,13 @@ if (!class_exists('xml_cdr')) {
|
|||
}
|
||||
|
||||
//store xml cdr on the file system as a file
|
||||
if ($this->setting->get('cdr', 'storage') == "dir" && $error != "true") {
|
||||
if ($this->settings->get('cdr', 'storage') == "dir" && $error != "true") {
|
||||
if (!empty($uuid)) {
|
||||
$tmp_dir = $this->setting->get('switch', 'log').'/xml_cdr/archive/'.$start_year.'/'.$start_month.'/'.$start_day;
|
||||
$tmp_dir = $this->settings->get('switch', 'log').'/xml_cdr/archive/'.$start_year.'/'.$start_month.'/'.$start_day;
|
||||
if(!file_exists($tmp_dir)) {
|
||||
mkdir($tmp_dir, 0770, true);
|
||||
}
|
||||
if ($this->setting->get('cdr', 'format') == "xml") {
|
||||
if ($this->settings->get('cdr', 'format') == "xml") {
|
||||
$tmp_file = $uuid.'.xml';
|
||||
$fh = fopen($tmp_dir.'/'.$tmp_file, 'w');
|
||||
fwrite($fh, $xml_string);
|
||||
|
|
@ -1140,8 +1170,8 @@ if (!class_exists('xml_cdr')) {
|
|||
public function call_flow_summary($call_flow_array) {
|
||||
|
||||
//set the time zone
|
||||
if (!empty($this->setting->get('domain', 'time_zone'))) {
|
||||
$time_zone = $this->setting->get('domain', 'time_zone');
|
||||
if (!empty($this->settings->get('domain', 'time_zone'))) {
|
||||
$time_zone = $this->settings->get('domain', 'time_zone');
|
||||
}
|
||||
else {
|
||||
$time_zone = date_default_timezone_get();
|
||||
|
|
@ -1151,8 +1181,9 @@ if (!class_exists('xml_cdr')) {
|
|||
date_default_timezone_set($time_zone);
|
||||
|
||||
//get the destination select list
|
||||
$destination = new destinations;
|
||||
$destination_array = $destination->get('dialplan');
|
||||
if ($this->destinations) {
|
||||
$destination_array = $this->destinations->get('dialplan');
|
||||
}
|
||||
|
||||
//add new rows when callee_id_number exists
|
||||
$new_rows = 0;
|
||||
|
|
@ -1278,6 +1309,15 @@ if (!class_exists('xml_cdr')) {
|
|||
$app['status'] = 'routed';
|
||||
}
|
||||
|
||||
//add the source if there is a value
|
||||
if (!empty($row["caller_profile"]["username"])) {
|
||||
$app_source = $this->find_app($destination_array, $row["caller_profile"]["username"]);
|
||||
$app['source_number'] = $row["caller_profile"]["username"];
|
||||
$app['source_uuid'] = $app_source['uuid'];
|
||||
$app['source_name'] = $app_source['name'];
|
||||
$app['source_label'] = $app_source['label'];
|
||||
}
|
||||
|
||||
//outbound routes
|
||||
if ($this->call_direction == 'outbound') {
|
||||
$status = 'missed';
|
||||
|
|
@ -1288,7 +1328,6 @@ if (!class_exists('xml_cdr')) {
|
|||
if (!empty($row["caller_profile"]["username"])) {
|
||||
//add to the application array
|
||||
$app['application'] = 'extensions';
|
||||
$app['source'] = $row["caller_profile"]["username"];
|
||||
$app['status'] = $status;
|
||||
$app['name'] = '';
|
||||
$app['label'] = 'extensions';
|
||||
|
|
@ -1362,25 +1401,35 @@ if (!class_exists('xml_cdr')) {
|
|||
}
|
||||
|
||||
//build the application urls
|
||||
$destination_url = "/app/".($app['application'] ?? '')."/".$destination->singular($app['application'] ?? '')."_edit.php?id=".($app["uuid"] ?? '');
|
||||
$application_url = "/app/".($app['application'] ?? '')."/".($app['application'] ?? '').".php";
|
||||
if (!empty($app['application']) && $app['application'] == 'call_centers') {
|
||||
$destination_url = "/app/".($app['application'] ?? '')."/".$destination->singular($app['application'] ?? '')."_queue_edit.php?id=".($app["uuid"] ?? '');
|
||||
$application_url = "/app/".($app['application'] ?? '')."/".$destination->singular($app['application'] ?? '')."_queues.php";
|
||||
if (!empty($app['application'])) {
|
||||
//build the source url
|
||||
$source_url = '';
|
||||
if (!empty($app["source_uuid"])) {
|
||||
$source_url = "/app/".($app['application'] ?? '')."/".$this->singular($app['application'] ?? '')."_edit.php?id=".($app["source_uuid"] ?? '');
|
||||
}
|
||||
|
||||
//build the destination url
|
||||
$destination_url = '';
|
||||
$destination_url = "/app/".($app['application'] ?? '')."/".$this->singular($app['application'] ?? '')."_edit.php?id=".($app["uuid"] ?? '');
|
||||
$application_url = "/app/".($app['application'] ?? '')."/".($app['application'] ?? '').".php";
|
||||
if ($app['application'] == 'call_centers') {
|
||||
$destination_url = "/app/".($app['application'] ?? '')."/".$this->singular($app['application'] ?? '')."_queue_edit.php?id=".($app["uuid"] ?? '');
|
||||
$application_url = "/app/".($app['application'] ?? '')."/".$this->singular($app['application'] ?? '')."_queues.php";
|
||||
}
|
||||
}
|
||||
|
||||
//add the application and destination details
|
||||
$language2 = new text;
|
||||
$text2 = $language2->get($this->setting->get('domain', 'language'), 'app/'.($app['application'] ?? ''));
|
||||
$text2 = $language2->get($this->settings->get('domain', 'language'), 'app/'.($app['application'] ?? ''));
|
||||
$call_flow_summary[$x]["application_name"] = ($app['application'] ?? '');
|
||||
$call_flow_summary[$x]["application_label"] = trim($text2['title-'.($app['application'] ?? '')] ?? '');
|
||||
$call_flow_summary[$x]["call_direction"] = $this->call_direction;
|
||||
|
||||
$call_flow_summary[$x]["application_url"] = $application_url;
|
||||
if ($this->call_direction == 'outbound') {
|
||||
$call_flow_summary[$x]["source_uuid"] = ($app['uuid'] ?? '');
|
||||
$call_flow_summary[$x]["source_number"] = $app['source'];
|
||||
$call_flow_summary[$x]["source_label"] = ($app['label'] ?? '');
|
||||
$call_flow_summary[$x]["source_uuid"] = ($app['source_uuid'] ?? '');
|
||||
$call_flow_summary[$x]["source_number"] = ($app['source_number'] ?? '');
|
||||
$call_flow_summary[$x]["source_label"] = ($app['source_label'] ?? '');
|
||||
$call_flow_summary[$x]["source_url"] = $destination_url;
|
||||
$call_flow_summary[$x]["source_name"] = $app['description'] ?? '';
|
||||
//$call_flow_summary[$x]["source_description"] = $app['description'] ?? '';
|
||||
|
|
@ -1391,14 +1440,14 @@ if (!class_exists('xml_cdr')) {
|
|||
$call_flow_summary[$x]["destination_description"] = '';
|
||||
}
|
||||
else {
|
||||
$call_flow_summary[$x]["source_uuid"] = '';
|
||||
$call_flow_summary[$x]["source_number"] = '';
|
||||
$call_flow_summary[$x]["source_label"] = '';
|
||||
$call_flow_summary[$x]["source_url"] = '';
|
||||
$call_flow_summary[$x]["source_uuid"] = ($app['source_uuid'] ?? '');
|
||||
$call_flow_summary[$x]["source_number"] = ($app['source_number'] ?? '');
|
||||
$call_flow_summary[$x]["source_label"] = ($app['source_label'] ?? '');
|
||||
$call_flow_summary[$x]["source_url"] = ($source_url ?? '');
|
||||
$call_flow_summary[$x]["destination_name"] = ($app['description'] ?? '');
|
||||
$call_flow_summary[$x]["destination_uuid"] = ($app['uuid'] ?? '');
|
||||
$call_flow_summary[$x]["destination_label"] = ($app['label'] ?? '');
|
||||
$call_flow_summary[$x]["destination_url"] = $destination_url;
|
||||
$call_flow_summary[$x]["destination_url"] = $destination_url ?? '';
|
||||
//$call_flow_summary[$x]["destination_description"] = $app['description'] ?? '';
|
||||
}
|
||||
$call_flow_summary[$x]["destination_number"] = $row["caller_profile"]["destination_number"];
|
||||
|
|
@ -1413,10 +1462,10 @@ if (!class_exists('xml_cdr')) {
|
|||
//add the call flow times
|
||||
$call_flow_summary[$x]["start_epoch"] = round($profile_created_epoch);
|
||||
$call_flow_summary[$x]["end_epoch"] = round($profile_end_epoch);
|
||||
$call_flow_summary[$x]["start_stamp"] = date("Y-m-d H:i:s", $profile_created_epoch);
|
||||
$call_flow_summary[$x]["end_stamp"] = date("Y-m-d H:i:s", $profile_end_epoch);
|
||||
$call_flow_summary[$x]["start_stamp"] = date("Y-m-d H:i:s", (int)$profile_created_epoch);
|
||||
$call_flow_summary[$x]["end_stamp"] = date("Y-m-d H:i:s", (int)$profile_end_epoch);
|
||||
$call_flow_summary[$x]["duration_seconds"] = round($profile_end_epoch - $profile_created_epoch);
|
||||
$call_flow_summary[$x]["duration_formatted"] = gmdate("G:i:s",(int) $call_flow_summary[$x]["duration_seconds"]);
|
||||
$call_flow_summary[$x]["duration_formatted"] = gmdate("G:i:s",(int)$call_flow_summary[$x]["duration_seconds"]);
|
||||
unset($app);
|
||||
$x++;
|
||||
}
|
||||
|
|
@ -1498,7 +1547,7 @@ if (!class_exists('xml_cdr')) {
|
|||
}
|
||||
|
||||
public function moved_to_failed($failed_file) {
|
||||
$xml_cdr_dir = $this->setting->get('switch', 'log', '/var/log/freeswitch').'/xml_cdr';
|
||||
$xml_cdr_dir = $this->settings->get('switch', 'log', '/var/log/freeswitch').'/xml_cdr';
|
||||
if (!file_exists($xml_cdr_dir.'/failed')) {
|
||||
if (!mkdir($xml_cdr_dir.'/failed', 0660, true)) {
|
||||
die('Failed to create '.$xml_cdr_dir.'/failed');
|
||||
|
|
@ -1511,7 +1560,7 @@ if (!class_exists('xml_cdr')) {
|
|||
* get xml from the filesystem and save it to the database
|
||||
*/
|
||||
public function read_files() {
|
||||
$xml_cdr_dir = $this->setting->get('switch', 'log').'/xml_cdr';
|
||||
$xml_cdr_dir = $this->settings->get('switch', 'log').'/xml_cdr';
|
||||
$dir_handle = opendir($xml_cdr_dir);
|
||||
$x = 0;
|
||||
while($file = readdir($dir_handle)) {
|
||||
|
|
@ -1611,9 +1660,9 @@ if (!class_exists('xml_cdr')) {
|
|||
|
||||
//authentication for xml cdr http post
|
||||
if (!defined('STDIN')) {
|
||||
if ($this->setting->get('cdr', 'http_enabled')) {
|
||||
if ($this->settings->get('cdr', 'http_enabled')) {
|
||||
//get the contents of xml_cdr.conf.xml
|
||||
$conf_xml_string = file_get_contents($this->setting->get('switch', 'conf').'/autoload_configs/xml_cdr.conf.xml');
|
||||
$conf_xml_string = file_get_contents($this->settings->get('switch', 'conf').'/autoload_configs/xml_cdr.conf.xml');
|
||||
|
||||
//parse the xml to get the call detail record info
|
||||
try {
|
||||
|
|
@ -1643,7 +1692,7 @@ if (!class_exists('xml_cdr')) {
|
|||
|
||||
//if http enabled is set to false then deny access
|
||||
if (!defined('STDIN')) {
|
||||
if ($this->setting->get('cdr', 'http_enabled') == "false") {
|
||||
if ($this->settings->get('cdr', 'http_enabled') == "false") {
|
||||
openlog('FusionPBX', LOG_NDELAY, LOG_AUTH);
|
||||
syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR'].'] XML CDR import default setting http_enabled is not enabled. Line: '.__line__);
|
||||
closelog();
|
||||
|
|
@ -1655,7 +1704,7 @@ if (!class_exists('xml_cdr')) {
|
|||
|
||||
//check for the correct username and password
|
||||
if (!defined('STDIN')) {
|
||||
if ($this->setting->get('cdr', 'http_enabled', true)) {
|
||||
if ($this->settings->get('cdr', 'http_enabled', true)) {
|
||||
if ($auth_array[0] == $_SERVER["PHP_AUTH_USER"] && $auth_array[1] == $_SERVER["PHP_AUTH_PW"]) {
|
||||
//echo "access granted\n";
|
||||
$this->username = $auth_array[0];
|
||||
|
|
@ -1703,8 +1752,8 @@ if (!class_exists('xml_cdr')) {
|
|||
public function user_summary() {
|
||||
|
||||
//set the time zone
|
||||
if (!empty($this->setting->get('domain', 'time_zone'))) {
|
||||
$time_zone = $this->setting->get('domain', 'time_zone');
|
||||
if (!empty($this->settings->get('domain', 'time_zone'))) {
|
||||
$time_zone = $this->settings->get('domain', 'time_zone');
|
||||
}
|
||||
else {
|
||||
$time_zone = date_default_timezone_get();
|
||||
|
|
@ -2158,6 +2207,46 @@ if (!class_exists('xml_cdr')) {
|
|||
unset($records);
|
||||
} //method
|
||||
|
||||
|
||||
/**
|
||||
* define singular function to convert a word in english to singular
|
||||
*/
|
||||
public function singular($word) {
|
||||
//"-es" is used for words that end in "-x", "-s", "-z", "-sh", "-ch" in which case you add
|
||||
if (substr($word, -2) == "es") {
|
||||
if (substr($word, -4) == "sses") { // eg. 'addresses' to 'address'
|
||||
return substr($word,0,-2);
|
||||
}
|
||||
elseif (substr($word, -3) == "ses") { // eg. 'databases' to 'database' (necessary!)
|
||||
return substr($word,0,-1);
|
||||
}
|
||||
elseif (substr($word, -3) == "ies") { // eg. 'countries' to 'country'
|
||||
return substr($word,0,-3)."y";
|
||||
}
|
||||
elseif (substr($word, -3, 1) == "x") {
|
||||
return substr($word,0,-2);
|
||||
}
|
||||
elseif (substr($word, -3, 1) == "s") {
|
||||
return substr($word,0,-2);
|
||||
}
|
||||
elseif (substr($word, -3, 1) == "z") {
|
||||
return substr($word,0,-2);
|
||||
}
|
||||
elseif (substr($word, -4, 2) == "sh") {
|
||||
return substr($word,0,-2);
|
||||
}
|
||||
elseif (substr($word, -4, 2) == "ch") {
|
||||
return substr($word,0,-2);
|
||||
}
|
||||
else {
|
||||
return rtrim($word, "s");
|
||||
}
|
||||
}
|
||||
else {
|
||||
return rtrim($word, "s");
|
||||
}
|
||||
} //method
|
||||
|
||||
/**
|
||||
* Removes old entries for in the database xml_cdr, xml_cdr_flow, xml_cdr_json, xml_cdr_logs table
|
||||
* see {@link https://github.com/fusionpbx/fusionpbx-app-maintenance/} FusionPBX Maintenance App
|
||||
|
|
|
|||
|
|
@ -263,12 +263,13 @@
|
|||
$outbound_caller_id_number = urldecode($array["variables"]["outbound_caller_id_number"] ?? '');
|
||||
|
||||
//set the time zone
|
||||
if (isset($_SESSION['domain']['time_zone']['name'])) {
|
||||
date_default_timezone_set($_SESSION['domain']['time_zone']['name']);
|
||||
}
|
||||
date_default_timezone_set($settings->get('domain', 'time_zone', 'GMT'));
|
||||
|
||||
//create the destinations object
|
||||
$destinations = new destinations();
|
||||
|
||||
//build the call flow summary array
|
||||
$xml_cdr = new xml_cdr;
|
||||
$xml_cdr = new xml_cdr(["database" => $database, "settings" => $settings, "destinations" => $destinations]);
|
||||
$xml_cdr->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$xml_cdr->call_direction = $call_direction; //used to determine when the call is outbound
|
||||
$xml_cdr->status = $status; //used to determine when the call is outbound
|
||||
|
|
@ -496,37 +497,33 @@
|
|||
echo "</tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<div class='card'>\n";
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
echo " <th>".$text['label-application']."</th>\n";
|
||||
if ($call_direction == 'outbound') {
|
||||
echo " <th>".$text['label-source']."</th>\n";
|
||||
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <th>".$text['label-application']."</th>\n";
|
||||
if ($call_direction == 'local' || $call_direction == 'outbound') {
|
||||
echo " <th>".$text['label-source']."</th>\n";
|
||||
}
|
||||
echo " <th>".$text['label-destination']."</th>\n";
|
||||
echo " <th>".$text['label-name']."</th>\n";
|
||||
echo " <th>".$text['label-start']."</th>\n";
|
||||
echo " <th>".$text['label-end']."</th>\n";
|
||||
echo " <th>".$text['label-duration']."</th>\n";
|
||||
echo " <th>".$text['label-status']."</th>\n";
|
||||
echo "</tr>\n";
|
||||
echo " <th>".$text['label-destination']."</th>\n";
|
||||
echo " <th>".$text['label-name']."</th>\n";
|
||||
echo " <th>".$text['label-start']."</th>\n";
|
||||
echo " <th>".$text['label-end']."</th>\n";
|
||||
echo " <th>".$text['label-duration']."</th>\n";
|
||||
echo " <th>".$text['label-status']."</th>\n";
|
||||
echo " </tr>\n";
|
||||
$i = 1;
|
||||
foreach ($call_flow_summary as $row) {
|
||||
echo "<tr >\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href=\"".$row["application_url"]."\">".escape($row["application_label"])."</a></td>\n";
|
||||
if ($call_direction == 'outbound') {
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href=\"".$row["source_url"]."\">".escape($row["source_number"])."</a></td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row["destination_number"])."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href=\"".$row["source_url"]."\">".escape($row["source_name"])."</a></td>\n";
|
||||
echo " <tr >\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href=\"".$row["application_url"]."\">".escape($row["application_label"])."</a></td>\n";
|
||||
if ($call_direction == 'local' || $call_direction == 'outbound') {
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href=\"".$row["source_url"]."\">".escape($row["source_number"])."</a></td>\n";
|
||||
}
|
||||
else {
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href=\"".$row["destination_url"]."\">".escape($row["destination_number"])."</a></td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href=\"".$row["destination_url"]."\">".escape($row["destination_name"])."</a></td>\n";
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row["start_stamp"])."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row["end_stamp"])."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row["duration_formatted"])."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($text['label-'.$row["destination_status"]] ?? '')."</td>\n";
|
||||
echo "</tr>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href=\"".$row["destination_url"]."\">".escape($row["destination_number"])."</a></td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href=\"".$row["destination_url"]."\">".escape($row["destination_label"])."</a></td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row["start_stamp"])."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row["end_stamp"])."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row["duration_formatted"])."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($text['label-'.$row["destination_status"]] ?? '')."</td>\n";
|
||||
echo " </tr>\n";
|
||||
|
||||
//alternate $c
|
||||
$c = $c ? 0 : 1;
|
||||
|
|
@ -534,7 +531,7 @@
|
|||
//increment the row count
|
||||
$i++;
|
||||
}
|
||||
echo "</table>";
|
||||
echo " </table>";
|
||||
echo "</div>\n";
|
||||
echo "<br /><br />\n";
|
||||
|
||||
|
|
@ -542,14 +539,14 @@
|
|||
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($record_transcription)) {
|
||||
echo "<b>".$text['label-transcription']."</b><br>\n";
|
||||
echo "<div class='card'>\n";
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
echo " <th>".$text['label-text']."</th>\n";
|
||||
echo "</tr>\n";
|
||||
echo "<tr >\n";
|
||||
echo " <td valign='top' class='".$row_style[0]."'>".escape($record_transcription)."</td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</table>";
|
||||
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <th>".$text['label-text']."</th>\n";
|
||||
echo " </tr>\n";
|
||||
echo " <tr >\n";
|
||||
echo " <td valign='top' class='".$row_style[0]."'>".escape($record_transcription)."</td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " </table>";
|
||||
echo "</div>\n";
|
||||
echo "<br /><br />\n";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue