Creation of station profiles

Station profiles allows you to define a profile for where you are operating from including your operating callsign, gridsquare, dxcc, state, cq, itu and sota.

This is then made available via the "stations" tab when adding a QSO as a drop down.
This commit is contained in:
Peter Goodhall 2019-01-01 19:14:25 +00:00
parent 71d8eb22a2
commit df3de16d5a
12 changed files with 419 additions and 3 deletions

View File

@ -14,12 +14,14 @@ class QSO extends CI_Controller {
{
$this->load->model('cat');
$this->load->model('stations');
$this->load->model('logbook_model');
$this->load->model('user_model');
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
$data['notice'] = false;
$data['stations'] = $this->stations->all();
$data['radios'] = $this->cat->radios();
$data['query'] = $this->logbook_model->last_custom('16');
@ -57,7 +59,8 @@ class QSO extends CI_Controller {
'mode' => $this->input->post('mode'),
'sat_name' => $this->input->post('sat_name'),
'sat_mode' => $this->input->post('sat_mode'),
'radio' => $this->input->post('radio')
'radio' => $this->input->post('radio'),
'station_profile_id' => $this->input->post('station_profile')
);
// ];

View File

@ -0,0 +1,61 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
Handles Displaying of information for awards.
These are taken from comments fields or ADIF fields
*/
class Station extends CI_Controller {
public function index()
{
$this->load->model('stations');
$data['stations'] = $this->stations->all();
// Render Page
$data['page_title'] = "Station Profiles";
$this->load->view('layout/header', $data);
$this->load->view('station_profile/index');
$this->load->view('layout/footer');
}
public function create()
{
$this->load->model('stations');
$this->load->model('dxcc');
$data['dxcc_list'] = $this->dxcc->list();
$this->load->library('form_validation');
$this->form_validation->set_rules('station_profile_name', 'Station Profile Name', 'required');
if ($this->form_validation->run() == FALSE)
{
$data['page_title'] = "Create Station Profile";
$this->load->view('layout/header', $data);
$this->load->view('station_profile/create');
$this->load->view('layout/footer');
}
else
{
$this->stations->add();
redirect('station');
}
}
public function edit()
{
}
public function delete($id) {
$this->load->model('stations');
$this->stations->delete($id);
redirect('station');
}
}

View File

@ -15,6 +15,10 @@ class Frequency {
'SSB'=>"3700000",
'DATA'=>"3583000",
"CW"=>"3550000"),
'60m'=>array(
'SSB'=>"5330000",
'DATA'=>"5330000",
"CW"=>"5260000"),
'40m'=>array(
'SSB'=>"7100000",
'DATA'=>"7040000",

View File

@ -85,5 +85,10 @@ class DXCC extends CI_Model {
function empty_table($table) {
$this->db->empty_table($table);
}
function list() {
$this->db->order_by('name', 'ASC');
return $this->db->get('dxcc_entities');
}
}
?>

View File

@ -112,7 +112,6 @@ class Logbook_model extends CI_Model {
$locator = $this->config->item('locator');
}
// Create array with QSO Data
$data = array(
'COL_TIME_ON' => $datetime,
@ -164,6 +163,29 @@ class Logbook_model extends CI_Model {
'COL_CQZ' => $this->input->post('cqz'),
);
// If station profile has been provided fill in the fields
if($this->input->post('station_profile') != "0") {
$station = $this->check_station($this->input->post('station_profile'));
if (strpos(trim($station['station_gridsquare']), ',') !== false) {
$data['COL_MY_VUCC_GRIDS'] = strtoupper(trim($station['station_gridsquare']));
} else {
$data['COL_MY_GRIDSQUARE'] = strtoupper(trim($station['station_gridsquare']));
}
$data['COL_MY_CITY'] = strtoupper(trim($station['station_city']));
$data['COL_MY_IOTA'] = strtoupper(trim($station['station_iota']));
$data['COL_MY_SOTA_REF'] = strtoupper(trim($station['station_sota']));
$data['COL_STATION_CALLSIGN'] = strtoupper(trim($station['station_callsign']));
$data['COL_MY_DXCC'] = strtoupper(trim($station['station_dxcc']));
$data['COL_MY_COUNTRY'] = strtoupper(trim($station['station_country']));
$data['COL_MY_CNTY'] = strtoupper(trim($station['station_cnty']));
$data['COL_MY_CQ_ZONE'] = strtoupper(trim($station['station_cq']));
$data['COL_MY_ITU_ZONE'] = strtoupper(trim($station['station_itu']));
}
// Decide whether its single gridsquare or a multi which makes it vucc_grids
if (strpos(trim($this->input->post('locator')), ',') !== false) {
$data['COL_VUCC_GRIDS'] = strtoupper(trim($this->input->post('locator')));
} else {
@ -185,6 +207,17 @@ class Logbook_model extends CI_Model {
$this->add_qso($data);
}
public function check_station($id){
$this->db->where('station_id', $id);
$query = $this->db->get('station_profile');
if ($query->num_rows() > 0) {
$row = $query->row_array();
return($row);
}
}
function add_qso($data) {
// Add QSO to database
$this->db->insert($this->config->item('table_name'), $data);

View File

@ -0,0 +1,59 @@
<?php
class Stations extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function all() {
return $this->db->get('station_profile');
}
function add() {
$data = array(
'station_profile_name' => $this->input->post('station_profile_name'),
'station_gridsquare' => strtoupper($this->input->post('gridsquare')),
'station_city' => $this->input->post('city'),
'station_iota' => strtoupper($this->input->post('iota')),
'station_sota' => strtoupper($this->input->post('sota')),
'station_callsign' => $this->input->post('station_callsign'),
'station_dxcc' => $this->input->post('dxcc'),
'station_country' => $this->input->post('station_country'),
'station_cnty' => $this->input->post('station_cnty'),
'station_cq' => $this->input->post('station_cq'),
'station_itu' => $this->input->post('station_itu'),
);
$this->db->insert('station_profile', $data);
}
function edit() {
$data = array(
'station_profile_name' => $this->input->post('station_profile_name'),
'station_gridsquare' => $this->input->post('gridsquare'),
'station_city' => $this->input->post('city'),
'station_iota' => $this->input->post('iota'),
'station_sota' => $this->input->post('sota'),
'station_callsign' => $this->input->post('station_callsign'),
'station_dxcc' => $this->input->post('dxcc'),
'station_country' => $this->input->post('station_country'),
'station_cnty' => $this->input->post('station_cnty'),
'station_cq' => $this->input->post('station_cq'),
'station_itu' => $this->input->post('station_itu'),
);
$this->db->where('station_id', $this->input->post('station_id'));
$this->db->update('station_profile', $data);
}
function delete($id) {
$this->db->delete('station_profile', array('station_id' => $id));
}
}
?>

View File

@ -79,6 +79,7 @@
<a href="#" class="dropdown-toggle">Admin</a>
<ul class="dropdown-menu">
<li><a href="<?php echo site_url('user');?>" title="Users">Users</a></li>
<li><a href="<?php echo site_url('station');?>" title="Station Profile">Station Profile</a></li>
<li><a href="<?php echo site_url('radio');?>" title="Backup">Radios</a></li>
<li><a href="<?php echo site_url('backup');?>" title="Backup">Backup</a></li>
<li><a href="<?php echo site_url('adif/import');?>" title="ADIF Import">ADIF Import</a></li>

View File

@ -191,6 +191,17 @@
</div>
<div id="station">
<table>
<tr>
<td>Station Profile</td>
<td>
<select class="station_profile" name="station_profile">
<option value="0" selected="selected">None</option>
<?php foreach ($stations->result() as $stationrow) { ?>
<option value="<?php echo $stationrow->station_id; ?>" <?php if($this->session->userdata('station_profile_id') == $stationrow->station_id) { echo "selected=\"selected\""; } ?>><?php echo $stationrow->station_profile_name; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>Radio</td>
<td>

View File

@ -0,0 +1,101 @@
<div id="container">
<h2><?php echo $page_title; ?></h2>
<?php if($this->session->flashdata('notice')) { ?>
<div id="message" >
<?php echo $this->session->flashdata('notice'); ?>
</div>
<?php } ?>
<?php
$this->load->helper('form');
?>
<?php echo validation_errors(); ?>
<form method="post" action="<?php echo site_url('station/create'); ?>" name="create_profile">
<table>
<tr>
<td>Station Profile Name</td>
<td><input type="text" name="station_profile_name" value="" required /></td>
</tr>
<tr>
<td>Station Callsign</td>
<td><input type="text" name="station_callsign" value="" required /></td>
</tr>
<tr>
<td>DXCC # For Country</td>
<td>
<?php if ($dxcc_list->num_rows() > 0) { ?>
<select id="dxcc_select" name="dxcc">
<?php foreach ($dxcc_list->result() as $dxcc) { ?>
<option value="<?php echo $dxcc->adif; ?>"><?php echo $dxcc->name; ?></option>
<?php } ?>
</select>
<?php } ?>
</td>
</tr>
<script>
$( document ).ready(function() {
$('#country').val($("#dxcc_select option:selected").text());
$( "#dxcc_select" ).change(function() {
$('#country').val($("#dxcc_select option:selected").text());
});
});
</script>
<tr>
<td>City</td>
<td><input type="text" name="city" value="" required /></td>
</tr>
<tr>
<td>Country</td>
<td><input type="text" id="country" name="station_country" value="" required />
</td>
</tr>
<tr>
<td>Cnty</td>
<td><input type="text" name="station_cnty" value="" /></td>
</tr>
<tr>
<td>CQ Zone</td>
<td><input type="text" name="station_cq" value="" required/></td>
</tr>
<tr>
<td>ITU Zone</td>
<td><input type="text" name="station_itu" value="" required/></td>
</tr>
<tr>
<td>Gridsquare</td>
<td><input type="text" name="gridsquare" value="" required /></td>
</tr>
<tr>
<td>IOTA Reference</td>
<td><input type="text" name="iota" value="" /></td>
</tr>
<tr>
<td>SOTA Reference</td>
<td><input type="text" name="sota" value="" /></td>
</tr>
</table>
<div class="actions"><input class="btn primary" type="submit" value="Submit" /></div>
</form>
</div>

View File

@ -0,0 +1,66 @@
<div id="container">
<h2><?php echo $page_title; ?></h2>
<p>Station Profiles define locations of operating positions, useful for portable operating or using a friends QTH.</p>
<?php if($this->session->flashdata('message')) { ?>
<!-- Display Message -->
<div class="alert-message error">
<p><?php echo $this->session->flashdata('message'); ?></p>
</div>
<?php } ?>
<div class="row show-grid">
<div class="span15">
<!-- Display Radio Statuses -->
<table class="station_profiles">
<?php
if ($stations->num_rows() > 0)
{
?>
<tr>
<td>Profile Name</td>
<td>Country</td>
<td>Gridsquare</td>
<td>City</td>
<td>IOTA</td>
<td>SOTA</td>
<td>Cnty</td>
<td>CQ</td>
<td>ITU</td>
<td></td>
</tr>
<?php
foreach ($stations->result() as $row)
{
?>
<tr>
<td><?php echo $row->station_profile_name;?></td>
<td><?php echo $row->station_country;?></td>
<td><?php echo $row->station_gridsquare;?></td>
<td><?php echo $row->station_city;?></td>
<td><?php echo $row->station_iota;?></td>
<td><?php echo $row->station_sota;?></td>
<td><?php echo $row->station_cnty;?></td>
<td><?php echo $row->station_cq;?></td>
<td><?php echo $row->station_itu;?></td>
<td><a href="<?php echo site_url('station/delete')."/".$row->station_id; ?>">Delete</a></td>
</tr>
<?php
}
} else {
echo "<p>Nothing to show</p>";
}
?>
</table>
<a class="btn primary" href="<?php echo site_url('station/create'); ?>">Create Station Profile</a>
</div>
</div>

View File

@ -3811,4 +3811,15 @@ ALTER TABLE `cat` ADD `downlink_freq` INT(11) NOT NULL AFTER `mode`, ADD `uplink
ALTER TABLE `TABLE_HRD_CONTACTS_V01` ADD `COL_ADDRESS_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_CREDIT_SUBMITTED`, ADD `COL_AWARD_GRANTED` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_ADDRESS_INTL`, ADD `COL_AWARD_SUMMITED` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_AWARD_GRANTED`, ADD `COL_CLUBLOG_QSO_UPLOAD_DATE` DATETIME NULL DEFAULT NULL AFTER `COL_AWARD_SUMMITED`, ADD `COL_CLUBLOG_QSO_UPLOAD_STATUS` VARCHAR(20) NULL DEFAULT NULL AFTER `COL_CLUBLOG_QSO_UPLOAD_DATE`, ADD `COL_COMMENT_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_CLUBLOG_QSO_UPLOAD_STATUS`, ADD `COL_COUNTRY_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_COMMENT_INTL`, ADD `COL_SILENT_KEY` VARCHAR(2) NULL DEFAULT NULL AFTER `COL_COUNTRY_INTL`, ADD `COL_SKCC` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_SILENT_KEY`, ADD `COL_DARC_DOK` VARCHAR(10) NULL DEFAULT NULL AFTER `COL_SKCC`, ADD `COL_FISTS` INT(10) NULL DEFAULT NULL AFTER `COL_DARC_DOK`, ADD `COL_FISTS_CC` INT(10) NULL DEFAULT NULL AFTER `COL_FISTS`, ADD `COL_HRDLOG_QSO_UPLOAD_DATE` DATETIME NULL DEFAULT NULL AFTER `COL_FISTS_CC`, ADD `COL_HRDLOG_QSO_UPLOAD_STATUS` VARCHAR(10) NULL DEFAULT NULL AFTER `COL_HRDLOG_QSO_UPLOAD_DATE`, ADD `COL_MY_ANTENNA` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_HRDLOG_QSO_UPLOAD_STATUS`, ADD `COL_MY_ANTENNA_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_MY_ANTENNA`, ADD `COL_MY_CITY_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_MY_ANTENNA_INTL`, ADD `COL_MY_COUNTRY_INTL` INT(6) NULL DEFAULT NULL AFTER `COL_MY_CITY_INTL`, ADD `COL_MY_DXCC` INT(6) NULL DEFAULT NULL AFTER `COL_MY_COUNTRY_INTL`, ADD `COL_MY_FISTS` INT(10) NULL DEFAULT NULL AFTER `COL_MY_DXCC`, ADD `COL_MY_IOTA_ISLAND_ID` VARCHAR(10) NULL DEFAULT NULL AFTER `COL_MY_FISTS`, ADD `COL_MY_NAME_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_MY_IOTA_ISLAND_ID`, ADD `COL_MY_POSTCODE_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_MY_NAME_INTL`, ADD `COL_MY_RIG_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_MY_POSTCODE_INTL`, ADD `COL_MY_SIG_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_MY_RIG_INTL`, ADD `COL_MY_SIG_INFO_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_MY_SIG_INTL`, ADD `COL_MY_SOTA_REF` VARCHAR(50) NULL DEFAULT NULL AFTER `COL_MY_SIG_INFO_INTL`, ADD `COL_MY_STREET_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_MY_SOTA_REF`, ADD `COL_MY_USACA_COUNTIES` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_MY_STREET_INTL`, ADD `COL_MY_VUCC_GRIDS` VARCHAR(50) NULL DEFAULT NULL AFTER `COL_MY_USACA_COUNTIES`, ADD `COL_NAME_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_MY_VUCC_GRIDS`, ADD `COL_NOTES_INTL` LONGTEXT NULL DEFAULT NULL AFTER `COL_NAME_INTL`, ADD `COL_QRZCOM_QSO_UPLOAD_DATE` DATETIME NULL DEFAULT NULL AFTER `COL_NOTES_INTL`, ADD `COL_QRZCOM_QSO_UPLOAD_STATUS` VARCHAR(10) NULL DEFAULT NULL AFTER `COL_QRZCOM_QSO_UPLOAD_DATE`, ADD `COL_QSO_DATE` DATE NULL DEFAULT NULL AFTER `COL_QRZCOM_QSO_UPLOAD_STATUS`, ADD `COL_QSO_DATE_OFF` DATE NULL DEFAULT NULL AFTER `COL_QSO_DATE`, ADD `COL_QTH_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_QSO_DATE_OFF`, ADD `COL_REGION` VARCHAR(25) NULL DEFAULT NULL AFTER `COL_QTH_INTL`, ADD `COL_RIG_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_REGION`, ADD `COL_SIG_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_RIG_INTL`, ADD `COL_SIG_INFO_INTL` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_SIG_INTL`;
ALTER TABLE `TABLE_HRD_CONTACTS_V01` ADD `COL_SOTA_REF` VARCHAR(30) NULL DEFAULT NULL AFTER `COL_SIG_INFO_INTL`, ADD `COL_SUBMODE` VARCHAR(25) NULL DEFAULT NULL AFTER `COL_SOTA_REF`, ADD `COL_UKSMG` VARCHAR(64) NULL DEFAULT NULL AFTER `COL_SUBMODE`, ADD `COL_USACA_COUNTIES` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_UKSMG`, ADD `COL_VUCC_GRIDS` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_USACA_COUNTIES`;
ALTER TABLE `TABLE_HRD_CONTACTS_V01` ADD `COL_SOTA_REF` VARCHAR(30) NULL DEFAULT NULL AFTER `COL_SIG_INFO_INTL`, ADD `COL_SUBMODE` VARCHAR(25) NULL DEFAULT NULL AFTER `COL_SOTA_REF`, ADD `COL_UKSMG` VARCHAR(64) NULL DEFAULT NULL AFTER `COL_SUBMODE`, ADD `COL_USACA_COUNTIES` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_UKSMG`, ADD `COL_VUCC_GRIDS` VARCHAR(255) NULL DEFAULT NULL AFTER `COL_USACA_COUNTIES`;
CREATE TABLE `station_profile` (
`station_id` int(11) NOT NULL,
`station_profile_name` varchar(200) NOT NULL,
`station_gridsquare` varchar(100) NOT NULL,
`station_city` varchar(100) NOT NULL,
`station_iota` varchar(100) NOT NULL,
`station_sota` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `station_profile` ADD `station_callsign` VARCHAR(50) NULL DEFAULT NULL AFTER `station_sota`, ADD `station_dxcc` INT(10) NULL DEFAULT NULL AFTER `station_callsign`, ADD `station_country` VARCHAR(255) NULL DEFAULT NULL AFTER `station_dxcc`, ADD `station_cnty` VARCHAR(200) NULL DEFAULT NULL AFTER `station_country`, ADD `station_cq` INT(5) NULL DEFAULT NULL AFTER `station_cnty`, ADD `station_itu` INT(5) NULL DEFAULT NULL AFTER `station_cq`;

View File

@ -0,0 +1,61 @@
-- phpMyAdmin SQL Dump
-- version 4.5.4.1deb2ubuntu2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Dec 31, 2018 at 04:29 PM
-- Server version: 10.2.15-MariaDB-10.2.15+maria~xenial-log
-- PHP Version: 7.2.6-1+ubuntu16.04.1+deb.sury.org+1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `2m0sql`
--
-- --------------------------------------------------------
--
-- Table structure for table `station_profile`
--
CREATE TABLE `station_profile` (
`station_id` int(11) NOT NULL,
`station_profile_name` varchar(200) NOT NULL,
`station_gridsquare` varchar(100) NOT NULL,
`station_city` varchar(100) NOT NULL,
`station_iota` varchar(100) NOT NULL,
`station_sota` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `station_profile`
--
ALTER TABLE `station_profile`
ADD PRIMARY KEY (`station_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `station_profile`
--
ALTER TABLE `station_profile`
MODIFY `station_id` int(11) NOT NULL AUTO_INCREMENT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
ALTER TABLE `station_profile` ADD `station_callsign` VARCHAR(50) NULL DEFAULT NULL AFTER `station_sota`, ADD `station_dxcc` INT(10) NULL DEFAULT NULL AFTER `station_callsign`, ADD `station_country` VARCHAR(255) NULL DEFAULT NULL AFTER `station_dxcc`, ADD `station_cnty` VARCHAR(200) NULL DEFAULT NULL AFTER `station_country`, ADD `station_cq` INT(5) NULL DEFAULT NULL AFTER `station_cnty`, ADD `station_itu` INT(5) NULL DEFAULT NULL AFTER `station_cq`;