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; + } +}