[Contesting] Implemented dupecheck

pull/1247/head
Andreas 2021-10-24 16:48:23 +02:00
rodzic 83107777b2
commit 36d1b75484
4 zmienionych plików z 69 dodań i 0 usunięć

Wyświetl plik

@ -150,4 +150,24 @@ class Contesting extends CI_Controller {
echo json_encode(array('message' => 'OK'));
return;
}
/*
* Function is used for dupe-checking in contestinglogging
*/
public function checkIfWorkedBefore() {
$call = $this->input->post('call');
$band = $this->input->post('band');
$mode = $this->input->post('mode');
$contest = $this->input->post('contest');
$qso = $this->input->post('qso');
$this->load->model('Contesting_model');
$result = $this->Contesting_model->checkIfWorkedBefore($call, $band, $mode, $contest, $qso);
header('Content-Type: application/json');
if ($result->num_rows()) {
echo json_encode(array('message' => 'Worked before'));
}
return;
}
}

Wyświetl plik

@ -142,4 +142,28 @@ class Contesting_model extends CI_Model {
return true;
}
function checkIfWorkedBefore($call, $band, $mode, $contest, $qso) {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
$qsoarray = explode(',', $qso);
$date = DateTime::createFromFormat('d-m-Y H:i:s', $qsoarray[0]);
$date = $date->format('Y-m-d H:i:s');
$this->db->where('STATION_ID', $station_id);
$this->db->where('COL_CALL', xss_clean($call));
$this->db->where("COL_BAND", xss_clean($band));
$this->db->where("COL_CONTEST_ID", xss_clean($contest));
$this->db->where("COL_TIME_ON >=", $date);
$this->db->group_start();
$this->db->where("COL_MODE", xss_clean($mode));
$this->db->or_where("COL_SUBMODE", xss_clean($mode));
$this->db->group_end();
$query = $this->db->get($this->config->item('table_name'));
return $query;
}
}

Wyświetl plik

@ -113,6 +113,7 @@
<div class="form-group col-md-3">
<label for="callsign"><?php echo $this->lang->line('gen_hamradio_callsign'); ?></label>
<input type="text" class="form-control form-control-sm" id="callsign" name="callsign" required>
<small id="callsign_info" class="badge badge-danger"></small>
</div>
<div class="form-group col-md-1">

Wyświetl plik

@ -165,12 +165,33 @@ $("#callsign").keyup(function () {
$('.callsign-suggestions').text(result);
highlight(call.toUpperCase());
});
checkIfWorkedBefore();
}
else if (call.length <= 2) {
$('.callsign-suggestions').text("");
}
});
function checkIfWorkedBefore() {
$('#callsign_info').text("");
$.ajax({
url: base_url + 'index.php/contesting/checkIfWorkedBefore',
type: 'post',
data: {
'call': $("#callsign").val(),
'mode': $("#mode").val(),
'band': $("#band").val(),
'contest': $("#contestname").val(),
'qso': localStorage.getItem("qso")
},
success: function (result) {
if (result.message == 'Worked before') {
$('#callsign_info').text("Worked before!");
}
}
});
}
function reset_log_fields() {
$('#name').val("");
$('.callsign-suggestions').text("");
@ -181,6 +202,7 @@ function reset_log_fields() {
$('#exch_gridsquare_r').val("");
$("#callsign").focus();
setRst($("#mode").val());
$('#callsign_info').text("");
}
RegExp.escape = function (text) {
@ -218,6 +240,7 @@ $('#mode').change(function () {
$('#frequency_rx').val("");
});
setRst($("#mode").val());
checkIfWorkedBefore();
});
/* Calculate Frequency */
@ -227,6 +250,7 @@ $('#band').change(function () {
$('#frequency').val(result);
$('#frequency_rx').val("");
});
checkIfWorkedBefore();
});
$('#exchangetype').change(function () {