diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php
index ff6a51174..1b9b94f18 100644
--- a/application/controllers/Awards.php
+++ b/application/controllers/Awards.php
@@ -259,4 +259,75 @@ class Awards extends CI_Controller {
$this->load->view('interface_assets/footer');
}
+ public function iota () {
+ $this->load->model('iota');
+ $data['worked_bands'] = $this->iota->get_worked_bands(); // Used in the view for band select
+
+ if ($this->input->post('band') != NULL) { // Band is not set when page first loads.
+ if ($this->input->post('band') == 'All') { // Did the user specify a band? If not, use all bands
+ $bands = $data['worked_bands'];
+ }
+ else {
+ $bands[] = $this->input->post('band');
+ }
+ }
+ else {
+ $bands = $data['worked_bands'];
+ }
+
+ $data['bands'] = $bands; // Used for displaying selected band(s) in the table in the view
+
+ if($this->input->method() === 'post') {
+ $postdata['worked'] = $this->input->post('worked');
+ $postdata['confirmed'] = $this->input->post('confirmed');
+ $postdata['notworked'] = $this->input->post('notworked');
+ $postdata['includedeleted'] = $this->input->post('includedeleted');
+ $postdata['Africa'] = $this->input->post('Africa');
+ $postdata['Asia'] = $this->input->post('Asia');
+ $postdata['Europe'] = $this->input->post('Europe');
+ $postdata['NorthAmerica'] = $this->input->post('NorthAmerica');
+ $postdata['SouthAmerica'] = $this->input->post('SouthAmerica');
+ $postdata['Oceania'] = $this->input->post('Oceania');
+ $postdata['Antarctica'] = $this->input->post('Antarctica');
+ $postdata['band'] = $this->input->post('band');
+ }
+ else { // Setting default values at first load of page
+ $postdata['worked'] = 1;
+ $postdata['confirmed'] = 1;
+ $postdata['notworked'] = 1;
+ $postdata['includedeleted'] = 1;
+ $postdata['Africa'] = 1;
+ $postdata['Asia'] = 1;
+ $postdata['Europe'] = 1;
+ $postdata['NorthAmerica'] = 1;
+ $postdata['SouthAmerica'] = 1;
+ $postdata['Oceania'] = 1;
+ $postdata['Antarctica'] = 1;
+ $postdata['band'] = 'All';
+ }
+
+ $iotalist = $this->iota->fetchIota($postdata);
+ $data['iota_array'] = $this->iota->get_iota_array($iotalist, $bands, $postdata);
+
+ // Render Page
+ $data['page_title'] = "Awards - IOTA (Islands On The Air)";
+ $this->load->view('interface_assets/header', $data);
+ $this->load->view('awards/iota/index');
+ $this->load->view('interface_assets/footer');
+ }
+
+ public function iota_details(){
+ $this->load->model('logbook_model');
+
+ $iota = str_replace('"', "", $this->input->get("Iota"));
+ $band = str_replace('"', "", $this->input->get("Band"));
+ $data['results'] = $this->logbook_model->iota_qso_details($iota, $band);
+
+ // Render Page
+ $data['page_title'] = "Log View - IOTA";
+ $data['filter'] = "iota ".$iota. " and ".$band;
+ $this->load->view('interface_assets/header', $data);
+ $this->load->view('awards/iota/details');
+ $this->load->view('interface_assets/footer');
+ }
}
diff --git a/application/models/Iota.php b/application/models/Iota.php
new file mode 100644
index 000000000..484a5667a
--- /dev/null
+++ b/application/models/Iota.php
@@ -0,0 +1,318 @@
+0,
+ "80m"=>0,
+ "60m"=>0,
+ "40m"=>0,
+ "30m"=>0,
+ "20m"=>0,
+ "17m"=>0,
+ "15m"=>0,
+ "12m"=>0,
+ "10m"=>0,
+ "6m" =>0,
+ "4m" =>0,
+ "2m" =>0,
+ "70cm"=>0,
+ "23cm"=>0,
+ "13cm"=>0,
+ "9cm"=>0,
+ "6cm"=>0,
+ "3cm"=>0,
+ "1.25cm"=>0,
+ "SAT"=>0,
+ );
+
+ function __construct()
+ {
+ // Call the Model constructor
+ parent::__construct();
+
+ }
+
+ function get_worked_bands() {
+ $CI =& get_instance();
+ $CI->load->model('Stations');
+ $station_id = $CI->Stations->find_active();
+
+ // 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\""
+ );
+ $worked_slots = array();
+ foreach($data->result() as $row){
+ array_push($worked_slots, $row->COL_BAND);
+ }
+
+ $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\""
+ );
+
+ foreach($SAT_data->result() as $row){
+ array_push($worked_slots, strtoupper($row->COL_PROP_MODE));
+ }
+
+
+ // bring worked-slots in order of defined $bandslots
+ $results = array();
+ foreach(array_keys($this->bandslots) as $slot) {
+ if(in_array($slot, $worked_slots)) {
+ array_push($results, $slot);
+ }
+ }
+ return $results;
+ }
+
+ function get_iota_array($iotaArray, $bands, $postdata) {
+ $CI =& get_instance();
+ $CI->load->model('Stations');
+ $station_id = $CI->Stations->find_active();
+
+ foreach ($bands as $band) { // Looping through bands and entities to generate the array needed for display
+ foreach ($iotaArray as $iota) {
+ $iotaMatrix[$iota->tag]['prefix'] = $iota->prefix;
+ $iotaMatrix[$iota->tag]['name'] = $iota->name;
+ //$iotaMatrix[$iota->tag]['status'] = $iota->status;
+ if ($postdata['includedeleted'])
+ $iotaMatrix[$iota->tag]['Deleted'] = isset($iota->status) && $iota->status == 'D' ? "
Y
" : '';
+ $iotaMatrix[$iota->tag][$band] = '-';
+ }
+
+ // If worked is checked, we add worked iotas to the array
+ if ($postdata['worked'] != NULL) {
+ $workedIota = $this->getIotaBandWorked($station_id, $band, $postdata);
+ foreach ($workedIota as $wiota) {
+ $iotaMatrix[$wiota->tag][$band] = '';;
+ }
+ }
+
+ // If confirmed is checked, we add confirmed iotas to the array
+ if ($postdata['confirmed'] != NULL) {
+ $confirmedIota = $this->getIotaBandConfirmed($station_id, $band, $postdata);
+ foreach ($confirmedIota as $ciota) {
+ $iotaMatrix[$ciota->tag][$band] = '';;
+ }
+ }
+ }
+
+ // 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);
+ foreach ($workedIota as $wiota) {
+ if (array_key_exists($wiota->tag, $iotaMatrix)) {
+ unset($iotaMatrix[$wiota->tag]);
+ }
+ }
+ }
+
+ // 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);
+ foreach ($confirmedIOTA as $ciota) {
+ if (array_key_exists($ciota->tag, $iotaMatrix)) {
+ unset($iotaMatrix[$ciota->tag]);
+ }
+ }
+ }
+
+ if (isset($iotaMatrix)) {
+ return $iotaMatrix;
+ }
+ else {
+ return 0;
+ }
+ }
+
+ function getIotaBandConfirmed($station_id, $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
+ and col_qsl_rcvd = 'Y'";
+
+ if ($band == 'SAT') {
+ $sql .= " and col_prop_mode ='" . $band . "'";
+ }
+ else {
+ $sql .= " and col_band ='" . $band . "'";
+ }
+
+ if ($postdata['includedeleted'] == NULL) {
+ $sql .= " and coalesce(iota.status, '') <> 'D'";
+ }
+
+ if ($postdata['includedeleted'] == NULL) {
+ $sql .= " and coalesce(iota.status, '') <> 'D'";
+ }
+
+ $sql .= $this->addContinentsToQuery($postdata);
+
+ $query = $this->db->query($sql);
+
+ return $query->result();
+ }
+
+ function getIotaBandWorked($station_id, $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';
+
+ if ($band == 'SAT') {
+ $sql .= " and col_prop_mode ='" . $band . "'";
+ }
+ else {
+ $sql .= " and col_band ='" . $band . "'";
+ }
+
+ if ($postdata['includedeleted'] == NULL) {
+ $sql .= " and coalesce(iota.status, '') <> 'D'";
+ }
+
+ $sql .= $this->addContinentsToQuery($postdata);
+
+ $query = $this->db->query($sql);
+
+ return $query->result();
+ }
+
+ 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) {
+ $sql .= " and coalesce(iota.status, '') <> 'D'";
+ }
+
+ $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";
+ if ($postdata['band'] != 'All') {
+ if ($postdata['band'] == 'SAT') {
+ $sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
+ }
+ else {
+ $sql .= " and col_band ='" . $postdata['band'] . "'";
+ }
+ }
+ $sql .= ")";
+ }
+
+ $sql .= ' order by tag';
+ $query = $this->db->query($sql);
+
+ return $query->result();
+ }
+
+ function getIotaWorked($station_id, $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 .
+ " and col_iota = thcv.col_iota";
+
+ if ($postdata['band'] != 'All') {
+ if ($postdata['band'] == 'SAT') {
+ $sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
+ }
+ else {
+ $sql .= " and col_band ='" . $postdata['band'] . "'";
+ }
+ }
+
+ $sql .= " and col_qsl_rcvd = 'Y')";
+
+ if ($postdata['band'] != 'All') {
+ if ($postdata['band'] == 'SAT') {
+ $sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
+ }
+ else {
+ $sql .= " and col_band ='" . $postdata['band'] . "'";
+ }
+ }
+
+ if ($postdata['includedeleted'] == NULL) {
+ $sql .= " and coalesce(iota.status, '') <> 'D'";
+ }
+
+ $sql .= $this->addContinentsToQuery($postdata);
+
+ $query = $this->db->query($sql);
+
+ return $query->result();
+ }
+
+ function getIotaConfirmed($station_id, $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 col_qsl_rcvd = 'Y'";
+
+ if ($postdata['includedeleted'] == NULL) {
+ $sql .= " and coalesce(iota.status, '') <> 'D'";
+ }
+
+ $sql .= $this->addContinentsToQuery($postdata);
+
+ if ($postdata['band'] != 'All') {
+ if ($postdata['band'] == 'SAT') {
+ $sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
+ }
+ else {
+ $sql .= " and col_band ='" . $postdata['band'] . "'";
+ }
+ }
+
+ if ($postdata['includedeleted'] == NULL) {
+ $sql .= " and coalesce(iota.status, '') <> 'D'";
+ }
+
+ $sql .= $this->addContinentsToQuery($postdata);
+
+ $query = $this->db->query($sql);
+
+ return $query->result();
+ }
+
+ // Made function instead of repeating this several times
+ function addContinentsToQuery($postdata) {
+ $sql = '';
+ if ($postdata['Africa'] == NULL) {
+ $sql .= " and left(tag, 2) <> 'AF'";
+ }
+
+ if ($postdata['Europe'] == NULL) {
+ $sql .= " and left(tag, 2) <> 'EU'";
+ }
+
+ if ($postdata['Asia'] == NULL) {
+ $sql .= " and left(tag, 2) <> 'AS'";
+ }
+
+ if ($postdata['SouthAmerica'] == NULL) {
+ $sql .= " and left(tag, 2) <> 'SA'";
+ }
+
+ if ($postdata['NorthAmerica'] == NULL) {
+ $sql .= " and left(tag, 2) <> 'NA'";
+ }
+
+ if ($postdata['Oceania'] == NULL) {
+ $sql .= " and left(tag, 2) <> 'OC'";
+ }
+
+ if ($postdata['Antarctica'] == NULL) {
+ $sql .= " and left(tag, 2) <> 'AN'";
+ }
+ return $sql;
+ }
+}
+?>
\ No newline at end of file
diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php
index 0ad10816f..98323176e 100755
--- a/application/models/Logbook_model.php
+++ b/application/models/Logbook_model.php
@@ -190,6 +190,22 @@ class Logbook_model extends CI_Model {
return $this->db->get($this->config->item('table_name'));
}
+ public function iota_qso_details($iota, $band){
+ $CI =& get_instance();
+ $CI->load->model('Stations');
+ $station_id = $CI->Stations->find_active();
+
+ $this->db->where('station_id', $station_id);
+ $this->db->where('COL_IOTA', $iota);
+ if($band != "SAT") {
+ $this->db->where('COL_BAND', $band);
+ } else {
+ $this->db->where('COL_PROP_MODE', "SAT");
+ }
+
+ return $this->db->get($this->config->item('table_name'));
+ }
+
public function cq_qso_details($cqzone){
$CI =& get_instance();
$CI->load->model('Stations');
diff --git a/application/views/awards/iota/details.php b/application/views/awards/iota/details.php
new file mode 100644
index 000000000..8e2917028
--- /dev/null
+++ b/application/views/awards/iota/details.php
@@ -0,0 +1,7 @@
+
+
+
Logbook
+
+
Filtering on
+
+load->view('view_log/partial/log') ?>
diff --git a/application/views/awards/iota/index.php b/application/views/awards/iota/index.php
new file mode 100644
index 000000000..c8341c589
--- /dev/null
+++ b/application/views/awards/iota/index.php
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+ load->view("awards/nav_bar")?>
+
+
+
+
+ | # |
+ Iota |
+ Prefix |
+ Name | ';
+ if ($this->input->post('includedeleted') || $this->input->method() !== 'post')
+ echo ' Deleted | ';
+
+ foreach($bands as $band) {
+ echo '' . $band . ' | ';
+ }
+ echo '
+
+
';
+ foreach ($iota_array as $iota => $value) {
+ echo '
+ | '. $i++ .' |
+ '. $iota .' | ';
+ foreach ($value as $key) {
+ echo '' . $key . ' | ';
+ }
+ echo '
';
+ }
+ echo '';
+
+ }
+ else {
+ echo '';
+ }
+ ?>
+
\ No newline at end of file
diff --git a/application/views/awards/nav_bar.php b/application/views/awards/nav_bar.php
index 3ad416e4c..33ae85872 100644
--- a/application/views/awards/nav_bar.php
+++ b/application/views/awards/nav_bar.php
@@ -6,4 +6,5 @@
SOTA
CQ
DOK
+ IOTA
\ No newline at end of file