[OQRS] Added OQRS system

这个提交包含在:
Andreas 2022-11-15 18:29:33 +01:00
父节点 96dadd685e
当前提交 9d1f30d8e8
共有 21 个文件被更改,包括 1304 次插入1 次删除

查看文件

@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 105;
$config['migration_version'] = 106;
/*
|--------------------------------------------------------------------------

查看文件

@ -0,0 +1,183 @@
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
This controller contains features for oqrs (Online QSL Request System)
*/
class Oqrs extends CI_Controller {
function __construct() {
parent::__construct();
// Commented out to get public access
// $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() {
$this->load->model('oqrs_model');
$data['stations'] = $this->oqrs_model->get_oqrs_stations();
$data['page_title'] = "Log Search & OQRS";
$this->load->view('interface_assets/header', $data);
$this->load->view('oqrs/index');
$this->load->view('interface_assets/footer');
}
public function get_station_info() {
$this->load->model('oqrs_model');
$result = $this->oqrs_model->get_station_info($this->input->post('station_id'));
header('Content-Type: application/json');
echo json_encode($result);
}
public function get_qsos() {
$this->load->model('bands');
$data['bands'] = $this->bands->get_worked_bands_oqrs($this->security->xss_clean($this->input->post('station_id')));
$this->load->model('oqrs_model');
$result = $this->oqrs_model->get_qsos($this->input->post('station_id'), $this->input->post('callsign'), $data['bands']);
$data['callsign'] = $this->security->xss_clean($this->input->post('callsign'));
$data['result'] = $result['qsoarray'];
$data['qsocount'] = $result['qsocount'];
$this->load->view('oqrs/result', $data);
}
public function not_in_log() {
$data['page_title'] = "Log Search & OQRS";
$this->load->model('bands');
$data['bands'] = $this->bands->get_worked_bands_oqrs($this->security->xss_clean($this->input->post('station_id')));
$this->load->view('oqrs/notinlogform', $data);
}
public function save_not_in_log() {
$postdata = $this->input->post();
$this->load->model('oqrs_model');
$this->oqrs_model->save_not_in_log($postdata);
$this->alert_oqrs_request($postdata);
}
/*
* Fetches data when the user wants to make a request form, and loads info via the view
*/
public function request_form() {
$this->load->model('oqrs_model');
$data['result'] = $this->oqrs_model->getQueryData($this->input->post('station_id'), $this->input->post('callsign'));
$data['callsign'] = $this->security->xss_clean($this->input->post('callsign'));
$data['qslinfo'] = $this->oqrs_model->getQslInfo($this->input->post('station_id'));
$this->load->view('oqrs/request', $data);
}
public function requests() {
$data['page_title'] = "OQRS Requests";
$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) {
$location_list = "'".implode("','",$logbooks_locations_array)."'";
} else {
$location_list = null;
}
$this->load->model('oqrs_model');
$data['result'] = $this->oqrs_model->getOqrsRequests($location_list);
$this->load->view('interface_assets/header', $data);
$this->load->view('oqrs/showrequests');
$this->load->view('interface_assets/footer');
}
public function save_oqrs_request() {
$postdata = $this->input->post();
$this->load->model('oqrs_model');
$this->oqrs_model->save_oqrs_request($postdata);
$this->alert_oqrs_request($postdata);
}
public function delete_oqrs_line() {
$id = $this->input->post('id');
$this->load->model('oqrs_model');
$this->oqrs_model->delete_oqrs_line($id);
}
public function search_log() {
$this->load->model('oqrs_model');
$callsign = $this->input->post('callsign');
$data['qsos'] = $this->oqrs_model->search_log($this->security->xss_clean($callsign));
$this->load->view('qslprint/qsolist', $data);
}
public function search_log_time_date() {
$this->load->model('oqrs_model');
$time = $this->security->xss_clean($this->input->post('time'));
$date = $this->security->xss_clean($this->input->post('date'));
$mode = $this->security->xss_clean($this->input->post('mode'));
$band = $this->security->xss_clean($this->input->post('band'));
$data['qsos'] = $this->oqrs_model->search_log_time_date($time, $date, $band, $mode);
$this->load->view('qslprint/qsolist', $data);
}
public function alert_oqrs_request($postdata) {
$this->load->model('user_model');
$email = $this->user_model->get_email_address($this->session->userdata('user_id'));
$this->load->model('oqrs_model');
$sendEmail = $this->oqrs_model->getOqrsEmailSetting($this->security->xss_clean($this->input->post('station_id')));
if($email != "" && $sendEmail == "1") {
$this->load->library('email');
if($this->optionslib->get_option('emailProtocol') == "smtp") {
$config = Array(
'protocol' => $this->optionslib->get_option('emailProtocol'),
'smtp_host' => $this->optionslib->get_option('smtpHost'),
'smtp_port' => $this->optionslib->get_option('smtpPort'),
'smtp_user' => $this->optionslib->get_option('smtpUsername'),
'smtp_pass' => $this->optionslib->get_option('smtpPassword'),
'crlf' => "\r\n",
'newline' => "\r\n"
);
$this->email->initialize($config);
}
$data['callsign'] = $this->security->xss_clean($postdata['callsign']);
$message = $this->load->view('email/oqrs_request', $data, TRUE);
$this->email->from('noreply@cloudlog.co.uk', 'Cloudlog');
$this->email->to($email);
$this->email->subject('Cloudlog OQRS from ' . strtoupper($data['callsign']));
$this->email->message($message);
if (! $this->email->send()) {
$this->session->set_flashdata('warning', 'Email settings are incorrect.');
} else {
$this->session->set_flashdata('notice', 'Password Reset Processed.');
}
}
}
public function mark_oqrs_line_as_done() {
$this->load->model('oqrs_model');
$id = $this->security->xss_clean($this->input->post('id'));
$this->oqrs_model->mark_oqrs_line_as_done($id);
}
}

查看文件

@ -176,6 +176,15 @@ class QSLPrint extends CI_Controller {
$this->qslprint_model->add_qso_to_print_queue($this->security->xss_clean($id));
}
public function show_oqrs() {
$id = $this->security->xss_clean($this->input->post('id'));
$this->load->model('qslprint_model');
$data['result'] = $this->qslprint_model->show_oqrs($id);
$this->load->view('oqrs/showoqrs', $data);
}
}
/* End of file Qslprint.php */

查看文件

@ -0,0 +1,105 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_add_oqrs extends CI_Migration {
public function up()
{
if (!$this->db->field_exists('oqrs', 'station_profile')) {
$fields = array(
'oqrs int DEFAULT 0',
);
$this->dbforge->add_column('station_profile', $fields);
}
if (!$this->db->field_exists('oqrs_text', 'station_profile')) {
$fields = array(
'oqrs_text text DEFAULT ""',
);
$this->dbforge->add_column('station_profile', $fields);
}
if (!$this->db->field_exists('oqrs_email', 'station_profile')) {
$fields = array(
'oqrs_email int DEFAULT 0',
);
$this->dbforge->add_column('station_profile', $fields);
}
if (!$this->db->table_exists('oqrs')) {
$this->dbforge->add_field(array(
'id' => array(
'type' => 'INT',
'constraint' => 20,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'unique' => TRUE
),
'requesttime' => array(
'type' => 'timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
),
'date' => array(
'type' => 'date',
),
'time' => array(
'type' => 'time',
),
'band' => array(
'type' => 'VARCHAR',
'constraint' => 10,
),
'mode' => array(
'type' => 'VARCHAR',
'constraint' => 12,
),
'requestcallsign' => array(
'type' => 'VARCHAR',
'constraint' => 32,
),
'station_id' => array(
'type' => 'int',
),
'note' => array(
'type' => 'TEXT',
),
'email' => array(
'type' => 'TEXT',
),
'qslroute' => array(
'type' => 'VARCHAR',
'constraint' => 50,
),
'status' => array(
'type' => 'int',
),
'qsoid' => array(
'type' => 'int',
)
));
$this->dbforge->add_key('id', TRUE);
$this->dbforge->create_table('oqrs');
}
}
public function down()
{
if ($this->db->field_exists('oqrs', 'station_profile')) {
$this->dbforge->drop_column('station_profile', 'oqrs');
}
if ($this->db->field_exists('oqrs_text', 'station_profile')) {
$this->dbforge->drop_column('station_profile', 'oqrs_text');
}
if ($this->db->field_exists('oqrs_email', 'station_profile')) {
$this->dbforge->drop_column('station_profile', 'oqrs_email');
}
$this->dbforge->drop_table('oqrs');
}
}

查看文件

@ -315,6 +315,51 @@ class Bands extends CI_Model {
return true;
}
function get_worked_bands_oqrs($station_id) {
// get all worked slots from database
$data = $this->db->query(
"SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `".$this->config->item('table_name')."` WHERE station_id in (" . $station_id . ") AND COL_PROP_MODE != \"SAT\""
);
$worked_slots = array();
foreach($data->result() as $row){
array_push($worked_slots, $row->COL_BAND);
}
$SAT_data = $this->db->query(
"SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM `".$this->config->item('table_name')."` WHERE station_id in (" . $station_id . ") AND COL_PROP_MODE = \"SAT\""
);
foreach($SAT_data->result() as $row){
array_push($worked_slots, strtoupper($row->COL_PROP_MODE));
}
// php5
usort(
$worked_slots,
function($b, $a) {
sscanf($a, '%f%s', $ac, $ar);
sscanf($b, '%f%s', $bc, $br);
if ($ar == $br) {
return ($ac < $bc) ? -1 : 1;
}
return ($ar < $br) ? -1 : 1;
}
);
// Only for php7+
// usort(
// $worked_slots,
// function($b, $a) {
// sscanf($a, '%f%s', $ac, $ar);
// sscanf($b, '%f%s', $bc, $br);
// return ($ar == $br) ? $ac <=> $bc : $ar <=> $br;
// }
// );
return $worked_slots;
}
}
?>

查看文件

@ -0,0 +1,250 @@
<?php
class Oqrs_model extends CI_Model {
function get_oqrs_stations() {
$this->db->where('oqrs', "1");
return $this->db->get('station_profile');
}
function get_station_info($station_id) {
$station_id = $this->security->xss_clean($station_id);
$sql = 'select
count(*) as count,
min(col_time_on) as mindate,
max(col_time_on) as maxdate
from ' . $this->config->item('table_name') . ' where station_id = ' . $station_id;
$query = $this->db->query($sql);
return $query->row();
}
function get_qsos($station_id, $callsign, $bands){
$modes = $this->get_worked_modes($station_id);
// Creating an empty array with all the bands and modes from the database
foreach ($modes as $mode) {
foreach ($bands as $band) {
$resultArray[$mode][$band] = '-';
}
}
// Populating array with worked band/mode combinations
$worked = $this->getQueryData($station_id, $callsign);
foreach ($worked as $w) {
$resultArray[$w->col_mode][$w->col_band] = '<i class="fa fa-check" aria-hidden="true"></i>';
}
$result['qsocount'] = count($worked);
$result['qsoarray'] = $resultArray;
return $result;
}
/*
* Builds query depending on what we are searching for
*/
function getQueryData($station_id, $callsign) {
$station_id = $this->security->xss_clean($station_id);
$callsign = $this->security->xss_clean($callsign);
$sql = 'select lower(col_mode) col_mode, coalesce(col_submode, "") col_submode, col_band from ' . $this->config->item('table_name') . ' where station_id = ' . $station_id . ' and col_call ="' . $callsign . '"';
$query = $this->db->query($sql);
return $query->result();
}
/*
* Get's the worked modes from the log
*/
function get_worked_modes($station_id)
{
// get all worked modes from database
$data = $this->db->query(
"SELECT distinct LOWER(`COL_MODE`) as `COL_MODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id in (" . $station_id . ") order by COL_MODE ASC"
);
$results = array();
foreach ($data->result() as $row) {
array_push($results, $row->COL_MODE);
}
$data = $this->db->query(
"SELECT distinct LOWER(`COL_SUBMODE`) as `COL_SUBMODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id in (" . $station_id . ") and coalesce(COL_SUBMODE, '') <> '' order by COL_SUBMODE ASC"
);
foreach ($data->result() as $row) {
if (!in_array($row, $results)) {
array_push($results, $row->COL_SUBMODE);
}
}
return $results;
}
function getOqrsRequests($location_list) {
$sql = 'select * from oqrs join station_profile on oqrs.station_id = station_profile.station_id where oqrs.station_id in (' . $location_list . ') and oqrs.status < 2';
$query = $this->db->query($sql);
return $query->result();
}
function save_oqrs_request($postdata) {
$qsos = $postdata['qsos'];
foreach($qsos as $qso) {
$data = array(
'date' => xss_clean($qso[0]),
'time' => xss_clean($qso[1]),
'band' => xss_clean($qso[2]),
'mode' => xss_clean($qso[3]),
'requestcallsign' => xss_clean($postdata['callsign']),
'station_id' => xss_clean($postdata['station_id']),
'note' => xss_clean($postdata['message']),
'email' => xss_clean($postdata['email']),
'qslroute' => xss_clean($postdata['qslroute']),
'status' => '0',
);
$qsoid = $this->check_oqrs($data);
if ($qsoid > 0) {
$data['status'] = '2';
$data['qsoid'] = $qsoid;
}
$this->db->insert('oqrs', $data);
}
}
function delete_oqrs_line($id) {
$sql = 'delete from oqrs where id =' . xss_clean($id);
$query = $this->db->query($sql);
return true;
}
// Status:
// 0 = open request
// 1 = not in log request
// 2 = request done, means we found a match in the log
function save_not_in_log($postdata) {
$qsos = $postdata['qsos'];
foreach($qsos as $qso) {
$data = array(
'date' => xss_clean($qso[0]),
'time' => xss_clean($qso[1]),
'band' => xss_clean($qso[2]),
'mode' => xss_clean($qso[3]),
'requestcallsign' => xss_clean($postdata['callsign']),
'station_id' => xss_clean($postdata['station_id']),
'note' => xss_clean($postdata['message']),
'email' => xss_clean($postdata['email']),
'qslroute' => '',
'status' => '1',
);
$this->db->insert('oqrs', $data);
}
}
function check_oqrs($qsodata) {
$sql = 'select * from ' . $this->config->item('table_name') .
' where col_band = \'' . $qsodata['band'] . '\'
and col_call = \'' . $qsodata['requestcallsign'] . '\'
and date(col_time_on) = \'' . $qsodata['date'] . '\'
and (col_mode = \'' . $qsodata['mode'] . '\'
or col_submode = \'' . $qsodata['mode'] . '\')
and timediff(time(col_time_on), \'' . $qsodata['time'] . '\') <= 3000
and station_id = ' . $qsodata['station_id'];
$query = $this->db->query($sql);
if ($result = $query->result()) {
$id = 0;
foreach ($result as $qso) {
$this->paperqsl_requested($qso->COL_PRIMARY_KEY, $qsodata['qslroute']);
$id = $qso->COL_PRIMARY_KEY;
}
return $id;
}
return 0;
}
// Set Paper to requested
function paperqsl_requested($qso_id, $method) {
$data = array(
'COL_QSLSDATE' => date('Y-m-d H:i:s'),
'COL_QSL_SENT' => 'R',
'COL_QSL_SENT_VIA ' => $method
);
$this->db->where('COL_PRIMARY_KEY', $qso_id);
$this->db->update($this->config->item('table_name'), $data);
}
function search_log($callsign) {
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
// always filter user. this ensures that no inaccesible QSOs will be returned
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
$this->db->where('COL_CALL like "%'.$callsign.'%"');
$this->db->order_by("COL_TIME_ON", "ASC");
$query = $this->db->get($this->config->item('table_name'));
return $query;
}
function search_log_time_date($time, $date, $band, $mode) {
$sql = 'select * from ' . $this->config->item('table_name') . ' thcv
join station_profile on thcv.station_id = station_profile.station_id where col_band = \'' . $band . '\'
and date(col_time_on) = \'' . $date . '\'
and (col_mode = \'' . $mode . '\'
or col_submode = \'' . $mode . '\')
and timediff(time(col_time_on), \'' . $time . '\') <= 3000
and station_profile.user_id = '. $this->session->userdata('user_id');
return $this->db->query($sql);;
}
function mark_oqrs_line_as_done($id) {
$data = array(
'status' => '2',
);
$this->db->where('id', $id);
$this->db->update('oqrs', $data);
}
function getQslInfo($station_id) {
$sql = 'select oqrs_text from station_profile where station_id = ' . $station_id;
$query = $this->db->query($sql);
if ($query->num_rows() > 0)
{
$row = $query->row();
return $row->oqrs_text;
}
return '';
}
function getOqrsEmailSetting($station_id) {
$sql = 'select oqrs_email from station_profile where station_id = ' . $station_id;
$query = $this->db->query($sql);
if ($query->num_rows() > 0)
{
$row = $query->row();
return $row->oqrs_email;
}
return '';
}
}

查看文件

@ -49,6 +49,7 @@ class Qslprint_model extends CI_Model {
}
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->join('oqrs', 'oqrs.qsoid = '.$this->config->item('table_name').'.COL_PRIMARY_KEY', 'left outer');
// always filter user. this ensures that even if the station_id is from another user no inaccesible QSOs will be returned
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
$this->db->where_in('COL_QSL_SENT', array('R', 'Q'));
@ -112,6 +113,17 @@ class Qslprint_model extends CI_Model {
return $query;
}
function show_oqrs($id) {
$this->db->select('requesttime as "Request time", requestcallsign as "Requester", email as "Email", note as "Note"');
$this->db->join('station_profile', 'station_profile.station_id = oqrs.station_id');
// always filter user. this ensures that no inaccesible QSOs will be returned
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
$this->db->where('oqrs.id = ' .$id);
$query = $this->db->get('oqrs');
return $query->result();
}
}
?>

查看文件

@ -77,6 +77,9 @@ class Stations extends CI_Model {
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)),
'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)),
'oqrs' => xss_clean($this->input->post('oqrs', true)),
'oqrs_email' => xss_clean($this->input->post('oqrsemail', true)),
'oqrs_text' => xss_clean($this->input->post('oqrstext', true)),
);
// Insert Records
@ -103,6 +106,9 @@ class Stations extends CI_Model {
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)),
'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)),
'oqrs' => xss_clean($this->input->post('oqrs', true)),
'oqrs_email' => xss_clean($this->input->post('oqrsemail', true)),
'oqrs_text' => xss_clean($this->input->post('oqrstext', true)),
);
$this->db->where('user_id', $this->session->userdata('user_id'));

查看文件

@ -76,6 +76,14 @@ class User_Model extends CI_Model {
}
}
function get_email_address($userid) {
$this->db->where('user_id', $userid);
$query = $this->db->get($this->config->item('auth_table'));
$ret = $query->row();
return $ret->user_email;
}
// FUNCTION: bool exists($username)
// Check if a user exists (by username)
function exists($username) {

查看文件

@ -0,0 +1,8 @@
Hi,
You got an OQRS request from <?php echo strtoupper($callsign); ?>.
Please log into your Cloudlog and process it.
Regards,
Cloudlog.

查看文件

@ -39,6 +39,10 @@ function load_was_map() {
</script>
<?php } ?>
<?php if ($this->uri->segment(1) == "oqrs") { ?>
<script src="<?php echo base_url() ;?>assets/js/sections/oqrs.js"></script>
<?php } ?>
<?php if ($this->uri->segment(1) == "awards" && ($this->uri->segment(2) == "cq") ) { ?>
<script src="<?php echo base_url(); ?>assets/js/Polyline.encoded.js"></script>
<script id="cqmapjs" type="text/javascript" src="<?php echo base_url(); ?>assets/js/sections/cqmap.js" tileUrl="<?php echo $this->optionslib->get_option('option_map_tile_server');?>"></script>
@ -3032,6 +3036,32 @@ function deleteQsl(id) {
}
});
});
function showOqrs(id) {
$.ajax({
url: base_url + 'index.php/qslprint/show_oqrs',
type: 'post',
data: {'id': id},
success: function(html) {
BootstrapDialog.show({
title: 'OQRS',
size: BootstrapDialog.SIZE_WIDE,
cssClass: 'qso-dialog',
nl2br: false,
message: html,
onshown: function(dialog) {
$('[data-toggle="tooltip"]').tooltip();
},
buttons: [{
label: 'Close',
action: function (dialogItself) {
dialogItself.close();
}
}]
});
}
});
}
</script>
<?php } ?>

查看文件

@ -214,6 +214,10 @@
<a class="dropdown-item" href="<?php echo site_url('qslprint');?>" title="Print Requested QSLs"><i class="fas fa-print"></i> Print Requested QSLs</a>
<a class="dropdown-item" href="<?php echo site_url('oqrs');?>" title="OQRS"><i class="fa fa-id-card"></i> OQRS</a>
<a class="dropdown-item" href="<?php echo site_url('oqrs/requests');?>" title="OQRS Requests"><i class="fa fa-id-card"></i> OQRS Requests</a>
<a class="dropdown-item" href="<?php echo site_url('kml');?>" title="KML Export for Google Earth"><i class="fas fa-sync"></i> KML Export</a>
<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>

查看文件

@ -0,0 +1,39 @@
<div class="container">
<br>
<h2><?php echo $page_title; ?></h2>
<div class="card">
<div class="card-header">
Request a QSL card
</div>
<div class="card-body">
<?php
echo '<div class="resulttable">';
if ($stations->result() != NULL) { ?>
<form class="form-inline" enctype="multipart/form-data">
<label class="my-1 mr-2" for="station">Select station: </label>
<select id="station" class="custom-select my-1 mr-sm-2" name="station">
<?php foreach($stations->result() as $station) {
echo '<option value="' . $station->station_id . '">' . $station->station_callsign . '</option>'."\n";
} ?>
</select>
<button id="button1id" type="button" onclick="loadStationInfo();" name="button1id" class="btn btn-sm btn-primary"> Proceed</button>
</form>
<div class="stationinfo"></div>
<div class="searchinfo"></div>
<?php }
else {
echo 'No stations found that are using Cloudlog OQRS.';
}
?>
</div>
</div>
</div>

查看文件

@ -0,0 +1,43 @@
<br />
If you can't find your QSO in the log, please fill out the form below. You will be contacted after the log has been
checked.<br />
<table style="width:100%"
class="notinlog-table table-sm table table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>Time (UTC)</th>
<th class="center"><span class="larger_font band">Band</th>
<th class="center">Mode</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><input class="form-control" type="date" name="date" value="" id="date" placeholder="YYYY-MM-DD"></td>
<td><input class="form-control" type="text" name="time" value="" id="time" maxlength="5" placeholder="HH:MM"></td>
<td><input class="form-control" type="text" name="band" value="" id="band"></td>
<td><input class="form-control" type="text" name="mode" value="" id="mode"></td>
</tr>
</tbody>
</table>
<button type="button" onclick="oqrsAddLine(this.form);" class="btn btn-sm btn-primary"><i class="fas fa-plus-square"></i> Add line</button>
<br />
<form>
<div class="form-group">
<label for="message">Message</label>
<textarea name="message" class="form-control" id="exampleFormControlTextarea1" rows="3" aria-describedby="messageHelp"></textarea>
<small id="messageHelp" class="form-text text-muted">Any extra information we need to know about?</small>
</div>
<div class="form-group">
<label for="emailInput">E-mail</label>
<input type="text" class="form-control" name="email" id="emailInput" aria-describedby="emailInputHelp" required>
<small id="emailInputHelp" class="form-text text-muted">Your e-mail address where we can contact you</small>
</div>
<button type="button" onclick="saveNotInLogRequest(this.form);" class="btn btn-sm btn-primary"><i
class="fas fa-plus-square"></i> Send not in log request</button>
</form>

查看文件

@ -0,0 +1,67 @@
<?php if ($qslinfo != '') {
echo '<br />QSL information <br /><br />';
echo $qslinfo;
echo '<br />';
}
?>
<br />
The following QSO(s) were found. Please fill out the date and time and submit your request.
<table style="width:100%"
class="result-table table-sm table table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>Time (UTC)</th>
<th class="center"><span class="larger_font band">Band</th>
<th class="center">Mode</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
foreach ($result as $qso) {
echo '<tr>';
echo '<td>'. $i++ .'</td>';
echo '<td><input class="form-control" type="date" name="date" value="" id="date" placeholder="YYYY-MM-DD"></td>';
echo '<td><input class="form-control" type="text" name="time" value="" id="time" maxlength="5" placeholder="HH:MM"></td>';
echo '<td id="band">'. $qso->col_band .'</td>';
echo '<td id="mode">'; echo $qso->col_submode == null ? strtoupper($qso->col_mode) : strtoupper($qso->col_submode); echo '</td>';
echo '</tr>';
}
?>
</tbody>
</table>
<br />
<form>
<div class="form-check form-check-inline">
<label class="form-check-label">QSL Route</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="qslroute" id="bureau" value="b" checked/>
<label class="form-check-label" for="bureau">Bureau</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="qslroute" id="direct" value="d" />
<label class="form-check-label" for="direct">Direct (write address in message below)</label>
</div>
<br /><br />
<div class="form-group">
<label for="message">Message</label>
<textarea name="message" class="form-control" id="messageInput" rows="3" aria-describedby="messageHelp"></textarea>
<small id="messageHelp" class="form-text text-muted">Any extra information we need to know about?</small>
</div>
<div class="form-group">
<label for="emailInput">E-mail</label>
<input type="text" class="form-control" name="mode" id="emailInput" aria-describedby="emailInputHelp" required>
<small id="emailInputHelp" class="form-text text-muted">Your e-mail address where we can contact you</small>
</div>
<button type="button" onclick="submitOqrsRequest(this.form);" class="btn btn-sm btn-primary"><i
class="fas fa-plus-square"></i> Submit request</button>
</form>

查看文件

@ -0,0 +1,36 @@
<?php
if ($qsocount > 0) {
$count = 0;
echo '<br />Log search result for ' . strtoupper($callsign) . ':<br />';
echo '
<table style="width:100%" class="result-table table-sm table table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<th></th>';
foreach($bands as $band) {
echo '<th>' . $band . '</th>';
}
echo '</tr>
</thead>
<tbody>';
foreach ($result as $mode => $value) {
echo '<tr>
<td>'. strtoupper($mode) .'</td>';
foreach ($value as $key => $val) {
echo '<td>' . $val . '</td>';
if ($val != '-') {
$count++;
}
}
echo '</tr>';
}
echo '</tbody></table>';
echo strtoupper($callsign) . ' has ' . $count . ' band slot(s) and has ' . $qsocount . ' QSO(s) in the log.<br /><br />';
?>
<button onclick="requestOqrs();" class="btn btn-primary btn-sm" type="button"> Request QSL</button>
<?php } else {
echo '<br />No QSOs found in the log.<br />';
}
?>
<button onclick="notInLog();" class="btn btn-primary btn-sm" type="button"> Not in log?</button>

查看文件

@ -0,0 +1,26 @@
<?php
if ($result) {
array_to_table($result);
}
function array_to_table($table)
{
echo '<table class="table-sm table table-bordered table-hover table-striped table-condensed text-center">';
// Table header
foreach ($table[0] as $key=>$value) {
echo "<th>".$key."</th>";
}
// Table body
foreach ($table as $value) {
echo "<tr>";
foreach ($value as $val) {
echo "<td>".$val."</td>";
}
echo "</tr>";
}
echo "</table>";
}
?>

查看文件

@ -0,0 +1,126 @@
<div class="container">
<br>
<h2><?php echo $page_title; ?></h2>
<?php
if (count($result) > 0) {
$station_id = '';
$tablebody = '';
$requester = '';
$first = true;
$second = true;
foreach ($result as $qso) {
if ($station_id != $qso->station_id) {
if (!$first) {
write_table($tablebody);
$tablebody = '';
echo '</div></div><br />';
}
insert_station_data($qso);
$first = false;
}
if ($requester != $qso->requestcallsign) {
if (!$second) {
write_table($tablebody);
}
$second = false;
insert_requester($qso);
write_table_header();
$tablebody = '';
}
$tablebody .= insert_qso_data($qso);
$requester = $qso->requestcallsign;
$station_id = $qso->station_id;
}
write_table($tablebody);
echo '</div></div><br />';
} else {
echo 'No OQRS requests were found at this time.';
}
?>
</div>
</div>
</div>
<?php
function insert_station_data($station) {
?>
<div>
<h5>
Station id: <strong><?php echo $station->station_id; ?></strong>
Station callsign: <strong><?php echo $station->station_callsign; ?></strong>
Profile Name: <strong><?php echo $station->station_profile_name; ?></strong>
Country: <strong><?php echo $station->station_country; ?></strong>
Gridsquare: <strong><?php echo $station->station_gridsquare; ?></strong>
</h5>
<div>
<?php
}
function insert_requester($requester) {
?>
OQRS Request:
<table style="width:100%" class="result-table table-sm table table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<th>Requester</th>
<th>Time of request</th>
<th>E-mail</th>
<th>Note</th>
<th>QSL route</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $requester->requestcallsign ?></td>
<td><?php echo $requester->requesttime ?></td>
<td><?php echo $requester->email ?></td>
<td><?php echo $requester->note ?></td>
<td><?php echo $requester->qslroute; ?></td>
</tr>
</tbody>
</table>
<?php
}
function insert_qso_data($qso) {
$tablebody = '';
$tablebody .= '<tr class="oqrsid_'.$qso->id.'">
<td>' . $qso->date . '</td>
<td>' . $qso->time . '</td>
<td>' . $qso->band . '</td>
<td>' . $qso->mode . '</td>
<td><button class="btn btn-primary btn-sm" type="button" onclick="searchLog(\''. $qso->requestcallsign .'\');"><i class="fas fa-search"></i> Call</button>
<button class="btn btn-primary btn-sm" type="button" onclick="searchLogTimeDate(\''. $qso->id .'\');"><i class="fas fa-search"></i> Date/Time</button>
</td>
<td><a href="javascript:markOqrsLineAsDone('. $qso->id .');" class="btn btn-danger btn-sm" onclick=""><i class="fas fa-plus-square"></i></a></td>
<td><a href="javascript:deleteOqrsLine('. $qso->id .');" class="btn btn-danger btn-sm" onclick=""><i class="fas fa-trash-alt"></i></a></td>
</tr>';
return $tablebody;
}
function write_table_header() {
?>
<table style="width:100%" class="result-table table-sm table table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<th>Date</th>
<th>Time (UTC)</th>
<th>Band</th>
<th>Mode</th>
<th>Check log</th>
<th>Mark as done</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
}
function write_table($tablebody) {
echo $tablebody; ?>
</tbody>
</table>
<?php
}

查看文件

@ -235,6 +235,27 @@
</div>
</div>
<div class="form-group">
<label for="oqrs">OQRS Enabled</label>
<select class="custom-select" id="oqrs" name="oqrs">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</div>
<div class="form-group">
<label for="oqrs">OQRS Email alert</label>
<select class="custom-select" id="oqrsemail" name="oqrsemail">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
<small id="oqrsemailHelp" class="form-text text-muted">Make sure email is set up under admin and global options.</small>
</div>
<div class="form-group">
<label for="oqrstext">OQRS Text</label>
<input type="text" class="form-control" name="oqrstext" id="oqrstext" aria-describedby="oqrstextHelp">
<small id="oqrstextHelp" class="form-text text-muted">Some info you want to add regarding QSL'ing.</small>
</div>
<button type="submit" class="btn btn-primary"><i class="fas fa-plus-square"></i> Create Station Location</button>
</form>

查看文件

@ -341,6 +341,37 @@
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md">
<div class="card">
<h5 class="card-header">OQRS</h5>
<div class="card-body">
<div class="form-group">
<label for="oqrs">OQRS Enabled</label>
<select class="custom-select" id="oqrs" name="oqrs">
<option value="1" <?php if ($my_station_profile->oqrs == 1) { echo " selected =\"selected\""; } ?>>Yes</option>
<option value="0" <?php if ($my_station_profile->oqrs == 0) { echo " selected =\"selected\""; } ?>>No</option>
</select>
</div>
<div class="form-group">
<label for="oqrs">OQRS Email alert</label>
<select class="custom-select" id="oqrsemail" name="oqrsemail">
<option value="1" <?php if ($my_station_profile->oqrs_email == 1) { echo " selected =\"selected\""; } ?>>Yes</option>
<option value="0" <?php if ($my_station_profile->oqrs_email == 0) { echo " selected =\"selected\""; } ?>>No</option>
</select>
<small id="oqrsemailHelp" class="form-text text-muted">Make sure email is set up under admin and global options.</small>
</div>
<div class="form-group">
<label for="oqrstext">OQRS Text</label>
<input type="text" class="form-control" name="oqrstext" id="oqrstext" aria-describedby="oqrstextHelp" value="<?php if(set_value('oqrs_text') != "") { echo set_value('oqrs_text'); } else { echo $my_station_profile->oqrs_text; } ?>">
<small id="oqrstextHelp" class="form-text text-muted">Some info you want to add regarding QSL'ing.</small>
</div>
</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary"><i class="fas fa-plus-square"></i> <?php echo $form_action; ?> Station Location</button>

254
assets/js/sections/oqrs.js 普通文件
查看文件

@ -0,0 +1,254 @@
function loadStationInfo() {
$(".stationinfo").empty();
$(".searchinfo").empty();
$.ajax({
url: base_url+'index.php/oqrs/get_station_info',
type: 'post',
data: {'station_id': $("#station").val()},
success: function (data) {
if (data.count > 0) {
$(".stationinfo").append('<br />' + data.count + ' Qsos logged between ' + data.mindate + ' and ' + data.maxdate + '.<br /><br />');
$(".stationinfo").append('<form class="form-inline"><label class="my-1 mr-2" for="oqrssearch">Enter your callsign: </label><input class="form-control mr-sm-2" id="oqrssearch" type="search" name="callsign" placeholder="Search Callsign" aria-label="Search"><button onclick="searchOqrs();" class="btn btn-sm btn-primary" type="button"><i class="fas fa-search"></i> Search</button></form>');
} else {
$(".stationinfo").append("No QSOs for this callsign was found!");
}
}
});
}
function searchOqrs() {
$(".searchinfo").empty();
$.ajax({
url: base_url+'index.php/oqrs/get_qsos',
type: 'post',
data: {'station_id': $("#station").val(), 'callsign': $("#oqrssearch").val()},
success: function (data) {
$(".searchinfo").append(data);
}
});
}
function notInLog() {
$.ajax({
url: base_url + 'index.php/oqrs/not_in_log',
type: 'post',
data: {'station_id': $("#station").val(), 'callsign': $("#oqrssearch").val()},
success: function(html) {
$(".searchinfo").html(html);
}
});
}
function saveNotInLogRequest() {
$(".alertinfo").remove();
if ($("#emailInput").val() == '') {
$(".searchinfo").prepend('<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>You need to fill out an email address!</div></div>');
} else {
const qsos = [];
$(".notinlog-table tbody tr").each(function(i) {
var data = [];
var datecell = $("#date", this).val();
var timecell = $("#time", this).val();
var bandcell = $("#band", this).val();
var modecell = $("#mode", this).val();
if (datecell != "" && timecell != "" && bandcell != "" && modecell != "") {
data.push(datecell);
data.push(timecell);
data.push(bandcell);
data.push(modecell);
qsos.push(data);
}
});
if (qsos.length === 0) {
$(".searchinfo").prepend('<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>You need to fill the QSO information before submitting a request!</div></div>');
} else {
$.ajax({
url: base_url+'index.php/oqrs/save_not_in_log',
type: 'post',
data: { 'station_id': $("#station").val(),
'callsign': $("#oqrssearch").val(),
'email': $("#emailInput").val(),
'message': $("#messageInput").val(),
'qsos': qsos
},
success: function (data) {
$(".stationinfo").empty();
$(".searchinfo").empty();
$(".stationinfo").append('<br /><div class="alert alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>Your not in log query has been saved!</div>');
}
});
}
}
}
function oqrsAddLine() {
var rowCount = $('.notinlog-table tr').length;
var $myTable = $('.notinlog-table');
var $row = $('<tr></tr>');
var $iterator = $('<td></td>').html(rowCount);
var $date = $('<td></td>').html('<input class="form-control" type="date" name="date" value="" id="date" placeholder="YYYY-MM-DD">');
var $time = $('<td></td>').html('<input class="form-control" type="text" name="time" value="" id="time" maxlength="5" placeholder="HH:MM">');
var $band = $('<td></td>').html('<input class="form-control" type="text" name="band" value="" id="band">');
var $mode = $('<td></td>').html('<input class="form-control" type="text" name="mode" value="" id="mode">');
$row.append($iterator, $date, $time, $band, $mode);
$myTable.append($row);
}
function requestOqrs() {
$.ajax({
url: base_url + 'index.php/oqrs/request_form',
type: 'post',
data: {'station_id': $("#station").val(), 'callsign': $("#oqrssearch").val()},
success: function(html) {
$(".searchinfo").html(html);
$('.result-table').DataTable({
"pageLength": 25,
responsive: false,
ordering: false,
"scrollY": "410px",
"scrollCollapse": true,
"paging": false,
"scrollX": true,
});
}
});
}
function submitOqrsRequest() {
$(".alertinfo").remove();
if ($("#emailInput").val() == '') {
$(".searchinfo").prepend('<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>You need to fill out an email address!</div></div>');
} else {
const qsos = [];
$(".result-table tbody tr").each(function(i) {
var data = [];
var datecell = $("#date", this).val();
var timecell = $("#time", this).val();
var bandcell = $("#band", this).text();
var modecell = $("#mode", this).text();
if (datecell != "" && timecell != "") {
data.push(datecell);
data.push(timecell);
data.push(bandcell);
data.push(modecell);
qsos.push(data);
}
});
if (qsos.length === 0) {
$(".searchinfo").prepend('<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>You need to fill the QSO information before submitting a request!</div></div>');
} else {
$.ajax({
url: base_url+'index.php/oqrs/save_oqrs_request',
type: 'post',
data: { 'station_id': $("#station").val(),
'callsign': $("#oqrssearch").val(),
'email': $("#emailInput").val(),
'message': $("#messageInput").val(),
'qsos': qsos,
'qslroute': $('input[name="qslroute"]:checked').val()
},
success: function (data) {
$(".stationinfo").empty();
$(".searchinfo").empty();
$(".stationinfo").append('<br /><div class="alert alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>Your QSL request has been saved!</div>');
}
});
}
}
}
function deleteOqrsLine(id) {
BootstrapDialog.confirm({
title: 'DANGER',
message: 'Warning! Are you sure you want to delete this OQRS request?',
type: BootstrapDialog.TYPE_DANGER,
closable: true,
draggable: true,
btnOKClass: 'btn-danger',
callback: function (result) {
$.ajax({
url: base_url+'index.php/oqrs/delete_oqrs_line',
type: 'post',
data: { 'id': id,
},
success: function (data) {
$(".oqrsid_"+id).remove();
}
});
}
});
}
function searchLog(callsign) {
$.ajax({
url: base_url + 'index.php/oqrs/search_log',
type: 'post',
data: {'callsign': callsign,
},
success: function(html) {
BootstrapDialog.show({
title: 'QSO List',
size: BootstrapDialog.SIZE_WIDE,
cssClass: 'qso-dialog',
nl2br: false,
message: html,
onshown: function(dialog) {
$('[data-toggle="tooltip"]').tooltip();
},
buttons: [{
label: 'Close',
action: function (dialogItself) {
dialogItself.close();
}
}]
});
}
});
}
function searchLogTimeDate(id) {
$.ajax({
url: base_url + 'index.php/oqrs/search_log_time_date',
type: 'post',
data: {'time': $('.oqrsid_'+id+ ' td:nth-child(2)').text(),
'date': $('.oqrsid_'+id+ ' td:nth-child(1)').text(),
'band': $('.oqrsid_'+id+ ' td:nth-child(3)').text(),
'mode': $('.oqrsid_'+id+ ' td:nth-child(4)').text()
},
success: function(html) {
BootstrapDialog.show({
title: 'QSO List',
size: BootstrapDialog.SIZE_WIDE,
cssClass: 'qso-dialog',
nl2br: false,
message: html,
onshown: function(dialog) {
$('[data-toggle="tooltip"]').tooltip();
},
buttons: [{
label: 'Close',
action: function (dialogItself) {
dialogItself.close();
}
}]
});
}
});
}
function markOqrsLineAsDone(id) {
$.ajax({
url: base_url+'index.php/oqrs/mark_oqrs_line_as_done',
type: 'post',
data: { 'id': id,
},
success: function (data) {
$(".oqrsid_"+id).remove();
}
});
}