Changed WAS to binding

This commit is contained in:
int2001
2024-09-06 12:41:12 +00:00
parent d6ef132589
commit 9bf6746000

View File

@@ -21,8 +21,8 @@ class was extends CI_Model {
$states = array(); // Used for keeping track of which states that are not worked
$qsl = $this->genfunctions->gen_qsl_from_postdata($postdata);
$qsl = $this->genfunctions->gen_qsl_from_postdata($postdata);
foreach ($stateArray as $state) { // Generating array for use in the table
$states[$state]['count'] = 0; // Inits each state's count
}
@@ -84,11 +84,9 @@ class was extends CI_Model {
/*
* Function gets worked and confirmed summary on each band on the active stationprofile
*/
function get_was_summary($bands, $postdata)
{
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
function get_was_summary($bands, $postdata) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
@@ -112,14 +110,14 @@ class was extends CI_Model {
return $wasSummary;
}
function getSummaryByBand($band, $postdata, $location_list)
{
function getSummaryByBand($band, $postdata, $location_list) {
$bindings=[];
$sql = "SELECT count(distinct thcv.col_state) as count FROM " . $this->config->item('table_name') . " thcv";
$sql .= " where station_id in (" . $location_list . ")";
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
$sql .= " and thcv.col_prop_mode = ?";
$bindings[]=$band;
} else if ($band == 'All') {
$this->load->model('bands');
@@ -131,28 +129,31 @@ class was extends CI_Model {
" and thcv.col_prop_mode !='SAT'";
} else {
$sql .= " and thcv.col_prop_mode !='SAT'";
$sql .= " and thcv.col_band ='" . $band . "'";
$sql .= " and thcv.col_band = ?";
$bindings[]=$band;
}
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$bindings[]=$postdata['mode'];
$bindings[]=$postdata['mode'];
}
$sql .= $this->addStateToQuery();
$query = $this->db->query($sql);
$query = $this->db->query($sql,$bindings);
return $query->result();
}
function getSummaryByBandConfirmed($band, $postdata, $location_list)
{
function getSummaryByBandConfirmed($band, $postdata, $location_list) {
$bindings=[];
$sql = "SELECT count(distinct thcv.col_state) as count FROM " . $this->config->item('table_name') . " thcv";
$sql .= " where station_id in (" . $location_list . ")";
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
$sql .= " and thcv.col_prop_mode = ?";
$bindings[]=$band;
} else if ($band == 'All') {
$this->load->model('bands');
@@ -164,18 +165,21 @@ class was extends CI_Model {
" and thcv.col_prop_mode !='SAT'";
} else {
$sql .= " and thcv.col_prop_mode !='SAT'";
$sql .= " and thcv.col_band ='" . $band . "'";
$sql .= " and thcv.col_band = ?";
$bindings[]=$band;
}
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$bindings[]=$postdata['mode'];
$bindings[]=$postdata['mode'];
}
$sql .= $this->genfunctions->addQslToQuery($postdata);
$sql .= $this->addStateToQuery();
$query = $this->db->query($sql);
$query = $this->db->query($sql,$bindings);
return $query->result();
}
@@ -185,26 +189,31 @@ class was extends CI_Model {
* $postdata contains data from the form, in this case Lotw or QSL are used
*/
function getWasWorked($location_list, $band, $postdata) {
$bindings=[];
$sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv
where station_id in (" . $location_list . ")";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$bindings[]=$postdata['mode'];
$bindings[]=$postdata['mode'];
}
$sql .= $this->addStateToQuery();
$sql .= $this->genfunctions->addBandToQuery($band);
$sql .= $this->genfunctions->addBandToQuery($band,$bindings);
$sql .= " and not exists (select 1 from ". $this->config->item('table_name') .
" where station_id in (". $location_list . ")" .
" and col_state = thcv.col_state";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$bindings[]=$postdata['mode'];
$bindings[]=$postdata['mode'];
}
$sql .= $this->genfunctions->addBandToQuery($band);
$sql .= $this->genfunctions->addBandToQuery($band,$bindings);
$sql .= $this->genfunctions->addQslToQuery($postdata);
@@ -212,7 +221,7 @@ class was extends CI_Model {
$sql .= ")";
$query = $this->db->query($sql);
$query = $this->db->query($sql,$bindings);
return $query->result();
}
@@ -222,20 +231,23 @@ class was extends CI_Model {
* $postdata contains data from the form, in this case Lotw or QSL are used
*/
function getWasConfirmed($location_list, $band, $postdata) {
$bindings=[];
$sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv
where station_id in (" . $location_list . ")";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
$sql .= " and (col_mode = ? or col_submode = ?)";
$bindings[]=$postdata['mode'];
$bindings[]=$postdata['mode'];
}
$sql .= $this->addStateToQuery();
$sql .= $this->genfunctions->addBandToQuery($band);
$sql .= $this->genfunctions->addBandToQuery($band,$bindings);
$sql .= $this->genfunctions->addQslToQuery($postdata);
$query = $this->db->query($sql);
$query = $this->db->query($sql,$bindings);
return $query->result();
}