Skip to content

Commit

Permalink
[Awards][Sigs] Creation of the Sig area within the Awards dropdown wi…
Browse files Browse the repository at this point in the history
…th data grids and ADIF export

Creation of the Sig area within the Awards dropdown that shows each unique SIG option in the database and the ability to see the references along with exporting them as ADIF.
  • Loading branch information
magicbug authored Mar 20, 2021
2 parents 257f973 + 94980ec commit 0237660
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 16 deletions.
80 changes: 65 additions & 15 deletions application/controllers/Awards.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

/*
Handles Displaying of information for awards.
These are taken from comments fields or ADIF fields
These are taken from comments fields or ADIF fields
*/

class Awards extends CI_Controller {

function __construct()
{
parent::__construct();
Expand All @@ -24,7 +24,7 @@ public function index()
$this->load->view('awards/index');
$this->load->view('interface_assets/footer');
}

public function dok ()
{
//echo "Needs Developed";
Expand All @@ -39,7 +39,7 @@ public function dok ()
$this->load->view('interface_assets/footer');

}

public function dok_details_ajax(){
$a = $this->input->post();
$q = "";
Expand Down Expand Up @@ -72,7 +72,7 @@ public function dok_details_ajax(){
$data['filter'] = str_replace("(and)", ", ", $q);//implode(", ", array_keys($a));
$this->load->view('awards/details', $data);
}

public function dxcc () {
$this->load->model('dxcc');
$this->load->model('modes');
Expand Down Expand Up @@ -200,52 +200,52 @@ public function vucc_details_ajax(){
Comment field - WAB:#
*/
public function wab() {

// Grab all worked WABs
$this->load->model('wab');
$data['wab_all'] = $this->wab->get_all();

// Render Page
$data['page_title'] = "Awards - WAB";
$this->load->view('interface_assets/header', $data);
$this->load->view('awards/wab/index');
$this->load->view('interface_assets/footer');
}

/*
Handles showing worked SOTAs
Comment field - SOTA:#
*/
public function sota() {

// Grab all worked sota stations
$this->load->model('sota');
$data['sota_all'] = $this->sota->get_all();

// Render page
$data['page_title'] = "Awards - SOTA";
$this->load->view('interface_assets/header', $data);
$this->load->view('awards/sota/index');
$this->load->view('interface_assets/footer');
}

/*
Handles showing worked WACRAL members (wacral.org)
Comment field - WACRAL:#
*/
public function wacral() {

// Grab all worked wacral members
$this->load->model('wacral');
$data['wacral_all'] = $this->wacral->get_all();

// Render page
$data['page_title'] = "Awards - WACRAL Members";
$this->load->view('interface_assets/header', $data);
$this->load->view('awards/wacral/index');
$this->load->view('interface_assets/footer');
}

public function cq(){
$this->load->model('cq');
$zones = array();
Expand Down Expand Up @@ -477,4 +477,54 @@ public function counties_details_ajax(){
$data['filter'] = "county " . $state;
$this->load->view('awards/details', $data);
}

/*
Handles showing worked Sigs
Adif fields: my_sig
*/
public function sig() {
// Grab all worked sig stations
$this->load->model('sig');

$data['sig_types'] = $this->sig->get_all_sig_types();

// Render page
$data['page_title'] = "Awards - SIG";
$this->load->view('interface_assets/header', $data);
$this->load->view('awards/sig/index');
$this->load->view('interface_assets/footer');
}

/*
Handles showing worked Sigs
*/
public function sig_details() {

// Grab all worked sig stations
$this->load->model('sig');
$type = str_replace('"', "", $this->input->get("type"));
$data['sig_all'] = $this->sig->get_all($type);
$data['type'] = $type;

// Render page
$data['page_title'] = "Awards - SIG - " . $type;
$this->load->view('interface_assets/header', $data);
$this->load->view('awards/sig/qso_list');
$this->load->view('interface_assets/footer');
}

/*
Handles exporting SIGS to ADIF
*/
public function sigexportadif() {
// Set memory limit to unlimited to allow heavy usage
ini_set('memory_limit', '-1');

$this->load->model('adif_data');
//$type = str_replace('"', "", $this->input->get("type"));
$type = $this->uri->segment(3);
$data['qsos'] = $this->adif_data->sig_all($type);

$this->load->view('adif/data/exportall', $data);
}
}
16 changes: 16 additions & 0 deletions application/models/Adif_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,22 @@ function mark_lotw_sent($id) {
$this->db->where('COL_PRIMARY_KEY', $id);
$this->db->update($this->config->item('table_name'), $data);
}

function sig_all($type) {
$this->load->model('stations');
$active_station_id = $this->stations->find_active();

$this->db->select(''.$this->config->item('table_name').'.*, station_profile.*');
$this->db->from($this->config->item('table_name'));
$this->db->where($this->config->item('table_name').'.station_id', $active_station_id);
$this->db->where($this->config->item('table_name').'.COL_SIG', $type);

$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC");

$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');

return $this->db->get();
}
}

?>
40 changes: 40 additions & 0 deletions application/models/Sig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

class Sig extends CI_Model {

function __construct()
{
parent::__construct();
}

function get_all($type) {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();

$this->db->where("station_id", $station_id);
$this->db->order_by("COL_SIG_INFO", "ASC");
$this->db->where('COL_SIG =', $type);

return $this->db->get($this->config->item('table_name'));
}

function get_all_sig_types() {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();

$sql = "select col_sig, count(*) qsos, count(distinct col_sig_info) refs from " . $this->config->item('table_name') .
" where col_sig <> ''" .
" and station_id = " . $station_id .
" group by col_sig";

$query = $this->db->query($sql);

return $query->result();
}


}

?>
35 changes: 35 additions & 0 deletions application/views/awards/sig/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div class="container">
<h2><?php echo $page_title; ?></h2>

<?php if ($sig_types) { ?>
<table style="width:100%" class="table-sm table tabledxcc table-bordered table-hover table-striped table-condensed text-center">

<tr>
<td>Award Type</td>
<td># QSOs</td>
<td># Refs</td>
</tr>

<?php
foreach ($sig_types as $row) {
?>

<tr>
<td>
<?php echo $row->col_sig; ?>
</td>
<td>
<a href='sig_details?type="<?php echo $row->col_sig; ?>"'><?php echo $row->qsos; ?></a>
</td>
<td>
<a href='sig_details?type="<?php echo $row->col_sig; ?>"'><?php echo $row->refs; ?></a>
</td>
</tr>
<?php } ?>
</table>
<?php }
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>
32 changes: 32 additions & 0 deletions application/views/awards/sig/qso_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<div class="container">
<h2><?php echo $page_title; ?></h2>

<?php if ($sig_all) { ?>

<table class="table table-sm table-striped table-hover">

<tr>
<td>Reference</td>
<td>Date/Time</td>
<td>Callsign</td>
<td>Band</td>
<td>RST Sent</td>
<td>RST Received</td>
</tr>
<?php foreach ($sig_all->result() as $row) { ?>
<tr>
<td>
<?php echo $row->COL_SIG_INFO; ?>
</td>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('d/m/y', $timestamp); ?> - <?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
<td><?php echo $row->COL_CALL; ?></td>
<td><?php echo $row->COL_BAND; ?></td>
<td><?php echo $row->COL_RST_SENT; ?></td>
<td><?php echo $row->COL_RST_RCVD; ?></td>
</tr>
<?php } ?>

</table>
<?php } ?>
<p><a href="<?php echo site_url('/awards/sigexportadif/' . $type); ?>" title="Export QSOs to ADIF" target="_blank" class="btn btn-primary">Export QSOs to ADIF</a></p>
</div>
4 changes: 3 additions & 1 deletion application/views/interface_assets/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@
<a class="dropdown-item" href="<?php echo site_url('awards/dxcc');?>">DXCC</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('awards/iota');?>">IOTA</a>
<div class="dropdown-divider"></div>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('awards/sig');?>">SIG</a>
<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>
Expand Down

0 comments on commit 0237660

Please sign in to comment.