[Contesting] Implemented dupecheck
这个提交包含在:
父节点
83107777b2
当前提交
36d1b75484
共有 4 个文件被更改,包括 69 次插入 和 0 次删除
|
|
@ -150,4 +150,24 @@ class Contesting extends CI_Controller {
|
||||||
echo json_encode(array('message' => 'OK'));
|
echo json_encode(array('message' => 'OK'));
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,4 +142,28 @@ class Contesting_model extends CI_Model {
|
||||||
|
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="callsign"><?php echo $this->lang->line('gen_hamradio_callsign'); ?></label>
|
<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>
|
<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>
|
||||||
|
|
||||||
<div class="form-group col-md-1">
|
<div class="form-group col-md-1">
|
||||||
|
|
|
||||||
|
|
@ -165,12 +165,33 @@ $("#callsign").keyup(function () {
|
||||||
$('.callsign-suggestions').text(result);
|
$('.callsign-suggestions').text(result);
|
||||||
highlight(call.toUpperCase());
|
highlight(call.toUpperCase());
|
||||||
});
|
});
|
||||||
|
checkIfWorkedBefore();
|
||||||
}
|
}
|
||||||
else if (call.length <= 2) {
|
else if (call.length <= 2) {
|
||||||
$('.callsign-suggestions').text("");
|
$('.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() {
|
function reset_log_fields() {
|
||||||
$('#name').val("");
|
$('#name').val("");
|
||||||
$('.callsign-suggestions').text("");
|
$('.callsign-suggestions').text("");
|
||||||
|
|
@ -181,6 +202,7 @@ function reset_log_fields() {
|
||||||
$('#exch_gridsquare_r').val("");
|
$('#exch_gridsquare_r').val("");
|
||||||
$("#callsign").focus();
|
$("#callsign").focus();
|
||||||
setRst($("#mode").val());
|
setRst($("#mode").val());
|
||||||
|
$('#callsign_info').text("");
|
||||||
}
|
}
|
||||||
|
|
||||||
RegExp.escape = function (text) {
|
RegExp.escape = function (text) {
|
||||||
|
|
@ -218,6 +240,7 @@ $('#mode').change(function () {
|
||||||
$('#frequency_rx').val("");
|
$('#frequency_rx').val("");
|
||||||
});
|
});
|
||||||
setRst($("#mode").val());
|
setRst($("#mode").val());
|
||||||
|
checkIfWorkedBefore();
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Calculate Frequency */
|
/* Calculate Frequency */
|
||||||
|
|
@ -227,6 +250,7 @@ $('#band').change(function () {
|
||||||
$('#frequency').val(result);
|
$('#frequency').val(result);
|
||||||
$('#frequency_rx').val("");
|
$('#frequency_rx').val("");
|
||||||
});
|
});
|
||||||
|
checkIfWorkedBefore();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#exchangetype').change(function () {
|
$('#exchangetype').change(function () {
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用