From 70db88b521af19ddbc4d9dfcdfdafa85f5e03d1d Mon Sep 17 00:00:00 2001 From: int2001 Date: Sat, 30 Dec 2023 20:17:24 +0000 Subject: [PATCH] Added time of "Worked before" in Contest-Section --- application/controllers/Contesting.php | 3 ++- application/models/Contesting_model.php | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/application/controllers/Contesting.php b/application/controllers/Contesting.php index 2ab204b6..dbfb8614 100644 --- a/application/controllers/Contesting.php +++ b/application/controllers/Contesting.php @@ -189,7 +189,8 @@ class Contesting extends CI_Controller { header('Content-Type: application/json'); if ($result && $result->num_rows()) { - echo json_encode(array('message' => 'Worked before')); + $timeb4=$result->row()->b4; + echo json_encode(array('message' => 'Worked '.$timeb4.' before')); } return; } diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php index 3ab63248..d92a1b20 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_on) b4'); $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;