Add SOTA csv export function
这个提交包含在:
父节点
54f6ff9e4c
当前提交
3ce3c12e39
共有 6 个文件被更改,包括 322 次插入 和 0 次删除
47
application/controllers/Csv.php
普通文件
47
application/controllers/Csv.php
普通文件
|
|
@ -0,0 +1,47 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Csv extends CI_Controller {
|
||||
|
||||
public function index() {
|
||||
$this->load->model('user_model');
|
||||
|
||||
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
|
||||
$this->load->model('modes');
|
||||
$this->load->model('logbook_model');
|
||||
$this->load->model('stations');
|
||||
$this->load->model('bands');
|
||||
|
||||
$data['station_profile'] = $this->stations->all_of_user(); // Used in the view for station location select
|
||||
$data['worked_bands'] = $this->bands->get_worked_bands(); // Used in the view for band select
|
||||
$data['modes'] = $this->modes->active(); // Used in the view for mode select
|
||||
$data['dxcc'] = $this->logbook_model->fetchDxcc(); // Used in the view for dxcc select
|
||||
|
||||
$data['page_title'] = "SOTA CSV Export";
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('csv/index');
|
||||
$this->load->view('interface_assets/footer');
|
||||
|
||||
}
|
||||
|
||||
public function export() {
|
||||
$this->load->model('csv_model');
|
||||
|
||||
// Parameters
|
||||
$station_id = $this->security->xss_clean($this->input->post('station_profile'));
|
||||
$band = $this->security->xss_clean($this->input->post('band'));
|
||||
$mode = $this->security->xss_clean($this->input->post('mode'));
|
||||
$dxcc = $this->security->xss_clean($this->input->post('dxcc_id'));
|
||||
$cqz = $this->security->xss_clean($this->input->post('cqz'));
|
||||
$propagation = $this->security->xss_clean($this->input->post('prop_mode'));
|
||||
$fromdate = $this->security->xss_clean($this->input->post('fromdate'));
|
||||
$todate = $this->security->xss_clean($this->input->post('todate'));
|
||||
|
||||
// Get QSOs with valid SOTA info
|
||||
$data['qsos'] = $this->csv_model->get_qsos($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate);
|
||||
|
||||
$this->load->view('csv/data/export', $data);
|
||||
}
|
||||
|
||||
}
|
||||
78
application/models/Csv_model.php
普通文件
78
application/models/Csv_model.php
普通文件
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
class Csv_model extends CI_Model
|
||||
{
|
||||
|
||||
/*
|
||||
* Gets the grids from the datbase
|
||||
*
|
||||
* Filters:
|
||||
*
|
||||
* $band = filter on band
|
||||
* $mode = filter on mode
|
||||
* $dxcc = filter on dxx
|
||||
* $cqz = filter on cq zone
|
||||
* $propagation = Filter on propagation
|
||||
* $fromdate = Date range from
|
||||
* $todate = Date range to
|
||||
*
|
||||
*/
|
||||
function get_qsos($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate) {
|
||||
$sql = "";
|
||||
|
||||
$sql .= "SELECT station_callsign, COL_MY_SOTA_REF, COL_QSO_DATE, COL_TIME_ON, COL_BAND, COL_MODE, COL_CALL, COL_SOTA_REF, COL_COMMENT
|
||||
FROM ".$this->config->item('table_name').
|
||||
" JOIN station_profile on station_profile.station_id = ".$this->config->item('table_name').".station_id".
|
||||
" WHERE COL_SOTA_REF <> ''";
|
||||
|
||||
if ($station_id != "All") {
|
||||
$sql .= ' and ' . $this->config->item('table_name'). '.station_id = ' . $station_id;
|
||||
}
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
} else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$sql .= " and (COL_MODE = '" . $mode . "' or COL_SUBMODE = '" . $mode . "')";
|
||||
}
|
||||
|
||||
if ($dxcc != 'All') {
|
||||
$sql .= " and COL_DXCC ='" . $dxcc . "'";
|
||||
}
|
||||
|
||||
if ($cqz != 'All') {
|
||||
$sql .= " and COL_CQZ ='" . $cqz . "'";
|
||||
}
|
||||
|
||||
if ($propagation != 'All') {
|
||||
$sql .= " and COL_PROP_MODE ='" . $propagation . "'";
|
||||
}
|
||||
|
||||
// If date is set, we format the date and add it to the where-statement
|
||||
if ($fromdate != "") {
|
||||
$from = DateTime::createFromFormat('d/m/Y', $fromdate);
|
||||
$from = $from->format('Y-m-d');
|
||||
$sql .= " and date(COL_TIME_ON) >='" . $from . "'";
|
||||
}
|
||||
if ($todate != "") {
|
||||
$to = DateTime::createFromFormat('d/m/Y', $todate);
|
||||
$to = $to->format('Y-m-d');
|
||||
$sql .= " and date(COL_TIME_ON) <='" . $to . "'";
|
||||
}
|
||||
|
||||
$sql .= ' and station_profile.user_id = ' . $this->session->userdata('user_id');
|
||||
|
||||
$sql .= ' ORDER BY `COL_TIME_ON` ASC';
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="'.$this->session->userdata('user_callsign').'-SOTA-'.date('dmY-Hi').'.csv"');
|
||||
$CI =& get_instance();
|
||||
$bands = array(
|
||||
"2190m" => "VLF",
|
||||
"560m" => "VLF",
|
||||
"160m" => "1.8MHz",
|
||||
"80m" => "3.5MHz",
|
||||
"60m" => "5MHz",
|
||||
"40m" => "7MHz",
|
||||
"30m" => "10MHz",
|
||||
"20m" => "14MHz",
|
||||
"17m" => "18MHz",
|
||||
"15m" => "21MHz",
|
||||
"12m" => "24MHz",
|
||||
"10m" => "28MHz",
|
||||
"6m" => "50MHz",
|
||||
"4m" => "70MHz",
|
||||
"2m" => "144MHz",
|
||||
"1.25m" => "220MHz",
|
||||
"70cm" => "433MHz",
|
||||
"33cm" => "900MHz",
|
||||
"23cm" => "1240MHz",
|
||||
"13cm" => "2.3GHz",
|
||||
"9cm" => "3.4GHz",
|
||||
"6cm" => "5.6GHz",
|
||||
"3cm" => "10GHz",
|
||||
"1.25cm" => "24GHz",
|
||||
"6mm" => "MIcROWAVE",
|
||||
"4mm" => "MIcROWAVE",
|
||||
"2.5mm" => "MIcROWAVE",
|
||||
"2mm" => "MIcROWAVE",
|
||||
"1mm" => "MIcROWAVE"
|
||||
);
|
||||
foreach ($qsos as $qso) {
|
||||
$timestamp = strtotime($qso['COL_TIME_ON']);
|
||||
print "V2;".$qso['station_callsign'].";".$qso['COL_MY_SOTA_REF'].";".date('d/m/y', $timestamp).";".date('Hi', $timestamp).";".$bands[$qso['COL_BAND']].";".$qso['COL_MODE'].";".$qso['COL_CALL'].";".$qso['COL_SOTA_REF'].";".$qso['COL_COMMENT']."\n";
|
||||
}
|
||||
?>
|
||||
137
application/views/csv/index.php
普通文件
137
application/views/csv/index.php
普通文件
|
|
@ -0,0 +1,137 @@
|
|||
<div class="container">
|
||||
<br>
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Export your logbook for SOTA uploads.
|
||||
</div>
|
||||
|
||||
<div class="alert alert-warning" role="alert">
|
||||
Only QSOs with SOTA information will be exported!
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<form class="form" action="<?php echo site_url('csv/export'); ?>" method="post" enctype="multipart/form-data">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="station_profile"><?php echo $this->lang->line('cloudlog_station_profile'); ?></label>
|
||||
<select name="station_profile" class="station_id custom-select">
|
||||
<option value="All">All</option>
|
||||
<?php foreach ($station_profile->result() as $station) { ?>
|
||||
<option value="<?php echo $station->station_id; ?>">Callsign: <?php echo $station->station_callsign; ?> (<?php echo $station->station_profile_name; ?>)</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="band">Band</label>
|
||||
<select id="band" name="band" class="custom-select">
|
||||
<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 class="form-group col-md-3">
|
||||
<label for="mode">Mode</label>
|
||||
<select id="mode" name="mode" class="form-control custom-select">
|
||||
<option value="All">All</option>
|
||||
<?php
|
||||
foreach($modes->result() as $mode){
|
||||
if ($mode->submode == null) {
|
||||
echo '<option value="' . $mode->mode . '">'. $mode->mode . '</option>'."\n";
|
||||
} else {
|
||||
echo '<option value="' . $mode->submode . '">' . $mode->submode . '</option>'."\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="dxcc_id">DXCC</label>
|
||||
<select class="custom-select" id="dxcc_id" name="dxcc_id">
|
||||
<option value="All">All</option>
|
||||
<?php
|
||||
foreach($dxcc as $d){
|
||||
echo '<option value=' . $d->adif . '>' . $d->prefix . ' - ' . ucwords(strtolower(($d->name))) . '</option>';
|
||||
}
|
||||
?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="cqz">CQ Zone</label>
|
||||
<select class="custom-select" id="cqz" name="cqz">
|
||||
<option value="All">All</option>
|
||||
<?php
|
||||
for ($i = 1; $i<=40; $i++) {
|
||||
echo '<option value="'. $i . '">'. $i .'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-5">
|
||||
<label for="selectPropagation">Propagation Mode</label>
|
||||
<select class="custom-select" id="selectPropagation" name="prop_mode">
|
||||
<option value="All">All</option>
|
||||
<option value="AUR">Aurora</option>
|
||||
<option value="AUE">Aurora-E</option>
|
||||
<option value="BS">Back scatter</option>
|
||||
<option value="ECH">EchoLink</option>
|
||||
<option value="EME">Earth-Moon-Earth</option>
|
||||
<option value="ES">Sporadic E</option>
|
||||
<option value="FAI">Field Aligned Irregularities</option>
|
||||
<option value="F2">F2 Reflection</option>
|
||||
<option value="INTERNET">Internet-assisted</option>
|
||||
<option value="ION">Ionoscatter</option>
|
||||
<option value="IRL">IRLP</option>
|
||||
<option value="MS">Meteor scatter</option>
|
||||
<option value="RPT">Terrestrial or atmospheric repeater or transponder</option>
|
||||
<option value="RS">Rain scatter</option>
|
||||
<option value="SAT">Satellite</option>
|
||||
<option value="TEP">Trans-equatorial</option>
|
||||
<option value="TR">Tropospheric ducting</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="datetimepicker1">From date:</label>
|
||||
<div class="csvdatepicker input-group date col-md-12" id="datetimepicker1" data-target-input="nearest">
|
||||
<input name="fromdate" type="text" placeholder="DD/MM/YYYY" class="form-control datetimepicker-input" data-target="#datetimepicker1"/>
|
||||
<div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="datetimepicker2">To date:</label>
|
||||
<div class="csvdatepicker input-group date col-md-12" id="datetimepicker2" data-target-input="nearest">
|
||||
<input name="todate" "totype="text" placeholder="DD/MM/YYYY" class="form-control datetimepicker-input" data-target="#datetimepicker2"/>
|
||||
<div class="input-group-append" data-target="#datetimepicker2" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button type="submit" class="btn btn-primary mb-2" value="Export">Export</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2552,6 +2552,24 @@ function deleteQsl(id) {
|
|||
</script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "csv") { ?>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/moment.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/tempusdominus-bootstrap-4.min.js"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
$('#datetimepicker1').datetimepicker({
|
||||
format: 'DD/MM/YYYY',
|
||||
});
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$('#datetimepicker2').datetimepicker({
|
||||
format: 'DD/MM/YYYY',
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "qslprint") { ?>
|
||||
<script>
|
||||
function deleteFromQslQueue(id) {
|
||||
|
|
|
|||
|
|
@ -210,6 +210,8 @@
|
|||
|
||||
<a class="dropdown-item" href="<?php echo site_url('dxatlas');?>" title="DX Atlas Gridsquare Export"><i class="fas fa-sync"></i> DX Atlas Gridsquare Export</a>
|
||||
|
||||
<a class="dropdown-item" href="<?php echo site_url('csv');?>" title="SOTA CSV Export"><i class="fas fa-sync"></i> SOTA CSV Export</a>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<a class="dropdown-item" href="<?php echo site_url('lotw');?>" title="Synchronise with Logbook of the World (LotW)"><i class="fas fa-sync"></i> Logbook of the World</a>
|
||||
|
|
|
|||
正在加载…
在新工单中引用