kopia lustrzana https://github.com/magicbug/Cloudlog
Merge pull request #1157 from AndreasK79/iota_station_logbooks
[IOTA Award] Updated code to support station logbookspull/1162/head
commit
4ec4500716
|
@ -32,13 +32,15 @@ class IOTA extends CI_Model {
|
|||
}
|
||||
|
||||
function get_worked_bands() {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
// get all worked slots from database
|
||||
$data = $this->db->query(
|
||||
"SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `".$this->config->item('table_name')."` WHERE station_id = ".$station_id." AND COL_PROP_MODE != \"SAT\""
|
||||
"SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `".$this->config->item('table_name')."` WHERE station_id in (" . $location_list . ") AND COL_PROP_MODE != \"SAT\""
|
||||
);
|
||||
$worked_slots = array();
|
||||
foreach($data->result() as $row){
|
||||
|
@ -46,7 +48,7 @@ class IOTA extends CI_Model {
|
|||
}
|
||||
|
||||
$SAT_data = $this->db->query(
|
||||
"SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM `".$this->config->item('table_name')."` WHERE station_id = ".$station_id." AND COL_PROP_MODE = \"SAT\""
|
||||
"SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM `".$this->config->item('table_name')."` WHERE station_id in (" . $location_list . ") AND COL_PROP_MODE = \"SAT\""
|
||||
);
|
||||
|
||||
foreach($SAT_data->result() as $row){
|
||||
|
@ -64,9 +66,11 @@ class IOTA extends CI_Model {
|
|||
}
|
||||
|
||||
function get_iota_array($iotaArray, $bands, $postdata) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
foreach ($bands as $band) { // Looping through bands and iota to generate the array needed for display
|
||||
foreach ($iotaArray as $iota) {
|
||||
|
@ -79,7 +83,7 @@ class IOTA extends CI_Model {
|
|||
|
||||
// If worked is checked, we add worked iotas to the array
|
||||
if ($postdata['worked'] != NULL) {
|
||||
$workedIota = $this->getIotaBandWorked($station_id, $band, $postdata);
|
||||
$workedIota = $this->getIotaBandWorked($location_list, $band, $postdata);
|
||||
foreach ($workedIota as $wiota) {
|
||||
$iotaMatrix[$wiota->tag][$band] = '<div class="alert-danger"><a href=\'javascript:displayContacts("'.$wiota->tag.'","'. $band . '","'. $postdata['mode'] . '","IOTA")\'>W</a></div>';
|
||||
}
|
||||
|
@ -87,7 +91,7 @@ class IOTA extends CI_Model {
|
|||
|
||||
// If confirmed is checked, we add confirmed iotas to the array
|
||||
if ($postdata['confirmed'] != NULL) {
|
||||
$confirmedIota = $this->getIotaBandConfirmed($station_id, $band, $postdata);
|
||||
$confirmedIota = $this->getIotaBandConfirmed($location_list, $band, $postdata);
|
||||
foreach ($confirmedIota as $ciota) {
|
||||
$iotaMatrix[$ciota->tag][$band] = '<div class="alert-success"><a href=\'javascript:displayContacts("'.$ciota->tag.'","'. $band . '","'. $postdata['mode'] . '","IOTA")\'>C</a></div>';
|
||||
}
|
||||
|
@ -96,7 +100,7 @@ class IOTA extends CI_Model {
|
|||
|
||||
// We want to remove the worked iotas in the list, since we do not want to display them
|
||||
if ($postdata['worked'] == NULL) {
|
||||
$workedIota = $this->getIotaWorked($station_id, $postdata);
|
||||
$workedIota = $this->getIotaWorked($location_list, $postdata);
|
||||
foreach ($workedIota as $wiota) {
|
||||
if (array_key_exists($wiota->tag, $iotaMatrix)) {
|
||||
unset($iotaMatrix[$wiota->tag]);
|
||||
|
@ -106,7 +110,7 @@ class IOTA extends CI_Model {
|
|||
|
||||
// We want to remove the confirmed iotas in the list, since we do not want to display them
|
||||
if ($postdata['confirmed'] == NULL) {
|
||||
$confirmedIOTA = $this->getIotaConfirmed($station_id, $postdata);
|
||||
$confirmedIOTA = $this->getIotaConfirmed($location_list, $postdata);
|
||||
foreach ($confirmedIOTA as $ciota) {
|
||||
if (array_key_exists($ciota->tag, $iotaMatrix)) {
|
||||
unset($iotaMatrix[$ciota->tag]);
|
||||
|
@ -122,11 +126,11 @@ class IOTA extends CI_Model {
|
|||
}
|
||||
}
|
||||
|
||||
function getIotaBandConfirmed($station_id, $band, $postdata) {
|
||||
function getIotaBandConfirmed($location_list, $band, $postdata) {
|
||||
$sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv
|
||||
join iota on thcv.col_iota = iota.tag
|
||||
where station_id = " . $station_id .
|
||||
" and thcv.col_iota is not null
|
||||
where station_id in (" . $location_list .
|
||||
") and thcv.col_iota is not null
|
||||
and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
|
||||
|
||||
if ($postdata['mode'] != 'All') {
|
||||
|
@ -152,11 +156,11 @@ class IOTA extends CI_Model {
|
|||
return $query->result();
|
||||
}
|
||||
|
||||
function getIotaBandWorked($station_id, $band, $postdata) {
|
||||
function getIotaBandWorked($location_list, $band, $postdata) {
|
||||
$sql = 'SELECT distinct col_iota as tag FROM ' . $this->config->item('table_name'). ' thcv
|
||||
join iota on thcv.col_iota = iota.tag
|
||||
where station_id = ' . $station_id .
|
||||
' and thcv.col_iota is not null';
|
||||
where station_id in (' . $location_list .
|
||||
') and thcv.col_iota is not null';
|
||||
|
||||
if ($postdata['mode'] != 'All') {
|
||||
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
|
||||
|
@ -182,10 +186,6 @@ class IOTA extends CI_Model {
|
|||
}
|
||||
|
||||
function fetchIota($postdata) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
|
||||
$sql = "select tag, name, prefix, dxccid, status from iota where 1=1";
|
||||
|
||||
if ($postdata['includedeleted'] == NULL) {
|
||||
|
@ -195,7 +195,7 @@ class IOTA extends CI_Model {
|
|||
$sql .= $this->addContinentsToQuery($postdata);
|
||||
|
||||
if ($postdata['notworked'] == NULL) {
|
||||
$sql .= " and exists (select 1 from " . $this->config->item('table_name') . " where station_id = ". $station_id . " and col_iota = iota.tag";
|
||||
$sql .= " and exists (select 1 from " . $this->config->item('table_name') . " where station_id in (". $location_list . ") and col_iota = iota.tag";
|
||||
|
||||
if ($postdata['mode'] != 'All') {
|
||||
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
|
||||
|
@ -219,12 +219,12 @@ class IOTA extends CI_Model {
|
|||
return $query->result();
|
||||
}
|
||||
|
||||
function getIotaWorked($station_id, $postdata) {
|
||||
function getIotaWorked($location_list, $postdata) {
|
||||
$sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv
|
||||
join iota on thcv.col_iota = iota.tag
|
||||
where station_id = " . $station_id .
|
||||
" and thcv.col_iota is not null
|
||||
and not exists (select 1 from ". $this->config->item('table_name') . " where station_id = ". $station_id .
|
||||
where station_id in (" . $location_list .
|
||||
") and thcv.col_iota is not null
|
||||
and not exists (select 1 from ". $this->config->item('table_name') . " where station_id = ". $location_list .
|
||||
" and col_iota = thcv.col_iota";
|
||||
|
||||
if ($postdata['mode'] != 'All') {
|
||||
|
@ -268,11 +268,11 @@ class IOTA extends CI_Model {
|
|||
return $query->result();
|
||||
}
|
||||
|
||||
function getIotaConfirmed($station_id, $postdata) {
|
||||
function getIotaConfirmed($location_list, $postdata) {
|
||||
$sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv
|
||||
join iota on thcv.col_iota = iota.tag
|
||||
where station_id = " . $station_id .
|
||||
" and thcv.col_iota is not null
|
||||
where station_id in (" . $location_list .
|
||||
") and thcv.col_iota is not null
|
||||
and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
|
||||
|
||||
if ($postdata['mode'] != 'All') {
|
||||
|
@ -338,19 +338,21 @@ class IOTA extends CI_Model {
|
|||
*/
|
||||
function get_iota_summary($bands)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
foreach ($bands as $band) {
|
||||
$worked = $this->getSummaryByBand($band, $station_id);
|
||||
$confirmed = $this->getSummaryByBandConfirmed($band, $station_id);
|
||||
$worked = $this->getSummaryByBand($band, $location_list);
|
||||
$confirmed = $this->getSummaryByBandConfirmed($band, $location_list);
|
||||
$iotaSummary['worked'][$band] = $worked[0]->count;
|
||||
$iotaSummary['confirmed'][$band] = $confirmed[0]->count;
|
||||
}
|
||||
|
||||
$workedTotal = $this->getSummaryByBand('All', $station_id);
|
||||
$confirmedTotal = $this->getSummaryByBandConfirmed('All', $station_id);
|
||||
$workedTotal = $this->getSummaryByBand('All', $location_list);
|
||||
$confirmedTotal = $this->getSummaryByBandConfirmed('All', $location_list);
|
||||
|
||||
$iotaSummary['worked']['Total'] = $workedTotal[0]->count;
|
||||
$iotaSummary['confirmed']['Total'] = $confirmedTotal[0]->count;
|
||||
|
@ -358,11 +360,11 @@ class IOTA extends CI_Model {
|
|||
return $iotaSummary;
|
||||
}
|
||||
|
||||
function getSummaryByBand($band, $station_id)
|
||||
function getSummaryByBand($band, $location_list)
|
||||
{
|
||||
$sql = "SELECT count(distinct thcv.col_iota) as count FROM " . $this->config->item('table_name') . " thcv";
|
||||
|
||||
$sql .= " where station_id = " . $station_id;
|
||||
$sql .= " where station_id in (" . $location_list . ")";
|
||||
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
|
||||
|
@ -378,11 +380,11 @@ class IOTA extends CI_Model {
|
|||
return $query->result();
|
||||
}
|
||||
|
||||
function getSummaryByBandConfirmed($band, $station_id)
|
||||
function getSummaryByBandConfirmed($band, $location_list)
|
||||
{
|
||||
$sql = "SELECT count(distinct thcv.col_iota) as count FROM " . $this->config->item('table_name') . " thcv";
|
||||
|
||||
$sql .= " where station_id = " . $station_id;
|
||||
$sql .= " where station_id in (" . $location_list . ")";
|
||||
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
|
||||
|
|
Ładowanie…
Reference in New Issue