mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Merge branch 'dev' into cronmanager
This commit is contained in:
@@ -15,65 +15,66 @@ class Contesting extends CI_Controller {
|
||||
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('cat');
|
||||
$this->load->model('stations');
|
||||
$this->load->model('modes');
|
||||
public function index() {
|
||||
$this->load->model('cat');
|
||||
$this->load->model('stations');
|
||||
$this->load->model('modes');
|
||||
$this->load->model('contesting_model');
|
||||
$this->load->model('bands');
|
||||
|
||||
$data['my_gridsquare'] = $this->stations->find_gridsquare();
|
||||
$data['radios'] = $this->cat->radios();
|
||||
$data['modes'] = $this->modes->active();
|
||||
$data['radios'] = $this->cat->radios();
|
||||
$data['modes'] = $this->modes->active();
|
||||
$data['contestnames'] = $this->contesting_model->getActivecontests();
|
||||
$data['bands'] = $this->bands->get_user_bands_for_qso_entry();
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('start_date', 'Date', 'required');
|
||||
$this->form_validation->set_rules('start_time', 'Time', 'required');
|
||||
$this->form_validation->set_rules('callsign', 'Callsign', 'required');
|
||||
$this->form_validation->set_rules('start_date', 'Date', 'required');
|
||||
$this->form_validation->set_rules('start_time', 'Time', 'required');
|
||||
$this->form_validation->set_rules('callsign', 'Callsign', 'required');
|
||||
|
||||
$data['page_title'] = "Contest Logging";
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('contesting/index');
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
}
|
||||
|
||||
public function getSessionQsos() {
|
||||
$this->load->model('Contesting_model');
|
||||
public function getSessionQsos() {
|
||||
session_write_close();
|
||||
$this->load->model('Contesting_model');
|
||||
|
||||
$qso = $this->input->post('qso');
|
||||
$qso = $this->input->post('qso');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($this->Contesting_model->getSessionQsos($qso));
|
||||
}
|
||||
}
|
||||
|
||||
public function getSession() {
|
||||
$this->load->model('Contesting_model');
|
||||
session_write_close();
|
||||
$this->load->model('Contesting_model');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($this->Contesting_model->getSession());
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteSession() {
|
||||
$this->load->model('Contesting_model');
|
||||
$this->load->model('Contesting_model');
|
||||
|
||||
$qso = $this->input->post('qso');
|
||||
$qso = $this->input->post('qso');
|
||||
|
||||
$data = $this->Contesting_model->deleteSession($qso);
|
||||
$data = $this->Contesting_model->deleteSession($qso);
|
||||
|
||||
return json_encode($data);
|
||||
}
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
public function setSession() {
|
||||
$this->load->model('Contesting_model');
|
||||
|
||||
$this->Contesting_model->setSession();
|
||||
|
||||
return json_encode("ok");
|
||||
}
|
||||
$this->load->model('Contesting_model');
|
||||
$this->Contesting_model->setSession();
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($this->Contesting_model->getSession());
|
||||
}
|
||||
|
||||
public function create() {
|
||||
$this->load->model('Contesting_model');
|
||||
@@ -82,13 +83,10 @@ class Contesting extends CI_Controller {
|
||||
$this->form_validation->set_rules('name', 'Contest Name', 'required');
|
||||
$this->form_validation->set_rules('adifname', 'Adif Contest Name', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE)
|
||||
{
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$data['page_title'] = "Create Mode";
|
||||
$this->load->view('contesting/create', $data);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->Contesting_model->add();
|
||||
}
|
||||
}
|
||||
@@ -190,7 +188,7 @@ class Contesting extends CI_Controller {
|
||||
header('Content-Type: application/json');
|
||||
if ($result && $result->num_rows()) {
|
||||
$timeb4=substr($result->row()->b4,0,5);
|
||||
$custom_date_format = $this->session->userdata('user_date_format');
|
||||
$custom_date_format = $this->session->userdata('user_date_format');
|
||||
$abstimeb4=date($custom_date_format, strtotime($result->row()->COL_TIME_OFF)).' '.date('H:i',strtotime($result->row()->COL_TIME_OFF));
|
||||
echo json_encode(array('message' => 'Worked at '.$abstimeb4.' ('.$timeb4.' ago) before'));
|
||||
}
|
||||
|
||||
@@ -1,60 +1,56 @@
|
||||
<?php
|
||||
class Contesting_model extends CI_Model {
|
||||
|
||||
/*
|
||||
* This function gets the QSOs to fill the "Contest Logbook" under the contesting form.
|
||||
*/
|
||||
function getSessionQsos($qso) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
/*
|
||||
* This function gets the QSOs to fill the "Contest Logbook" under the contesting form.
|
||||
*/
|
||||
function getSessionQsos($qso) {
|
||||
$this->load->model('Stations');
|
||||
$station_id = $this->Stations->find_active();
|
||||
|
||||
$qsoarray = explode(',', $qso);
|
||||
$qsoarray = explode(',', $qso);
|
||||
|
||||
$contestid = $qsoarray[2];
|
||||
$date = DateTime::createFromFormat('d-m-Y H:i:s', $qsoarray[0]);
|
||||
if ($date == false) $date = DateTime::createFromFormat('d-m-Y H:i', $qsoarray[0]);
|
||||
$date = $date->format('Y-m-d H:i:s');
|
||||
$contestid = $qsoarray[2];
|
||||
$date = DateTime::createFromFormat('d-m-Y H:i:s', $qsoarray[0]);
|
||||
if ($date == false) $date = DateTime::createFromFormat('d-m-Y H:i', $qsoarray[0]);
|
||||
$date = $date->format('Y-m-d H:i:s');
|
||||
|
||||
$sql = "SELECT date_format(col_time_on, '%d-%m-%Y %H:%i:%s') as col_time_on, col_call, col_band, col_mode,
|
||||
col_submode, col_rst_sent, col_rst_rcvd, coalesce(col_srx, '') col_srx, coalesce(col_srx_string, '') col_srx_string,
|
||||
coalesce(col_stx, '') col_stx, coalesce(col_stx_string, '') col_stx_string, coalesce(col_gridsquare, '') col_gridsquare,
|
||||
coalesce(col_vucc_grids, '') col_vucc_grids FROM " .
|
||||
$this->config->item('table_name') .
|
||||
" WHERE station_id = ? AND COL_TIME_ON >= ? AND COL_CONTEST_ID = ? ORDER BY COL_PRIMARY_KEY ASC";
|
||||
$sql = "SELECT date_format(col_time_on, '%d-%m-%Y %H:%i:%s') as col_time_on, col_call, col_band, col_mode,
|
||||
col_submode, col_rst_sent, col_rst_rcvd, coalesce(col_srx, '') col_srx, coalesce(col_srx_string, '') col_srx_string,
|
||||
coalesce(col_stx, '') col_stx, coalesce(col_stx_string, '') col_stx_string, coalesce(col_gridsquare, '') col_gridsquare,
|
||||
coalesce(col_vucc_grids, '') col_vucc_grids FROM " .
|
||||
$this->config->item('table_name') .
|
||||
" WHERE station_id = ? AND COL_TIME_ON >= ? AND COL_CONTEST_ID = ? ORDER BY COL_PRIMARY_KEY ASC";
|
||||
|
||||
$data = $this->db->query($sql,array($station_id, $date, $contestid));
|
||||
return $data->result();
|
||||
}
|
||||
$data = $this->db->query($sql,array($station_id, $date, $contestid));
|
||||
return $data->result();
|
||||
}
|
||||
|
||||
function getSession() {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
$this->load->model('Stations');
|
||||
$station_id = $this->Stations->find_active();
|
||||
|
||||
$sql = "SELECT * from contest_session where station_id = " . $station_id;
|
||||
$sql = "SELECT * from contest_session where station_id = " . $station_id;
|
||||
|
||||
$data = $this->db->query($sql);
|
||||
return $data->row();
|
||||
}
|
||||
$data = $this->db->query($sql);
|
||||
return $data->row();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function deleteSession() {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
$this->load->model('Stations');
|
||||
$station_id = $this->Stations->find_active();
|
||||
|
||||
$sql = "delete from contest_session where station_id = " . $station_id;
|
||||
$sql = "delete from contest_session where station_id = " . $station_id;
|
||||
|
||||
$this->db->query($sql);
|
||||
$this->db->query($sql);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function setSession() {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
$this->load->model('Stations');
|
||||
$station_id = $this->Stations->find_active();
|
||||
|
||||
$qso = "";
|
||||
|
||||
@@ -74,9 +70,9 @@ class Contesting_model extends CI_Model {
|
||||
'station_id' => $station_id,
|
||||
);
|
||||
|
||||
$sql = "SELECT * from contest_session where station_id = " . $station_id;
|
||||
$sql = "SELECT * from contest_session where station_id = " . $station_id;
|
||||
|
||||
$querydata = $this->db->query($sql);
|
||||
$querydata = $this->db->query($sql);
|
||||
|
||||
if ($querydata->num_rows() == 0) {
|
||||
$this->db->insert('contest_session', $data);
|
||||
@@ -84,23 +80,23 @@ class Contesting_model extends CI_Model {
|
||||
}
|
||||
|
||||
$result = $querydata->row();
|
||||
$qsoarray = explode(',', $result->qso);
|
||||
$qsoarray = explode(',', $result->qso);
|
||||
if ($qsoarray[1] != "") {
|
||||
$data['qso'] = $result->qso;
|
||||
}
|
||||
|
||||
$this->updateSession($data, $station_id);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function updateSession($data, $station_id) {
|
||||
$this->db->where('station_id', $station_id);
|
||||
|
||||
$this->db->update('contest_session', $data);
|
||||
}
|
||||
}
|
||||
|
||||
function getActivecontests() {
|
||||
function getActivecontests() {
|
||||
|
||||
$sql = "SELECT name, adifname FROM contest WHERE active = 1 ORDER BY name ASC";
|
||||
|
||||
@@ -208,15 +204,14 @@ class Contesting_model extends CI_Model {
|
||||
}
|
||||
|
||||
function checkIfWorkedBefore($call, $band, $mode, $contest) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
$this->load->model('Stations');
|
||||
$station_id = $this->Stations->find_active();
|
||||
|
||||
$contest_session = $this->getSession();
|
||||
|
||||
|
||||
if ($contest_session && $contest_session->qso != "") {
|
||||
$qsoarray = explode(',', $contest_session->qso);
|
||||
|
||||
|
||||
$date = DateTime::createFromFormat('d-m-Y H:i:s', $qsoarray[0]);
|
||||
if ($date == false) $date = DateTime::createFromFormat('d-m-Y H:i', $qsoarray[0]);
|
||||
$date = $date->format('Y-m-d H:i:s');
|
||||
@@ -231,49 +226,48 @@ class Contesting_model extends CI_Model {
|
||||
$this->db->where("COL_MODE", xss_clean($mode));
|
||||
$this->db->or_where("COL_SUBMODE", xss_clean($mode));
|
||||
$this->db->group_end();
|
||||
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "DESC");
|
||||
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "DESC");
|
||||
$query = $this->db->get($this->config->item('table_name'));
|
||||
|
||||
|
||||
return $query;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
$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);
|
||||
|
||||
// If date is set, we format the date and add it to the where-statement
|
||||
if ($from != 0) {
|
||||
$from = DateTime::createFromFormat('Y-m-d', $from);
|
||||
$from = $from->format('Y-m-d');
|
||||
$this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) >= '".$from."'");
|
||||
}
|
||||
if ($to != 0) {
|
||||
$to = DateTime::createFromFormat('Y-m-d', $to);
|
||||
$to = $to->format('Y-m-d');
|
||||
$this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) <= '".$to."'");
|
||||
}
|
||||
// If date is set, we format the date and add it to the where-statement
|
||||
if ($from != 0) {
|
||||
$from = DateTime::createFromFormat('Y-m-d', $from);
|
||||
$from = $from->format('Y-m-d');
|
||||
$this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) >= '".$from."'");
|
||||
}
|
||||
if ($to != 0) {
|
||||
$to = DateTime::createFromFormat('Y-m-d', $to);
|
||||
$to = $to->format('Y-m-d');
|
||||
$this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) <= '".$to."'");
|
||||
}
|
||||
|
||||
$this->db->where($this->config->item('table_name').'.COL_CONTEST_ID', $contest_id);
|
||||
|
||||
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC");
|
||||
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC");
|
||||
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
|
||||
return $this->db->get();
|
||||
}
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
function get_logged_contests2() {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
$this->load->model('Stations');
|
||||
$station_id = $this->Stations->find_active();
|
||||
|
||||
$sql = "select col_contest_id, min(date(col_time_on)) mindate, max(date(col_time_on)) maxdate, year(col_time_on) year, month(col_time_on) month
|
||||
from " . $this->config->item('table_name') . "
|
||||
where coalesce(COL_CONTEST_ID, '') <> ''
|
||||
and station_id =" . $station_id;
|
||||
from " . $this->config->item('table_name') . "
|
||||
where coalesce(COL_CONTEST_ID, '') <> ''
|
||||
and station_id =" . $station_id;
|
||||
|
||||
$sql .= " group by COL_CONTEST_ID , year(col_time_on), month(col_time_on) order by year(col_time_on) desc";
|
||||
|
||||
@@ -285,9 +279,9 @@ class Contesting_model extends CI_Model {
|
||||
function get_logged_years($station_id) {
|
||||
|
||||
$sql = "select distinct year(col_time_on) year
|
||||
from " . $this->config->item('table_name') . "
|
||||
where coalesce(COL_CONTEST_ID, '') <> ''
|
||||
and station_id =" . $station_id;
|
||||
from " . $this->config->item('table_name') . "
|
||||
where coalesce(COL_CONTEST_ID, '') <> ''
|
||||
and station_id =" . $station_id;
|
||||
|
||||
$sql .= " order by year(col_time_on) desc";
|
||||
|
||||
@@ -298,27 +292,27 @@ class Contesting_model extends CI_Model {
|
||||
|
||||
function get_logged_contests($station_id, $year) {
|
||||
$sql = "select distinct col_contest_id
|
||||
from " . $this->config->item('table_name') . "
|
||||
where coalesce(COL_CONTEST_ID, '') <> ''
|
||||
and station_id =" . $station_id .
|
||||
" and year(col_time_on) ='" . $year . "'";
|
||||
from " . $this->config->item('table_name') . "
|
||||
where coalesce(COL_CONTEST_ID, '') <> ''
|
||||
and station_id =" . $station_id .
|
||||
" and year(col_time_on) ='" . $year . "'";
|
||||
|
||||
$sql .= " order by COL_CONTEST_ID asc";
|
||||
|
||||
$data = $this->db->query($sql);
|
||||
|
||||
return $data->result();
|
||||
}
|
||||
return $data->result();
|
||||
}
|
||||
|
||||
function get_contest_dates($station_id, $year, $contestid) {
|
||||
$sql = "select distinct (date(col_time_on)) date
|
||||
from " . $this->config->item('table_name') . "
|
||||
where coalesce(COL_CONTEST_ID, '') <> ''
|
||||
and station_id =" . $station_id .
|
||||
" and year(col_time_on) ='" . $year . "' and col_contest_id ='" . $contestid . "'";
|
||||
from " . $this->config->item('table_name') . "
|
||||
where coalesce(COL_CONTEST_ID, '') <> ''
|
||||
and station_id =" . $station_id .
|
||||
" and year(col_time_on) ='" . $year . "' and col_contest_id ='" . $contestid . "'";
|
||||
|
||||
$data = $this->db->query($sql);
|
||||
|
||||
return $data->result();
|
||||
return $data->result();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,13 +53,13 @@ async function reset_contest_session() {
|
||||
"columnDefs": [
|
||||
{
|
||||
"render": function ( data, type, row ) {
|
||||
return pad(row[8],3);
|
||||
return row[8] !== null && row[8] !== '' ? pad(row[8], 3) : '';
|
||||
},
|
||||
"targets" : 8
|
||||
},
|
||||
{
|
||||
"render": function ( data, type, row ) {
|
||||
return pad(row[9],3);
|
||||
return row[9] !== null && row[9] !== '' ? pad(row[9], 3) : '';
|
||||
},
|
||||
"targets" : 9
|
||||
}
|
||||
@@ -94,10 +94,9 @@ async function setSession(formdata) {
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (data) {
|
||||
|
||||
sessiondata=data;
|
||||
}
|
||||
});
|
||||
sessiondata=await getSession(); // refresh Sessiondata
|
||||
}
|
||||
|
||||
// realtime clock
|
||||
@@ -166,7 +165,6 @@ document.onkeyup = function (e) {
|
||||
reset_log_fields();
|
||||
// Space to jump to either callsign or the various exchanges
|
||||
} else if (e.which == 32) {
|
||||
getCallbook();
|
||||
var exchangetype = $("#exchangetype").val();
|
||||
|
||||
if (manual && $(document.activeElement).attr("id") == "start_time") {
|
||||
@@ -378,10 +376,12 @@ if ($('#frequency').val() == "") {
|
||||
|
||||
/* on mode change */
|
||||
$('#mode').change(function () {
|
||||
if ($('#radio').val() == '0') {
|
||||
$.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function (result) {
|
||||
$('#frequency').val(result);
|
||||
$('#frequency_rx').val("");
|
||||
});
|
||||
}
|
||||
setRst($("#mode").val());
|
||||
checkIfWorkedBefore();
|
||||
});
|
||||
@@ -389,10 +389,12 @@ $('#mode').change(function () {
|
||||
/* Calculate Frequency */
|
||||
/* on band change */
|
||||
$('#band').change(function () {
|
||||
if ($('#radio').val() == '0') {
|
||||
$.get('qso/band_to_freq/' + $(this).val() + '/' + $('.mode').val(), function (result) {
|
||||
$('#frequency').val(result);
|
||||
$('#frequency_rx').val("");
|
||||
});
|
||||
}
|
||||
checkIfWorkedBefore();
|
||||
});
|
||||
|
||||
@@ -474,6 +476,7 @@ function logQso() {
|
||||
if ($("#callsign").val().length > 0) {
|
||||
|
||||
$('.callsign-suggestions').text("");
|
||||
$('#callsign_info').text("");
|
||||
|
||||
var table = $('.qsotable').DataTable();
|
||||
var exchangetype = $("#exchangetype").val();
|
||||
@@ -621,13 +624,13 @@ async function refresh_qso_table(data) {
|
||||
"columnDefs": [
|
||||
{
|
||||
"render": function ( data, type, row ) {
|
||||
return pad(row[8],3);
|
||||
return row[8] !== null && row[8] !== '' ? pad(row[8], 3) : '';
|
||||
},
|
||||
"targets" : 8
|
||||
},
|
||||
{
|
||||
"render": function ( data, type, row ) {
|
||||
return pad(row[9],3);
|
||||
return row[9] !== null && row[9] !== '' ? pad(row[9], 3) : '';
|
||||
},
|
||||
"targets" : 9
|
||||
}
|
||||
@@ -638,34 +641,33 @@ async function refresh_qso_table(data) {
|
||||
table.clear();
|
||||
|
||||
var mode = '';
|
||||
var data;
|
||||
$.each(html, function () {
|
||||
if (this.col_submode == null || this.col_submode == '') {
|
||||
mode = this.col_mode;
|
||||
} else {
|
||||
mode = this.col_submode;
|
||||
}
|
||||
var data = [];
|
||||
$.each(html, function () {
|
||||
if (this.col_submode == null || this.col_submode == '') {
|
||||
mode = this.col_mode;
|
||||
} else {
|
||||
mode = this.col_submode;
|
||||
}
|
||||
|
||||
data = [[
|
||||
this.col_time_on,
|
||||
this.col_call,
|
||||
this.col_band,
|
||||
mode,
|
||||
this.col_rst_sent,
|
||||
this.col_rst_rcvd,
|
||||
this.col_stx_string,
|
||||
this.col_srx_string,
|
||||
this.col_stx,
|
||||
this.col_srx,
|
||||
this.col_gridsquare,
|
||||
this.col_vucc_grids
|
||||
]];
|
||||
data.push([
|
||||
this.col_time_on,
|
||||
this.col_call,
|
||||
this.col_band,
|
||||
mode,
|
||||
this.col_rst_sent,
|
||||
this.col_rst_rcvd,
|
||||
this.col_stx_string,
|
||||
this.col_srx_string,
|
||||
this.col_stx,
|
||||
this.col_srx,
|
||||
this.col_gridsquare,
|
||||
this.col_vucc_grids
|
||||
]);
|
||||
});
|
||||
|
||||
if (data.length > 0) {
|
||||
table.rows.add(data).draw();
|
||||
}
|
||||
|
||||
});
|
||||
if (data.length > 0) {
|
||||
table.rows.add(data).draw();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user