Merge branch 'dev' into search_fix

这个提交包含在:
Andreas Kristiansen 2022-11-04 16:40:15 +01:00 提交者 GitHub
当前提交 437f60359e
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 13 个文件被更改,包括 285 次插入14 次删除

34
application/controllers/Logbook.php 可执行文件 -> 普通文件
查看文件

@ -711,6 +711,40 @@ class Logbook extends CI_Controller {
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
$this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', 'desc');
return $this->db->get();
}
function search_duplicates($station_id) {
$station_id = $this->security->xss_clean($station_id);
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'select count(*) as occurence, COL_CALL, COL_MODE, COL_SUBMODE, station_callsign, COL_SAT_NAME, COL_BAND, min(col_time_on) Mintime, max(col_time_on) Maxtime from ' . $this->config->item('table_name') .
' join station_profile on ' . $this->config->item('table_name') . '.station_id = station_profile.station_id where ' . $this->config->item('table_name') .'.station_id in ('. $location_list . ')';
if ($station_id != 'All') {
$sql .= ' and station_profile.station_id = ' . $station_id;
}
$sql .= ' group by col_call, col_mode, COL_SUBMODE, STATION_CALLSIGN, col_band, COL_SAT_NAME having count(*) > 1 and timediff(maxtime, mintime) < 3000';
$query = $this->db->query($sql);
$data['qsos'] = $query;
$this->load->view('search/duplicates_result.php', $data);
}
/*

查看文件

@ -56,6 +56,18 @@ class Search extends CI_Controller {
}
}
// Searches for duplicate QSOs within 30m of time difference
public function duplicates() {
$this->load->model('stations');
$data['station_profile'] = $this->stations->all_of_user();
$data['page_title'] = "Duplicate QSOs within 30m time difference";
$this->load->view('interface_assets/header', $data);
$this->load->view('search/duplicates');
$this->load->view('interface_assets/footer');
}
function json_result() {
if(isset($_POST['search'])) {
$result = $this->fetchQueryResult($_POST['search'], false);

查看文件

@ -25,26 +25,47 @@ class Timeline extends CI_Controller {
$band = 'All';
}
if ($this->input->post('mode') != NULL) { // Band is not set when page first loads.
if ($this->input->post('mode') != NULL) {
$mode = $this->input->post('mode');
}
else {
$mode = 'All';
}
if ($this->input->post('awardradio') != NULL) { // Band is not set when page first loads.
if ($this->input->post('awardradio') != NULL) {
$award = $this->input->post('awardradio');
}
else {
$award = 'dxcc';
}
if ($this->input->post('qsl') != NULL) {
$qsl = $this->input->post('qsl');
}
else {
$qsl = '0';
}
if ($this->input->post('lotw') != NULL) {
$lotw = $this->input->post('lotw');
}
else {
$lotw = '0';
}
if ($this->input->post('eqsl') != NULL) {
$eqsl = $this->input->post('eqsl');
}
else {
$eqsl = '0';
}
$this->load->model('modes');
$this->load->model('bands');
$data['modes'] = $this->modes->active();
$data['timeline_array'] = $this->Timeline_model->get_timeline($band, $mode, $award);
$data['timeline_array'] = $this->Timeline_model->get_timeline($band, $mode, $award, $qsl, $lotw, $eqsl);
$data['worked_bands'] = $this->bands->get_worked_bands();
$data['bandselect'] = $band;
$data['modeselect'] = $mode;

查看文件

@ -3,7 +3,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
class Timeline_model extends CI_Model
{
function get_timeline($band, $mode, $award) {
function get_timeline($band, $mode, $award, $qsl, $lotw, $eqsl) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@ -15,16 +15,16 @@ class Timeline_model extends CI_Model
$location_list = "'".implode("','",$logbooks_locations_array)."'";
switch ($award) {
case 'dxcc': $result = $this->get_timeline_dxcc($band, $mode, $location_list); break;
case 'was': $result = $this->get_timeline_was($band, $mode, $location_list); break;
case 'iota': $result = $this->get_timeline_iota($band, $mode, $location_list); break;
case 'waz': $result = $this->get_timeline_waz($band, $mode, $location_list); break;
case 'dxcc': $result = $this->get_timeline_dxcc($band, $mode, $location_list, $qsl, $lotw, $eqsl); break;
case 'was': $result = $this->get_timeline_was($band, $mode, $location_list, $qsl, $lotw, $eqsl); break;
case 'iota': $result = $this->get_timeline_iota($band, $mode, $location_list, $qsl, $lotw, $eqsl); break;
case 'waz': $result = $this->get_timeline_waz($band, $mode, $location_list, $qsl, $lotw, $eqsl); break;
}
return $result;
}
public function get_timeline_dxcc($band, $mode, $location_list) {
public function get_timeline_dxcc($band, $mode, $location_list, $qsl, $lotw, $eqsl) {
$sql = "select min(date(COL_TIME_ON)) date, prefix, col_country, end, adif from "
.$this->config->item('table_name'). " thcv
join dxcc_entities on thcv.col_dxcc = dxcc_entities.adif
@ -44,6 +44,8 @@ class Timeline_model extends CI_Model
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .= $this->addQslToQuery($qsl, $lotw, $eqsl);
$sql .= " group by col_dxcc, col_country
order by date desc";
@ -52,7 +54,7 @@ class Timeline_model extends CI_Model
return $query->result();
}
public function get_timeline_was($band, $mode, $location_list) {
public function get_timeline_was($band, $mode, $location_list, $qsl, $lotw, $eqsl) {
$sql = "select min(date(COL_TIME_ON)) date, col_state from "
.$this->config->item('table_name'). " thcv
where station_id in (" . $location_list . ")";
@ -74,6 +76,8 @@ class Timeline_model extends CI_Model
$sql .= " and COL_DXCC in ('291', '6', '110')";
$sql .= " and COL_STATE in ('AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY')";
$sql .= $this->addQslToQuery($qsl, $lotw, $eqsl);
$sql .= " group by col_state
order by date desc";
@ -82,7 +86,7 @@ class Timeline_model extends CI_Model
return $query->result();
}
public function get_timeline_iota($band, $mode, $location_list) {
public function get_timeline_iota($band, $mode, $location_list, $qsl, $lotw, $eqsl) {
$sql = "select min(date(COL_TIME_ON)) date, col_iota, name, prefix from "
.$this->config->item('table_name'). " thcv
join iota on thcv.col_iota = iota.tag
@ -102,6 +106,8 @@ class Timeline_model extends CI_Model
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .= $this->addQslToQuery($qsl, $lotw, $eqsl);
$sql .= " and col_iota <> '' group by col_iota, name, prefix
order by date desc";
@ -110,7 +116,7 @@ class Timeline_model extends CI_Model
return $query->result();
}
public function get_timeline_waz($band, $mode, $location_list) {
public function get_timeline_waz($band, $mode, $location_list, $qsl, $lotw, $eqsl) {
$sql = "select min(date(COL_TIME_ON)) date, col_cqz from "
.$this->config->item('table_name'). " thcv
where station_id in (" . $location_list . ")";
@ -129,6 +135,8 @@ class Timeline_model extends CI_Model
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .= $this->addQslToQuery($qsl, $lotw, $eqsl);
$sql .= " and col_cqz <> '' group by col_cqz
order by date desc";
@ -136,5 +144,39 @@ class Timeline_model extends CI_Model
return $query->result();
}
// Adds confirmation to query
function addQslToQuery($qsl, $lotw, $eqsl) {
$sql = '';
if ($lotw == 1 and $qsl == 0 and $eqsl == 0) {
$sql .= " and col_lotw_qsl_rcvd = 'Y'";
}
if ($qsl == 1 and $lotw == 0 and $eqsl == 0) {
$sql .= " and col_qsl_rcvd = 'Y'";
}
if ($eqsl == 1 and $lotw == 0 and $qsl == 0) {
$sql .= " and col_eqsl_qsl_rcvd = 'Y'";
}
if ($lotw == 1 and $qsl == 1 and $eqsl == 0) {
$sql .= " and (col_lotw_qsl_rcvd = 'Y' or col_qsl_rcvd = 'Y')";
}
if ($qsl == 1 and $lotw == 0 and $eqsl == 1) {
$sql .= " and (col_qsl_rcvd = 'Y' or col_eqsl_qsl_rcvd = 'Y')";
}
if ($eqsl == 1 and $lotw == 1 and $qsl == 0) {
$sql .= " and (col_eqsl_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
}
if ($qsl == 1 && $lotw == 1 && $eqsl == 1) {
$sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y' or col_eqsl_qsl_rcvd = 'Y')";
}
return $sql;
}
}

查看文件

@ -855,7 +855,7 @@ function getLookupResult() {
<?php } ?>
<?php if ($this->uri->segment(1) == "search") { ?>
<script type="text/javascript">
$(function () {
$('[data-toggle="tooltip"]').tooltip()
@ -892,9 +892,34 @@ function getLookupResult() {
});
});
</script>
<?php if ($this->uri->segment(1) == "search") { ?>
<script type="text/javascript">
i=0;
function findduplicates(){
event.preventDefault();
$('#partial_view').load(base_url+"index.php/logbook/search_duplicates/"+$("#station_id").val(), function() {
$('.qsolist').DataTable({
"pageLength": 25,
responsive: false,
ordering: false,
"scrollY": "500px",
"scrollCollapse": true,
"paging": false,
"scrollX": true,
dom: 'Bfrtip',
buttons: [
'csv'
]
});
// change color of csv-button if dark mode is chosen
if (isDarkModeTheme()) {
$(".buttons-csv").css("color", "white");
}
});
}
function searchButtonPress(){
event.preventDefault()
if ($('#callsign').val()) {

查看文件

@ -0,0 +1,43 @@
<div class="container search">
<h1>
Search
<small class="text-muted">Ready to find a QSO?</small>
</h1>
<div class="card text-center">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('search'); ?>">Search</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('search/filter'); ?>">Advanced Search</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="<?php echo site_url('search/duplicates'); ?>">Duplicate QSOs</a>
</li>
</ul>
</div>
<div class="card-body">
<form method="post" action="" id="search_box" name="test">
<div class="form-group row">
<label for="callsign" class="col-sm-2 col-form-label">Station location:</label>
<select id="station_id" name="station_profile" class="custom-select col-sm-3 mb-3 mr-sm-3">
<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 class="col-sm-2">
<button onclick="findduplicates();" class="btn btn-outline-success my-2 my-sm-0" type="submit"><i class="fas fa-search"></i> Search</button>
</div>
</div>
</form>
<div id="partial_view"></div>
</div>
</div>
</div>

查看文件

@ -0,0 +1,50 @@
<?php
if ($qsos->result() != NULL) {
Echo 'The following QSOs were found on the same band, mode, date and time difference 30 minutes:';
echo '<table style="width:100%" class="qsolist table-sm table-bordered table-hover table-striped table-condensed">
<thead>
<tr>
<th style=\'text-align: center\'>Occurrence</th>
<th style=\'text-align: center\'>'.$this->lang->line('gen_hamradio_callsign').'</th>
<th style=\'text-align: center\'>Min date</th>
<th style=\'text-align: center\'>Min time</th>
<th style=\'text-align: center\'>Max date</th>
<th style=\'text-align: center\'>Max time</th>
<th style=\'text-align: center\'>' . $this->lang->line('gen_hamradio_mode') . '</th>
<th style=\'text-align: center\'>' . $this->lang->line('gen_hamradio_band') . '</th>
<th style=\'text-align: center\'>' . $this->lang->line('gen_hamradio_station') . '</th>
</tr>
</thead><tbody>';
// Get Date format
if($this->session->userdata('user_date_format')) {
// If Logged in and session exists
$custom_date_format = $this->session->userdata('user_date_format');
} else {
// Get Default date format from /config/cloudlog.php
$custom_date_format = $this->config->item('qso_date_format');
}
$i = 0;
foreach ($qsos->result() as $qso) {
echo '<tr>';
echo '<td style=\'text-align: center\'>' . $qso->occurence . '</td>';
echo '<td style=\'text-align: center\'><form id="searchcall_'.$i.'" method="POST" action="'.site_url('search'). '"><input type="hidden" value="'. strtoupper($qso->COL_CALL) .'" name="callsign"><a href="javascript:$(\'#searchcall_'.$i++.'\').submit()">' . $qso->COL_CALL . '</a></form></td>';
echo '<td style=\'text-align: center\'>'; $timestamp = strtotime($qso->Mintime); echo date($custom_date_format, $timestamp); echo '</td>';
echo '<td style=\'text-align: center\'>'; $timestamp = strtotime($qso->Mintime); echo date('H:i', $timestamp); echo '</td>';
echo '<td style=\'text-align: center\'>'; $timestamp = strtotime($qso->Maxtime); echo date($custom_date_format, $timestamp); echo '</td>';
echo '<td style=\'text-align: center\'>'; $timestamp = strtotime($qso->Maxtime); echo date('H:i', $timestamp); echo '</td>';
echo '<td style=\'text-align: center\'>'; echo $qso->COL_SUBMODE==null?$qso->COL_MODE:$qso->COL_SUBMODE; echo '</td>';
echo '<td style=\'text-align: center\'>'; if($qso->COL_SAT_NAME != null) { echo $qso->COL_SAT_NAME; } else { echo strtolower($qso->COL_BAND); }; echo '</td>';
echo '<td style=\'text-align: center\'><span class="badge badge-light">' . $qso->station_callsign . '</span></td>';
echo '</tr>';
}
echo '</tbody></table>';
?>
<?php
} else {
echo '<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>No duplicate QSO\'s were found.</div>';
}
?>

查看文件

@ -21,6 +21,9 @@
</li>
<li class="nav-item">
<a class="nav-link active" href="<?php echo site_url('search/filter'); ?>">Advanced Search</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('search/duplicates'); ?>">Duplicate QSOs</a>
</li>
</ul>
</div>

查看文件

@ -13,6 +13,9 @@
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('search/filter'); ?>">Advanced Search</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url('search/duplicates'); ?>">Duplicate QSOs</a>
</li>
</ul>
</div>

查看文件

@ -68,6 +68,24 @@
</div>
</div>
<div class="form-group row">
<div class="col-md-1 control-label">Confirmation</div>
<div class="col-md-10">
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="qsl" value="1" id="qsl" <?php if ($this->input->post('qsl')) echo ' checked="checked"'; ?> >
<label class="form-check-label" for="qsl">QSL</label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="lotw" value="1" id="lotw" <?php if ($this->input->post('lotw')) echo ' checked="checked"'; ?> >
<label class="form-check-label" for="lotw">LoTW</label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="eqsl" value="1" id="eqsl" <?php if ($this->input->post('eqsl')) echo ' checked="checked"'; ?> >
<label class="form-check-label" for="eqsl">eQSL</label>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-md-1 control-label" for="button1id"></label>
<div class="col-md-10">

查看文件

@ -298,7 +298,7 @@
<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) { ?>
<br>
<div style="display: inline-block;"><p class="editButton"><a class="btn btn-primary" href="<?php echo site_url('qso/edit'); ?>/<?php echo $row->COL_PRIMARY_KEY; ?>" href="javascript:;"><i class="fas fa-edit"></i><?php echo $this->lang->line('qso_btn_edit_qso'); ?></a></p></div>
<div style="display: inline-block;"><form method="POST" action="<?php echo site_url('search'); ?>"><input type="hidden" value="<?php echo strtoupper($row->COL_CALL); ?>" name="callsign"><button class="btn btn-primary" type="submit"><i class="fas fa-eye"></i> More QSOs</button><form></div>
<div style="display: inline-block;"><form method="POST" action="<?php echo site_url('search'); ?>"><input type="hidden" value="<?php echo strtoupper($row->COL_CALL); ?>" name="callsign"><button class="btn btn-primary" type="submit"><i class="fas fa-eye"></i> More QSOs</button></form></div>
<?php } ?>
<?php

查看文件

@ -189,6 +189,8 @@ $("#callsign").keyup(function () {
highlight(call.toUpperCase());
});
checkIfWorkedBefore();
var qTable = $('.qsotable').DataTable();
qTable.search(call).draw();
}
else if (call.length <= 2) {
$('.callsign-suggestions').text("");
@ -226,6 +228,9 @@ function reset_log_fields() {
$("#callsign").focus();
setRst($("#mode").val());
$('#callsign_info').text("");
var qTable = $('.qsotable').DataTable();
qTable.search('').draw();
}
RegExp.escape = function (text) {
@ -396,6 +401,9 @@ function logQso() {
localStorage.setItem("gridsquarereceived", $("#exch_gridsquare_r").val());
localStorage.setItem("gridsquaresent", $("#exch_gridsquare_s").val());
localStorage.setItem("copytodok", $('#copyexchangetodok').is(":checked"));
var qTable = $('.qsotable').DataTable();
qTable.search('').draw();
}
});
}

查看文件

@ -566,5 +566,17 @@
}
]
}
},
"GREENCUBE":{
"Modes":{
"V":[
{
"Uplink_Mode":"PKT",
"Uplink_Freq":"435310000",
"Downlink_Mode":"PKT",
"Downlink_Freq":"435310000"
}
]
}
}
}