diff --git a/application/controllers/Contesting.php b/application/controllers/Contesting.php index 2ab204b6..672f97f4 100644 --- a/application/controllers/Contesting.php +++ b/application/controllers/Contesting.php @@ -189,7 +189,10 @@ class Contesting extends CI_Controller { header('Content-Type: application/json'); if ($result && $result->num_rows()) { - echo json_encode(array('message' => 'Worked before')); + $timeb4=substr($result->row()->b4,0,5); + $custom_date_format = $this->session->userdata('user_date_format'); + $abstimeb4=date($custom_date_format, strtotime($result->row()->COL_TIME_OFF)).' '.date('H:i',strtotime($result->row()->COL_TIME_OFF)); + echo json_encode(array('message' => 'Worked at '.$abstimeb4.' ('.$timeb4.' ago) before')); } return; } diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php index 3ab63248..ce2f4823 100644 --- a/application/models/Contesting_model.php +++ b/application/models/Contesting_model.php @@ -219,7 +219,8 @@ class Contesting_model extends CI_Model { $date = DateTime::createFromFormat('d-m-Y H:i:s', $qsoarray[0]); $date = $date->format('Y-m-d H:i:s'); - + + $this->db->select('timediff(UTC_TIMESTAMP(),col_time_off) b4, COL_TIME_OFF'); $this->db->where('STATION_ID', $station_id); $this->db->where('COL_CALL', xss_clean($call)); $this->db->where("COL_BAND", xss_clean($band)); @@ -229,6 +230,7 @@ class Contesting_model extends CI_Model { $this->db->where("COL_MODE", xss_clean($mode)); $this->db->or_where("COL_SUBMODE", xss_clean($mode)); $this->db->group_end(); + $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "DESC"); $query = $this->db->get($this->config->item('table_name')); return $query; diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js index 2356d2f7..a06196ec 100644 --- a/assets/js/sections/contesting.js +++ b/assets/js/sections/contesting.js @@ -241,8 +241,8 @@ function checkIfWorkedBefore() { 'contest': $("#contestname").val() }, success: function (result) { - if (result.message == 'Worked before') { - $('#callsign_info').text("Worked before!"); + if (result.message.substr(0,6) == 'Worked') { + $('#callsign_info').text(result.message); } } });