[Cabrillo export] Added station location

这个提交包含在:
Andreas 2023-04-12 14:24:03 +02:00
父节点 7423c9eae6
当前提交 ef3c92d9cf
共有 6 个文件被更改,包括 92 次插入46 次删除

查看文件

@ -9,21 +9,24 @@ if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cabrillo extends CI_Controller {
function __construct()
{
function __construct() {
parent::__construct();
$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'); }
}
public function index()
{
public function index() {
$data['page_title'] = "Export Cabrillo";
$this->load->model('Contesting_model');
$this->load->model('stations');
$data['contestyears'] = $this->Contesting_model->get_logged_years();
$data['station_profile'] = $this->stations->all_of_user();
$active_station_id = $this->stations->find_active();
$station_profile = $this->stations->profile($active_station_id);
$data['active_station_info'] = $station_profile->row();
$footerData = [];
$footerData['scripts'] = [
@ -37,7 +40,20 @@ class Cabrillo extends CI_Controller {
public function getContests() {
$this->load->model('Contesting_model');
$result = $this->Contesting_model->get_logged_contests($this->input->post('year'));
$station_id = $this->security->xss_clean($this->input->post('station_id'));
$year = $this->security->xss_clean($this->input->post('year'));
$result = $this->Contesting_model->get_logged_contests($station_id, $year);
header('Content-Type: application/json');
echo json_encode($result);
}
public function getYears() {
$this->load->model('Contesting_model');
$station_id = $this->security->xss_clean($this->input->post('station_id'));
$result = $this->Contesting_model->get_logged_years($station_id);
header('Content-Type: application/json');
echo json_encode($result);
@ -45,7 +61,11 @@ class Cabrillo extends CI_Controller {
public function getContestDates() {
$this->load->model('Contesting_model');
$result = $this->Contesting_model->get_contest_dates($this->input->post('year'), $this->input->post('contestid'));
$station_id = $this->security->xss_clean($this->input->post('station_id'));
$year = $this->security->xss_clean($this->input->post('year'));
$contestid = $this->security->xss_clean($this->input->post('contestid'));
$result = $this->Contesting_model->get_contest_dates($station_id, $year, $contestid);
header('Content-Type: application/json');
echo json_encode($result);
@ -56,6 +76,11 @@ class Cabrillo extends CI_Controller {
ini_set('memory_limit', '-1');
$this->load->model('Contesting_model');
$this->load->model('stations');
$station_id = $this->security->xss_clean($this->input->post('station_id'));
$contest_id = $this->security->xss_clean($this->input->post('contestid'));
$fromto = $this->security->xss_clean($this->input->post('contestdates'));
@ -64,10 +89,14 @@ class Cabrillo extends CI_Controller {
$from = $fromto[0];
$to = $fromto[1];
$data['qsos'] = $this->Contesting_model->export_custom($from, $to, $contest_id);
$station = $this->stations->profile($station_id);
$station = $station->row();
$data['qsos'] = $this->Contesting_model->export_custom($from, $to, $contest_id, $station_id);
$data['contest_id'] = $contest_id;
$data['callsign'] = '';
$data['callsign'] = $station->station_callsign;
$data['claimed_score'] = '';
$data['operators'] = '';
$data['club'] = '';
@ -76,6 +105,7 @@ class Cabrillo extends CI_Controller {
$data['address2'] = '';
$data['address3'] = '';
$data['soapbox'] = '';
$data['gridlocator'] = $station->station_gridsquare;
$this->load->view('cabrillo/export', $data);
}

查看文件

@ -2,7 +2,7 @@
class Cabrilloformat {
public function header($contest_id, $callsign, $claimed_score, $operators, $club, $name, $address1, $address2, $address3, $soapbox) {
public function header($contest_id, $callsign, $claimed_score, $operators, $club, $name, $address1, $address2, $address3, $soapbox, $gridlocator) {
$cab_header = "";
$cab_header .= "START-OF-LOG: 3.0"."\r\n";
$cab_header .= "CONTEST: ".$contest_id."\r\n";
@ -24,6 +24,10 @@ class Cabrilloformat {
$cab_header .= "ADDRESS: ".$address3."\r\n";
$cab_header .= "SOAPBOX: ".$soapbox."\r\n";
if($gridlocator != null) {
$cab_header .= "GRID-LOCATOR: ".$gridlocator."\r\n";
}
return $cab_header;
}

查看文件

@ -161,11 +161,7 @@ class Contesting_model extends CI_Model {
return $query;
}
function export_custom($from, $to, $contest_id) {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
function export_custom($from, $to, $contest_id, $station_id) {
$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', $station_id);
@ -208,10 +204,7 @@ class Contesting_model extends CI_Model {
return ($data->result());
}
function get_logged_years() {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
function get_logged_years($station_id) {
$sql = "select distinct year(col_time_on) year
from " . $this->config->item('table_name') . "
@ -222,16 +215,10 @@ class Contesting_model extends CI_Model {
$data = $this->db->query($sql);
return ($data->result());
return $data->result();
}
function get_logged_contests($year) {
$year = $this->security->xss_clean($year);
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
function get_logged_contests($station_id, $year) {
$sql = "select distinct col_contest_id
from " . $this->config->item('table_name') . "
where coalesce(COL_CONTEST_ID, '') <> ''
@ -245,14 +232,7 @@ class Contesting_model extends CI_Model {
return $data->result();
}
function get_contest_dates($year, $contestid) {
$year = $this->security->xss_clean($year);
$contestid = $this->security->xss_clean($contestid);
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
function get_contest_dates($station_id, $year, $contestid) {
$sql = "select min(date(col_time_on)) mindate, max(date(col_time_on)) maxdate
from " . $this->config->item('table_name') . "
where coalesce(COL_CONTEST_ID, '') <> ''

查看文件

@ -5,7 +5,7 @@ header('Content-Disposition: attachment; filename="'.$callsign.'-'.$contest_id.'
$CI =& get_instance();
$CI->load->library('Cabrilloformat');
echo $CI->cabrilloformat->header($contest_id, $callsign, $claimed_score, $operators, $club, $name, $address1, $address2, $address3, $soapbox);
echo $CI->cabrilloformat->header($contest_id, $callsign, $claimed_score, $operators, $club, $name, $address1, $address2, $address3, $soapbox, $gridlocator);
foreach ($qsos->result() as $row) {
echo $CI->cabrilloformat->qso($row);
}

查看文件

@ -12,17 +12,22 @@
<?php
echo '<div class="contests">';
if ($contestyears) { ?>
if ($station_profile) { ?>
<form class="form" action="<?php echo site_url('cabrillo/export'); ?>" method="post" enctype="multipart/form-data">
<div class="form-group form-inline row">
<div class="col-md-2 control-label" for="year">Select year: </div>
<select id="year" class="custom-select my-1 mr-sm-2 col-md-2" name="year">
<?php foreach ($contestyears as $row) { ?>
<option value="<?php echo $row->year; ?>"><?php echo $row->year;?></option>
<?php } ?>
</select>
<button id="button1id" type="button" onclick="loadContests();" name="button1id" class="btn btn-sm btn-primary"> Proceed</button>
<div class="col-md-2 control-label" for="station_id">Select Station Location: </div>
<select id="station_id" name="station_id" class="custom-select my-1 mr-sm-2 col-md-2">
<?php foreach ($station_profile->result() as $station) { ?>
<option value="<?php echo $station->station_id; ?>" <?php if ($station->station_id == $this->stations->find_active()) { echo " selected =\"selected\""; } ?>>Callsign: <?php echo $station->station_callsign; ?> (<?php echo $station->station_profile_name; ?>)</option>
<?php } ?>
</select>
<button id="button1id" type="button" onclick="loadYears();" name="button1id" class="btn btn-sm btn-primary"> Proceed</button>
</div>
<div class="form-group form-inline row contestyear">
</div>
<div class="form-group form-inline row contestname">
</div>

查看文件

@ -1,10 +1,36 @@
function loadYears() {
$(".contestyear").empty();
$(".contestname").empty();
$(".contestdates").empty();
$.ajax({
url: base_url+'index.php/cabrillo/getYears',
type: 'post',
data: {'station_id': $("#station_id").val()},
success: function (data) {
$(".contestyear").append('<div class="col-md-2 control-label" for="year">Select year: </div>' +
'<select id="year" class="custom-select my-1 mr-sm-2 col-md-2" name="year">' +
'</select>' +
' <button onclick="loadContests();" class="btn btn-sm btn-primary" type="button">Proceed</button>');
$.each(data, function(key, value) {
$('#year')
.append($("<option></option>")
.attr("value",value.year)
.text(value.year));
});
}
});
}
function loadContests() {
$(".contestname").empty();
$(".contestdates").empty();
$.ajax({
url: base_url+'index.php/cabrillo/getContests',
type: 'post',
data: {'year': $("#year").val()},
data: {'year': $("#year").val(),
'station_id': $("#station_id").val()
},
success: function (data) {
$(".contestname").append('<div class="col-md-2 control-label" for="contestid">Select contest: </div>' +
'<select class="custom-select my-1 mr-sm-2 col-md-3" id="contestid" name="contestid">' +
@ -27,7 +53,8 @@ function loadContestDates() {
url: base_url+'index.php/cabrillo/getContestDates',
type: 'post',
data: {'year': $("#year").val(),
'contestid': $("#contestid").val()},
'contestid': $("#contestid").val(),
'station_id': $("#station_id").val()},
success: function (data) {
$(".contestdates").append('<div class="col-md-2 control-label" for="contestdates">Select daterange: </div>' +
'<select class="custom-select my-1 mr-sm-2 col-md-3" id="contestdates" name="contestdates">' +