Refactor Logbook_model formatting and indentation

Standardized code formatting and indentation throughout Logbook_model.php for improved readability and maintainability. No functional changes were made; only whitespace, comment alignment, and consistent brace placement were updated.
这个提交包含在:
Peter Goodhall 2025-08-18 14:34:32 +01:00
父节点 adf658903b
当前提交 46155ba2de

查看文件

@ -118,7 +118,6 @@ class Logbook_model extends CI_Model
} }
if ($this->input->post('dxcc_id') == "") { if ($this->input->post('dxcc_id') == "") {
$dxcc = $this->check_dxcc_table(strtoupper(trim($callsign)), $datetime); $dxcc = $this->check_dxcc_table(strtoupper(trim($callsign)), $datetime);
if (empty($dxcc[0])) { if (empty($dxcc[0])) {
$dxcc_id = null; $dxcc_id = null;
@ -126,13 +125,12 @@ class Logbook_model extends CI_Model
$dxcc_id = $dxcc[0]; $dxcc_id = $dxcc[0];
} }
} else { } else {
// if $country isn't empty // if $country isn't empty and dxcc_id is 0 use the DXCC ID from the callsign lookup
if (!empty($country) && $this->input->post('dxcc_id') == "0") { if (!empty($country) && $this->input->post('dxcc_id') == "0") {
$dxcc_id = $dxcc_id; $dxcc_id = $dxcc_id;
} else { } else {
$dxcc_id = $this->input->post('dxcc_id'); $dxcc_id = $this->input->post('dxcc_id');
} }
} }
if ($this->input->post('continent') == "") { if ($this->input->post('continent') == "") {
@ -3008,7 +3006,8 @@ class Logbook_model extends CI_Model
} }
// Consolidated method to get all country statistics in one query // Consolidated method to get all country statistics in one query
function get_countries_statistics_consolidated($StationLocationsArray = null) { function get_countries_statistics_consolidated($StationLocationsArray = null)
{
if ($StationLocationsArray == null) { if ($StationLocationsArray == null) {
$CI = &get_instance(); $CI = &get_instance();
$CI->load->model('logbooks_model'); $CI->load->model('logbooks_model');
@ -4516,7 +4515,7 @@ class Logbook_model extends CI_Model
// Decrypt the password // Decrypt the password
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
if(!$this->session->userdata('qrz_session_key')) { if (!$this->session->userdata('qrz_session_key')) {
$qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password); $qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password);
$this->session->set_userdata('qrz_session_key', $qrz_session_key); $this->session->set_userdata('qrz_session_key', $qrz_session_key);
} }
@ -4534,7 +4533,7 @@ class Logbook_model extends CI_Model
// Decrypt the password // Decrypt the password
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
if(!$this->session->userdata('hamqth_session_key')) { if (!$this->session->userdata('hamqth_session_key')) {
$hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password); $hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password);
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key); $this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
} }
@ -4659,7 +4658,7 @@ class Logbook_model extends CI_Model
// Decrypt the password // Decrypt the password
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
if(!$this->session->userdata('qrz_session_key')) { if (!$this->session->userdata('qrz_session_key')) {
$qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password); $qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password);
$this->session->set_userdata('qrz_session_key', $qrz_session_key); $this->session->set_userdata('qrz_session_key', $qrz_session_key);
} }
@ -4688,7 +4687,7 @@ class Logbook_model extends CI_Model
// Decrypt the password // Decrypt the password
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
if(!$this->session->userdata('hamqth_session_key')) { if (!$this->session->userdata('hamqth_session_key')) {
$hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password); $hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password);
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key); $this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
} }
@ -4863,7 +4862,7 @@ class Logbook_model extends CI_Model
// [JSON PLOT] return array for plot qso for map // // [JSON PLOT] return array for plot qso for map //
public function get_plot_array_for_map($qsos_result, $isVisitor = false) public function get_plot_array_for_map($qsos_result, $isVisitor = false)
{ {
$this->load->library('qra'); $this->load->library('qra');
$CI = &get_instance(); $CI = &get_instance();
$CI->load->library('DxccFlag'); $CI->load->library('DxccFlag');
@ -4876,7 +4875,7 @@ class Logbook_model extends CI_Model
$plot['label'] = $row->COL_CALL; $plot['label'] = $row->COL_CALL;
$plot['callsign'] = $row->COL_CALL; $plot['callsign'] = $row->COL_CALL;
$flag = strtolower($CI->dxccflag->getISO($row->COL_DXCC)); $flag = strtolower($CI->dxccflag->getISO($row->COL_DXCC));
$plot['flag'] = '<span data-bs-toggle="tooltip" title="' . ucwords(strtolower(($row->name==null?"- NONE -":$row->name))) . '"><span class="fi fi-' . $flag .'"></span></span> '; $plot['flag'] = '<span data-bs-toggle="tooltip" title="' . ucwords(strtolower(($row->name == null ? "- NONE -" : $row->name))) . '"><span class="fi fi-' . $flag . '"></span></span> ';
$plot['html'] = ($row->COL_GRIDSQUARE != null ? "<b>Grid:</b> " . $row->COL_GRIDSQUARE . "<br />" : ""); $plot['html'] = ($row->COL_GRIDSQUARE != null ? "<b>Grid:</b> " . $row->COL_GRIDSQUARE . "<br />" : "");
$plot['html'] .= "<b>Date/Time:</b> " . $row->COL_TIME_ON . "<br />"; $plot['html'] .= "<b>Date/Time:</b> " . $row->COL_TIME_ON . "<br />";
$plot['html'] .= ($row->COL_SAT_NAME != null) ? ("<b>SAT:</b> " . $row->COL_SAT_NAME . "<br />") : ("<b>Band:</b> " . $row->COL_BAND . " "); $plot['html'] .= ($row->COL_SAT_NAME != null) ? ("<b>SAT:</b> " . $row->COL_SAT_NAME . "<br />") : ("<b>Band:</b> " . $row->COL_BAND . " ");
@ -4942,7 +4941,8 @@ class Logbook_model extends CI_Model
* @param array $batch_data Array of records from the ADIF file. * @param array $batch_data Array of records from the ADIF file.
* @return string HTML table rows for the processed batch. * @return string HTML table rows for the processed batch.
*/ */
public function process_qrz_batch($batch_data) { public function process_qrz_batch($batch_data)
{
$table = ""; $table = "";
$update_batch_data = []; $update_batch_data = [];
$this->load->model('Stations'); $this->load->model('Stations');
@ -4952,14 +4952,14 @@ class Logbook_model extends CI_Model
} }
// Step 1: Build WHERE clause for fetching potential matches // Step 1: Build WHERE clause for fetching potential matches
$this->db->select($this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_MODE, '); $this->db->select($this->config->item('table_name') . '.COL_PRIMARY_KEY, ' . $this->config->item('table_name') . '.COL_CALL, ' . $this->config->item('table_name') . '.COL_TIME_ON, ' . $this->config->item('table_name') . '.COL_BAND, ' . $this->config->item('table_name') . '.COL_MODE, ');
$this->db->from($this->config->item('table_name')); $this->db->from($this->config->item('table_name'));
$this->db->group_start(); // Start grouping OR conditions $this->db->group_start(); // Start grouping OR conditions
foreach ($batch_data as $record) { foreach ($batch_data as $record) {
$this->db->or_group_start(); // Start group for this record's AND conditions $this->db->or_group_start(); // Start group for this record's AND conditions
$this->db->where($this->config->item('table_name').'.COL_CALL', $record['call']); $this->db->where($this->config->item('table_name') . '.COL_CALL', $record['call']);
$this->db->like($this->config->item('table_name').'.COL_TIME_ON', $record['time_on'], 'after'); $this->db->like($this->config->item('table_name') . '.COL_TIME_ON', $record['time_on'], 'after');
$this->db->where($this->config->item('table_name').'.COL_BAND', $record['band']); $this->db->where($this->config->item('table_name') . '.COL_BAND', $record['band']);
$this->db->group_end(); // End group for this record's AND conditions $this->db->group_end(); // End group for this record's AND conditions
} }
$this->db->group_end(); // End grouping OR conditions $this->db->group_end(); // End grouping OR conditions
@ -5020,7 +5020,8 @@ class Logbook_model extends CI_Model
* @param string $user_format The user's preferred date format (e.g., 'd/m/Y', 'Y-m-d') * @param string $user_format The user's preferred date format (e.g., 'd/m/Y', 'Y-m-d')
* @return string Returns date in Y-m-d format for database storage, or original input if parsing fails * @return string Returns date in Y-m-d format for database storage, or original input if parsing fails
*/ */
private function parse_user_date($date_input, $user_format = null) { private function parse_user_date($date_input, $user_format = null)
{
if (empty($date_input)) { if (empty($date_input)) {
return $date_input; return $date_input;
} }