From dcdfd66a0173d198b7ccb7da507c9ef03caef5ac Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Mon, 30 Jan 2023 19:54:27 +0100 Subject: [PATCH] [Timeline] Added VUCC as selection for award --- application/controllers/Timeline.php | 7 +- application/models/Logbook_model.php | 32 ------ application/models/Timeline_model.php | 155 ++++++++++++++++++++++++++ application/views/timeline/index.php | 36 +++++- 4 files changed, 193 insertions(+), 37 deletions(-) diff --git a/application/controllers/Timeline.php b/application/controllers/Timeline.php index 29ee5416..ab1dcf88 100644 --- a/application/controllers/Timeline.php +++ b/application/controllers/Timeline.php @@ -76,14 +76,14 @@ class Timeline extends CI_Controller { } public function details() { - $this->load->model('logbook_model'); + $this->load->model('timeline_model'); $querystring = str_replace('"', "", $this->input->post("Querystring")); $band = str_replace('"', "", $this->input->post("Band")); $mode = str_replace('"', "", $this->input->post("Mode")); $type = str_replace('"', "", $this->input->post("Type")); - $data['results'] = $this->logbook_model->timeline_qso_details($querystring, $band, $mode, $type); + $data['results'] = $this->timeline_model->timeline_qso_details($querystring, $band, $mode, $type); switch($type) { @@ -100,6 +100,9 @@ class Timeline extends CI_Controller { case 'waz' : $data['page_title'] = "Log View - WAZ"; $data['filter'] = "CQ zone ". $querystring; break; + case 'vucc' : $data['page_title'] = "Log View - VUCC"; + $data['filter'] = "Gridsquare ". $querystring; + break; } if ($band != "All") { diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index f6ae8ae8..31083107 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -385,38 +385,6 @@ class Logbook_model extends CI_Model { return $this->db->query($sql); } - public function timeline_qso_details($querystring, $band, $mode, $type){ - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - - $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); - - 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); - } - } - - if ($mode != 'All') { - $this->db->where('col_mode', $mode); - } - - $this->db->where_in('station_profile.station_id', $logbooks_locations_array); - - switch($type) { - case 'dxcc': $this->db->where('COL_DXCC', $querystring); break; - case 'was': $this->db->where('COL_STATE', $querystring); break; - case 'iota': $this->db->where('COL_IOTA', $querystring); break; - case 'waz': $this->db->where('COL_CQZ', $querystring); break; - } - - return $this->db->get($this->config->item('table_name')); - } - public function activator_details($call, $band, $leogeo){ $CI =& get_instance(); $CI->load->model('logbooks_model'); diff --git a/application/models/Timeline_model.php b/application/models/Timeline_model.php index 684bd732..c3520e4d 100644 --- a/application/models/Timeline_model.php +++ b/application/models/Timeline_model.php @@ -19,6 +19,7 @@ class Timeline_model extends CI_Model case 'was': $result = $this->get_timeline_was($band, $mode, $location_list, $qsl, $lotw, $eqsl); break; case 'iota': $result = $this->get_timeline_iota($band, $mode, $location_list, $qsl, $lotw, $eqsl); break; case 'waz': $result = $this->get_timeline_waz($band, $mode, $location_list, $qsl, $lotw, $eqsl); break; + case 'vucc': $result = $this->get_timeline_vucc($band, $mode, $location_list, $qsl, $lotw, $eqsl); break; } return $result; @@ -178,5 +179,159 @@ class Timeline_model extends CI_Model } return $sql; } + + public function get_timeline_vucc3($band, $mode, $location_list, $qsl, $lotw, $eqsl) { + // $sql = "select min(date(COL_TIME_ON)) date, col_gridsquare from " + $sql = "select min(date(COL_TIME_ON)) date, upper(substring(col_gridsquare, 1, 4)) gridsquare from " + .$this->config->item('table_name'). " thcv + where station_id in (" . $location_list . ")"; + + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + } + else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + + if ($mode != 'All') { + $sql .= " and col_mode ='" . $mode . "'"; + } + + $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl); + + $sql .= " and col_gridsquare <> '' group by upper(substring(col_gridsquare, 1, 4)) + order by date desc"; + + $query = $this->db->query($sql); + $this->vucc_shit($band, $mode, $location_list, $qsl, $lotw, $eqsl); + + return $query->result(); + } + + public function timeline_qso_details($querystring, $band, $mode, $type){ + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); + + 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); + } + } + + if ($mode != 'All') { + $this->db->where('col_mode', $mode); + } + + $this->db->where_in('station_profile.station_id', $logbooks_locations_array); + + switch($type) { + case 'dxcc': $this->db->where('COL_DXCC', $querystring); break; + case 'was': $this->db->where('COL_STATE', $querystring); break; + case 'iota': $this->db->where('COL_IOTA', $querystring); break; + case 'waz': $this->db->where('COL_CQZ', $querystring); break; + case 'vucc': $this->db->group_start(); $this->db->like('COL_GRIDSQUARE', $querystring); $this->db->or_like('COL_VUCC_GRIDS',$querystring); $this->db->group_end();break; + } + + return $this->db->get($this->config->item('table_name')); + } + + public function get_timeline_vucc($band, $mode, $location_list, $qsl, $lotw, $eqsl) { + $timeline = array(); + + $col_gridsquare = $this->get_gridsquare($band, $mode, $location_list, $qsl, $lotw, $eqsl); + + foreach ($col_gridsquare as $grid) { + $timeline[] = array( + 'gridsquare' => $grid->gridsquare, + 'date' => $grid->date); + } + + $col_vucc_grids = $this->get_vucc_grids($band, $mode, $location_list, $qsl, $lotw, $eqsl); + + foreach ($col_vucc_grids as $gridSplit) { + $grids = explode(",", $gridSplit->gridsquare); + foreach($grids as $key) { + $grid_four = strtoupper(substr(trim($key),0,4)); + if (!array_search($grid_four, array_column($timeline, 'gridsquare'))) { + $timeline[] = array( + 'gridsquare' => $grid_four, + 'date' => $gridSplit->date); + } + } + } + usort($timeline, function($a, $b) { + return $b['date'] <=> $a['date']; + }); + + return $timeline; + } + + public function get_gridsquare($band, $mode, $location_list, $qsl, $lotw, $eqsl) { + // $sql = "select min(date(COL_TIME_ON)) date, col_gridsquare from " + $sql = "select min(date(COL_TIME_ON)) date, upper(substring(col_gridsquare, 1, 4)) gridsquare from " + .$this->config->item('table_name'). " thcv + where station_id in (" . $location_list . ")"; + + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + } + else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + + if ($mode != 'All') { + $sql .= " and col_mode ='" . $mode . "'"; + } + + $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl); + + $sql .= " and col_gridsquare <> '' group by upper(substring(col_gridsquare, 1, 4)) + order by date desc"; + + $query = $this->db->query($sql); + + return $query->result(); + } + + public function get_vucc_grids($band, $mode, $location_list, $qsl, $lotw, $eqsl) { + // $sql = "select min(date(COL_TIME_ON)) date, col_gridsquare from " + $sql = "select date(COL_TIME_ON) date, upper(col_vucc_grids) gridsquare from " + .$this->config->item('table_name'). " thcv + where station_id in (" . $location_list . ")"; + + if ($band != 'All') { + if ($band == 'SAT') { + $sql .= " and col_prop_mode ='" . $band . "'"; + } + else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and col_band ='" . $band . "'"; + } + } + + if ($mode != 'All') { + $sql .= " and col_mode ='" . $mode . "'"; + } + + $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl); + + $sql .= " and col_vucc_grids <> ''"; + + $query = $this->db->query($sql); + + return $query->result(); + } } diff --git a/application/views/timeline/index.php b/application/views/timeline/index.php index 3d6049e4..7ec62a34 100644 --- a/application/views/timeline/index.php +++ b/application/views/timeline/index.php @@ -65,12 +65,16 @@ Worked All Zones (WAZ) +
+ input->post('awardradio') == 'vucc') echo ' checked'?>> + +
- -
Confirmation
-
+
input->post('qsl')) echo ' checked="checked"'; ?> > @@ -114,6 +118,7 @@ case 'was': $result = write_was_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break; case 'iota': $result = write_iota_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break; case 'waz': $result = write_waz_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break; + case 'vucc': $result = write_vucc_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break; } } else { @@ -236,3 +241,28 @@ function write_waz_timeline($timeline_array, $custom_date_format, $bandselect, $ } echo '
'; } + +function write_vucc_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $award) { + $i = count($timeline_array); + echo ' + + + + + + + + + '; + + foreach ($timeline_array as $line) { + $date_as_timestamp = strtotime($line['date']); + echo ' + + + + + '; + } + echo '
#DateGridsquareShow QSOs
' . $i-- . '' . date($custom_date_format, $date_as_timestamp) . '' . $line['gridsquare'] . 'Show
'; +}