From 839b124c92357685f629c9df93a1eaecf08561fa Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 27 Oct 2023 13:28:53 +0200 Subject: [PATCH 1/2] Show list of unassigned QSOs --- application/controllers/Maintenance.php | 4 +-- application/models/Logbook_model.php | 4 ++- application/views/maintenance/main.php | 35 +++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/application/controllers/Maintenance.php b/application/controllers/Maintenance.php index 0e0deb2f..f6dd25c2 100644 --- a/application/controllers/Maintenance.php +++ b/application/controllers/Maintenance.php @@ -14,8 +14,8 @@ class Maintenance extends CI_Controller { $this->load->model('Stations'); $data['stations']=$this->Stations->all(); $data['page_title'] = "Maintenance"; - $data['is_there_qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id(); - if ($data['is_there_qsos_with_no_station_id']) { + $data['qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id(); + if ($data['qsos_with_no_station_id']) { $data['calls_wo_sid']=$this->Logbook_model->calls_without_station_id(); } $this->load->view('interface_assets/header', $data); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 6a48fbcc..643d4b97 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -4109,10 +4109,12 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray = } public function check_for_station_id() { + $this->db->select('COL_TIME_ON, COL_CALL, COL_MODE, COL_BAND'); $this->db->where('station_id =', NULL); $query = $this->db->get($this->config->item('table_name')); + log_message('debug','SQL: '.$this->db->last_query()); if($query->num_rows() >= 1) { - return $query->num_rows(); + return $query->result(); } else { return 0; } diff --git a/application/views/maintenance/main.php b/application/views/maintenance/main.php index 1cc03355..c1c6432e 100644 --- a/application/views/maintenance/main.php +++ b/application/views/maintenance/main.php @@ -13,11 +13,42 @@
QSO-DB Maintenance
- = 1) { ?> +
+
+ + + + + + + + + + session->userdata('user_date_format')) { + $custom_date_format = $this->session->userdata('user_date_format'); + } else { + $custom_date_format = 'd.m.Y'; + } + foreach ($qsos_with_no_station_id as $qso) { + echo ''; + $timestamp = strtotime($qso->COL_TIME_ON); + echo ''; + $timestamp = strtotime($qso->COL_TIME_ON); + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } ?> + + + +
DateTimeCallModeBand
'.date($custom_date_format, $timestamp).''.date('H:i', $timestamp).''.$qso->COL_CALL.''.$qso->COL_MODE.''.$qso->COL_BAND.'
+

Please reassign those QSOs to an existing station location:

From adb8e8d03caab4434d72d63e6fb5fb05426b642d Mon Sep 17 00:00:00 2001 From: phl0 Date: Sat, 28 Oct 2023 16:06:32 +0200 Subject: [PATCH 2/2] Allow for selection of QSOs to be reassigned --- application/controllers/Maintenance.php | 4 +-- application/models/Logbook_model.php | 39 ++++++++++++++----------- application/views/maintenance/main.php | 4 ++- assets/js/sections/maintenance.js | 27 ++++++++++++++++- 4 files changed, 53 insertions(+), 21 deletions(-) diff --git a/application/controllers/Maintenance.php b/application/controllers/Maintenance.php index f6dd25c2..5ac18615 100644 --- a/application/controllers/Maintenance.php +++ b/application/controllers/Maintenance.php @@ -29,6 +29,7 @@ class Maintenance extends CI_Controller { $this->load->model('Logbook_model'); $this->load->model('Stations'); $call = xss_clean(($this->input->post('call'))); + $qsoids = xss_clean(($this->input->post('qsoids'))); $station_profile_id = xss_clean(($this->input->post('station_id'))); // Check if target-station-id exists @@ -39,8 +40,7 @@ class Maintenance extends CI_Controller { if ($station->station_id == $station_profile_id) { $allowed=true; } } if ($allowed) { - log_message("error",$call." to ".$station_profile_id); - $status=$this->Logbook_model->update_all_station_ids($station_profile_id,$call); + $status=$this->Logbook_model->update_station_ids($station_profile_id,$call,$qsoids); } else { $status=false; } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 643d4b97..98cabe72 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -4109,7 +4109,7 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray = } public function check_for_station_id() { - $this->db->select('COL_TIME_ON, COL_CALL, COL_MODE, COL_BAND'); + $this->db->select('COL_PRIMARY_KEY, COL_TIME_ON, COL_CALL, COL_MODE, COL_BAND'); $this->db->where('station_id =', NULL); $query = $this->db->get($this->config->item('table_name')); log_message('debug','SQL: '.$this->db->last_query()); @@ -4167,24 +4167,29 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray = } } - public function update_all_station_ids($station_id,$station_callsign) { + public function update_station_ids($station_id,$station_callsign,$qsoids) { - $data = array( - 'station_id' => $station_id, - ); + if (! empty($qsoids)) { + $data = array( + 'station_id' => $station_id, + ); - $this->db->where(array('station_id' => NULL)); - if ($station_callsign == '') { - $this->db->where(array('col_station_callsign' => NULL)); - } else { - $this->db->where('col_station_callsign', $station_callsign); - } - $this->db->update($this->config->item('table_name'), $data); - if ($this->db->affected_rows() > 0) { - return TRUE; - } else { - return FALSE; - } + $this->db->where_in('COL_PRIMARY_KEY', $qsoids); + $this->db->where(array('station_id' => NULL)); + if ($station_callsign == '') { + $this->db->where(array('col_station_callsign' => NULL)); + } else { + $this->db->where('col_station_callsign', $station_callsign); + } + $this->db->update($this->config->item('table_name'), $data); + if ($this->db->affected_rows() > 0) { + return TRUE; + } else { + return FALSE; + } + } else { + return FALSE; + } } public function parse_frequency($frequency) diff --git a/application/views/maintenance/main.php b/application/views/maintenance/main.php index c1c6432e..4a93da3c 100644 --- a/application/views/maintenance/main.php +++ b/application/views/maintenance/main.php @@ -22,6 +22,7 @@ + @@ -35,6 +36,7 @@ } foreach ($qsos_with_no_station_id as $qso) { echo ''; + echo ''; $timestamp = strtotime($qso->COL_TIME_ON); echo ''; $timestamp = strtotime($qso->COL_TIME_ON); @@ -69,7 +71,7 @@ foreach ($stations->result() as $station) { $options.=''; } - echo $options.''; + echo $options.''; } ?>
Date Time Call
'.date($custom_date_format, $timestamp).'
diff --git a/assets/js/sections/maintenance.js b/assets/js/sections/maintenance.js index 69cb91e3..b8bafad8 100644 --- a/assets/js/sections/maintenance.js +++ b/assets/js/sections/maintenance.js @@ -1,8 +1,15 @@ function reassign(call,target_profile_id) { + let qsoids = []; + let elements = document.getElementsByName("cBox[]"); + elements.forEach((item) => { + if (item.checked) { + qsoids.push(item.value); + } + }); $.ajax({ url: base_url + 'index.php/maintenance/reassign', type: 'post', - data: {'call': call, 'station_id': target_profile_id}, + data: {'call': call, 'station_id': target_profile_id, 'qsoids' : qsoids}, success: function (resu) { if (resu.status) { location.reload(); @@ -10,3 +17,21 @@ function reassign(call,target_profile_id) { } }); } + +function toggleAll(source) { + console.log('test'); + if (source.checked) { + let elements = document.getElementsByName("cBox[]"); + elements.forEach((item) => { + item.checked = true; + }) + source.checked = true; + } + if (!source.checked) { + let elements = document.getElementsByName("cBox[]"); + elements.forEach((item) => { + item.checked = false; + }) + source.checked = false; + } +}