get($_SESSION['domain']['language']['code'], 'core/user_settings'); //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) $missed_limit = !empty($selected_blocks) && (is_array($selected_blocks) && in_array('counts', $selected_blocks)) ? 10 : 5; //set the sql time format $sql_time_format = 'DD Mon HH12:MI am'; if (!empty($_SESSION['domain']['time_format']['text'])) { $sql_time_format = $_SESSION['domain']['time_format']['text'] == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI"; } //get the missed calls from call detail records $sql = "select \n"; $sql .= " status, \n"; $sql .= " direction, \n"; $sql .= " to_char(timezone(:time_zone, start_stamp), '".$sql_time_format."') as start_date_time, \n"; $sql .= " caller_id_name, \n"; $sql .= " caller_id_number, \n"; $sql .= " answer_stamp \n"; $sql .= "from \n"; $sql .= " v_xml_cdr \n"; $sql .= "where \n"; $sql .= " domain_uuid = :domain_uuid \n"; $sql .= " and ( \n"; $sql .= " direction = 'inbound' \n"; $sql .= " or direction = 'local' \n"; $sql .= " ) \n"; $sql .= " and (status = 'missed') "; $sql .= " and hangup_cause <> 'LOSE_RACE' "; 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 = :assigned_extension_uuid_".$x; $sql_where_array[] = "destination_number = :destination_number_".$x; $parameters['assigned_extension_uuid_'.$x] = $assigned_extension_uuid; $parameters['destination_number_'.$x] = $assigned_extension; $x++; } if (!empty($sql_where_array)) { $sql .= "and (".implode(' or ', $sql_where_array).") \n"; } unset($sql_where_array); } else { $sql .= "and false \n"; } } $sql .= "and start_epoch > ".(time() - 86400)." \n"; $sql .= "order by \n"; $sql .= "start_epoch desc \n"; $sql .= "limit :missed_limit \n"; $parameters['missed_limit'] = $missed_limit; $parameters['time_zone'] = isset($_SESSION['domain']['time_zone']['name']) ? $_SESSION['domain']['time_zone']['name'] : date_default_timezone_get(); $parameters['domain_uuid'] = $_SESSION['domain_uuid']; if (!isset($database)) { $database = new database; } $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"; //missed calls echo "
| \n"; } echo " | ".$text['label-cid_number']." | \n"; echo "".$text['label-missed']." | \n"; echo "
|---|---|---|
| \n";
if ($theme_cdr_images_exist) {
$call_result = $row['status'];
if (isset($row['direction'])) {
echo " | \n";
echo "".((is_numeric($row['caller_id_number'])) ? format_phone($row['caller_id_number']) : $row['caller_id_number'])." | \n"; echo "".$start_date_time." | \n"; echo "