Merge pull request #2082 from AndreasK79/oqrs_grouped

pull/2087/head
Andreas Kristiansen 2023-04-26 21:07:27 +02:00 zatwierdzone przez GitHub
commit 54e137db90
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
8 zmienionych plików z 338 dodań i 69 usunięć

Wyświetl plik

@ -255,7 +255,7 @@ class Options extends CI_Controller {
function oqrs() {
$data['page_title'] = "Cloudlog Options";
$data['sub_heading'] = "OQRS Global text";
$data['sub_heading'] = "OQRS Options";
$this->load->view('interface_assets/header', $data);
$this->load->view('options/oqrs');
@ -265,7 +265,7 @@ class Options extends CI_Controller {
function oqrs_save() {
$data['page_title'] = "Cloudlog Options";
$data['sub_heading'] = "OQRS Global text";
$data['sub_heading'] = "OQRS Options";
$this->load->helper(array('form', 'url'));
@ -273,8 +273,10 @@ class Options extends CI_Controller {
$global_oqrs_text = $this->optionslib->update('global_oqrs_text', $this->input->post('global_oqrs_text'), null);
$global_oqrs_text = $this->optionslib->update('groupedSearch', $this->input->post('groupedSearch'), null);
if($global_oqrs_text == TRUE) {
$this->session->set_flashdata('success', 'OQRS Global text has been saved.');
$this->session->set_flashdata('success', 'OQRS options have been saved.');
}
redirect('/options/oqrs');

Wyświetl plik

@ -22,7 +22,7 @@ class Oqrs extends CI_Controller {
$data['stations'] = $this->oqrs_model->get_oqrs_stations();
$data['page_title'] = "Log Search & OQRS";
$data['global_oqrs_text'] = $this->optionslib->get_option('global_oqrs_text');
$data['groupedSearch'] = $this->optionslib->get_option('groupedSearch');
$this->load->view('visitor/layout/header', $data);
$this->load->view('oqrs/index');
@ -50,11 +50,19 @@ class Oqrs extends CI_Controller {
$this->load->view('oqrs/result', $data);
}
public function get_qsos_grouped() {
$this->load->model('oqrs_model');
$data['result'] = $this->oqrs_model->getQueryDataGrouped($this->input->post('callsign'));
$data['callsign'] = $this->security->xss_clean($this->input->post('callsign'));
$this->load->view('oqrs/request_grouped', $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')));
// $data['bands'] = $this->bands->get_worked_bands_oqrs($this->security->xss_clean($this->input->post('station_id')));
$this->load->view('oqrs/notinlogform', $data);
}
@ -103,8 +111,15 @@ class Oqrs extends CI_Controller {
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);
$station_ids = $this->oqrs_model->save_oqrs_request($postdata);
$this->alert_oqrs_request($postdata, $station_ids);
}
public function save_oqrs_request_grouped() {
$postdata = $this->input->post();
$this->load->model('oqrs_model');
$station_ids = $this->oqrs_model->save_oqrs_request_grouped($postdata);
$this->alert_oqrs_request($postdata, $station_ids);
}
public function delete_oqrs_line() {
@ -134,49 +149,51 @@ class Oqrs extends CI_Controller {
$this->load->view('oqrs/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") {
public function alert_oqrs_request($postdata, $station_ids) {
foreach ($station_ids as $id) {
$this->load->model('user_model');
$email = $this->user_model->get_email_address($id);
$this->load->model('oqrs_model');
$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']);
$data['usermessage'] = $this->security->xss_clean($postdata['message']);
$message = $this->load->view('email/oqrs_request', $data, TRUE);
$this->email->from('noreply@cloudlog.co.uk', 'Cloudlog');
$this->email->to($email);
$this->email->reply_to($this->security->xss_clean($postdata['email']), strtoupper($data['callsign']));
$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.');
$sendEmail = $this->oqrs_model->getOqrsEmailSetting($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']);
$data['usermessage'] = $this->security->xss_clean($postdata['message']);
$message = $this->load->view('email/oqrs_request', $data, TRUE);
$this->email->from('noreply@cloudlog.co.uk', 'Cloudlog');
$this->email->to($email);
$this->email->reply_to($this->security->xss_clean($postdata['email']), strtoupper($data['callsign']));
$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.');
}
}
}
}

Wyświetl plik

@ -42,6 +42,18 @@ class Oqrs_model extends CI_Model {
return $result;
}
function get_qsos_grouped($callsign){
// Populating array with worked band/mode combinations
$worked = $this->getQueryData($station_id, $callsign);
$result['qsocount'] = count($worked);
$result['qsoarray'] = $resultArray;
return $result;
}
/*
* Builds query depending on what we are searching for
*/
@ -57,6 +69,26 @@ class Oqrs_model extends CI_Model {
return $query->result();
}
/*
* Builds query depending on what we are searching for
*/
function getQueryDataGrouped($callsign) {
$callsign = $this->security->xss_clean($callsign);
$sql = 'select lower(col_mode) col_mode, coalesce(col_submode, "") col_submode, col_band, station_callsign, station_profile_name, l.station_id from ' . $this->config->item('table_name') . ' as l join station_profile on l.station_id = station_profile.station_id where station_profile.oqrs = "1" and l.col_call ="' . $callsign . '" and l.col_prop_mode != "SAT"';
$sql .= ' union all select lower(col_mode) col_mode, coalesce(col_submode, "") col_submode, "SAT" col_band, station_callsign, station_profile_name, l.station_id from ' .
$this->config->item('table_name') . ' l' .
' join station_profile on l.station_id = station_profile.station_id where station_profile.oqrs = "1" and col_call ="' . $callsign . '" and col_prop_mode = "SAT"';
$query = $this->db->query($sql);
if ($query) {
return $query->result();
}
return;
}
/*
* Get's the worked modes from the log
*/
@ -92,6 +124,7 @@ class Oqrs_model extends CI_Model {
}
function save_oqrs_request($postdata) {
$station_ids = array();
$qsos = $postdata['qsos'];
foreach($qsos as $qso) {
$data = array(
@ -115,7 +148,45 @@ class Oqrs_model extends CI_Model {
}
$this->db->insert('oqrs', $data);
if(!in_array(xss_clean($postdata['station_id']), $station_ids)){
array_push($station_ids, xss_clean($postdata['station_id']));
}
}
return $station_ids;
}
function save_oqrs_request_grouped($postdata) {
$station_ids = array();
$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($qso[4]),
'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);
if(!in_array(xss_clean($qso[4]), $station_ids)){
array_push($station_ids, xss_clean($qso[4]));
}
}
return $station_ids;
}
function delete_oqrs_line($id) {
@ -178,16 +249,15 @@ class Oqrs_model extends CI_Model {
// 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
);
$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->where('COL_PRIMARY_KEY', $qso_id);
$this->db->update($this->config->item('table_name'), $data);
$this->db->update($this->config->item('table_name'), $data);
}
function search_log($callsign) {

Wyświetl plik

@ -76,8 +76,9 @@ class User_Model extends CI_Model {
}
}
function get_email_address($userid) {
$this->db->where('user_id', $userid);
function get_email_address($station_id) {
$this->db->where('station_id', $station_id);
$this->db->join('station_profile', 'station_profile.user_id = '.$this->config->item('auth_table').'.user_id');
$query = $this->db->get($this->config->item('auth_table'));
$ret = $query->row();

Wyświetl plik

@ -35,9 +35,18 @@
<?php echo form_open('options/oqrs_save'); ?>
<div class="form-group">
<label for="globalSearch">OQRS Global text</label>
<p>This text is an optional text that can be displayed on top of the OQRS page.</p>
<label for="globalSearch">Global text</label>
<input type="text" name="global_oqrs_text" class="form-control" id="global_oqrs_text" aria-describedby="global_oqrs_text" value="<?php echo $this->optionslib->get_option('global_oqrs_text'); ?>">
<small id="global_oqrs_text_help" class="form-text text-muted">This text is an optional text that can be displayed on top of the OQRS page.</small>
</div>
<div class="form-group">
<label for="groupedSearch">Grouped search</label>
<select name="groupedSearch" class="form-control" id="groupedSearch">
<option value="off" <?php if($this->optionslib->get_option('groupedSearch') == "off") { echo "selected=\"selected\""; } ?>>Off</option>
<option value="on" <?php if($this->optionslib->get_option('groupedSearch') == "on") { echo "selected=\"selected\""; } ?>>On</option>
</select>
<small id="groupedSearchHelp" class="form-text text-muted">When this is on, all station locations with OQRS active, will be searched at once.</small>
</div>
<!-- Save the Form -->

Wyświetl plik

@ -10,12 +10,35 @@
</div>
<div class="card-body">
<div class="stationinfo">
<?php
if ($global_oqrs_text) {
echo $global_oqrs_text;
echo '<br />';
echo '<br /><br />';
}
if ($groupedSearch == 'on') {
echo 'This search will search in all station locations where OQRS is active.<br /><br /><form class="form-inline" onsubmit="return false;"><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" required="required">
<button onclick="searchOqrsGrouped();" class="btn btn-sm btn-primary" id="stationbuttonsubmit" type="button"><i class="fas fa-search"></i> Search</button>
</form>';
echo '<div class="searchinfo"></div>';
?>
<script>// Get the input field
var input = document.getElementById("oqrssearch");
// Execute a function when the user presses a key on the keyboard
input.addEventListener("keypress", function(event) {
// If the user presses the "Enter" key on the keyboard
if (event.key === "Enter") {
// Cancel the default action, if needed
event.preventDefault();
// Trigger the button element with a click
document.getElementById("stationbuttonsubmit").click();
}
});</script>
<?php
} else {
echo '<div class="resulttable">';
if ($stations->result() != NULL) { ?>
@ -28,16 +51,18 @@
</select>
<button id="button1id" type="button" onclick="loadStationInfo();" name="button1id" class="btn btn-sm btn-primary"> Proceed</button>
</form>
</div>
<div class="stationinfo"></div>
<div class="searchinfo"></div>
<?php
}
<?php }
else {
echo 'No stations found that are using Cloudlog OQRS.';
}
?>
else {
echo 'No stations found that are using Cloudlog OQRS.';
}
}
?>
</div>
</div>
</div>
</div>

Wyświetl plik

@ -0,0 +1,68 @@
<br />
<?php if ($result) { ?>
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>
<th class="center">Callsign</th>
<th class="center">Name</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
foreach ($result as $qso) {
echo '<tr stationid="'. $qso->station_id.'">';
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 qsotime" 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 '<td>'. $qso->station_callsign .'</td>';
echo '<td>'. $qso->station_profile_name .'</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="submitOqrsRequestGrouped(this.form);" class="btn btn-sm btn-primary"><i
class="fas fa-plus-square"></i> Submit request</button>
</form>
<?php } else {
echo 'No QSOs found in the log.<br />';
}
?>

Wyświetl plik

@ -41,6 +41,37 @@ function searchOqrs() {
});
}
function searchOqrsGrouped() {
$(".searchinfo").empty();
$.ajax({
url: base_url+'index.php/oqrs/get_qsos_grouped',
type: 'post',
data: {'callsign': $("#oqrssearch").val().toUpperCase()},
success: function (data) {
$(".searchinfo").append(data);
$('.qsotime').change(function() {
var raw_time = $(this).val();
if(raw_time.match(/^\d\[0-6]d$/)) {
raw_time = "0"+raw_time;
}
if(raw_time.match(/^[012]\d[0-5]\d$/)) {
raw_time = raw_time.substring(0,2)+":"+raw_time.substring(2,4);
$(this).val(raw_time);
}
});
$('.result-table').DataTable({
"pageLength": 25,
responsive: false,
ordering: false,
"scrollY": "410px",
"scrollCollapse": true,
"paging": false,
"scrollX": true,
});
}
});
}
function notInLog() {
$.ajax({
url: base_url + 'index.php/oqrs/not_in_log',
@ -206,6 +237,52 @@ function submitOqrsRequest() {
}
}
function submitOqrsRequestGrouped() {
$(".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 stationid = this.getAttribute('stationid');;
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);
data.push(stationid);
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_grouped',
type: 'post',
data: {
'callsign': $("#oqrssearch").val().toUpperCase(),
'email': $("#emailInput").val(),
'message': $("#messageInput").val(),
'qsos': qsos,
'qslroute': $('input[name="qslroute"]:checked').val()
},
success: function (data) {
$(".stationinfo").empty();
$(".searchinfo").empty();
$(".searchinfo").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 searchLog(callsign) {
$.ajax({
url: base_url + 'index.php/oqrs/search_log',