Initial commit

This commit is contained in:
Szymon Porwolik
2025-11-16 14:15:26 +01:00
parent c8c1208558
commit 668edd9646
6 changed files with 1106 additions and 0 deletions

View File

@@ -2374,4 +2374,133 @@ class Awards extends CI_Controller {
$this->load->view('awards/wpx/wpx_details', $data);
}
/*
Handles displaying the Polska Award (Polish Award)
Tracks contacts with Polish voivodeships (provinces) for the Poland award program
Uses COL_STATE field for voivodeship codes (16 Polish voivodeships)
*/
public function pl_polska() {
$footerData = [];
$footerData['scripts'] = [
'assets/js/sections/award_pl_polska.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/award_pl_polska.js")),
'assets/js/leaflet/L.Maidenhead.js',
];
$this->load->model('logbooks_model');
$this->load->model('stations');
// Get station profiles for multiselect
$data['station_profile'] = $this->stations->all_of_user();
$data['active_station_id'] = $this->session->userdata('active_station_logbook');
$this->load->model('award_pl_polska');
$this->load->model('bands');
// Define valid bands for Polska award (per PZK rules)
// https://awards.pzk.org.pl/polish-awards/polska.html
// SAT is explicitly excluded (no satellite/repeater contacts allowed)
$data['worked_bands'] = array('160M', '80M', '40M', '30M', '20M', '17M', '15M', '12M', '10M', '6M', '2M');
if($this->input->method() === 'post') {
$postdata['qsl'] = $this->security->xss_clean($this->input->post('qsl'));
$postdata['lotw'] = $this->security->xss_clean($this->input->post('lotw'));
$postdata['eqsl'] = $this->security->xss_clean($this->input->post('eqsl'));
$postdata['qrz'] = $this->security->xss_clean($this->input->post('qrz'));
$postdata['clublog'] = $this->security->xss_clean($this->input->post('clublog'));
// Always use active logbook (no multiselect)
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
} else {
$postdata['qsl'] = 1;
$postdata['lotw'] = 1;
$postdata['eqsl'] = 0;
$postdata['qrz'] = 0;
$postdata['clublog'] = 0;
// Default to active logbook
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
}
// Add confirmed key for gen_qsl_from_postdata function compatibility
$postdata['confirmed'] = 1;
if ($logbooks_locations_array) {
$location_list = "'".implode("','",$logbooks_locations_array)."'";
// Simplified data - just confirmed counts
$data['polska_array'] = $this->award_pl_polska->get_polska_simple_by_modes($postdata, $location_list);
$data['polska_totals'] = $this->award_pl_polska->get_polska_totals_by_modes($postdata, $location_list);
// Band-based data (simplified)
$data['polska_array_bands'] = $this->award_pl_polska->get_polska_simple_by_bands($data['worked_bands'], $postdata, $location_list);
$data['polska_totals_bands'] = $this->award_pl_polska->get_polska_totals_by_bands($data['worked_bands'], $postdata, $location_list);
// Calculate award classes for each mode category
$data['polska_classes'] = array();
$mode_categories = array('MIXED', 'PHONE', 'CW', 'DIGI');
foreach ($mode_categories as $category) {
$postdata_temp = $postdata;
$postdata_temp['mode'] = $category;
$postdata_temp['band'] = 'All';
$data['polska_classes'][$category] = $this->award_pl_polska->getPolskaClassByCategory($location_list, $category, $postdata_temp, true);
}
// Calculate award classes for each band
$data['polska_classes_bands'] = array();
$valid_bands = array('160M', '80M', '40M', '30M', '20M', '17M', '15M', '12M', '10M', '6M', '2M');
foreach ($valid_bands as $band) {
$postdata_temp = $postdata;
$postdata_temp['band'] = $band;
$postdata_temp['mode'] = 'All';
$data['polska_classes_bands'][$band] = $this->award_pl_polska->getPolskaClassByBand($location_list, $band, $postdata_temp, true);
}
} else {
$location_list = null;
$data['polska_array'] = null;
$data['polska_totals'] = null;
$data['polska_array_bands'] = null;
$data['polska_totals_bands'] = null;
$data['polska_classes'] = null;
$data['polska_classes_bands'] = null;
}
// Render page
$data['page_title'] = sprintf(__("Awards - %s"), __('"Polska" Award'));
$data['user_map_custom'] = $this->optionslib->get_map_custom();
$this->load->view('interface_assets/header', $data);
$this->load->view('awards/pl_polska/index');
$this->load->view('interface_assets/footer', $footerData);
}
/*
function polska_map
Returns JSON data for Polska Award map visualization
*/
public function polska_map() {
$this->load->model('award_pl_polska');
// Get category (MIXED, PHONE, CW, DIGI, or band like 20M)
$category = $this->security->xss_clean($this->input->post('category'));
if (!$category) {
$category = 'MIXED';
}
$postdata['qsl'] = $this->input->post('qsl') == 0 ? NULL: 1;
$postdata['lotw'] = $this->input->post('lotw') == 0 ? NULL: 1;
$postdata['eqsl'] = $this->input->post('eqsl') == 0 ? NULL: 1;
$postdata['qrz'] = $this->input->post('qrz') == 0 ? NULL: 1;
$postdata['clublog'] = $this->input->post('clublog') == 0 ? NULL: 1;
// Get location list for active station
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$location_list = "'" . implode("','", $logbooks_locations_array) . "'";
// Get map status directly from model
$voivodeships = $this->award_pl_polska->get_polska_map_status($category, $postdata, $location_list);
header('Content-Type: application/json');
echo json_encode($voivodeships);
}
}

View File

@@ -0,0 +1,329 @@
<?php
class Award_pl_polska extends CI_Model {
// Award constants
private $DXCC_POLAND = '269';
private $AWARD_START_DATE = '1999-01-01';
private $VALID_BANDS = array('160M','80M','40M','30M','20M','17M','15M','12M','10M','6M','2M');
private $MODE_CATEGORIES = array('MIXED', 'PHONE', 'CW', 'DIGI');
// Voivodeship codes and names
private $voivodeship_names = array(
'D' => 'Dolnośląskie',
'P' => 'Kujawsko-Pomorskie',
'B' => 'Lubuskie',
'L' => 'Lubelskie',
'C' => 'Łódzkie',
'M' => 'Małopolskie',
'R' => 'Mazowieckie',
'U' => 'Opolskie',
'K' => 'Podkarpackie',
'O' => 'Podlaskie',
'F' => 'Pomorskie',
'G' => 'Śląskie',
'S' => 'Świętokrzyskie',
'J' => 'Warmińsko-Mazurskie',
'W' => 'Wielkopolskie',
'Z' => 'Zachodniopomorskie'
);
function __construct() {
$this->load->library('Genfunctions');
}
/**
* Get voivodeship codes
*/
function getVoivodeshipCodes() {
return array_keys($this->voivodeship_names);
}
/**
* Get voivodeship name from code
*/
function getVoivodeshipName($code) {
return isset($this->voivodeship_names[$code]) ? $this->voivodeship_names[$code] : $code;
}
/**
* Build base SQL query
*/
private function buildBaseQuery($location_list, $withCount = false) {
$select = $withCount
? "SELECT UPPER(COL_STATE) as COL_STATE, COUNT(*) as qso_count"
: "SELECT DISTINCT UPPER(COL_STATE) as COL_STATE";
$sql = $select . "
FROM " . $this->config->item('table_name') . " thcv
WHERE station_id IN (" . $location_list . ")
AND COL_DXCC = '" . $this->DXCC_POLAND . "'
AND COL_TIME_ON >= '" . $this->AWARD_START_DATE . "'
AND (COL_PROP_MODE != 'SAT' OR COL_PROP_MODE IS NULL)
AND COL_BAND IN ('" . implode("','", $this->VALID_BANDS) . "')
AND COL_STATE IS NOT NULL AND COL_STATE != ''
AND UPPER(COL_STATE) IN ('" . implode("','", $this->getVoivodeshipCodes()) . "')";
return $sql;
}
/**
* Add band filter to query
*/
private function addBandFilter($sql, $band) {
if ($band != 'All') {
$sql .= " AND COL_BAND = '" . $band . "'";
}
return $sql;
}
/**
* Add mode category filter to query
*/
private function addModeCategoryFilter($sql, $mode_category) {
if ($mode_category == 'PHONE') {
$sql .= " AND (UPPER(COL_MODE) IN ('SSB','USB','LSB','AM','FM','SSTV') OR UPPER(COL_SUBMODE) IN ('SSB','USB','LSB','AM','FM','SSTV'))";
} elseif ($mode_category == 'CW') {
$sql .= " AND (UPPER(COL_MODE) = 'CW' OR UPPER(COL_SUBMODE) = 'CW')";
} elseif ($mode_category == 'DIGI') {
$digi_modes = "'RTTY','PSK','PSK31','PSK63','PSK125','PSKR','FSK','FSK441','FT4','FT8','JS8','JT4','JT6M','JT9','JT65','MFSK','OLIVIA','OPERA','PAX','PAX2','PKT','Q15','QRA64','ROS','T10','THOR','THRB','TOR','VARA','WSPR'";
$sql .= " AND (UPPER(COL_MODE) IN (" . $digi_modes . ") OR UPPER(COL_SUBMODE) IN (" . $digi_modes . "))";
}
return $sql;
}
/**
* Finalize query with GROUP BY
*/
private function finalizeQuery($sql, $withCount = false) {
if ($withCount) {
$sql .= " GROUP BY UPPER(COL_STATE)";
}
return $sql;
}
/**
* Execute voivodeship query
*/
private function queryVoivodeships($location_list, $options = array()) {
$band = isset($options['band']) ? $options['band'] : 'All';
$mode_category = isset($options['mode_category']) ? $options['mode_category'] : null;
$confirmed = isset($options['confirmed']) ? $options['confirmed'] : false;
$withCount = isset($options['withCount']) ? $options['withCount'] : false;
$postdata = isset($options['postdata']) ? $options['postdata'] : array();
$sql = $this->buildBaseQuery($location_list, $withCount);
$sql = $this->addBandFilter($sql, $band);
if ($mode_category) {
$sql = $this->addModeCategoryFilter($sql, $mode_category);
}
if ($confirmed && !empty($postdata)) {
$sql .= $this->genfunctions->addQslToQuery($postdata);
}
$sql = $this->finalizeQuery($sql, $withCount);
$query = $this->db->query($sql);
return $query->result();
}
/**
* Calculate award class based on minimum QSOs per voivodeship
*/
private function calculateAwardClass($counts) {
$voiv_codes = $this->getVoivodeshipCodes();
$min_count = PHP_INT_MAX;
foreach ($voiv_codes as $code) {
if (!isset($counts[$code]) || $counts[$code] == 0) {
return null;
}
$min_count = min($min_count, $counts[$code]);
}
if ($min_count >= 12) return 'gold';
if ($min_count >= 7) return 'silver';
if ($min_count >= 3) return 'bronze';
if ($min_count >= 1) return 'basic';
return null;
}
/**
* Get confirmed QSO counts by mode categories
*/
function get_polska_simple_by_modes($postdata, $location_list) {
$result = array();
foreach ($this->voivodeship_names as $code => $name) {
$result[$code] = array_fill_keys($this->MODE_CATEGORIES, 0);
}
foreach ($this->MODE_CATEGORIES as $category) {
$voivData = $this->queryVoivodeships($location_list, array(
'mode_category' => $category,
'confirmed' => true,
'withCount' => true,
'postdata' => $postdata
));
foreach ($voivData as $line) {
if (isset($result[$line->COL_STATE])) {
$result[$line->COL_STATE][$category] = (int)$line->qso_count;
}
}
}
return $result;
}
/**
* Get confirmed QSO counts by bands
*/
function get_polska_simple_by_bands($bands, $postdata, $location_list) {
$result = array();
foreach ($this->voivodeship_names as $code => $name) {
$result[$code] = array_fill_keys($bands, 0);
}
foreach ($bands as $band) {
$voivData = $this->queryVoivodeships($location_list, array(
'band' => $band,
'confirmed' => true,
'withCount' => true,
'postdata' => $postdata
));
foreach ($voivData as $line) {
if (isset($result[$line->COL_STATE])) {
$result[$line->COL_STATE][$band] = (int)$line->qso_count;
}
}
}
return $result;
}
/**
* Get total confirmed voivodeship counts by mode categories
*/
function get_polska_totals_by_modes($postdata, $location_list) {
$totals = array();
foreach ($this->MODE_CATEGORIES as $category) {
$voivData = $this->queryVoivodeships($location_list, array(
'mode_category' => $category,
'confirmed' => true,
'postdata' => $postdata
));
$totals[$category] = count($voivData);
}
return $totals;
}
/**
* Get total confirmed voivodeship counts by bands
*/
function get_polska_totals_by_bands($bands, $postdata, $location_list) {
$totals = array();
foreach ($bands as $band) {
$voivData = $this->queryVoivodeships($location_list, array(
'band' => $band,
'confirmed' => true,
'postdata' => $postdata
));
$totals[$band] = count($voivData);
}
return $totals;
}
/**
* Get award class by mode category
*/
function getPolskaClassByCategory($location_list, $mode_category, $postdata, $confirmed = false) {
$voivData = $this->queryVoivodeships($location_list, array(
'mode_category' => $mode_category,
'confirmed' => $confirmed,
'withCount' => true,
'postdata' => $postdata
));
$counts = array();
foreach ($voivData as $row) {
$counts[$row->COL_STATE] = $row->qso_count;
}
return $this->calculateAwardClass($counts);
}
/**
* Get award class by band
*/
function getPolskaClassByBand($location_list, $band, $postdata, $confirmed = false) {
$voivData = $this->queryVoivodeships($location_list, array(
'band' => $band,
'confirmed' => $confirmed,
'withCount' => true,
'postdata' => $postdata
));
$counts = array();
foreach ($voivData as $row) {
$counts[$row->COL_STATE] = $row->qso_count;
}
return $this->calculateAwardClass($counts);
}
/**
* Get map status (W=worked, C=confirmed, -=not worked)
*/
function get_polska_map_status($category, $postdata, $location_list) {
$result = array();
foreach ($this->voivodeship_names as $code => $name) {
$result[$code] = '-';
}
$options = array('withCount' => true);
if (in_array($category, $this->MODE_CATEGORIES)) {
$options['mode_category'] = $category;
} elseif (in_array($category, $this->VALID_BANDS)) {
$options['band'] = $category;
}
// Get worked voivodeships
$workedData = $this->queryVoivodeships($location_list, $options);
$workedVoivs = array();
foreach ($workedData as $line) {
$workedVoivs[$line->COL_STATE] = true;
}
// Get confirmed voivodeships
$options['confirmed'] = true;
$options['postdata'] = $postdata;
$confirmedData = $this->queryVoivodeships($location_list, $options);
$confirmedVoivs = array();
foreach ($confirmedData as $line) {
$confirmedVoivs[$line->COL_STATE] = true;
}
// Build result
foreach ($this->voivodeship_names as $code => $name) {
if (isset($confirmedVoivs[$code])) {
$result[$code] = 'C';
} elseif (isset($workedVoivs[$code])) {
$result[$code] = 'W';
}
}
return $result;
}
}

View File

@@ -648,6 +648,40 @@ class Logbook_model extends CI_Model {
$this->db->where('COL_STATE', $searchphrase);
$this->db->where_in('COL_DXCC', ['287']);
break;
case 'POLSKA':
$this->db->where('COL_STATE', $searchphrase);
$this->db->where('COL_DXCC', '269');
$this->db->where('COL_TIME_ON >=', '1999-01-01 00:00:00');
// Exclude satellite contacts for Polska Award
$this->db->group_start();
$this->db->where('COL_PROP_MODE !=', 'SAT');
$this->db->or_where('COL_PROP_MODE IS NULL');
$this->db->group_end();
// Only count allowed bands for Polska Award
$this->db->where_in('COL_BAND', ['160M','80M','40M','30M','20M','17M','15M','12M','10M','6M','2M']);
// Handle mode categories for Polska Award
if (strtoupper($mode) == 'PHONE') {
$this->db->group_start();
$this->db->where_in('UPPER(COL_MODE)', ['SSB','USB','LSB','AM','FM','SSTV']);
$this->db->or_where_in('UPPER(COL_SUBMODE)', ['SSB','USB','LSB','AM','FM','SSTV']);
$this->db->group_end();
$mode = ''; // Clear mode so it's not processed again later
} elseif (strtoupper($mode) == 'DIGI') {
$this->db->group_start();
$this->db->where_in('UPPER(COL_MODE)', ['RTTY','PSK','PSK31','PSK63','PSK125','PSKR','FSK','FSK441','FT4','FT8','JS8','JT4','JT6M','JT9','JT65','MFSK','OLIVIA','OPERA','PAX','PAX2','PKT','Q15','QRA64','ROS','T10','THOR','THRB','TOR','VARA','WSPR']);
$this->db->or_where_in('UPPER(COL_SUBMODE)', ['RTTY','PSK','PSK31','PSK63','PSK125','PSKR','FSK','FSK441','FT4','FT8','JS8','JT4','JT6M','JT9','JT65','MFSK','OLIVIA','OPERA','PAX','PAX2','PKT','Q15','QRA64','ROS','T10','THOR','THRB','TOR','VARA','WSPR']);
$this->db->group_end();
$mode = ''; // Clear mode so it's not processed again later
} elseif (strtoupper($mode) == 'CW') {
$this->db->where('UPPER(COL_MODE)', 'CW');
$mode = ''; // Clear mode so it's not processed again later
} elseif (strtoupper($mode) == 'MIXED') {
$mode = 'All'; // MIXED means all modes
}
break;
case 'JCC':
$this->db->where('COL_CNTY', $searchphrase);
$this->db->where('COL_DXCC', '339');

View File

@@ -0,0 +1,379 @@
<script>
var tileUrl="<?php echo $this->optionslib->get_option('option_map_tile_server');?>";
var lang_polish_voivodeship = "<?= __("Polish Voivodeships"); ?>";
var lang_hover_over_voivodeship = "<?= __("Hover over a voivodeship"); ?>";
</script>
<style>
#polska-map {
height: calc(100vh - 500px) !important;
max-height: 900px !important;
position: relative;
}
.map-spinner-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}
</style>
<div class="container">
<!-- Award Info Box -->
<br>
<div class="position-relative">
<div id="awardInfoButton">
<script>
var lang_awards_info_button = "<?= __("Award Info"); ?>";
var lang_award_info_ln1 = "<?= __('"Polska" Award'); ?>";
var lang_award_info_ln2 = "<?= __("The Polska Award is issued by the Polish Amateur Radio Union (PZK) for contacts with stations operating from all 16 Polish voivodeships (provinces). Valid from January 1, 1999."); ?>";
var lang_award_info_ln3 = "<?= __("Award categories: MIXED (all modes/bands), PHONE (SSB/AM/FM/SSTV), CW, DIGI (RTTY/PSK/FSK), and individual bands (160M-2M). Classes: Basic (1 QSO/voiv), Bronze (3), Silver (7), Gold (12). All 16 voivodeships required."); ?>";
var lang_award_info_ln4 = "<?= sprintf(__("Official rules and information: %s"), "<a href='https://awards.pzk.org.pl/polish-awards/polska.html' target='_blank'>" . __("PZK Polska Award Rules") . "</a>"); ?>";
var lang_award_info_ln5 = "<?= __("Requirements: COL_STATE (voivodeship code), COL_DXCC=269 (Poland), QSO date >= 1999-01-01. No cross-band/cross-mode/repeater contacts."); ?>";
</script>
<h2><?php echo $page_title; ?></h2>
<button type="button" class="btn btn-sm btn-primary me-1" id="displayAwardInfo"><?= __("Award Info"); ?></button>
</div>
</div>
<!-- End of Award Info Box -->
<form class="form" action="<?php echo site_url('awards/pl_polska'); ?>" method="post" enctype="multipart/form-data">
<fieldset>
<div class="mb-3 row">
<label class="col-md-2 control-label"><?= __("Station Location"); ?></label>
<div class="col-md-10">
<?php
$active_station = null;
foreach ($station_profile->result() as $station) {
if ($station->station_id == $active_station_id) {
$active_station = $station;
break;
}
}
if ($active_station) {
echo '<span class="badge text-bg-info">' . htmlspecialchars($active_station->station_profile_name) . '</span>';
}
?>
</div>
</div>
<div class="mb-3 row">
<div class="col-md-2">
<?= __("Confirmation methods"); ?>
<i class="fas fa-info-circle" data-bs-toggle="tooltip" data-bs-placement="right" title="<?= __("According to official award rules, paper QSL cards or LoTW confirmations are accepted for award applications. Other digital confirmations are shown here for tracking purposes only."); ?>"></i>
</div>
<div class="col-md-10">
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="qsl" value="1" id="qsl" <?php if ($this->input->post('qsl') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="qsl"><?= __("QSL"); ?></label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="lotw" value="1" id="lotw" <?php if ($this->input->post('lotw') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="lotw"><?= __("LoTW"); ?></label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="eqsl" value="1" id="eqsl" <?php if ($this->input->post('eqsl')) echo ' checked="checked"'; ?> >
<label class="form-check-label" for="eqsl"><?= __("eQSL"); ?></label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="qrz" value="1" id="qrz" <?php if ($this->input->post('qrz')) echo ' checked="checked"'; ?> >
<label class="form-check-label" for="qrz"><?= __("QRZ.com"); ?></label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="clublog" value="1" id="clublog" <?php if ($this->input->post('clublog')) echo ' checked="checked"'; ?> >
<label class="form-check-label" for="clublog"><?= __("Clublog"); ?></label>
</div>
</div>
</div>
<div class="mb-3 row">
<label class="col-md-2 control-label" for="button1id"></label>
<div class="col-md-10">
<button id="button2id" type="reset" name="button2id" class="btn btn-sm btn-warning"><?= __("Reset"); ?></button>
<button id="button1id" type="submit" name="button1id" class="btn btn-sm btn-primary"><?= __("Show"); ?></button>
</div>
</div>
</fieldset>
</form>
<br />
<?php
if ($polska_array) {
$mode_categories = array('MIXED', 'PHONE', 'CW', 'DIGI');
// Award Categories Information
echo '<div class="card mb-3">';
echo '<div class="card-header"><h5 class="mb-0"><i class="fas fa-trophy"></i> ' . __('Award Categories') . '</h5></div>';
echo '<div class="card-body">';
echo '<p class="mb-2">' . __('Polska Award categories are based on the minimum number of confirmed QSOs with each of all 16 voivodeships:') . '</p>';
echo '<div class="row">';
echo '<div class="col-md-6">';
echo '<ul class="mb-2">';
echo '<li><i class="fas fa-certificate text-secondary"></i> <strong>' . __('Basic Class') . ':</strong> ' . __('1 QSO per voivodeship') . '</li>';
echo '<li><i class="fas fa-medal" style="color: #cd7f32 !important;"></i> <strong>' . __('Bronze Class (3rd)') . ':</strong> ' . __('3 QSOs per voivodeship') . '</li>';
echo '</ul>';
echo '</div>';
echo '<div class="col-md-6">';
echo '<ul class="mb-2">';
echo '<li><i class="fas fa-medal" style="color: #c0c0c0 !important;"></i> <strong>' . __('Silver Class (2nd)') . ':</strong> ' . __('7 QSOs per voivodeship') . '</li>';
echo '<li><i class="fas fa-trophy text-warning"></i> <strong>' . __('Gold Class (1st)') . ':</strong> ' . __('12 QSOs per voivodeship') . '</li>';
echo '</ul>';
echo '</div>';
echo '</div>';
// Display entitlement if user has earned any confirmed classes
if (isset($polska_classes)) {
$eligible_classes = array();
foreach ($mode_categories as $category) {
if (isset($polska_classes[$category]) && $polska_classes[$category]) {
$eligible_classes[] = $category . ' (' . ucfirst($polska_classes[$category]) . ')';
}
}
$valid_bands = array('160M', '80M', '40M', '30M', '20M', '17M', '15M', '12M', '10M', '6M', '2M');
if (isset($polska_classes_bands)) {
foreach ($polska_classes_bands as $band => $class) {
if (in_array(strtoupper($band), $valid_bands) && $class) {
$eligible_classes[] = strtoupper($band) . ' (' . ucfirst($class) . ')';
}
}
}
if (!empty($eligible_classes)) {
echo '<div class="alert alert-success mb-0 py-2" role="alert" style="font-size: 0.9rem;">';
echo '<strong><i class="fas fa-award"></i> ' . __('Congratulations!') . '</strong> ';
echo __('You are entitled to the following award categories') . ': ';
$formatted_classes = array();
foreach ($eligible_classes as $class_text) {
if (preg_match('/^(.*?)\s*\(([^)]+)\)$/', $class_text, $matches)) {
$category = $matches[1];
$level = strtolower($matches[2]);
$icon = '';
if ($level == 'gold') $icon = '<i class="fas fa-trophy text-warning"></i> ';
elseif ($level == 'silver') $icon = '<i class="fas fa-medal" style="color: #c0c0c0 !important;"></i> ';
elseif ($level == 'bronze') $icon = '<i class="fas fa-medal" style="color: #cd7f32 !important;"></i> ';
elseif ($level == 'basic') $icon = '<i class="fas fa-certificate text-secondary"></i> ';
$formatted_classes[] = '<strong>' . $icon . $category . ' (' . ucfirst($level) . ')</strong>';
} else {
$formatted_classes[] = '<strong>' . $class_text . '</strong>';
}
}
echo implode(', ', $formatted_classes);
echo '</div>';
}
}
echo '</div>';
echo '</div>';
?>
<!-- Bootstrap Tabs Navigation -->
<ul class="nav nav-tabs" id="polskaTabs" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="mode-tab" data-bs-toggle="tab" data-bs-target="#mode-content" type="button" role="tab" aria-controls="mode-content" aria-selected="true">
<?= __("QSOs by Mode Category") ?>
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="band-tab" data-bs-toggle="tab" data-bs-target="#band-content" type="button" role="tab" aria-controls="band-content" aria-selected="false">
<?= __("QSOs by Band") ?>
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="map-tab" data-bs-toggle="tab" data-bs-target="#map-content" type="button" role="tab" aria-controls="map-content" aria-selected="false">
<?= __("Map") ?>
</button>
</li>
</ul>
<!-- Tab Content -->
<div class="tab-content" id="polskaTabsContent">
<!-- Tab 1: QSOs by Mode Category -->
<div class="tab-pane fade show active" id="mode-content" role="tabpanel" aria-labelledby="mode-tab">
<div class="mt-3">
<?php
echo '<table style="width:100%" id="polskatable" class="table table-sm table-bordered table-hover table-striped table-condensed text-center">
<thead class="table-secondary">
<tr>
<th style="width: 20%"><strong>' . __('Voivodeship') . '</strong></th>
<th style="width: 10%"><strong>' . __('Code') . '</strong></th>
<th style="width: 17.5%"><strong>' . __('MIXED') . '</strong></th>
<th style="width: 17.5%"><strong>' . __('PHONE') . '</strong></th>
<th style="width: 17.5%"><strong>' . __('CW') . '</strong></th>
<th style="width: 17.5%"><strong>' . __('DIGI') . '</strong></th>
</tr>
</thead>
<tbody>';
foreach ($polska_array as $voivodeship_code => $value) {
$voivodeship_name = $this->award_pl_polska->getVoivodeshipName($voivodeship_code);
echo '<tr>
<td style="text-align: left">' . $voivodeship_name . '</td>
<td>' . $voivodeship_code . '</td>';
foreach ($mode_categories as $category) {
$count = isset($value[$category]) ? $value[$category] : 0;
if ($count > 0) {
echo '<td><div class="bg-success text-white">' . $count . '</div></td>';
} else {
echo '<td>-</td>';
}
}
echo '</tr>';
}
echo '</tbody>
<tfoot class="table-secondary">
<tr>
<td colspan="2" style="text-align: left"><strong>' . __("Total voivodeships") . '</strong></td>';
foreach ($mode_categories as $category) {
$count = isset($polska_totals[$category]) ? $polska_totals[$category] : 0;
echo '<td style="text-align: center">';
// Add class icon if earned
if (isset($polska_classes[$category]) && $polska_classes[$category]) {
$class_name = $polska_classes[$category];
$icon = '';
if ($class_name == 'gold') $icon = '<i class="fas fa-trophy text-warning"></i>';
elseif ($class_name == 'silver') $icon = '<i class="fas fa-medal" style="color: #c0c0c0 !important;"></i>';
elseif ($class_name == 'bronze') $icon = '<i class="fas fa-medal" style="color: #cd7f32 !important;"></i>';
elseif ($class_name == 'basic') $icon = '<i class="fas fa-certificate text-secondary"></i>';
echo '<span title="' . __('Bravo! You are entitled to') . ' ' . $category . ' ' . ucfirst($class_name) . ' ' . __('category award!') . '">' . $icon . '</span> ';
}
echo '<strong>' . $count . '/16</strong></td>';
}
echo '</tr>
</tfoot>
</table>';
?>
</div>
</div>
<!-- Tab 2: QSOs by Band -->
<div class="tab-pane fade" id="band-content" role="tabpanel" aria-labelledby="band-tab">
<div class="mt-3">
<?php
if (isset($polska_array_bands) && isset($worked_bands) && $polska_array_bands) {
echo '<table style="width:100%" id="polskatable_bands" class="table table-sm table-bordered table-hover table-striped table-condensed text-center">
<thead class="table-secondary">
<tr>
<th style="text-align: left; width: 20%"><strong>' . __('Voivodeship') . '</strong></th>
<th style="width: 7%"><strong>' . __('Code') . '</strong></th>';
foreach($worked_bands as $band) {
echo '<th><strong>' . $band . '</strong></th>';
}
echo '</tr>
</thead>
<tbody>';
foreach ($polska_array_bands as $voivodeship_code => $value) {
$voivodeship_name = $this->award_pl_polska->getVoivodeshipName($voivodeship_code);
echo '<tr>
<td style="text-align: left">' . $voivodeship_name . '</td>
<td>' . $voivodeship_code . '</td>';
foreach ($worked_bands as $band) {
$count = isset($value[$band]) ? $value[$band] : 0;
if ($count > 0) {
echo '<td><div class="bg-success text-white">' . $count . '</div></td>';
} else {
echo '<td>-</td>';
}
}
echo '</tr>';
}
echo '</tbody>
<tfoot class="table-secondary">
<tr>
<td colspan="2" style="text-align: left"><strong>' . __("Total voivodeships") . '</strong></td>';
foreach ($worked_bands as $band) {
$count = isset($polska_totals_bands[$band]) ? $polska_totals_bands[$band] : 0;
echo '<td style="text-align: center">';
// Add class icon if earned
if (isset($polska_classes_bands[$band]) && $polska_classes_bands[$band]) {
$class_name = $polska_classes_bands[$band];
$icon = '';
if ($class_name == 'gold') $icon = '<i class="fas fa-trophy text-warning"></i>';
elseif ($class_name == 'silver') $icon = '<i class="fas fa-medal" style="color: #c0c0c0 !important;"></i>';
elseif ($class_name == 'bronze') $icon = '<i class="fas fa-medal" style="color: #cd7f32 !important;"></i>';
elseif ($class_name == 'basic') $icon = '<i class="fas fa-certificate text-secondary"></i>';
echo '<span title="' . __('Bravo! You are entitled to') . ' ' . strtoupper($band) . ' ' . ucfirst($class_name) . ' ' . __('category award!') . '">' . $icon . '</span> ';
}
echo '<strong>' . $count . '/16</strong></td>';
}
echo '</tr>
</tfoot>
</table>';
}
?>
</div>
</div>
<!-- Tab 3: Map -->
<div class="tab-pane fade" id="map-content" role="tabpanel" aria-labelledby="map-tab">
<div class="mt-3">
<div class="mb-3">
<label for="polska-category-select" class="form-label"><?= __("Award Category:") ?></label>
<select id="polska-category-select" class="form-select" style="max-width: 300px;">
<optgroup label="<?= __("Mode Categories") ?>">
<option value="MIXED" selected><?= __("MIXED") ?></option>
<option value="PHONE"><?= __("PHONE") ?></option>
<option value="CW"><?= __("CW") ?></option>
<option value="DIGI"><?= __("DIGI") ?></option>
</optgroup>
<optgroup label="<?= __("Band Categories") ?>">
<option value="160M">160M</option>
<option value="80M">80M</option>
<option value="40M">40M</option>
<option value="30M">30M</option>
<option value="20M">20M</option>
<option value="17M">17M</option>
<option value="15M">15M</option>
<option value="12M">12M</option>
<option value="10M">10M</option>
<option value="6M">6M</option>
<option value="2M">2M</option>
</optgroup>
</select>
</div>
<div id="polska-map" class="map-leaflet"></div>
</div>
</div>
</div>
<!-- Tips Section -->
<div class="text-muted small mt-3">
<i class="fas fa-info-circle me-1"></i><?= __('Tip:') ?> <?= __('This award uses the State field from your logbook. Ensure this field is populated for all SP (Poland) contacts.') ?> <?= __('Use') ?> <strong><?= __('Logbook Advanced') ?> / <?= __('Actions') ?> / <?= __('Fix State') ?></strong> <?= __('to auto-populate states from Maidenhead locators.') ?>
</div>
<?php
} else {
echo '<div class="alert alert-danger" role="alert">' . __("Nothing found!") . '</div>';
}
?>
</div>
</div>
</div>

View File

@@ -265,6 +265,12 @@
</ul>
</li>
<div class="dropdown-divider"></div>
<li><a class="dropdown-item dropdown-toggle dropdown-toggle-submenu" data-bs-toggle="dropdown" href="#">🇵🇱 <?= __("Poland"); ?></a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="<?php echo site_url('awards/pl_polska'); ?>"><i class="fas fa-trophy"></i> <?= __("\"Polska\" Award"); ?></a></li>
</ul>
</li>
<div class="dropdown-divider"></div>
<li><a class="dropdown-item dropdown-toggle dropdown-toggle-submenu" data-bs-toggle="dropdown" href="#">🇨🇭 <?= __("Switzerland"); ?></a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="<?php echo site_url('awards/helvetia'); ?>"><i class="fas fa-trophy"></i> H26</a></li>

View File

@@ -0,0 +1,229 @@
$(document).ready(function() {
// Auto-load map when Map tab is shown
$('#map-tab').on('shown.bs.tab', function (e) {
if (!map) {
load_polska_map();
}
});
// Reload map when category changes
$('#polska-category-select').on('change', function() {
load_polska_map();
});
});
// Polska Award Map Implementation
var voivodeships;
var geojson;
var map;
var info;
var legend;
var maidenhead;
var cachedGeoJSON = null; // Cache for GeoJSON data
var isLoading = false; // Prevent duplicate API calls
function showMapSpinner() {
var mapContainer = $('#polska-map');
if (!mapContainer.find('.map-spinner-overlay').length) {
mapContainer.append('<div class="map-spinner-overlay"><div class="spinner-border text-primary" role="status"><span class="visually-hidden">Loading...</span></div></div>');
}
mapContainer.find('.map-spinner-overlay').show();
}
function hideMapSpinner() {
$('#polska-map .map-spinner-overlay').hide();
}
function load_polska_map() {
// Prevent duplicate calls while loading
if (isLoading) {
return;
}
isLoading = true;
var category = $('#polska-category-select').val() || 'MIXED';
showMapSpinner();
$.ajax({
url: base_url + 'index.php/awards/polska_map',
type: 'post',
data: {
category: category,
qsl: +$('#qsl').prop('checked'),
lotw: +$('#lotw').prop('checked'),
eqsl: +$('#eqsl').prop('checked'),
qrz: +$('#qrz').prop('checked'),
clublog: +$('#clublog').prop('checked'),
},
success: function(data) {
voivodeships = data;
// Load GeoJSON only once, then cache it
if (cachedGeoJSON) {
updatePolskaMap(data);
} else {
$.getJSON(base_url + 'assets/json/geojson/states_269.geojson', function(mapcoordinates) {
cachedGeoJSON = mapcoordinates;
initPolskaMap(data);
});
}
},
error: function() {
console.error("Failed to load Polska map data");
},
complete: function() {
isLoading = false;
hideMapSpinner();
}
});
}
// Initialize map for the first time
function initPolskaMap(data) {
// Initialize the map
map = L.map('polska-map');
L.tileLayer(tileUrl, {
maxZoom: 18,
attribution: '&copy; OpenStreetMap contributors'
}).addTo(map);
// Info control for displaying voivodeship name on hover
info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;
};
info.update = function (props) {
this._div.innerHTML = '<h4>' + lang_polish_voivodeship + '</h4>' + (props ?
'<b>' + props.name + '</b><br />&nbsp;' : lang_hover_over_voivodeship + '<br />&nbsp;');
};
info.addTo(map);
// Add legend
addLegend(data);
// Add GeoJSON layer
geojson = L.geoJson(cachedGeoJSON, {
style: style,
onEachFeature: onEachFeature
}).addTo(map);
// Center map on Poland
map.setView([52, 19], 6);
// Add maidenhead grid overlay
maidenhead = L.maidenhead();
L.control.layers(null, {
[lang_general_gridsquares]: maidenhead
}).addTo(map);
maidenhead.addTo(map);
}
// Update map when category/filters change (reuse existing map)
function updatePolskaMap(data) {
// Remove old legend
if (legend) {
map.removeControl(legend);
legend = null;
}
// Remove old GeoJSON layer
if (geojson) {
map.removeLayer(geojson);
geojson = null;
}
// Add updated legend
addLegend(data);
// Add updated GeoJSON layer with new colors
geojson = L.geoJson(cachedGeoJSON, {
style: style,
onEachFeature: onEachFeature
}).addTo(map);
}
// Add legend with current counts
function addLegend(data) {
// Count statuses for legend
var confirmed = 0;
var workednotconfirmed = 0;
var notworked = 0;
cachedGeoJSON.features.forEach(function(feature) {
var voivCode = feature.properties.code;
var status = data[voivCode];
if (status == 'C') {
confirmed++;
} else if (status == 'W') {
workednotconfirmed++;
} else {
notworked++;
}
});
legend = L.control({ position: "topright" });
legend.onAdd = function(map) {
var div = L.DomUtil.create("div", "legend");
div.innerHTML += "<h4>" + lang_general_word_colors + "</h4>";
div.innerHTML += "<i style='background: green'></i><span>" + lang_general_word_confirmed + " (" + confirmed + ")</span><br>";
div.innerHTML += "<i style='background: orange'></i><span>" + lang_general_word_worked_not_confirmed + " (" + workednotconfirmed + ")</span><br>";
div.innerHTML += "<i style='background: red'></i><span>" + lang_general_word_not_worked + " (" + notworked + ")</span><br>";
return div;
};
legend.addTo(map);
}
function getColor(voivCode) {
// Get status from voivodeships data by voivodeship code
var status = voivodeships[voivCode];
return status == 'C' ? 'green' : // Confirmed
status == 'W' ? 'orange' : // Worked
'red'; // Not worked
}
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 3,
color: 'white',
dashArray: '',
fillOpacity: 0.8
});
layer.bringToFront();
info.update(layer.feature.properties);
}
function onEachFeature(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight
});
}
function resetHighlight(e) {
geojson.resetStyle(e.target);
info.update();
}
function style(feature) {
return {
fillColor: getColor(feature.properties.code),
weight: 1,
opacity: 1,
color: 'white',
fillOpacity: 0.6
};
}