IOTA Award added.

pull/440/head
AndreasK79 2020-03-07 11:39:22 +01:00
rodzic 0ecbef6d9f
commit 13771e9a07
6 zmienionych plików z 551 dodań i 0 usunięć

Wyświetl plik

@ -259,4 +259,75 @@ class Awards extends CI_Controller {
$this->load->view('interface_assets/footer');
}
public function iota () {
$this->load->model('iota');
$data['worked_bands'] = $this->iota->get_worked_bands(); // Used in the view for band select
if ($this->input->post('band') != NULL) { // Band is not set when page first loads.
if ($this->input->post('band') == 'All') { // Did the user specify a band? If not, use all bands
$bands = $data['worked_bands'];
}
else {
$bands[] = $this->input->post('band');
}
}
else {
$bands = $data['worked_bands'];
}
$data['bands'] = $bands; // Used for displaying selected band(s) in the table in the view
if($this->input->method() === 'post') {
$postdata['worked'] = $this->input->post('worked');
$postdata['confirmed'] = $this->input->post('confirmed');
$postdata['notworked'] = $this->input->post('notworked');
$postdata['includedeleted'] = $this->input->post('includedeleted');
$postdata['Africa'] = $this->input->post('Africa');
$postdata['Asia'] = $this->input->post('Asia');
$postdata['Europe'] = $this->input->post('Europe');
$postdata['NorthAmerica'] = $this->input->post('NorthAmerica');
$postdata['SouthAmerica'] = $this->input->post('SouthAmerica');
$postdata['Oceania'] = $this->input->post('Oceania');
$postdata['Antarctica'] = $this->input->post('Antarctica');
$postdata['band'] = $this->input->post('band');
}
else { // Setting default values at first load of page
$postdata['worked'] = 1;
$postdata['confirmed'] = 1;
$postdata['notworked'] = 1;
$postdata['includedeleted'] = 1;
$postdata['Africa'] = 1;
$postdata['Asia'] = 1;
$postdata['Europe'] = 1;
$postdata['NorthAmerica'] = 1;
$postdata['SouthAmerica'] = 1;
$postdata['Oceania'] = 1;
$postdata['Antarctica'] = 1;
$postdata['band'] = 'All';
}
$iotalist = $this->iota->fetchIota($postdata);
$data['iota_array'] = $this->iota->get_iota_array($iotalist, $bands, $postdata);
// Render Page
$data['page_title'] = "Awards - IOTA (Islands On The Air)";
$this->load->view('interface_assets/header', $data);
$this->load->view('awards/iota/index');
$this->load->view('interface_assets/footer');
}
public function iota_details(){
$this->load->model('logbook_model');
$iota = str_replace('"', "", $this->input->get("Iota"));
$band = str_replace('"', "", $this->input->get("Band"));
$data['results'] = $this->logbook_model->iota_qso_details($iota, $band);
// Render Page
$data['page_title'] = "Log View - IOTA";
$data['filter'] = "iota ".$iota. " and ".$band;
$this->load->view('interface_assets/header', $data);
$this->load->view('awards/iota/details');
$this->load->view('interface_assets/footer');
}
}

Wyświetl plik

@ -0,0 +1,318 @@
<?php
class IOTA extends CI_Model {
public $bandslots = array("160m"=>0,
"80m"=>0,
"60m"=>0,
"40m"=>0,
"30m"=>0,
"20m"=>0,
"17m"=>0,
"15m"=>0,
"12m"=>0,
"10m"=>0,
"6m" =>0,
"4m" =>0,
"2m" =>0,
"70cm"=>0,
"23cm"=>0,
"13cm"=>0,
"9cm"=>0,
"6cm"=>0,
"3cm"=>0,
"1.25cm"=>0,
"SAT"=>0,
);
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function get_worked_bands() {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
// get all worked slots from database
$data = $this->db->query(
"SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `".$this->config->item('table_name')."` WHERE station_id = ".$station_id." AND COL_PROP_MODE != \"SAT\""
);
$worked_slots = array();
foreach($data->result() as $row){
array_push($worked_slots, $row->COL_BAND);
}
$SAT_data = $this->db->query(
"SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM `".$this->config->item('table_name')."` WHERE station_id = ".$station_id." AND COL_PROP_MODE = \"SAT\""
);
foreach($SAT_data->result() as $row){
array_push($worked_slots, strtoupper($row->COL_PROP_MODE));
}
// bring worked-slots in order of defined $bandslots
$results = array();
foreach(array_keys($this->bandslots) as $slot) {
if(in_array($slot, $worked_slots)) {
array_push($results, $slot);
}
}
return $results;
}
function get_iota_array($iotaArray, $bands, $postdata) {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
foreach ($bands as $band) { // Looping through bands and entities to generate the array needed for display
foreach ($iotaArray as $iota) {
$iotaMatrix[$iota->tag]['prefix'] = $iota->prefix;
$iotaMatrix[$iota->tag]['name'] = $iota->name;
//$iotaMatrix[$iota->tag]['status'] = $iota->status;
if ($postdata['includedeleted'])
$iotaMatrix[$iota->tag]['Deleted'] = isset($iota->status) && $iota->status == 'D' ? "<div class='alert-danger'>Y</div>" : '';
$iotaMatrix[$iota->tag][$band] = '-';
}
// If worked is checked, we add worked iotas to the array
if ($postdata['worked'] != NULL) {
$workedIota = $this->getIotaBandWorked($station_id, $band, $postdata);
foreach ($workedIota as $wiota) {
$iotaMatrix[$wiota->tag][$band] = '<div class="alert-danger"><a href=\'iota_details?Iota="'.$wiota->tag.'"&Band="'. $band . '"\'>W</a></div>';;
}
}
// If confirmed is checked, we add confirmed iotas to the array
if ($postdata['confirmed'] != NULL) {
$confirmedIota = $this->getIotaBandConfirmed($station_id, $band, $postdata);
foreach ($confirmedIota as $ciota) {
$iotaMatrix[$ciota->tag][$band] = '<div class="alert-success"><a href=\'iota_details?Iota="'.$ciota->tag.'"&Band="'. $band . '"\'>C</a></div>';;
}
}
}
// We want to remove the worked iotas in the list, since we do not want to display them
if ($postdata['worked'] == NULL) {
$workedIota = $this->getIotaWorked($station_id, $postdata);
foreach ($workedIota as $wiota) {
if (array_key_exists($wiota->tag, $iotaMatrix)) {
unset($iotaMatrix[$wiota->tag]);
}
}
}
// We want to remove the confirmed iotas in the list, since we do not want to display them
if ($postdata['confirmed'] == NULL) {
$confirmedIOTA = $this->getIotaConfirmed($station_id, $postdata);
foreach ($confirmedIOTA as $ciota) {
if (array_key_exists($ciota->tag, $iotaMatrix)) {
unset($iotaMatrix[$ciota->tag]);
}
}
}
if (isset($iotaMatrix)) {
return $iotaMatrix;
}
else {
return 0;
}
}
function getIotaBandConfirmed($station_id, $band, $postdata) {
$sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv
join iota on thcv.col_iota = iota.tag
where station_id = " . $station_id .
" and thcv.col_iota is not null
and col_qsl_rcvd = 'Y'";
if ($band == 'SAT') {
$sql .= " and col_prop_mode ='" . $band . "'";
}
else {
$sql .= " and col_band ='" . $band . "'";
}
if ($postdata['includedeleted'] == NULL) {
$sql .= " and coalesce(iota.status, '') <> 'D'";
}
if ($postdata['includedeleted'] == NULL) {
$sql .= " and coalesce(iota.status, '') <> 'D'";
}
$sql .= $this->addContinentsToQuery($postdata);
$query = $this->db->query($sql);
return $query->result();
}
function getIotaBandWorked($station_id, $band, $postdata) {
$sql = 'SELECT distinct col_iota as tag FROM ' . $this->config->item('table_name'). ' thcv
join iota on thcv.col_iota = iota.tag
where station_id = ' . $station_id .
' and thcv.col_iota is not null';
if ($band == 'SAT') {
$sql .= " and col_prop_mode ='" . $band . "'";
}
else {
$sql .= " and col_band ='" . $band . "'";
}
if ($postdata['includedeleted'] == NULL) {
$sql .= " and coalesce(iota.status, '') <> 'D'";
}
$sql .= $this->addContinentsToQuery($postdata);
$query = $this->db->query($sql);
return $query->result();
}
function fetchIota($postdata) {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
$sql = "select tag, name, prefix, dxccid, status from iota where 1=1";
if ($postdata['includedeleted'] == NULL) {
$sql .= " and coalesce(iota.status, '') <> 'D'";
}
$sql .= $this->addContinentsToQuery($postdata);
if ($postdata['notworked'] == NULL) {
$sql .= " and exists (select 1 from " . $this->config->item('table_name') . " where station_id = ". $station_id . " and col_iota = iota.tag";
if ($postdata['band'] != 'All') {
if ($postdata['band'] == 'SAT') {
$sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
}
else {
$sql .= " and col_band ='" . $postdata['band'] . "'";
}
}
$sql .= ")";
}
$sql .= ' order by tag';
$query = $this->db->query($sql);
return $query->result();
}
function getIotaWorked($station_id, $postdata) {
$sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv
join iota on thcv.col_iota = iota.tag
where station_id = " . $station_id .
" and thcv.col_iota is not null
and not exists (select 1 from ". $this->config->item('table_name') . " where station_id = ". $station_id .
" and col_iota = thcv.col_iota";
if ($postdata['band'] != 'All') {
if ($postdata['band'] == 'SAT') {
$sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
}
else {
$sql .= " and col_band ='" . $postdata['band'] . "'";
}
}
$sql .= " and col_qsl_rcvd = 'Y')";
if ($postdata['band'] != 'All') {
if ($postdata['band'] == 'SAT') {
$sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
}
else {
$sql .= " and col_band ='" . $postdata['band'] . "'";
}
}
if ($postdata['includedeleted'] == NULL) {
$sql .= " and coalesce(iota.status, '') <> 'D'";
}
$sql .= $this->addContinentsToQuery($postdata);
$query = $this->db->query($sql);
return $query->result();
}
function getIotaConfirmed($station_id, $postdata) {
$sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv
join iota on thcv.col_iota = iota.tag
where station_id = " . $station_id .
" and thcv.col_iota is not null
and col_qsl_rcvd = 'Y'";
if ($postdata['includedeleted'] == NULL) {
$sql .= " and coalesce(iota.status, '') <> 'D'";
}
$sql .= $this->addContinentsToQuery($postdata);
if ($postdata['band'] != 'All') {
if ($postdata['band'] == 'SAT') {
$sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
}
else {
$sql .= " and col_band ='" . $postdata['band'] . "'";
}
}
if ($postdata['includedeleted'] == NULL) {
$sql .= " and coalesce(iota.status, '') <> 'D'";
}
$sql .= $this->addContinentsToQuery($postdata);
$query = $this->db->query($sql);
return $query->result();
}
// Made function instead of repeating this several times
function addContinentsToQuery($postdata) {
$sql = '';
if ($postdata['Africa'] == NULL) {
$sql .= " and left(tag, 2) <> 'AF'";
}
if ($postdata['Europe'] == NULL) {
$sql .= " and left(tag, 2) <> 'EU'";
}
if ($postdata['Asia'] == NULL) {
$sql .= " and left(tag, 2) <> 'AS'";
}
if ($postdata['SouthAmerica'] == NULL) {
$sql .= " and left(tag, 2) <> 'SA'";
}
if ($postdata['NorthAmerica'] == NULL) {
$sql .= " and left(tag, 2) <> 'NA'";
}
if ($postdata['Oceania'] == NULL) {
$sql .= " and left(tag, 2) <> 'OC'";
}
if ($postdata['Antarctica'] == NULL) {
$sql .= " and left(tag, 2) <> 'AN'";
}
return $sql;
}
}
?>

Wyświetl plik

@ -190,6 +190,22 @@ class Logbook_model extends CI_Model {
return $this->db->get($this->config->item('table_name'));
}
public function iota_qso_details($iota, $band){
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
$this->db->where('station_id', $station_id);
$this->db->where('COL_IOTA', $iota);
if($band != "SAT") {
$this->db->where('COL_BAND', $band);
} else {
$this->db->where('COL_PROP_MODE', "SAT");
}
return $this->db->get($this->config->item('table_name'));
}
public function cq_qso_details($cqzone){
$CI =& get_instance();
$CI->load->model('Stations');

Wyświetl plik

@ -0,0 +1,7 @@
<div class="container">
<h2>Logbook</h2>
<h3>Filtering on <?php echo $filter ?></h3>
<?php $this->load->view('view_log/partial/log') ?>

Wyświetl plik

@ -0,0 +1,138 @@
<div class="container">
<h1><?php echo $page_title; ?></h1>
<!-- Sub Nav for Awards -->
<?php $this->load->view("awards/nav_bar")?>
<form class="form" action="<?php echo site_url('awards/iota'); ?>" method="post" enctype="multipart/form-data">
<fieldset>
<!-- Multiple Checkboxes (inline) -->
<div class="form-group row">
<div class="col-md-2 control-label" for="checkboxes">Deleted DXCC</div>
<div class="col-md-10">
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="includedeleted" id="includedeleted" value="1" <?php if ($this->input->post('includedeleted') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="includedeleted">Include Deleted</label>
</div>
</div>
</div>
<!-- Multiple Checkboxes (inline) -->
<div class="form-group row">
<div class="col-md-2" for="checkboxes">Worked / confirmed</div>
<div class="col-md-10">
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="worked" id="worked" value="1" <?php if ($this->input->post('worked') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="worked">Show worked</label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="confirmed" id="confirmed" value="1" <?php if ($this->input->post('confirmed') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="confirmed">Show confirmed</label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="notworked" id="notworked" value="1" <?php if ($this->input->post('notworked') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="notworked">Show not worked</label>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-md-2">Continents</div>
<div class="col-md-10">
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="Antarctica" id="Antarctica" value="1" <?php if ($this->input->post('Antarctica') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="Antarctica">Antarctica</label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="Africa" id="Africa" value="1" <?php if ($this->input->post('Africa') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="Africa">Africa</label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="Asia" id="Asia" value="1" <?php if ($this->input->post('Asia') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="Asia">Asia</label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="Europe" id="Europe" value="1" <?php if ($this->input->post('Europe') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="Europe">Europe</label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="NorthAmerica" id="NorthAmerica" value="1" <?php if ($this->input->post('NorthAmerica') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="NorthAmerica">North America</label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="SouthAmerica" id="SouthAmerica" value="1" <?php if ($this->input->post('SouthAmerica') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="SouthAmerica">South America</label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="Oceania" id="Oceania" value="1" <?php if ($this->input->post('Oceania') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="Oceania">Oceania</label>
</div>
</div>
</div>
<!-- Select Basic -->
<div class="form-group row">
<label class="col-md-2 control-label" for="band">Band</label>
<div class="col-md-2">
<select id="band2" name="band" class="form-control">
<option value="All" <?php if ($this->input->post('band') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> >Every band</option>
<?php foreach($worked_bands as $band) {
echo '<option value="' . $band . '"';
if ($this->input->post('band') == $band) echo ' selected';
echo '>' . $band . '</option>'."\n";
} ?>
</select>
</div>
</div>
<!-- Button (Double) -->
<div class="form-group 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-danger">Reset</button>
<button id="button1id" type="submit" name="button1id" class="btn btn-success btn-primary">Show</button>
</div>
</div>
</fieldset>
</form>
<?php
$i = 1;
if ($iota_array) {
echo '
<table class="table table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<td>#</td>
<td>Iota</td>
<td>Prefix</td>
<td>Name</td>';
if ($this->input->post('includedeleted') || $this->input->method() !== 'post')
echo ' <td>Deleted</td>';
foreach($bands as $band) {
echo '<td>' . $band . '</td>';
}
echo '</tr>
</thead>
<tbody>';
foreach ($iota_array as $iota => $value) {
echo '<tr>
<td>'. $i++ .'</td>
<td>'. $iota .'</td>';
foreach ($value as $key) {
echo '<td>' . $key . '</td>';
}
echo '</tr>';
}
echo '</tfoot></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>';
}
?>
</div>

Wyświetl plik

@ -6,4 +6,5 @@
<a class="nav-link" href="<?php echo site_url('awards/sota'); ?>">SOTA</a>
<a class="nav-link" href="<?php echo site_url('awards/cq'); ?>">CQ</a>
<a class="nav-link" href="<?php echo site_url('awards/dok'); ?>">DOK</a>
<a class="nav-link" href="<?php echo site_url('awards/iota'); ?>">IOTA</a>
</nav>