get($settings->get('domain', 'language', 'en-us'), 'core/user_settings'); //get the dashboard label $widget_label = $text['label-'.$widget_key] ?? $widget_name; //create assigned extensions array if (is_array($_SESSION['user']['extension'])) { foreach ($_SESSION['user']['extension'] as $assigned_extension) { $assigned_extensions[$assigned_extension['extension_uuid']] = $assigned_extension['user']; } } unset($assigned_extension); //if also viewing system status, show more recent calls (more room avaialble) $recent_limit = isset($selected_blocks) && is_array($selected_blocks) && in_array('counts', $selected_blocks) ? 10 : 5; //set the time zone $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); //set the time format options: 12h, 24h if ($settings->get('domain', 'time_format') == '24h') { $time_format = 'DD Mon HH24:MI'; } else { $time_format = 'DD Mon HH12:MI am'; } //get the recent calls from call detail records $sql = " select status, direction, start_stamp, to_char(timezone(:time_zone, start_stamp), '".$time_format."') as start_date_time, caller_id_name, caller_id_number, destination_number, answer_stamp, bridge_uuid, sip_hangup_disposition from v_xml_cdr where domain_uuid = :domain_uuid "; if (!permission_exists('xml_cdr_domain')) { if (!empty($assigned_extensions)) { $x = 0; foreach ($assigned_extensions as $assigned_extension_uuid => $assigned_extension) { $sql_where_array[] = "extension_uuid = :extension_uuid_".$x; $parameters['extension_uuid_'.$x] = $assigned_extension_uuid; $x++; } if (!empty($sql_where_array)) { $sql .= "and (".implode(' or ', $sql_where_array).") "; } unset($sql_where_array); } else { $sql .= "and false \n"; } } $sql .= "and hangup_cause <> 'LOSE_RACE' "; $sql .= "and start_epoch > ".(time() - 86400)." "; $sql .= "order by start_epoch desc "; $sql .= "limit :recent_limit "; $parameters['recent_limit'] = $recent_limit; $parameters['time_zone'] = $time_zone; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $result = $database->select($sql, $parameters, 'all'); $num_rows = !empty($result) ? sizeof($result) : 0; //define row styles $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; //recent calls echo "
\n"; echo "
\n"; echo " ".escape($widget_label)."\n"; if ($widget_chart_type == "doughnut") { //add doughnut chart ?>
".$num_rows.""; } //dashboard icon if (!isset($widget_chart_type) || $widget_chart_type == "icon") { echo "
\n"; echo " \n"; echo " ".$num_rows."\n"; echo "
\n"; } echo "
\n"; if ($widget_details_state != 'disabled') { echo "
"; echo "\n"; echo "\n"; if ($num_rows > 0) { echo "\n"; } echo "\n"; echo "\n"; echo "\n"; if ($num_rows > 0) { $theme_cdr_images_exist = ( file_exists($theme_image_path."icon_cdr_inbound_answered.png") && file_exists($theme_image_path."icon_cdr_inbound_voicemail.png") && file_exists($theme_image_path."icon_cdr_inbound_cancelled.png") && file_exists($theme_image_path."icon_cdr_inbound_failed.png") && file_exists($theme_image_path."icon_cdr_outbound_answered.png") && file_exists($theme_image_path."icon_cdr_outbound_cancelled.png") && file_exists($theme_image_path."icon_cdr_outbound_failed.png") && file_exists($theme_image_path."icon_cdr_local_answered.png") && file_exists($theme_image_path."icon_cdr_local_voicemail.png") && file_exists($theme_image_path."icon_cdr_local_cancelled.png") && file_exists($theme_image_path."icon_cdr_local_failed.png") ) ? true : false; foreach ($result as $index => $row) { $start_date_time = str_replace('/0','/', ltrim($row['start_date_time'], '0')); if (!empty($_SESSION['domain']['time_format']) && $settings->get('domain', 'time_format') == '12h') { $start_date_time = str_replace(' 0',' ', $start_date_time); } //determine name $cdr_name = ($row['direction'] == 'inbound' || ($row['direction'] == 'local' && !empty($assigned_extensions) && is_array($assigned_extensions) && in_array($row['destination_number'], $assigned_extensions))) ? $row['caller_id_name'] : $row['destination_number']; //determine number to display if ($row['direction'] == 'inbound' || ($row['direction'] == 'local' && !empty($assigned_extensions) && is_array($assigned_extensions) && in_array($row['destination_number'], $assigned_extensions))) { $cdr_number = (is_numeric($row['caller_id_number'])) ? format_phone($row['caller_id_number']) : $row['caller_id_number']; $dest = $row['caller_id_number']; } else if ($row['direction'] == 'outbound' || ($row['direction'] == 'local' && !empty($assigned_extensions) && is_array($assigned_extensions) && in_array($row['caller_id_number'], $assigned_extensions))) { $cdr_number = (is_numeric($row['destination_number'])) ? format_phone($row['destination_number']) : $row['destination_number']; $dest = $row['destination_number']; } //set click-to-call variables if (permission_exists('click_to_call_call')) { $tr_link = "onclick=\"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php". "?src_cid_name=".urlencode($cdr_name ?? ''). "&src_cid_number=".urlencode($cdr_number ?? ''). "&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name'] ?? ''). "&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'] ?? ''). "&src=".urlencode($_SESSION['user']['extension'][0]['user'] ?? ''). "&dest=".urlencode($dest ?? ''). "&rec=".(filter_var($settings->get('click_to_call', 'record') ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false'). "&ringback=".$settings->get('click_to_call', 'ringback', 'us-ring'). "&auto_answer=".(filter_var($settings->get('click_to_call', 'auto_answer') ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false'). "');\" ". "style='cursor: pointer;'"; } echo "\n"; //determine call result and appropriate icon echo "\n"; echo "\n"; echo "\n"; echo "\n"; unset($cdr_name, $cdr_number); $c = ($c) ? 0 : 1; } } unset($sql, $parameters, $result, $num_rows, $index, $row); echo "
 ".$text['label-cid_number']."".$text['label-date_time']."
\n"; if ($theme_cdr_images_exist) { $call_result = $row['status']; if (isset($row['direction'])) { echo "\n"; } } echo "".($cdr_number ?? '')."".$start_date_time."
\n"; echo "".$text['label-view_all']."\n"; echo "
"; echo ""; } echo "
\n"; ?>