Merge pull request #869 from AndreasK79/us_counties

US Counties award added
这个提交包含在:
Peter Goodhall 2021-02-08 00:57:18 +00:00 提交者 GitHub
当前提交 0d2fe0a43b
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 7 个文件被更改,包括 272 次插入0 次删除

查看文件

@ -438,4 +438,43 @@ class Awards extends CI_Controller {
$data['filter'] = "iota ".$iota. " and ".$band;
$this->load->view('awards/details', $data);
}
public function counties() {
$this->load->model('counties');
$data['counties_array'] = $this->counties->get_counties_array();
// Render Page
$data['page_title'] = "Awards - US Counties";
$this->load->view('interface_assets/header', $data);
$this->load->view('awards/counties/index');
$this->load->view('interface_assets/footer');
}
public function counties_details() {
$this->load->model('counties');
$state = str_replace('"', "", $this->input->get("State"));
$type = str_replace('"', "", $this->input->get("Type"));
$data['counties_array'] = $this->counties->counties_details($state, $type);
$data['type'] = $type;
// Render Page
$data['page_title'] = "US Counties";
$data['filter'] = $type . " counties in state ".$state;
$this->load->view('interface_assets/header', $data);
$this->load->view('awards/counties/details');
$this->load->view('interface_assets/footer');
}
public function counties_details_ajax(){
$this->load->model('logbook_model');
$state = str_replace('"', "", $this->input->post("State"));
$county = str_replace('"', "", $this->input->post("County"));
$data['results'] = $this->logbook_model->county_qso_details($state, $county);
// Render Page
$data['page_title'] = "Log View - Counties";
$data['filter'] = "county " . $state;
$this->load->view('awards/details', $data);
}
}

查看文件

@ -0,0 +1,104 @@
<?php
class Counties extends CI_Model
{
function __construct() {
// Call the Model constructor
parent::__construct();
}
/*
* Fetches worked and confirmed counties
*/
function get_counties_array() {
$countiesArray = $this->get_counties_summary();
if (isset($countiesArray)) {
return $countiesArray;
} else {
return 0;
}
return 0;
}
/*
* Returns a result of worked/confirmed US Counties, grouped by STATE
* QSL card and EQSL is valid for award. Satellite does not count.
* No band split, as it only count the number of counties in the award.
*/
function get_counties_summary() {
$station_id = $this->get_station_id();
$sql = "select count(distinct COL_CNTY) countycountworked, coalesce(x.countycountconfirmed, 0) countycountconfirmed, thcv.COL_STATE
from " . $this->config->item('table_name') . " thcv
left outer join (
select count(distinct COL_CNTY) countycountconfirmed, COL_STATE
from " . $this->config->item('table_name') .
" where station_id =" . $station_id .
" and COL_DXCC in ('291', '6', '110')
and coalesce(COL_CNTY, '') <> ''
and COL_BAND != 'SAT'
and (col_qsl_rcvd='Y' or col_eqsl_qsl_rcvd='Y')
group by COL_STATE
order by COL_STATE
) x on thcv.COL_STATE = x.COL_STATE
where station_id =" . $station_id .
" and COL_DXCC in ('291', '6', '110')
and coalesce(COL_CNTY, '') <> ''
and COL_BAND != 'SAT'
group by thcv.COL_STATE
order by thcv.COL_STATE";
$query = $this->db->query($sql);
return $query->result_array();
}
function get_station_id() {
$CI =& get_instance();
$CI->load->model('Stations');
return $CI->Stations->find_active();
}
/*
* Makes a list of all counties in given state
*/
function counties_details($state, $type) {
if ($type == 'worked') {
$counties = $this->get_counties($state, 'none');
} else if ($type == 'confirmed') {
$counties = $this->get_counties($state, 'confirmed');
}
if (!isset($counties)) {
return 0;
} else {
ksort($counties);
return $counties;
}
}
function get_counties($state, $confirmationtype) {
$station_id = $this->get_station_id();
$sql = "select distinct COL_CNTY, COL_STATE
from " . $this->config->item('table_name') . " thcv
where station_id =" . $station_id .
" and COL_DXCC in ('291', '6', '110')
and coalesce(COL_CNTY, '') <> ''
and COL_BAND != 'SAT'";
if ($state != 'All') {
$sql .= " and COL_STATE = '" . $state . "'";
}
if ($confirmationtype != 'none') {
$sql .= " and (col_qsl_rcvd='Y' or col_eqsl_qsl_rcvd='Y')";
}
$sql .= " order by thcv.COL_STATE";
$query = $this->db->query($sql);
return $query->result_array();
}
}

查看文件

@ -2257,6 +2257,20 @@ class Logbook_model extends CI_Model {
return "Updated";
}
function county_qso_details($state, $county) {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
$this->db->where('station_id', $station_id);
$this->db->where('COL_STATE', $state);
$this->db->where('COL_CNTY', $county);
$this->db->where('COL_PROP_MODE !=', 'SAT');
return $this->db->get($this->config->item('table_name'));
}
}
function validateADIFDate($date, $format = 'Ymd')
@ -2264,4 +2278,8 @@ function validateADIFDate($date, $format = 'Ymd')
$d = DateTime::createFromFormat($format, $date);
return $d && $d->format($format) == $date;
}
?>

查看文件

@ -0,0 +1,27 @@
<div class="container">
<h2><?php echo $page_title; ?></h2>
<h3>Filtering on <?php echo $filter ?></h3>
<?php
$i = 1;
if ($counties_array) {
echo '<table style="width:100%" class="countiestable table table-sm table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<td>#</td>
<td>County</td>
</tr>
</thead>
<tbody>';
foreach ($counties_array as $county) {
echo '<tr>
<td>'. $i++ .'</td>
<td><a href=\'javascript:displayCountyContacts("'. $county['COL_STATE'] .'","'. $county['COL_CNTY'] .'")\'>'. $county['COL_CNTY'] .'</a></td>';
echo '</tr>';
}
echo '</tbody></table></div>';
}
else {
echo '<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>Nothing found!</div>';
}
?>

查看文件

@ -0,0 +1,33 @@
<div class="container">
<h2><?php echo $page_title; ?></h2>
<?php if ($counties_array) { ?>
<table style="width:100%" class="countiestable table table-sm table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<td>State</td>
<td>Counties Worked</td>
<td>Counties Confirmed</td>
</tr>
</thead>
<tbody>
<?php
$worked = 0;
$confirmed = 0;
foreach($counties_array as $counties) {
echo '<tr>';
echo '<td>' . $counties['COL_STATE'] .'</td>';
echo '<td><a href=\'counties_details?State="'.$counties['COL_STATE'].'"&Type="worked"\'>'. $counties['countycountworked'] .'</a></td>';
echo '<td><a href=\'counties_details?State="'.$counties['COL_STATE'].'"&Type="confirmed"\'>'. $counties['countycountconfirmed'] .'</a></td>';
echo '</tr>';
$worked += $counties['countycountworked'];
$confirmed += $counties['countycountconfirmed'];
}
?><tfoot><tr>
<td>Total</td>
<td><a href=counties_details?State="All"&Type="worked"><?php echo $worked ?></a></td>
<td><a href=counties_details?State="All"&Type="confirmed"><?php echo $confirmed ?></a></td>
</tr></tfoot>
</tbody>
</table>
<?php } ?>
</div>

查看文件

@ -2929,6 +2929,55 @@ function deleteQsl(id) {
});
</script>
<?php } ?>
<?php if ($this->uri->segment(2) == "counties" || $this->uri->segment(2) == "counties_details") { ?>
<script>
$('.countiestable').DataTable({
"pageLength": 25,
responsive: false,
ordering: false,
"scrollY": "390px",
"scrollCollapse": true,
"paging": false,
"scrollX": true,
dom: 'Bfrtip',
buttons: [
'csv'
]
});
// using this to change color of csv-button if dark mode is chosen
var background = $('body').css( "background-color");
if (background != ('rgb(255, 255, 255)')) {
$(".buttons-csv").css("color", "white");
}
function displayCountyContacts(state, county) {
var baseURL= "<?php echo base_url();?>";
$.ajax({
url: baseURL + 'index.php/awards/counties_details_ajax',
type: 'post',
data: {'State': state, 'County': county
},
success: function(html) {
BootstrapDialog.show({
title: 'QSO Data',
size: BootstrapDialog.SIZE_WIDE,
cssClass: 'qso-counties-dialog',
nl2br: false,
message: html,
buttons: [{
label: 'Close',
action: function (dialogItself) {
dialogItself.close();
}
}]
});
}
});
}
</script>
<?php } ?>
</body>
</html>

查看文件

@ -111,6 +111,8 @@
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('awards/sota');?>">SOTA</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('awards/counties');?>">US Counties</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('awards/vucc');?>">VUCC</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('awards/wab');?>">WAB</a>