diff --git a/application/controllers/Timeline.php b/application/controllers/Timeline.php new file mode 100644 index 00000000..8bd28ed1 --- /dev/null +++ b/application/controllers/Timeline.php @@ -0,0 +1,58 @@ +load->model('user_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + } + + public function index() + { + // Render Page + $data['page_title'] = "DXCC Timeline"; + + $this->load->model('Timeline_model'); + + if ($this->input->post('band') != NULL) { // Band is not set when page first loads. + $band = $this->input->post('band'); + } + else { + $band = 'All'; + } + + $data['dxcc_timeline_array'] = $this->Timeline_model->get_dxcc_timeline($band); + $data['worked_bands'] = $this->Timeline_model->get_worked_bands(); + $data['bandselect'] = $band; + + $this->load->view('interface_assets/header', $data); + $this->load->view('timeline/index'); + $this->load->view('interface_assets/footer'); + } + + public function details() { + $this->load->model('logbook_model'); + + $adif = str_replace('"', "", $this->input->get("Adif")); + $country = $this->logbook_model->get_entity($adif); + $band = str_replace('"', "", $this->input->get("Band")); + $data['results'] = $this->logbook_model->timeline_qso_details($adif, $band); + + // Render Page + $data['page_title'] = "Log View - DXCC"; + $data['filter'] = "country ". $country['name']; + + if ($band != "All") { + $data['filter'] .= " and " . $band; + } + + $this->load->view('interface_assets/header', $data); + $this->load->view('timeline/details'); + $this->load->view('interface_assets/footer'); + } + +} \ No newline at end of file diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 0968aff0..e11b8548 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -263,6 +263,26 @@ class Logbook_model extends CI_Model { return $this->db->get($this->config->item('table_name')); } + public function timeline_qso_details($adif, $band){ + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + if ($band != 'All') { + if ($band == 'SAT') { + $this->db->where('col_prop_mode', $band); + } else { + $this->db->where('COL_PROP_MODE !=', 'SAT'); + $this->db->where('col_band', $band); + } + } + + $this->db->where('station_id', $station_id); + $this->db->where('COL_DXCC', $adif); + + return $this->db->get($this->config->item('table_name')); + } + public function was_qso_details($state, $band){ $CI =& get_instance(); $CI->load->model('Stations'); diff --git a/application/models/Timeline_model.php b/application/models/Timeline_model.php new file mode 100644 index 00000000..7ce479ca --- /dev/null +++ b/application/models/Timeline_model.php @@ -0,0 +1,97 @@ +load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $sql = "select min(date(COL_TIME_ON)) date, prefix, col_country, end, adif from " + .$this->config->item('table_name'). " thcv + join dxcc_entities on thcv.col_dxcc = dxcc_entities.adif + where station_id = " . $station_id; + + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + } + else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + + $sql .= " group by col_dxcc, col_country + order by date desc"; + + $query = $this->db->query($sql); + + return $query->result(); + } + + public $bandslots = array("160m" => 0, + "80m" => 0, + "60m" => 0, + "40m" => 0, + "30m" => 0, + "20m" => 0, + "17m" => 0, + "15m" => 0, + "12m" => 0, + "10m" => 0, + "6m" => 0, + "4m" => 0, + "2m" => 0, + "70cm" => 0, + "23cm" => 0, + "13cm" => 0, + "9cm" => 0, + "6cm" => 0, + "3cm" => 0, + "1.25cm" => 0, + "SAT" => 0, + ); + + function get_worked_bands() + { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + // get all worked slots from database + $data = $this->db->query( + "SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `" . $this->config->item('table_name') . "` WHERE station_id = " . $station_id . " AND COL_PROP_MODE != \"SAT\"" + ); + $worked_slots = array(); + foreach ($data->result() as $row) { + array_push($worked_slots, $row->COL_BAND); + } + + $SAT_data = $this->db->query( + "SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id = " . $station_id . " AND COL_PROP_MODE = \"SAT\"" + ); + + foreach ($SAT_data->result() as $row) { + array_push($worked_slots, strtoupper($row->COL_PROP_MODE)); + } + + // bring worked-slots in order of defined $bandslots + $results = array(); + foreach (array_keys($this->bandslots) as $slot) { + if (in_array($slot, $worked_slots)) { + array_push($results, $slot); + } + } + return $results; + } + +} \ No newline at end of file diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index d166241d..5652842e 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -71,7 +71,9 @@
Distances worked - Days with QSOs + Days with QSOs + + DXCC Timeline diff --git a/application/views/timeline/details.php b/application/views/timeline/details.php new file mode 100644 index 00000000..56394d9f --- /dev/null +++ b/application/views/timeline/details.php @@ -0,0 +1,7 @@ +