kopia lustrzana https://github.com/magicbug/Cloudlog
[Quick lookup] WWFF added. Did some refactoring to simplify code, and make it easier to add queries.
rodzic
961f766d65
commit
c8b0e48bcd
|
@ -31,18 +31,22 @@ class Lookup extends CI_Controller {
|
||||||
$CI->load->model('Stations');
|
$CI->load->model('Stations');
|
||||||
$station_id = $CI->Stations->find_active();
|
$station_id = $CI->Stations->find_active();
|
||||||
|
|
||||||
$type = xss_clean($this->input->post('type'));
|
|
||||||
$dxcc = xss_clean($this->input->post('dxcc'));
|
|
||||||
$was = xss_clean($this->input->post('was'));
|
|
||||||
$cqz = xss_clean($this->input->post('cqz'));
|
|
||||||
$sota = xss_clean($this->input->post('sota'));
|
|
||||||
$grid = xss_clean($this->input->post('grid'));
|
|
||||||
$iota = xss_clean($this->input->post('iota'));
|
|
||||||
|
|
||||||
$this->load->model('lookup_model');
|
$this->load->model('lookup_model');
|
||||||
|
|
||||||
$data['bands'] = $this->lookup_model->get_Worked_Bands($station_id);
|
$data['bands'] = $this->lookup_model->get_Worked_Bands($station_id);
|
||||||
$data['result'] = $this->lookup_model->getSearchResult($station_id, $type, $dxcc, $was, $cqz, $sota, $grid, $iota, $data['bands']);
|
|
||||||
|
$queryinfo['type'] = xss_clean($this->input->post('type'));
|
||||||
|
$queryinfo['dxcc'] = xss_clean($this->input->post('dxcc'));
|
||||||
|
$queryinfo['was'] = xss_clean($this->input->post('was'));
|
||||||
|
$queryinfo['sota'] = xss_clean($this->input->post('sota'));
|
||||||
|
$queryinfo['grid'] = xss_clean($this->input->post('grid'));
|
||||||
|
$queryinfo['iota'] = xss_clean($this->input->post('iota'));
|
||||||
|
$queryinfo['cqz'] = xss_clean($this->input->post('cqz'));
|
||||||
|
$queryinfo['wwff'] = xss_clean($this->input->post('wwff'));
|
||||||
|
$queryinfo['station_id'] = $station_id;
|
||||||
|
$queryinfo['bands'] = $data['bands'];
|
||||||
|
|
||||||
|
$data['result'] = $this->lookup_model->getSearchResult($queryinfo);
|
||||||
$this->load->view('lookup/result', $data);
|
$this->load->view('lookup/result', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,28 +7,28 @@ class Lookup_model extends CI_Model{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSearchResult($station_id, $type, $dxcc, $was, $cqz, $sota, $grid, $iota, $bands){
|
function getSearchResult($queryinfo){
|
||||||
$modes = $this->get_worked_modes($station_id);
|
$modes = $this->get_worked_modes($queryinfo['station_id']);
|
||||||
|
|
||||||
return $this->getResultFromDatabase($station_id, $type, $dxcc, $was, $cqz, $sota, $grid, $iota, $modes, $bands);
|
return $this->getResultFromDatabase($queryinfo, $modes);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getResultFromDatabase($station_id, $type, $dxcc, $was, $cqz, $sota, $grid, $iota, $modes, $bands) {
|
function getResultFromDatabase($queryinfo, $modes) {
|
||||||
// Creating an empty array with all the bands and modes from the database
|
// Creating an empty array with all the bands and modes from the database
|
||||||
foreach ($modes as $mode) {
|
foreach ($modes as $mode) {
|
||||||
foreach ($bands as $band) {
|
foreach ($queryinfo['bands'] as $band) {
|
||||||
$resultArray[$mode][$band] = '-';
|
$resultArray[$mode][$band] = '-';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populating array with worked band/mode combinations
|
// Populating array with worked band/mode combinations
|
||||||
$worked = $this->getQueryData($station_id, $type, $dxcc, $was, $cqz, $sota, $grid, $iota,'worked');
|
$worked = $this->getQueryData($queryinfo, 'worked');
|
||||||
foreach ($worked as $w) {
|
foreach ($worked as $w) {
|
||||||
$resultArray[$w->col_mode][$w->col_band] = 'W';
|
$resultArray[$w->col_mode][$w->col_band] = 'W';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populating array with confirmed band/mode combinations
|
// Populating array with confirmed band/mode combinations
|
||||||
$confirmed = $this->getQueryData($station_id, $type, $dxcc, $was, $cqz, $sota, $grid, $iota,'confirmed');
|
$confirmed = $this->getQueryData($queryinfo, 'confirmed');
|
||||||
foreach ($confirmed as $c) {
|
foreach ($confirmed as $c) {
|
||||||
$resultArray[$c->col_mode][$c->col_band] = 'C';
|
$resultArray[$c->col_mode][$c->col_band] = 'C';
|
||||||
}
|
}
|
||||||
|
@ -39,102 +39,85 @@ class Lookup_model extends CI_Model{
|
||||||
/*
|
/*
|
||||||
* Builds query depending on what we are searching for
|
* Builds query depending on what we are searching for
|
||||||
*/
|
*/
|
||||||
function getQueryData($station_id, $type, $dxcc, $was, $cqz, $sota, $grid, $iota, $confirmedtype) {
|
function getQueryData($queryinfo, $confirmedtype) {
|
||||||
// If user inputs longer grid than 4 chars, we use only the first 4
|
// If user inputs longer grid than 4 chars, we use only the first 4
|
||||||
if (strlen($grid) > 4) {
|
if (strlen($queryinfo['grid']) > 4) {
|
||||||
$fixedgrid = substr($grid, 0, 4);
|
$fixedgrid = substr($queryinfo['grid'], 0, 4);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$fixedgrid = $grid;
|
$fixedgrid = $queryinfo['grid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sqlquerytypestring = '';
|
||||||
|
|
||||||
|
switch ($queryinfo['type']) {
|
||||||
|
case 'dxcc': $sqlquerytypestring .= " and col_dxcc = " . $queryinfo['dxcc']; break;
|
||||||
|
case 'iota': $sqlquerytypestring .= " and col_iota = '" . $queryinfo['iota'] . "'"; break;
|
||||||
|
case 'grid': $sqlquerytypestring .= " and (col_gridsquare like '%" . $fixedgrid . "%' or col_vucc_grids like '%" . $fixedgrid . "%')" ; break;
|
||||||
|
case 'cqz': $sqlquerytypestring .= " and col_cqz = " . $queryinfo['cqz']; break;
|
||||||
|
case 'was': $sqlquerytypestring .= " and col_state = '" . $queryinfo['was'] . "' and COL_DXCC in ('291', '6', '110')";; break;
|
||||||
|
case 'sota': $sqlquerytypestring .= " and col_sota_ref = '" . $queryinfo['sota'] . "'"; break;
|
||||||
|
case 'wwff': $sqlquerytypestring .= " and col_sig = 'WWFF' and col_sig_info = '" . $queryinfo['wwff'] . "'"; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sqlqueryconfirmationstring = '';
|
||||||
|
|
||||||
|
if ($confirmedtype == 'confirmed') {
|
||||||
|
$sqlqueryconfirmationstring .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetching info for all modes and bands except satellite
|
||||||
$sql = "SELECT distinct col_band, lower(col_mode) as col_mode FROM " . $this->config->item('table_name') . " thcv";
|
$sql = "SELECT distinct col_band, lower(col_mode) as col_mode FROM " . $this->config->item('table_name') . " thcv";
|
||||||
|
|
||||||
$sql .= " where station_id = " . $station_id;
|
$sql .= " where station_id = " . $queryinfo['station_id'];
|
||||||
|
|
||||||
$sql .= " and coalesce(col_submode, '') = ''";
|
$sql .= " and coalesce(col_submode, '') = ''";
|
||||||
|
|
||||||
$sql .= " and col_prop_mode != 'SAT'";
|
$sql .= " and col_prop_mode != 'SAT'";
|
||||||
|
|
||||||
switch ($type) {
|
$sql .= $sqlquerytypestring;
|
||||||
case 'dxcc': $sql .= " and col_dxcc = " . $dxcc; break;
|
|
||||||
case 'iota': $sql .= " and col_iota = '" . $iota . "'"; break;
|
|
||||||
case 'grid': $sql .= " and (col_gridsquare like '%" . $fixedgrid . "%' or col_vucc_grids like '%" . $fixedgrid . "%')" ; break;
|
|
||||||
case 'cqz': $sql .= " and col_cqz = " . $cqz; break;
|
|
||||||
case 'was': $sql .= " and col_state = '" . $was . "' and COL_DXCC in ('291', '6', '110')";; break;
|
|
||||||
case 'sota': $sql .= " and col_sota_ref = '" . $sota . "'"; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($confirmedtype == 'confirmed') {
|
$sql .= $sqlqueryconfirmationstring;
|
||||||
$sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Fetching info for all sub_modes and bands except satellite
|
||||||
$sql .= " union SELECT distinct col_band, lower(col_submode) as col_mode FROM " . $this->config->item('table_name') . " thcv";
|
$sql .= " union SELECT distinct col_band, lower(col_submode) as col_mode FROM " . $this->config->item('table_name') . " thcv";
|
||||||
|
|
||||||
$sql .= " where station_id = " . $station_id;
|
$sql .= " where station_id = " . $queryinfo['station_id'];
|
||||||
|
|
||||||
$sql .= " and coalesce(col_submode, '') <> ''";
|
$sql .= " and coalesce(col_submode, '') <> ''";
|
||||||
|
|
||||||
$sql .= " and col_prop_mode != 'SAT'";
|
$sql .= " and col_prop_mode != 'SAT'";
|
||||||
|
|
||||||
switch ($type) {
|
$sql .= $sqlquerytypestring;
|
||||||
case 'dxcc': $sql .= " and col_dxcc = " . $dxcc; break;
|
|
||||||
case 'iota': $sql .= " and col_iota = '" . $iota . "'"; break;
|
|
||||||
case 'grid': $sql .= " and (col_gridsquare like '%" . $fixedgrid . "%' or col_vucc_grids like '%" . $fixedgrid . "%')" ; break;
|
|
||||||
case 'cqz': $sql .= " and col_cqz = " . $cqz; break;
|
|
||||||
case 'was': $sql .= " and col_state = '" . $was . "' and COL_DXCC in ('291', '6', '110')";; break;
|
|
||||||
case 'sota': $sql .= " and col_sota_ref = '" . $sota . "'"; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($confirmedtype == 'confirmed') {
|
$sql .= $sqlqueryconfirmationstring;
|
||||||
$sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Fetching info for all modes on satellite
|
||||||
$sql .= " union SELECT distinct 'SAT' col_band, lower(col_mode) as col_mode FROM " . $this->config->item('table_name') . " thcv";
|
$sql .= " union SELECT distinct 'SAT' col_band, lower(col_mode) as col_mode FROM " . $this->config->item('table_name') . " thcv";
|
||||||
|
|
||||||
$sql .= " where station_id = " . $station_id;
|
$sql .= " where station_id = " . $queryinfo['station_id'];
|
||||||
|
|
||||||
$sql .= " and coalesce(col_submode, '') = ''";
|
$sql .= " and coalesce(col_submode, '') = ''";
|
||||||
|
|
||||||
$sql .= " and col_prop_mode = 'SAT'";
|
$sql .= " and col_prop_mode = 'SAT'";
|
||||||
|
|
||||||
switch ($type) {
|
$sql .= $sqlquerytypestring;
|
||||||
case 'dxcc': $sql .= " and col_dxcc = " . $dxcc; break;
|
|
||||||
case 'iota': $sql .= " and col_iota = '" . $iota . "'"; break;
|
|
||||||
case 'grid': $sql .= " and (col_gridsquare like '%" . $fixedgrid . "%' or col_vucc_grids like '%" . $fixedgrid . "%')" ; break;
|
|
||||||
case 'cqz': $sql .= " and col_cqz = " . $cqz; break;
|
|
||||||
case 'was': $sql .= " and col_state = '" . $was . "' and COL_DXCC in ('291', '6', '110')";; break;
|
|
||||||
case 'sota': $sql .= " and col_sota_ref = '" . $sota . "'"; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($confirmedtype == 'confirmed') {
|
$sql .= $sqlqueryconfirmationstring;
|
||||||
$sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Fetching info for all sub_modes on satellite
|
||||||
$sql .= " union SELECT distinct 'SAT' col_band, lower(col_submode) as col_mode FROM " . $this->config->item('table_name') . " thcv";
|
$sql .= " union SELECT distinct 'SAT' col_band, lower(col_submode) as col_mode FROM " . $this->config->item('table_name') . " thcv";
|
||||||
|
|
||||||
$sql .= " where station_id = " . $station_id;
|
$sql .= " where station_id = " . $queryinfo['station_id'];
|
||||||
|
|
||||||
$sql .= " and coalesce(col_submode, '') <> ''";
|
$sql .= " and coalesce(col_submode, '') <> ''";
|
||||||
|
|
||||||
$sql .= " and col_prop_mode = 'SAT'";
|
$sql .= " and col_prop_mode = 'SAT'";
|
||||||
|
|
||||||
switch ($type) {
|
$sql .= $sqlquerytypestring;
|
||||||
case 'dxcc': $sql .= " and col_dxcc = " . $dxcc; break;
|
|
||||||
case 'iota': $sql .= " and col_iota = '" . $iota . "'"; break;
|
|
||||||
case 'grid': $sql .= " and (col_gridsquare like '%" . $fixedgrid . "%' or col_vucc_grids like '%" . $fixedgrid . "%')" ; break;
|
|
||||||
case 'cqz': $sql .= " and col_cqz = " . $cqz; break;
|
|
||||||
case 'was': $sql .= " and col_state = '" . $was . "' and COL_DXCC in ('291', '6', '110')";; break;
|
|
||||||
case 'sota': $sql .= " and col_sota_ref= '" . $sota . "'"; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($confirmedtype == 'confirmed') {
|
$sql .= $sqlqueryconfirmationstring;
|
||||||
$sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = $this->db->query($sql);
|
$query = $this->db->query($sql);
|
||||||
|
|
||||||
|
|
|
@ -176,13 +176,7 @@ function spawnLookupModal() {
|
||||||
$('#quicklookupcqz').hide();
|
$('#quicklookupcqz').hide();
|
||||||
$('#quicklookupwas').hide();
|
$('#quicklookupwas').hide();
|
||||||
$('#quicklookuptext').hide();
|
$('#quicklookuptext').hide();
|
||||||
} else if (type == "grid") {
|
} else if (type == "grid" || type == "sota" || type == "wwff") {
|
||||||
$('#quicklookuptext').show();
|
|
||||||
$('#quicklookupiota').hide();
|
|
||||||
$('#quicklookupdxcc').hide();
|
|
||||||
$('#quicklookupcqz').hide();
|
|
||||||
$('#quicklookupwas').hide();
|
|
||||||
} else if (type == "sota") {
|
|
||||||
$('#quicklookuptext').show();
|
$('#quicklookuptext').show();
|
||||||
$('#quicklookupiota').hide();
|
$('#quicklookupiota').hide();
|
||||||
$('#quicklookupdxcc').hide();
|
$('#quicklookupdxcc').hide();
|
||||||
|
@ -229,6 +223,7 @@ function getLookupResult() {
|
||||||
cqz: $('#quicklookupcqz').val(),
|
cqz: $('#quicklookupcqz').val(),
|
||||||
iota: $('#quicklookupiota').val(),
|
iota: $('#quicklookupiota').val(),
|
||||||
sota: $('#quicklookuptext').val(),
|
sota: $('#quicklookuptext').val(),
|
||||||
|
wwff: $('#quicklookuptext').val(),
|
||||||
},
|
},
|
||||||
success: function (html) {
|
success: function (html) {
|
||||||
$('#lookupresulttable').html(html);
|
$('#lookupresulttable').html(html);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<option value="iota">IOTA</option>
|
<option value="iota">IOTA</option>
|
||||||
<option value="sota">SOTA</option>
|
<option value="sota">SOTA</option>
|
||||||
<option value="was">US State</option>
|
<option value="was">US State</option>
|
||||||
|
<option value="wwff">WWFF</option>
|
||||||
</select>
|
</select>
|
||||||
<div> </div>
|
<div> </div>
|
||||||
<input style="display:none" class="form-control input-group-sm" id="quicklookuptext" type="text" name="searchfield" placeholder="" aria-label="Search">
|
<input style="display:none" class="form-control input-group-sm" id="quicklookuptext" type="text" name="searchfield" placeholder="" aria-label="Search">
|
||||||
|
|
Ładowanie…
Reference in New Issue