diff --git a/app/xml_cdr/resources/dashboard/missed_calls.php b/app/xml_cdr/resources/dashboard/missed_calls.php index 7a97d9584d..02611ef3eb 100644 --- a/app/xml_cdr/resources/dashboard/missed_calls.php +++ b/app/xml_cdr/resources/dashboard/missed_calls.php @@ -28,10 +28,17 @@ //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), '".(!empty($_SESSION['domain']['time_format']) && $_SESSION['domain']['time_format']['text'] == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI")."') as start_date_time, \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"; @@ -43,7 +50,7 @@ $sql .= " direction = 'inbound' \n"; $sql .= " or direction = 'local' \n"; $sql .= " ) \n"; - $sql .= " and (missed_call = true or bridge_uuid is null) "; + $sql .= " and (status = 'missed') "; $sql .= " and hangup_cause <> 'LOSE_RACE' "; if (!permission_exists('xml_cdr_domain')) { if (!empty($assigned_extensions)) { @@ -67,6 +74,8 @@ $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; } @@ -145,7 +154,6 @@ ) ? true : false; foreach ($result as $index => $row) { - if ($index + 1 > $missed_limit) { break; } //only show limit $start_date_time = str_replace('/0','/', ltrim($row['start_date_time'], '0')); if (!empty($_SESSION['domain']['time_format']) && $_SESSION['domain']['time_format']['text'] == '12h') { $start_date_time = str_replace(' 0',' ', $start_date_time); @@ -168,7 +176,7 @@ echo "\n"; echo "\n"; if ($theme_cdr_images_exist) { - $call_result = ($row['answer_stamp'] != '') ? 'voicemail' : 'cancelled'; + $call_result = $row['status']; if (isset($row['direction'])) { echo " \n"; } @@ -183,11 +191,11 @@ unset($sql, $parameters, $result, $num_rows, $index, $row); echo "\n"; - echo "".$text['label-view_all']."\n"; + echo "".$text['label-view_all']."\n"; echo ""; //$n++; echo ""; echo "\n"; -?> \ No newline at end of file +?>