From f5f8243fc2585254f674af6604a93795d4b146b4 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sun, 14 Nov 2021 11:28:50 +0000 Subject: [PATCH 01/69] Revert "Merge branch 'station_logbooks' into master" This reverts commit 246cec2d667736bab62ee5b56280ad7467191d46, reversing changes made to 57f370aa1e20b0b1e30a58cb85b8f177319738ee. --- application/config/config.sample.php | 9 +- application/config/migration.php | 3 +- application/controllers/Accumulated.php | 4 +- application/controllers/Api.php | 5 +- application/controllers/Awards.php | 35 +- application/controllers/Dashboard.php | 13 +- application/controllers/Distances.php | 6 +- application/controllers/Dxatlas.php | 122 ------- application/controllers/Kml.php | 4 +- application/controllers/Logbook.php | 47 +-- application/controllers/Logbooks.php | 119 ------- application/controllers/Lookup.php | 11 +- application/controllers/Lotw.php | 11 +- application/controllers/Map.php | 43 +-- application/controllers/Options.php | 16 +- application/controllers/Qso.php | 2 +- application/controllers/Radio.php | 32 +- application/controllers/Station.php | 11 - application/controllers/Themes.php | 89 ----- application/controllers/Timeline.php | 3 +- application/controllers/Timeplotter.php | 4 +- application/controllers/Update.php | 27 +- application/controllers/User.php | 8 +- .../migrations/071_add_queries_table.php | 2 +- .../072_create_station_logbook_table.php | 54 --- ...ate_station_logbook_relationship_table.php | 56 --- .../074_add_userid_to_station_profiles.php | 22 -- ...d_active_station_logbook_to_user_table.php | 27 -- application/migrations/076_theme_table.php | 22 -- .../migrations/077_add_userid_to_notes.php | 21 -- .../migrations/078_add_userid_to_hardware.php | 22 -- .../migrations/079_add_userid_to_api.php | 21 -- application/models/Accumulate_model.php | 144 +++++--- application/models/Adif_data.php | 13 +- application/models/Api_model.php | 35 +- application/models/Bands.php | 140 -------- application/models/Cat.php | 56 +-- application/models/Clublog_model.php | 5 + application/models/Contesting_model.php | 6 + application/models/Counties.php | 29 +- application/models/Cq.php | 97 ++++-- application/models/Dayswithqso_model.php | 28 +- application/models/Distances_model.php | 207 +++++------ application/models/Dok.php | 68 +++- application/models/Dxatlas_model.php | 166 --------- application/models/Dxcc.php | 199 ++++++++--- application/models/Dxcc_entities.php | 5 + application/models/Dxcc_exceptions.php | 7 + application/models/Dxcc_prefixes.php | 9 +- application/models/Eqsl_images.php | 5 + application/models/Eqslmethods_model.php | 5 + application/models/Gridsquares_model.php | 148 ++++---- application/models/Iota.php | 133 +++++-- application/models/Logbook_model.php | 325 ++++++------------ application/models/Logbooks_model.php | 188 ---------- application/models/Lookup_model.php | 78 ++++- application/models/LotwCert.php | 6 + application/models/Modes.php | 6 + application/models/Note.php | 22 +- application/models/Options_model.php | 5 + application/models/Qsl_model.php | 7 + application/models/Qslprint_model.php | 5 + application/models/Search.php | 5 + application/models/Search_filter.php | 5 + application/models/Sig.php | 25 +- application/models/Sota.php | 17 +- application/models/Stations.php | 88 ++--- application/models/Stats.php | 5 + application/models/Themes_model.php | 50 --- application/models/Timeline_model.php | 96 +++++- application/models/Timeplotter_model.php | 69 +++- application/models/User_model.php | 15 +- application/models/Vucc.php | 88 ++++- application/models/Was.php | 111 ++++-- application/views/dxatlas/index.php | 137 -------- application/views/gridsquares/index.php | 4 +- application/views/interface_assets/footer.php | 87 +---- application/views/interface_assets/header.php | 17 +- .../views/interface_assets/mini_header.php | 6 +- application/views/logbooks/create.php | 41 --- application/views/logbooks/edit.php | 105 ------ application/views/logbooks/index.php | 59 ---- application/views/map/custom_date.php | 10 +- application/views/options/appearance.php | 17 +- application/views/station_profile/index.php | 9 +- application/views/themes/add.php | 37 -- application/views/themes/edit.php | 50 --- application/views/themes/index.php | 51 --- application/views/user/add.php | 29 +- application/views/user/edit.php | 27 +- assets/css/general.css | 8 - assets/js/sections/distances.js | 2 +- assets/js/sections/qso.js | 7 - install/config/config.php | 9 +- system/.htaccess | 7 +- system/core/Benchmark.php | 8 +- system/core/CodeIgniter.php | 107 ++++-- system/core/Common.php | 24 +- system/core/Config.php | 24 +- system/core/Controller.php | 15 +- system/core/Exceptions.php | 20 +- system/core/Hooks.php | 14 +- system/core/Input.php | 293 ++++++++++++++-- system/core/Lang.php | 23 +- system/core/Loader.php | 38 +- system/core/Log.php | 19 +- system/core/Model.php | 20 +- system/core/Output.php | 27 +- system/core/Router.php | 51 ++- system/core/Security.php | 70 ++-- system/core/URI.php | 130 +++---- system/core/Utf8.php | 22 +- system/core/compat/hash.php | 16 +- system/core/compat/index.html | 2 +- system/core/compat/mbstring.php | 16 +- system/core/compat/password.php | 20 +- system/core/compat/standard.php | 58 +++- system/core/index.html | 2 +- system/database/DB.php | 17 +- system/database/DB_cache.php | 8 +- system/database/DB_driver.php | 149 +++++--- system/database/DB_forge.php | 59 ++-- system/database/DB_query_builder.php | 217 ++++-------- system/database/DB_result.php | 19 +- system/database/DB_utility.php | 22 +- .../database/drivers/cubrid/cubrid_driver.php | 8 +- .../database/drivers/cubrid/cubrid_forge.php | 8 +- .../database/drivers/cubrid/cubrid_result.php | 8 +- .../drivers/cubrid/cubrid_utility.php | 8 +- system/database/drivers/cubrid/index.html | 2 +- .../database/drivers/ibase/ibase_driver.php | 8 +- system/database/drivers/ibase/ibase_forge.php | 12 +- .../database/drivers/ibase/ibase_result.php | 8 +- .../database/drivers/ibase/ibase_utility.php | 8 +- system/database/drivers/ibase/index.html | 2 +- system/database/drivers/index.html | 2 +- system/database/drivers/mssql/index.html | 2 +- .../database/drivers/mssql/mssql_driver.php | 22 +- system/database/drivers/mssql/mssql_forge.php | 8 +- .../database/drivers/mssql/mssql_result.php | 8 +- .../database/drivers/mssql/mssql_utility.php | 8 +- system/database/drivers/mysql/index.html | 2 +- .../database/drivers/mysql/mysql_driver.php | 67 ++-- system/database/drivers/mysql/mysql_forge.php | 8 +- .../database/drivers/mysql/mysql_result.php | 8 +- .../database/drivers/mysql/mysql_utility.php | 8 +- system/database/drivers/mysqli/index.html | 2 +- .../database/drivers/mysqli/mysqli_driver.php | 68 ++-- .../database/drivers/mysqli/mysqli_forge.php | 8 +- .../database/drivers/mysqli/mysqli_result.php | 22 +- .../drivers/mysqli/mysqli_utility.php | 14 +- system/database/drivers/oci8/index.html | 2 +- system/database/drivers/oci8/oci8_driver.php | 23 +- system/database/drivers/oci8/oci8_forge.php | 39 +-- system/database/drivers/oci8/oci8_result.php | 8 +- system/database/drivers/oci8/oci8_utility.php | 8 +- system/database/drivers/odbc/index.html | 2 +- system/database/drivers/odbc/odbc_driver.php | 8 +- system/database/drivers/odbc/odbc_forge.php | 6 +- system/database/drivers/odbc/odbc_result.php | 8 +- system/database/drivers/odbc/odbc_utility.php | 6 +- system/database/drivers/pdo/index.html | 2 +- system/database/drivers/pdo/pdo_driver.php | 23 +- system/database/drivers/pdo/pdo_forge.php | 6 +- system/database/drivers/pdo/pdo_result.php | 10 +- system/database/drivers/pdo/pdo_utility.php | 6 +- .../drivers/pdo/subdrivers/index.html | 2 +- .../drivers/pdo/subdrivers/pdo_4d_driver.php | 8 +- .../drivers/pdo/subdrivers/pdo_4d_forge.php | 8 +- .../pdo/subdrivers/pdo_cubrid_driver.php | 8 +- .../pdo/subdrivers/pdo_cubrid_forge.php | 8 +- .../pdo/subdrivers/pdo_dblib_driver.php | 8 +- .../pdo/subdrivers/pdo_dblib_forge.php | 8 +- .../pdo/subdrivers/pdo_firebird_driver.php | 8 +- .../pdo/subdrivers/pdo_firebird_forge.php | 14 +- .../drivers/pdo/subdrivers/pdo_ibm_driver.php | 8 +- .../drivers/pdo/subdrivers/pdo_ibm_forge.php | 8 +- .../pdo/subdrivers/pdo_informix_driver.php | 8 +- .../pdo/subdrivers/pdo_informix_forge.php | 8 +- .../pdo/subdrivers/pdo_mysql_driver.php | 15 +- .../pdo/subdrivers/pdo_mysql_forge.php | 8 +- .../drivers/pdo/subdrivers/pdo_oci_driver.php | 12 +- .../drivers/pdo/subdrivers/pdo_oci_forge.php | 41 +-- .../pdo/subdrivers/pdo_odbc_driver.php | 8 +- .../drivers/pdo/subdrivers/pdo_odbc_forge.php | 6 +- .../pdo/subdrivers/pdo_pgsql_driver.php | 14 +- .../pdo/subdrivers/pdo_pgsql_forge.php | 16 +- .../pdo/subdrivers/pdo_sqlite_driver.php | 20 +- .../pdo/subdrivers/pdo_sqlite_forge.php | 8 +- .../pdo/subdrivers/pdo_sqlsrv_driver.php | 8 +- .../pdo/subdrivers/pdo_sqlsrv_forge.php | 8 +- system/database/drivers/postgre/index.html | 2 +- .../drivers/postgre/postgre_driver.php | 56 +-- .../drivers/postgre/postgre_forge.php | 16 +- .../drivers/postgre/postgre_result.php | 8 +- .../drivers/postgre/postgre_utility.php | 8 +- system/database/drivers/sqlite3/index.html | 2 +- .../drivers/sqlite3/sqlite3_driver.php | 20 +- .../drivers/sqlite3/sqlite3_forge.php | 8 +- .../drivers/sqlite3/sqlite3_result.php | 8 +- .../drivers/sqlite3/sqlite3_utility.php | 8 +- system/database/drivers/sqlsrv/index.html | 2 +- .../database/drivers/sqlsrv/sqlsrv_driver.php | 8 +- .../database/drivers/sqlsrv/sqlsrv_forge.php | 8 +- .../database/drivers/sqlsrv/sqlsrv_result.php | 8 +- .../drivers/sqlsrv/sqlsrv_utility.php | 8 +- system/database/index.html | 2 +- system/fonts/index.html | 2 +- system/helpers/array_helper.php | 8 +- system/helpers/captcha_helper.php | 113 ++---- system/helpers/cookie_helper.php | 15 +- system/helpers/date_helper.php | 48 ++- system/helpers/directory_helper.php | 8 +- system/helpers/download_helper.php | 62 ++-- system/helpers/file_helper.php | 28 +- system/helpers/form_helper.php | 30 +- system/helpers/html_helper.php | 75 ++-- system/helpers/index.html | 2 +- system/helpers/inflector_helper.php | 66 +--- system/helpers/language_helper.php | 8 +- system/helpers/number_helper.php | 8 +- system/helpers/path_helper.php | 8 +- system/helpers/security_helper.php | 32 +- system/helpers/string_helper.php | 55 ++- system/helpers/text_helper.php | 8 +- system/helpers/typography_helper.php | 8 +- system/helpers/url_helper.php | 18 +- system/helpers/xml_helper.php | 8 +- system/index.html | 2 +- system/language/english/calendar_lang.php | 6 +- system/language/english/date_lang.php | 6 +- system/language/english/db_lang.php | 6 +- system/language/english/email_lang.php | 6 +- .../language/english/form_validation_lang.php | 8 +- system/language/english/ftp_lang.php | 6 +- system/language/english/imglib_lang.php | 7 +- system/language/english/index.html | 2 +- system/language/english/migration_lang.php | 6 +- system/language/english/number_lang.php | 6 +- system/language/english/pagination_lang.php | 6 +- system/language/english/profiler_lang.php | 6 +- system/language/english/unit_test_lang.php | 6 +- system/language/english/upload_lang.php | 6 +- system/language/finnish/calendar_lang.php | 2 +- system/language/index.html | 2 +- system/libraries/Cache/Cache.php | 19 +- system/libraries/Cache/drivers/Cache_apc.php | 14 +- system/libraries/Cache/drivers/Cache_apcu.php | 219 ------------ .../libraries/Cache/drivers/Cache_dummy.php | 14 +- system/libraries/Cache/drivers/Cache_file.php | 8 +- .../Cache/drivers/Cache_memcached.php | 38 +- .../libraries/Cache/drivers/Cache_redis.php | 130 +++---- .../Cache/drivers/Cache_wincache.php | 16 +- system/libraries/Cache/drivers/index.html | 2 +- system/libraries/Cache/index.html | 2 +- system/libraries/Calendar.php | 8 +- system/libraries/Driver.php | 6 +- system/libraries/Email.php | 291 +++++++++------- system/libraries/Encrypt.php | 10 +- system/libraries/Encryption.php | 21 +- system/libraries/Form_validation.php | 172 +++++---- system/libraries/Ftp.php | 8 +- system/libraries/Image_lib.php | 53 +-- system/libraries/Migration.php | 8 +- system/libraries/Pagination.php | 17 +- system/libraries/Parser.php | 8 +- system/libraries/Profiler.php | 26 +- system/libraries/Session/Session.php | 43 ++- system/libraries/Session/Session_driver.php | 46 +-- .../drivers/Session_database_driver.php | 129 +++---- .../Session/drivers/Session_files_driver.php | 38 +- .../drivers/Session_memcached_driver.php | 49 +-- .../Session/drivers/Session_redis_driver.php | 180 +++------- system/libraries/Session/drivers/index.html | 2 +- system/libraries/Session/index.html | 2 +- system/libraries/Table.php | 9 +- system/libraries/Trackback.php | 8 +- system/libraries/Typography.php | 8 +- system/libraries/Unit_test.php | 8 +- system/libraries/Upload.php | 26 +- system/libraries/User_agent.php | 8 +- system/libraries/Xmlrpc.php | 26 +- system/libraries/Xmlrpcs.php | 28 +- system/libraries/Zip.php | 20 +- system/libraries/index.html | 2 +- 285 files changed, 3958 insertions(+), 5210 deletions(-) delete mode 100644 application/controllers/Dxatlas.php delete mode 100644 application/controllers/Logbooks.php delete mode 100644 application/controllers/Themes.php delete mode 100644 application/migrations/072_create_station_logbook_table.php delete mode 100644 application/migrations/073_create_station_logbook_relationship_table.php delete mode 100644 application/migrations/074_add_userid_to_station_profiles.php delete mode 100644 application/migrations/075_add_active_station_logbook_to_user_table.php delete mode 100644 application/migrations/076_theme_table.php delete mode 100644 application/migrations/077_add_userid_to_notes.php delete mode 100644 application/migrations/078_add_userid_to_hardware.php delete mode 100644 application/migrations/079_add_userid_to_api.php delete mode 100644 application/models/Bands.php delete mode 100644 application/models/Dxatlas_model.php delete mode 100644 application/models/Logbooks_model.php delete mode 100644 application/models/Themes_model.php delete mode 100644 application/views/dxatlas/index.php delete mode 100644 application/views/logbooks/create.php delete mode 100644 application/views/logbooks/edit.php delete mode 100644 application/views/logbooks/index.php delete mode 100644 application/views/themes/add.php delete mode 100644 application/views/themes/edit.php delete mode 100644 application/views/themes/index.php delete mode 100644 system/libraries/Cache/drivers/Cache_apcu.php diff --git a/application/config/config.sample.php b/application/config/config.sample.php index fd619c4b..1f596a03 100644 --- a/application/config/config.sample.php +++ b/application/config/config.sample.php @@ -19,8 +19,6 @@ $config['directory'] = "logbook"; $config['callbook'] = "hamqth"; // Options are hamqth or qrz -$config['datadir'] = null; // default to install directory - /* |-------------------------------------------------------------------------- | Logbook Options @@ -74,9 +72,12 @@ $config['hamqth_password'] = ""; $config['use_auth'] = true; $config['auth_table'] = "users"; -$config['auth_mode'] = "3"; +$config['auth_mode'] = "0"; -$config['auth_level'][3] = "Operator"; +$config['auth_level'][0] = "Anonymous"; +$config['auth_level'][1] = "Viewer"; +$config['auth_level'][2] = "Editor"; +$config['auth_level'][3] = "API User"; $config['auth_level'][99] = "Administrator"; /* diff --git a/application/config/migration.php b/application/config/migration.php index a875a2db..227bc690 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,8 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ - -$config['migration_version'] = 79; +$config['migration_version'] = 71; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Accumulated.php b/application/controllers/Accumulated.php index 152d5abf..c299d4bf 100644 --- a/application/controllers/Accumulated.php +++ b/application/controllers/Accumulated.php @@ -16,9 +16,9 @@ class Accumulated extends CI_Controller { // Render Page $data['page_title'] = "Accumulated Statistics"; - $this->load->model('bands'); + $this->load->model('Accumulate_model'); - $data['worked_bands'] = $this->bands->get_worked_bands(); // Used in the view for band select + $data['worked_bands'] = $this->Accumulate_model->get_worked_bands(); $this->load->model('modes'); diff --git a/application/controllers/Api.php b/application/controllers/Api.php index 022e10a9..9e88e859 100644 --- a/application/controllers/Api.php +++ b/application/controllers/Api.php @@ -7,6 +7,7 @@ class API extends CI_Controller { { } + /* TODOs - Search Callsign (Return Json) @@ -475,10 +476,8 @@ class API extends CI_Controller { die(); } - $user_id = $this->api_model->key_userid($obj['key']); - // Store Result to Database - $this->cat->update($obj, $user_id); + $this->cat->update($obj); // Return Message diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 625a9ca6..4fa7d2ec 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -27,12 +27,10 @@ class Awards extends CI_Controller { public function dok () { + //echo "Needs Developed"; $this->load->model('dok'); - $this->load->model('bands'); - $data['doks'] = $this->dok->show_stats(); - - $data['worked_bands'] = $this->bands->get_worked_bands_dok(); // Used in the view for band select + $data['worked_bands'] = $this->dok->get_worked_bands(); // Render Page $data['page_title'] = "Awards - DOK"; @@ -78,9 +76,8 @@ class Awards extends CI_Controller { public function dxcc () { $this->load->model('dxcc'); $this->load->model('modes'); - $this->load->model('bands'); - $data['worked_bands'] = $this->bands->get_worked_bands(); // Used in the view for band select + $data['worked_bands'] = $this->dxcc->get_worked_bands(); // Used in the view for band select $data['modes'] = $this->modes->active(); // Used in the view for mode select if ($this->input->post('band') != NULL) { // Band is not set when page first loads. @@ -145,8 +142,7 @@ class Awards extends CI_Controller { public function vucc() { $this->load->model('vucc'); - $this->load->model('bands'); - $data['worked_bands'] = $this->bands->get_worked_bands(); + $data['worked_bands'] = $this->vucc->get_worked_bands(); $data['vucc_array'] = $this->vucc->get_vucc_array($data); @@ -230,18 +226,15 @@ class Awards extends CI_Controller { $this->load->view('interface_assets/footer'); } - public function cq() { + public function cq(){ $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)."'"; + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $this->load->model('cq'); $this->load->model('modes'); - $this->load->model('bands'); - $data['worked_bands'] = $this->bands->get_worked_bands($location_list); + $data['worked_bands'] = $this->cq->get_worked_bands($station_id); $data['modes'] = $this->modes->active(); // Used in the view for mode select if ($this->input->post('band') != NULL) { // Band is not set when page first loads. @@ -277,8 +270,8 @@ class Awards extends CI_Controller { $postdata['mode'] = 'All'; } - $data['cq_array'] = $this->cq->get_cq_array($bands, $postdata, $location_list); - $data['cq_summary'] = $this->cq->get_cq_summary($data['worked_bands'], $location_list); + $data['cq_array'] = $this->cq->get_cq_array($bands, $postdata, $station_id); + $data['cq_summary'] = $this->cq->get_cq_summary($data['worked_bands'], $station_id); // Render page $data['page_title'] = "Awards - CQ Magazine"; @@ -290,9 +283,8 @@ class Awards extends CI_Controller { public function was() { $this->load->model('was'); $this->load->model('modes'); - $this->load->model('bands'); - $data['worked_bands'] = $this->bands->get_worked_bands(); + $data['worked_bands'] = $this->was->get_worked_bands(); $data['modes'] = $this->modes->active(); // Used in the view for mode select if ($this->input->post('band') != NULL) { // Band is not set when page first loads. @@ -341,9 +333,8 @@ class Awards extends CI_Controller { public function iota () { $this->load->model('iota'); $this->load->model('modes'); - $this->load->model('bands'); - $data['worked_bands'] = $this->bands->get_worked_bands(); // Used in the view for band select + $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 @@ -484,7 +475,7 @@ class Awards extends CI_Controller { ini_set('memory_limit', '-1'); $this->load->model('adif_data'); - + //$type = str_replace('"', "", $this->input->get("type")); $type = $this->uri->segment(3); $data['qsos'] = $this->adif_data->sig_all($type); diff --git a/application/controllers/Dashboard.php b/application/controllers/Dashboard.php index ce8238fe..f539f572 100644 --- a/application/controllers/Dashboard.php +++ b/application/controllers/Dashboard.php @@ -4,24 +4,13 @@ class Dashboard extends CI_Controller { public function index() { - - // Check our version and run any migrations $this->load->library('Migration'); $this->migration->current(); - + // Database connections $this->load->model('logbook_model'); $this->load->model('user_model'); - - // Check if users logged in - - if($this->user_model->validate_session() == 0) { - // user is not logged in - redirect('user/login'); - } - - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { if($this->user_model->validate_session()) { $this->user_model->clear_session(); diff --git a/application/controllers/Distances.php b/application/controllers/Distances.php index 812d548c..8c1865f2 100644 --- a/application/controllers/Distances.php +++ b/application/controllers/Distances.php @@ -16,9 +16,9 @@ class Distances extends CI_Controller { // Render Page $data['page_title'] = "Distances Worked"; - $this->load->model('bands'); - $data['bands_available'] = $this->bands->get_worked_bands_distances(); - $data['sats_available'] = $this->bands->get_worked_sats(); + $this->load->model('Distances_model'); + $data['bands_available'] = $this->Distances_model->get_worked_bands(); + $data['sats_available'] = $this->Distances_model->get_worked_sats(); $this->load->view('interface_assets/header', $data); $this->load->view('distances/index'); diff --git a/application/controllers/Dxatlas.php b/application/controllers/Dxatlas.php deleted file mode 100644 index cf290bd2..00000000 --- a/application/controllers/Dxatlas.php +++ /dev/null @@ -1,122 +0,0 @@ -load->model('user_model'); - - if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - - $this->load->model('modes'); - $this->load->model('logbook_model'); - $this->load->model('stations'); - $this->load->model('bands'); - - $data['station_profile'] = $this->stations->all(); // Used in the view for station location select - $data['worked_bands'] = $this->bands->get_worked_bands(); // Used in the view for band select - $data['modes'] = $this->modes->active(); // Used in the view for mode select - $data['dxcc'] = $this->logbook_model->fetchDxcc(); // Used in the view for dxcc select - - $data['page_title'] = "DX Atlas Gridsquare Export"; - - $this->load->view('interface_assets/header', $data); - $this->load->view('dxatlas/index'); - $this->load->view('interface_assets/footer'); - - } - - public function export() { - $this->load->model('dxatlas_model'); - - // Parameters - $station_id = $this->security->xss_clean($this->input->post('station_profile')); - $band = $this->security->xss_clean($this->input->post('band')); - $mode = $this->security->xss_clean($this->input->post('mode')); - $dxcc = $this->security->xss_clean($this->input->post('dxcc_id')); - $cqz = $this->security->xss_clean($this->input->post('cqz')); - $propagation = $this->security->xss_clean($this->input->post('prop_mode')); - $fromdate = $this->security->xss_clean($this->input->post('fromdate')); - $todate = $this->security->xss_clean($this->input->post('todate')); - - // Get QSOs with Valid QRAs - $grids = $this->dxatlas_model->get_gridsquares($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate); - - $this->generateFiles($grids['worked'], $grids['confirmed'], $band); - } - - function generateFiles($wkdArray, $cfmArray, $band) { - - $gridCfmArray = []; - $gridWkdArray = []; - $fieldCfmArray = []; - $fieldWkdArray = []; - - foreach ($cfmArray as $grid) { - $field = substr($grid, 0, 2); - if (!in_array($field, $fieldCfmArray)) { - $fieldCfmArray[] = $field; - } - $gridCfmArray[] = $grid; - } - - - foreach ($wkdArray as $grid) { - $field = substr($grid, 0, 2); - if (!in_array($field, $fieldCfmArray)) { - if (!in_array($field, $fieldWkdArray)) { - $fieldWkdArray[] = $field; - } - } - if (!in_array($grid, $gridCfmArray)) { - $gridWkdArray[] = $grid; - } - } - - $gridWkdString = ''; - $gridCfmString = ''; - - asort($gridWkdArray); - asort($gridCfmArray); - asort($fieldWkdArray); - asort($fieldCfmArray); - - foreach ($fieldWkdArray as $fields) { - $gridWkdString .= $fields . "\r\n"; - } - - foreach ($gridWkdArray as $grids) { - $gridWkdString .= $grids . "\r\n"; - } - - foreach ($fieldCfmArray as $fields) { - $gridCfmString .= $fields . "\r\n"; - } - - foreach ($gridCfmArray as $grids) { - $gridCfmString .= $grids . "\r\n"; - } - - $this->makeZip($gridWkdString, $gridCfmString, $band); - } - - function makeZip($gridWkdString, $gridCfmString, $band) { - $zipFileName = 'dxatlas_gridsquares_'. $band . '.zip'; - // Prepare File - $file = tempnam("tmp", "zip"); - $zip = new ZipArchive(); - $zip->open($file, ZipArchive::OVERWRITE); - - // Stuff with content - $zip->addFromString($band . '_grids.wkd', $gridWkdString); - $zip->addFromString($band . '_grids.cfm', $gridCfmString); - - // Close and send to users - $zip->close(); - $length = filesize($file); - header('Content-Type: application/zip'); - header('Content-Length: ' . $length); - header('Content-Disposition: attachment; filename="' . $zipFileName . '"'); - readfile($file); - unlink($file); - } -} diff --git a/application/controllers/Kml.php b/application/controllers/Kml.php index b3126fe5..9d0f27ed 100644 --- a/application/controllers/Kml.php +++ b/application/controllers/Kml.php @@ -12,12 +12,12 @@ class Kml extends CI_Controller { public function index() { $this->load->model('user_model'); $this->load->model('modes'); + $this->load->model('dxcc'); $this->load->model('logbook_model'); - $this->load->model('bands'); if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - $data['worked_bands'] = $this->bands->get_worked_bands(); // Used in the view for band select + $data['worked_bands'] = $this->dxcc->get_worked_bands(); // Used in the view for band select $data['modes'] = $this->modes->active(); // Used in the view for mode select $data['dxcc'] = $this->logbook_model->fetchDxcc(); // Used in the view for dxcc select diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index cb051dc9..fd3e96c6 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -17,19 +17,19 @@ class Logbook extends CI_Controller { function index() { - - // Check if users logged in - $this->load->model('user_model'); - if($this->user_model->validate_session() == 0) { - // user is not logged in - redirect('user/login'); - } - - $this->load->model('logbook_model'); + $this->load->model('user_model'); + if(!$this->user_model->authorize($this->config->item('auth_mode'))) { + if($this->user_model->validate_session()) { + $this->user_model->clear_session(); + show_error('Access denied

Click here to log in as another user', 403); + } else { + redirect('user/login'); + } + } $this->load->library('pagination'); $config['base_url'] = base_url().'index.php/logbook/index/'; - $config['total_rows'] = $this->logbook_model->total_qsos(); + $config['total_rows'] = $this->db->count_all($this->config->item('table_name')); $config['per_page'] = '25'; $config['num_links'] = 6; $config['full_tag_open'] = ''; @@ -40,6 +40,7 @@ class Logbook extends CI_Controller { $this->pagination->initialize($config); //load the model and get results + $this->load->model('logbook_model'); $data['results'] = $this->logbook_model->get_qsos($config['per_page'],$this->uri->segment(3)); // Calculate Lat/Lng from Locator to use on Maps @@ -195,8 +196,9 @@ class Logbook extends CI_Controller { return false; $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + if($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); @@ -206,7 +208,7 @@ class Logbook extends CI_Controller { $this->db->where('COL_PROP_MODE !=','SAT'); } - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('station_id', $station_id); $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4)); $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc"); $this->db->limit(1); @@ -235,8 +237,8 @@ class Logbook extends CI_Controller { ]; $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); if($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); @@ -247,7 +249,7 @@ class Logbook extends CI_Controller { } - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('station_id', $station_id); $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4)); $query = $this->db->get($this->config->item('table_name'), 1, 0); @@ -269,8 +271,8 @@ class Logbook extends CI_Controller { ]; $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); if($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); @@ -281,7 +283,7 @@ class Logbook extends CI_Controller { } - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('station_id', $station_id); $this->db->where('COL_COUNTRY', urldecode($country)); $query = $this->db->get($this->config->item('table_name'), 1, 0); @@ -306,8 +308,8 @@ class Logbook extends CI_Controller { ]; $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); if($type == "SAT") { $this->db->where('COL_PROP_MODE', 'SAT'); @@ -318,7 +320,7 @@ class Logbook extends CI_Controller { } - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('station_id', $station_id); $this->db->where('COL_CALL', strtoupper($callsign)); $query = $this->db->get($this->config->item('table_name'), 1, 0); @@ -702,4 +704,5 @@ class Logbook extends CI_Controller { return $this->db->get(); } + } diff --git a/application/controllers/Logbooks.php b/application/controllers/Logbooks.php deleted file mode 100644 index 7b2c9250..00000000 --- a/application/controllers/Logbooks.php +++ /dev/null @@ -1,119 +0,0 @@ -load->helper(array('form', 'url')); - - $this->load->model('user_model'); - if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - } - - function index() { - $this->load->model('logbooks_model'); - - $data['my_logbooks'] = $this->logbooks_model->show_all(); - - // Render Page - $data['page_title'] = "Station Logbooks"; - $this->load->view('interface_assets/header', $data); - $this->load->view('logbooks/index'); - $this->load->view('interface_assets/footer'); - } - - public function create() - { - $this->load->library('form_validation'); - - $this->form_validation->set_rules('stationLogbook_Name', 'Station Logbook Name', 'required'); - - if ($this->form_validation->run() == FALSE) - { - $data['page_title'] = "Create Station Logbook"; - $this->load->view('interface_assets/header', $data); - $this->load->view('logbooks/create'); - $this->load->view('interface_assets/footer'); - } - else - { - $this->load->model('logbooks_model'); - $this->logbooks_model->add(); - - redirect('logbooks'); - } - } - - public function edit($id) - { - $this->load->library('form_validation'); - - $this->load->model('logbooks_model'); - $this->load->model('stations'); - - $station_logbook_id = $this->security->xss_clean($id); - - $station_logbook_details_query = $this->logbooks_model->logbook($station_logbook_id); - $data['station_locations_array'] = $this->logbooks_model->list_logbook_relationships($station_logbook_id); - - $data['station_logbook_details'] = $station_logbook_details_query->row(); - $data['station_locations_list'] = $this->stations->all_of_user(); - - $data['station_locations_linked'] = $this->logbooks_model->list_logbooks_linked($station_logbook_id); - - $data['page_title'] = "Edit Station Logbook"; - - $this->form_validation->set_rules('station_logbook_id', 'Station Logbook Name', 'required'); - - if ($this->form_validation->run() == FALSE) - { - $this->load->view('interface_assets/header', $data); - $this->load->view('logbooks/edit'); - $this->load->view('interface_assets/footer'); - } - else - { - - $data['notice'] = "Station Logbooks ".$this->security->xss_clean($this->input->post('station_logbook_name', true))." Updated"; - - if($this->input->post('SelectedStationLocation') != "") { - if($this->logbooks_model->relationship_exists($this->input->post('station_logbook_id'), $this->input->post('SelectedStationLocation')) != TRUE) { - // If no link exisits create - $this->logbooks_model->create_logbook_location_link($this->input->post('station_logbook_id'), $this->input->post('SelectedStationLocation')); - } - } else { - $this->logbooks_model->edit(); - } - - redirect('logbooks/edit/'.$this->input->post('station_logbook_id')); - } - } - - public function set_active($id) { - $this->load->model('logbooks_model'); - $this->logbooks_model->set_logbook_active($id); - $this->user_model->update_session($this->session->userdata('user_id')); - - redirect('logbooks'); - } - - public function delete($id) { - $this->load->model('logbooks_model'); - $this->logbooks_model->delete($id); - - redirect('logbooks'); - } - - public function delete_relationship($logbook_id, $station_id) { - $this->load->model('logbooks_model'); - $this->logbooks_model->delete_relationship($logbook_id, $station_id); - - redirect('logbooks/edit/'.$logbook_id); - } - -} \ No newline at end of file diff --git a/application/controllers/Lookup.php b/application/controllers/Lookup.php index f935cb6d..587fb7da 100644 --- a/application/controllers/Lookup.php +++ b/application/controllers/Lookup.php @@ -28,15 +28,12 @@ class Lookup extends CI_Controller { public function search() { $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)."'"; + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $this->load->model('lookup_model'); - $this->load->model('bands'); - $data['bands'] = $this->bands->get_worked_bands(); + $data['bands'] = $this->lookup_model->get_Worked_Bands($station_id); $data['type'] = xss_clean($this->input->post('type')); $data['dxcc'] = xss_clean($this->input->post('dxcc')); @@ -46,7 +43,7 @@ class Lookup extends CI_Controller { $data['iota'] = xss_clean($this->input->post('iota')); $data['cqz'] = xss_clean($this->input->post('cqz')); $data['wwff'] = xss_clean($this->input->post('wwff')); - $data['location_list'] = $location_list; + $data['station_id'] = $station_id; $data['result'] = $this->lookup_model->getSearchResult($data); diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 5dc2328f..300870e9 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -466,7 +466,6 @@ class Lotw extends CI_Controller { $tableheaders .= "LoTW QSL Received"; $tableheaders .= "Date LoTW Confirmed"; $tableheaders .= "State"; - $tableheaders .= "Gridsquare"; $tableheaders .= "Log Status"; $tableheaders .= "LoTW Status"; $tableheaders .= ""; @@ -513,15 +512,8 @@ class Lotw extends CI_Controller { } else { $state = ""; } - // Present only if the QSLing station specified a single valid grid square value in its station location uploaded to LoTW. - if (isset($record['gridsquare'])) { - $qsl_gridsquare = $record['gridsquare']; - } else { - $qsl_gridsquare = ""; - } - - $lotw_status = $this->logbook_model->lotw_update($time_on, $record['call'], $record['band'], $qsl_date, $record['qsl_rcvd'], $state, $qsl_gridsquare); + $lotw_status = $this->logbook_model->lotw_update($time_on, $record['call'], $record['band'], $qsl_date, $record['qsl_rcvd'], $state); } @@ -533,7 +525,6 @@ class Lotw extends CI_Controller { $table .= "".$record['qsl_rcvd'].""; $table .= "".$qsl_date.""; $table .= "".$state.""; - $table .= "".$qsl_gridsquare.""; $table .= "QSO Record: ".$status.""; $table .= "LoTW Record: ".$lotw_status.""; $table .= ""; diff --git a/application/controllers/Map.php b/application/controllers/Map.php index bfb47767..4abd750c 100644 --- a/application/controllers/Map.php +++ b/application/controllers/Map.php @@ -13,7 +13,7 @@ class Map extends CI_Controller { $qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator')); $data['qra'] = "set"; $data['qra_lat'] = $qra_position[0]; - $data['qra_lng'] = $qra_position[1]; + $data['qra_lng'] = $qra_position[1]; } else { $data['qra'] = "none"; } @@ -34,14 +34,14 @@ class Map extends CI_Controller { function custom() { - $this->load->model('bands'); - //$this->load->model('modes'); + $this->load->model('dxcc'); + $this->load->model('modes'); - $data['worked_bands'] = $this->bands->get_worked_bands(); // Used in the view for band select - //$data['modes'] = $this->modes->active(); // Used in the view for mode select + $data['worked_bands'] = $this->dxcc->get_worked_bands(); // Used in the view for band select + $data['modes'] = $this->modes->active(); // Used in the view for mode 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 + 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 { @@ -61,20 +61,20 @@ class Map extends CI_Controller { $qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator')); $data['qra'] = "set"; $data['qra_lat'] = $qra_position[0]; - $data['qra_lng'] = $qra_position[1]; + $data['qra_lng'] = $qra_position[1]; } else { $data['qra'] = "none"; } - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $result = $CI->logbooks_model->logbook($this->session->userdata('active_station_logbook'))->result(); - $logbook_name = $result[0]->logbook_name; + $this->load->model('Stations'); + $station_id = $this->Stations->find_active(); + $station_data = $this->Stations->profile_clean($station_id); // load the view - $data['logbook_name'] = $logbook_name; + $data['station_profile'] = $station_data; $data['page_title'] = "Map QSOs"; + if ($this->input->post('from')) { $from = $this->input->post('from'); $from = DateTime::createFromFormat('m/d/Y g:i A', $from); @@ -93,6 +93,7 @@ class Map extends CI_Controller { $footer_data['date_to'] = $temp_to->format('Y-m-d H:i:00'); } + $this->load->view('interface_assets/header', $data); $this->load->view('map/custom_date'); $this->load->view('interface_assets/footer',$footer_data); @@ -104,7 +105,7 @@ class Map extends CI_Controller { $end_date = $this->uri->segment(4); $band = $this->uri->segment(5); $this->load->model('logbook_model'); - + $this->load->library('qra'); $qsos = $this->logbook_model->map_custom_qsos(rawurldecode($start_date), rawurldecode($end_date), $band); @@ -119,7 +120,7 @@ class Map extends CI_Controller { echo ","; } - if($row->COL_SAT_NAME != null) { + if($row->COL_SAT_NAME != null) { echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; } else { echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; @@ -133,7 +134,7 @@ class Map extends CI_Controller { FROM dxcc_entities WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) ) ORDER BY LENGTH( prefix ) DESC - LIMIT 1 + LIMIT 1 '); foreach ($query->result() as $dxcc) { @@ -153,12 +154,12 @@ class Map extends CI_Controller { function map_data() { $this->load->model('logbook_model'); - + $this->load->library('qra'); //echo date('Y-m-d') $raw = strtotime('Monday last week'); - + $mon = date('Y-m-d', $raw); $sun = date('Y-m-d', strtotime('Monday next week')); @@ -174,7 +175,7 @@ class Map extends CI_Controller { echo ","; } - if($row->COL_SAT_NAME != null) { + if($row->COL_SAT_NAME != null) { echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; } else { echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; @@ -188,7 +189,7 @@ class Map extends CI_Controller { FROM dxcc_entities WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) ) ORDER BY LENGTH( prefix ) DESC - LIMIT 1 + LIMIT 1 '); foreach ($query->result() as $dxcc) { @@ -205,4 +206,4 @@ class Map extends CI_Controller { echo "}"; } -} +} \ No newline at end of file diff --git a/application/controllers/Options.php b/application/controllers/Options.php index be8b83ef..45c7478a 100644 --- a/application/controllers/Options.php +++ b/application/controllers/Options.php @@ -14,8 +14,8 @@ class Options extends CI_Controller { $this->load->model('user_model'); if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } } - - + + // Default /options view just gives some text to explain the options area function index() { @@ -23,14 +23,14 @@ class Options extends CI_Controller { //echo $this->config->item('option_theme'); //echo $this->optionslib->get_option('theme'); - + $data['page_title'] = "Cloudlog Options"; $this->load->view('interface_assets/header', $data); $this->load->view('options/index'); $this->load->view('interface_assets/footer'); } - + // function used to display the /appearance url function appearance() { @@ -41,10 +41,6 @@ class Options extends CI_Controller { $data['page_title'] = "Cloudlog Options"; $data['sub_heading'] = "Appearance"; - $this->load->model('Themes_model'); - - $data['themes'] = $this->Themes_model->getThemes(); - $this->load->view('interface_assets/header', $data); $this->load->view('options/appearance'); $this->load->view('interface_assets/footer'); @@ -105,10 +101,10 @@ class Options extends CI_Controller { // function used to display the /radio url function radio() { - + $data['page_title'] = "Cloudlog Options"; $data['sub_heading'] = "Radio Settings"; - + $this->load->view('interface_assets/header', $data); $this->load->view('options/radios'); $this->load->view('interface_assets/footer'); diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index c852bd14..245fc1a9 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -30,7 +30,7 @@ class QSO extends CI_Controller { $data['active_station_profile'] = $this->stations->find_active(); $data['notice'] = false; - $data['stations'] = $this->stations->all_of_user(); + $data['stations'] = $this->stations->all(); $data['radios'] = $this->cat->radios(); $data['query'] = $this->logbook_model->last_custom('5'); $data['dxcc'] = $this->logbook_model->fetchDxcc(); diff --git a/application/controllers/Radio.php b/application/controllers/Radio.php index 2a2a5709..d8c95838 100755 --- a/application/controllers/Radio.php +++ b/application/controllers/Radio.php @@ -7,21 +7,21 @@ // Check Auth $this->load->model('user_model'); if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - + // load the view - $data['page_title'] = "Hardware Interfaces"; + $data['page_title'] = "Radio Interface"; $this->load->view('interface_assets/header', $data); $this->load->view('radio/index'); $this->load->view('interface_assets/footer'); } - + function status() { - + // Check Auth $this->load->model('user_model'); if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - + $this->load->model('cat'); $query = $this->cat->status(); if ($query->num_rows() > 0) @@ -58,14 +58,14 @@ echo "No CAT Interfaced radios found."; echo ""; } - + } function json($id) { header('Content-Type: application/json'); - + $this->load->model('cat'); $query = $this->cat->radio_status($id); @@ -97,8 +97,8 @@ } // Get Satellite Mode - $uplink_mode = $this->get_mode_designator($row->uplink_freq); - $downlink_mode = $this->get_mode_designator($row->downlink_freq); + $uplink_mode = $this->get_mode_designator($row->uplink_freq); + $downlink_mode = $this->get_mode_designator($row->downlink_freq); if ($uplink_mode != "" && $downlink_mode != "") { $sat_mode = $uplink_mode."/".$downlink_mode; @@ -119,7 +119,7 @@ $sat_mode = ""; } - // Calculate how old the data is in minutes + // Calculate how old the data is in minutes $datetime1 = new DateTime(); // Today's Date/Time $datetime2 = new DateTime($row->newtime); $interval = $datetime1->diff($datetime2); @@ -127,7 +127,7 @@ $minutes = $interval->days * 24 * 60; $minutes += $interval->h * 60; $minutes += $interval->i; - + $updated_at = $minutes; // Return Json data @@ -143,7 +143,7 @@ } } - + function get_mode_designator($frequency) { if ($frequency > 21000000 && $frequency < 22000000) @@ -176,13 +176,13 @@ // Check Auth $this->load->model('user_model'); if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - + $this->load->model('cat'); - + $this->cat->delete($id); - + $this->session->set_flashdata('message', 'Radio Profile Deleted'); - + redirect('radio'); } diff --git a/application/controllers/Station.php b/application/controllers/Station.php index 35ce839a..e59b44dd 100644 --- a/application/controllers/Station.php +++ b/application/controllers/Station.php @@ -97,17 +97,6 @@ class Station extends CI_Controller { } } - // This function allows a user to claim ownership of a station location - function claim_user($id) { - // $id is the profile id - $this->load->model('stations'); - $this->stations->claim_user($id); - - echo $this->session->userdata('user_id'); - - redirect('station'); - } - function reassign_profile($id) { // $id is the profile that needs reassigned to QSOs $this->load->model('stations'); diff --git a/application/controllers/Themes.php b/application/controllers/Themes.php deleted file mode 100644 index 2420e689..00000000 --- a/application/controllers/Themes.php +++ /dev/null @@ -1,89 +0,0 @@ -lang->load('contesting'); - - $this->load->model('user_model'); - if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - } - - public function index() - { - $this->load->model('Themes_model'); - - $data['themes'] = $this->Themes_model->getThemes(); - - // Render Page - $data['page_title'] = "Themes"; - $this->load->view('interface_assets/header', $data); - $this->load->view('themes/index.php'); - $this->load->view('interface_assets/footer'); - } - - public function add() - { - $this->load->model('Themes_model'); - $this->load->library('form_validation'); - - $this->form_validation->set_rules('name', 'Theme Name', 'required'); - $this->form_validation->set_rules('foldername', 'Folder Name', 'required'); - - if ($this->form_validation->run() == FALSE) - { - $data['page_title'] = "Create Theme"; - $this->load->view('themes/add', $data); - } - else - { - $this->Themes_model->add(); - } - } - - public function edit($id) - { - $this->load->library('form_validation'); - - $this->load->model('Themes_model'); - - $item_id_clean = $this->security->xss_clean($id); - - $data['theme'] = $this->Themes_model->theme($item_id_clean); - - $data['page_title'] = "Edit Theme"; - - $this->form_validation->set_rules('name', 'Theme Name', 'required'); - $this->form_validation->set_rules('foldername', 'Folder Name', 'required'); - - if ($this->form_validation->run() == FALSE) - { - $this->load->view('interface_assets/header', $data); - $this->load->view('themes/edit'); - $this->load->view('interface_assets/footer'); - } - else - { - $this->Themes_model->edit($item_id_clean); - - $data['notice'] = "Theme ".$this->security->xss_clean($this->input->post('name', true))." Updated"; - - redirect('themes'); - } - } - - public function delete() { - $id = $this->input->post('id'); - $this->load->model('Themes_model'); - $this->Themes_model->delete($id); - } -} diff --git a/application/controllers/Timeline.php b/application/controllers/Timeline.php index 87321556..879df97b 100644 --- a/application/controllers/Timeline.php +++ b/application/controllers/Timeline.php @@ -40,12 +40,11 @@ class Timeline extends CI_Controller { } $this->load->model('modes'); - $this->load->model('bands'); $data['modes'] = $this->modes->active(); $data['timeline_array'] = $this->Timeline_model->get_timeline($band, $mode, $award); - $data['worked_bands'] = $this->bands->get_worked_bands(); + $data['worked_bands'] = $this->Timeline_model->get_worked_bands(); $data['bandselect'] = $band; $data['modeselect'] = $mode; diff --git a/application/controllers/Timeplotter.php b/application/controllers/Timeplotter.php index 42d3aa84..0857e512 100644 --- a/application/controllers/Timeplotter.php +++ b/application/controllers/Timeplotter.php @@ -16,9 +16,9 @@ class Timeplotter extends CI_Controller { // Render Page $data['page_title'] = "Timeplotter"; - $this->load->model('bands'); + $this->load->model('Timeplotter_model'); - $data['worked_bands'] = $this->bands->get_worked_bands(); + $data['worked_bands'] = $this->Timeplotter_model->get_worked_bands(); $this->load->model('dxcc'); $data['dxcc_list'] = $this->dxcc->list(); diff --git a/application/controllers/Update.php b/application/controllers/Update.php index 06ba2aae..f77f22d8 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -17,19 +17,6 @@ class Update extends CI_Controller { } - /* - * Create a path to a file in the updates folder, respecting the datadir - * configuration option. - */ - private function make_update_path($path) { - $path = "updates/" . $path; - $datadir = $this->config->item('datadir'); - if(!$datadir) { - return $path; - } - return $datadir . "/" . $path; - } - /* * Load the dxcc entities */ @@ -38,7 +25,7 @@ class Update extends CI_Controller { $this->load->model('dxcc_entities'); // Load the cty file - $xml_data = simplexml_load_file($this->make_update_path("cty.xml")); + $xml_data = simplexml_load_file("updates/cty.xml"); //$xml_data->entities->entity->count(); @@ -87,7 +74,7 @@ class Update extends CI_Controller { // Load Database connectors $this->load->model('dxcc_exceptions'); // Load the cty file - $xml_data = simplexml_load_file($this->make_update_path("cty.xml")); + $xml_data = simplexml_load_file("updates/cty.xml"); $count = 0; foreach ($xml_data->exceptions->exception as $record) { @@ -127,7 +114,7 @@ class Update extends CI_Controller { // Load Database connectors $this->load->model('dxcc_prefixes'); // Load the cty file - $xml_data = simplexml_load_file($this->make_update_path("cty.xml")); + $xml_data = simplexml_load_file("updates/cty.xml"); $count = 0; foreach ($xml_data->prefixes->prefix as $record) { @@ -182,8 +169,8 @@ class Update extends CI_Controller { $data .= gzgetc($gz); } gzclose($gz); - - file_put_contents($this->make_update_path("cty.xml"), $data); + + file_put_contents('./updates/cty.xml', $data); // Clear the tables, ready for new data $this->db->empty_table("dxcc_entities"); @@ -216,7 +203,7 @@ class Update extends CI_Controller { $html = $done."....
"; } - file_put_contents($this->make_update_path("status.html"), $html); + file_put_contents('./updates/status.html', $html); } @@ -244,7 +231,7 @@ class Update extends CI_Controller { } public function update_clublog_scp() { - $strFile = $this->make_update_path("clublog_scp.txt"); + $strFile = "./updates/clublog_scp.txt"; $url = "https://cdn.clublog.org/clublog.scp.gz"; set_time_limit(300); $this->update_status("Downloading Club Log SCP file"); diff --git a/application/controllers/User.php b/application/controllers/User.php index 7652f6c1..976ea38e 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -42,9 +42,6 @@ class User extends CI_Controller { $this->form_validation->set_rules('user_locator', 'Locator', 'required'); $this->form_validation->set_rules('user_timezone', 'Timezone', 'required'); - // Get themes list - $data['themes'] = $this->user_model->getThemes(); - // Get timezones $data['timezones'] = $this->user_model->timezones(); @@ -161,9 +158,6 @@ class User extends CI_Controller { $this->form_validation->set_rules('user_locator', 'Locator', 'required|xss_clean'); $this->form_validation->set_rules('user_timezone', 'Timezone', 'required'); - // Get themes list - $data['themes'] = $this->user_model->getThemes(); - // Get timezones $data['timezones'] = $this->user_model->timezones(); @@ -459,7 +453,7 @@ class User extends CI_Controller { if ($this->form_validation->run() == FALSE) { $data['page_title'] = "Login"; - $this->load->view('interface_assets/mini_header', $data); + $this->load->view('interface_assets/header', $data); $this->load->view('user/login'); $this->load->view('interface_assets/footer'); diff --git a/application/migrations/071_add_queries_table.php b/application/migrations/071_add_queries_table.php index 7b439c83..a1f90889 100644 --- a/application/migrations/071_add_queries_table.php +++ b/application/migrations/071_add_queries_table.php @@ -9,6 +9,6 @@ class Migration_add_queries_table extends CI_Migration public function down() { - + $this->db->query(""); } } diff --git a/application/migrations/072_create_station_logbook_table.php b/application/migrations/072_create_station_logbook_table.php deleted file mode 100644 index 452ec50b..00000000 --- a/application/migrations/072_create_station_logbook_table.php +++ /dev/null @@ -1,54 +0,0 @@ -db->table_exists('station_logbooks')) { - $this->dbforge->add_field(array( - 'logbook_id' => array( - 'type' => 'BIGINT', - 'constraint' => 20, - 'unsigned' => TRUE, - 'auto_increment' => TRUE, - 'unique' => TRUE - ), - - 'user_id' => array( - 'type' => 'BIGINT', - 'constraint' => 20, - 'unsigned' => TRUE, - 'auto_increment' => FALSE - ), - - 'logbook_name' => array( - 'type' => 'VARCHAR', - 'constraint' => '191', - 'null' => TRUE - ), - - 'modified' => array( - 'type' => 'timestamp', - 'null' => TRUE, - ) - )); - - $this->dbforge->add_key('logbook_id', TRUE); - $this->dbforge->add_key('user_id', TRUE); - - $this->dbforge->create_table('station_logbooks'); - } - } - - public function down() - { - $this->dbforge->drop_table('station_logbooks'); - } -} \ No newline at end of file diff --git a/application/migrations/073_create_station_logbook_relationship_table.php b/application/migrations/073_create_station_logbook_relationship_table.php deleted file mode 100644 index 8f487af0..00000000 --- a/application/migrations/073_create_station_logbook_relationship_table.php +++ /dev/null @@ -1,56 +0,0 @@ -db->table_exists('station_logbooks_relationship')) { - $this->dbforge->add_field(array( - 'logbook_relation_id' => array( - 'type' => 'BIGINT', - 'constraint' => 20, - 'unsigned' => TRUE, - 'auto_increment' => TRUE, - 'unique' => TRUE - ), - - 'station_logbook_id' => array( - 'type' => 'BIGINT', - 'constraint' => 20, - 'unsigned' => TRUE, - 'auto_increment' => FALSE - ), - - 'station_location_id' => array( - 'type' => 'BIGINT', - 'constraint' => 20, - 'unsigned' => TRUE, - 'auto_increment' => FALSE - ), - - 'modified' => array( - 'type' => 'timestamp', - 'null' => TRUE, - ) - )); - - $this->dbforge->add_key('logbook_relation_id', TRUE); - $this->dbforge->add_key('station_logbook_id', TRUE); - $this->dbforge->add_key('station_location_id', TRUE); - - $this->dbforge->create_table('station_logbooks_relationship'); - } - } - - public function down() - { - $this->dbforge->drop_table('station_logbooks_relationship'); - } -} \ No newline at end of file diff --git a/application/migrations/074_add_userid_to_station_profiles.php b/application/migrations/074_add_userid_to_station_profiles.php deleted file mode 100644 index 7a2c5161..00000000 --- a/application/migrations/074_add_userid_to_station_profiles.php +++ /dev/null @@ -1,22 +0,0 @@ -db->field_exists('user_id', 'station_profile')) { - $this->dbforge->add_column('station_profile', $fields); - } - } - - public function down() - { - $this->dbforge->drop_column('station_profile', 'user_id'); - } -} \ No newline at end of file diff --git a/application/migrations/075_add_active_station_logbook_to_user_table.php b/application/migrations/075_add_active_station_logbook_to_user_table.php deleted file mode 100644 index 89967405..00000000 --- a/application/migrations/075_add_active_station_logbook_to_user_table.php +++ /dev/null @@ -1,27 +0,0 @@ -db->field_exists('active_station_logbook', 'users')) { - $this->dbforge->add_column('users', $fields); - } - } - - public function down() - { - $this->dbforge->drop_column('users', 'active_station_logbook'); - } -} diff --git a/application/migrations/076_theme_table.php b/application/migrations/076_theme_table.php deleted file mode 100644 index 15ae9047..00000000 --- a/application/migrations/076_theme_table.php +++ /dev/null @@ -1,22 +0,0 @@ -db->table_exists('themes')) { - $this->db->query("create table themes (id integer not null auto_increment, name varchar(256) not null, foldername varchar(256) not null, primary key (id)) ENGINE=myisam DEFAULT CHARSET=utf8;"); - $this->db->query("INSERT INTO themes (name, foldername) values ('Blue','blue');"); - $this->db->query("INSERT INTO themes (name, foldername) values ('Cosmo','cosmo');"); - $this->db->query("INSERT INTO themes (name, foldername) values ('Cyborg (Dark)','cyborg');"); - $this->db->query("INSERT INTO themes (name, foldername) values ('Darkly (Dark)','darkly');"); - $this->db->query("INSERT INTO themes (name, foldername) values ('Default','default');"); - $this->db->query("INSERT INTO themes (name, foldername) values ('Superhero (Dark)','superhero');"); - } - } - - public function down(){ - - } -} diff --git a/application/migrations/077_add_userid_to_notes.php b/application/migrations/077_add_userid_to_notes.php deleted file mode 100644 index e15f3043..00000000 --- a/application/migrations/077_add_userid_to_notes.php +++ /dev/null @@ -1,21 +0,0 @@ -db->field_exists('user_id', 'notes')) { - $this->dbforge->add_column('notes', $fields); - } - } - - public function down() - { - $this->dbforge->drop_column('notes', 'user_id'); - } -} diff --git a/application/migrations/078_add_userid_to_hardware.php b/application/migrations/078_add_userid_to_hardware.php deleted file mode 100644 index 9edb4fd4..00000000 --- a/application/migrations/078_add_userid_to_hardware.php +++ /dev/null @@ -1,22 +0,0 @@ -db->field_exists('user_id', 'cat')) { - $this->dbforge->add_column('cat', $fields); - } - } - - public function down() - { - $this->dbforge->drop_column('cat', 'user_id'); - } -} diff --git a/application/migrations/079_add_userid_to_api.php b/application/migrations/079_add_userid_to_api.php deleted file mode 100644 index 0947b921..00000000 --- a/application/migrations/079_add_userid_to_api.php +++ /dev/null @@ -1,21 +0,0 @@ -db->field_exists('user_id', 'api')) { - $this->dbforge->add_column('api', $fields); - } - } - - public function down() - { - $this->dbforge->drop_column('api', 'user_id'); - } -} diff --git a/application/models/Accumulate_model.php b/application/models/Accumulate_model.php index bf959cf6..72c1b132 100644 --- a/application/models/Accumulate_model.php +++ b/application/models/Accumulate_model.php @@ -3,35 +3,39 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class Accumulate_model extends CI_Model { - function get_accumulated_data($band, $award, $mode, $period) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + function __construct() + { + // Call the Model constructor + parent::__construct(); + } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + function get_accumulated_data($band, $award, $mode, $period) { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); switch ($award) { - case 'dxcc': $result = $this->get_accumulated_dxcc($band, $mode, $period, $location_list); break; - case 'was': $result = $this->get_accumulated_was($band, $mode, $period, $location_list); break; - case 'iota': $result = $this->get_accumulated_iota($band, $mode, $period, $location_list); break; - case 'waz': $result = $this->get_accumulated_waz($band, $mode, $period, $location_list); break; + case 'dxcc': $result = $this->get_accumulated_dxcc($band, $mode, $period, $station_id); break; + case 'was': $result = $this->get_accumulated_was($band, $mode, $period, $station_id); break; + case 'iota': $result = $this->get_accumulated_iota($band, $mode, $period, $station_id); break; + case 'waz': $result = $this->get_accumulated_waz($band, $mode, $period, $station_id); break; } return $result; } - function get_accumulated_dxcc($band, $mode, $period, $location_list) { + function get_accumulated_dxcc($band, $mode, $period, $station_id) { if ($period == "year") { $sql = "SELECT year(col_time_on) as year, (select count(distinct b.col_dxcc) from " . $this->config->item('table_name') . - " as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")"; + " as b where year(col_time_on) <= year and b.station_id = ". $station_id; } else if ($period == "month") { $sql = "SELECT date_format(col_time_on, '%Y%m') as year, (select count(distinct b.col_dxcc) from " . $this->config->item('table_name') . - " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")"; + " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id; } if ($band != 'All') { @@ -44,11 +48,11 @@ class Accumulate_model extends CI_Model } if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + $sql .= " and col_mode ='" . $mode . "'"; } - $sql .=" and b.col_dxcc > 0) total from " . $this->config->item('table_name') . " as a - where a.station_id in (". $location_list . ")"; + $sql .=") total from " . $this->config->item('table_name') . " as a + where a.station_id = ". $station_id; if ($band != 'All') { if ($band == 'SAT') { @@ -60,17 +64,15 @@ class Accumulate_model extends CI_Model } if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + $sql .= " and col_mode ='" . $mode . "'"; } - $sql .= " and col_dxcc > 0"; - if ($period == "year") { - $sql .= " group by year(a.col_time_on) + $sql .= " group by year(a.col_time_on) order by year(a.col_time_on)"; } else if ($period == "month") { - $sql .= " group by date_format(a.col_time_on, '%Y%m') + $sql .= " group by date_format(a.col_time_on, '%Y%m') order by date_format(a.col_time_on, '%Y%m')"; } @@ -79,18 +81,18 @@ class Accumulate_model extends CI_Model return $query->result(); } - function get_accumulated_was($band, $mode, $period, $location_list) { + function get_accumulated_was($band, $mode, $period, $station_id) { if ($period == "year") { $sql = "SELECT year(col_time_on) as year, (select count(distinct b.col_state) from " . $this->config->item('table_name') . - " as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")"; + " as b where year(col_time_on) <= year and b.station_id = ". $station_id; } else if ($period == "month") { $sql = "SELECT date_format(col_time_on, '%Y%m') as year, (select count(distinct b.col_state) from " . $this->config->item('table_name') . - " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")"; + " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id; } if ($band != 'All') { @@ -103,14 +105,14 @@ class Accumulate_model extends CI_Model } if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + $sql .= " and col_mode ='" . $mode . "'"; } $sql .= " and COL_DXCC in ('291', '6', '110')"; $sql .= " and COL_STATE in ('AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY')"; $sql .=") total from " . $this->config->item('table_name') . " as a - where a.station_id in (". $location_list . ")"; + where a.station_id = ". $station_id; if ($band != 'All') { if ($band == 'SAT') { @@ -122,18 +124,18 @@ class Accumulate_model extends CI_Model } if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + $sql .= " and col_mode ='" . $mode . "'"; } $sql .= " and COL_DXCC in ('291', '6', '110')"; $sql .= " and COL_STATE in ('AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY')"; if ($period == "year") { - $sql .= " group by year(a.col_time_on) + $sql .= " group by year(a.col_time_on) order by year(a.col_time_on)"; } else if ($period == "month") { - $sql .= " group by date_format(a.col_time_on, '%Y%m') + $sql .= " group by date_format(a.col_time_on, '%Y%m') order by date_format(a.col_time_on, '%Y%m')"; } @@ -142,18 +144,18 @@ class Accumulate_model extends CI_Model return $query->result(); } - function get_accumulated_iota($band, $mode, $period, $location_list) { + function get_accumulated_iota($band, $mode, $period, $station_id) { if ($period == "year") { $sql = "SELECT year(col_time_on) as year, (select count(distinct b.col_iota) from " . $this->config->item('table_name') . - " as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")"; + " as b where year(col_time_on) <= year and b.station_id = ". $station_id; } else if ($period == "month") { $sql = "SELECT date_format(col_time_on, '%Y%m') as year, (select count(distinct b.col_iota) from " . $this->config->item('table_name') . - " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")"; + " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id; } if ($band != 'All') { @@ -166,11 +168,11 @@ class Accumulate_model extends CI_Model } if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + $sql .= " and col_mode ='" . $mode . "'"; } $sql .=") total from " . $this->config->item('table_name') . " as a - where a.station_id in (". $location_list . ")"; + where a.station_id = ". $station_id; if ($band != 'All') { if ($band == 'SAT') { @@ -182,15 +184,15 @@ class Accumulate_model extends CI_Model } if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + $sql .= " and col_mode ='" . $mode . "'"; } if ($period == "year") { - $sql .= " group by year(a.col_time_on) + $sql .= " group by year(a.col_time_on) order by year(a.col_time_on)"; } else if ($period == "month") { - $sql .= " group by date_format(a.col_time_on, '%Y%m') + $sql .= " group by date_format(a.col_time_on, '%Y%m') order by date_format(a.col_time_on, '%Y%m')"; } @@ -199,18 +201,18 @@ class Accumulate_model extends CI_Model return $query->result(); } - function get_accumulated_waz($band, $mode, $period, $location_list) { + function get_accumulated_waz($band, $mode, $period, $station_id) { if ($period == "year") { $sql = "SELECT year(col_time_on) as year, (select count(distinct b.col_cqz) from " . $this->config->item('table_name') . - " as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")"; + " as b where year(col_time_on) <= year and b.station_id = ". $station_id; } else if ($period == "month") { $sql = "SELECT date_format(col_time_on, '%Y%m') as year, (select count(distinct b.col_cqz) from " . $this->config->item('table_name') . - " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")"; + " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id = ". $station_id; } if ($band != 'All') { @@ -223,11 +225,11 @@ class Accumulate_model extends CI_Model } if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + $sql .= " and col_mode ='" . $mode . "'"; } $sql .=") total from " . $this->config->item('table_name') . " as a - where a.station_id in (". $location_list . ")"; + where a.station_id = ". $station_id; if ($band != 'All') { if ($band == 'SAT') { @@ -239,15 +241,15 @@ class Accumulate_model extends CI_Model } if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; + $sql .= " and col_mode ='" . $mode . "'"; } if ($period == "year") { - $sql .= " group by year(a.col_time_on) + $sql .= " group by year(a.col_time_on) order by year(a.col_time_on)"; } else if ($period == "month") { - $sql .= " group by date_format(a.col_time_on, '%Y%m') + $sql .= " group by date_format(a.col_time_on, '%Y%m') order by date_format(a.col_time_on, '%Y%m')"; } @@ -255,4 +257,58 @@ class Accumulate_model extends CI_Model return $query->result(); } + + function get_worked_bands() { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $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; + } + + public $bandslots = array("160m" => 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, + ); } \ No newline at end of file diff --git a/application/models/Adif_data.php b/application/models/Adif_data.php index 40bfacef..deaa9ea4 100644 --- a/application/models/Adif_data.php +++ b/application/models/Adif_data.php @@ -2,6 +2,12 @@ class adif_data extends CI_Model { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + function export_all() { $this->load->model('stations'); $active_station_id = $this->stations->find_active(); @@ -122,13 +128,12 @@ class adif_data extends CI_Model { } function sig_all($type) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $this->load->model('stations'); + $active_station_id = $this->stations->find_active(); $this->db->select(''.$this->config->item('table_name').'.*, station_profile.*'); $this->db->from($this->config->item('table_name')); - $this->db->where_in($this->config->item('table_name').'.station_id', $logbooks_locations_array); + $this->db->where($this->config->item('table_name').'.station_id', $active_station_id); $this->db->where($this->config->item('table_name').'.COL_SIG', $type); $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); diff --git a/application/models/Api_model.php b/application/models/Api_model.php index 747e1d47..f5c9e417 100644 --- a/application/models/Api_model.php +++ b/application/models/Api_model.php @@ -8,39 +8,37 @@ class API_Model extends CI_Model { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + // GET API Keys function keys() { - $this->db->where('user_id', $this->session->userdata('user_id')); return $this->db->get('api'); } function key_description($key) { - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('key', $key); + $this->db->where('key', $key); $query = $this->db->get('api'); return $query->result_array()[0]; } - function key_userid($key) { - $this->db->where('key', $key); - $query = $this->db->get('api'); - - return $query->result_array()[0]['user_id']; - } function update_key_description($key, $description) { - + $data = array( 'description' => xss_clean($description), ); $this->db->where('key', xss_clean($key)); - $this->db->where('user_id', $this->session->userdata('user_id')); $this->db->update('api', xss_clean($data)); } + function country_worked($dxcc_num, $band, $mode){ if($band == "all") { @@ -95,38 +93,35 @@ class API_Model extends CI_Model { function delete_key($key) { - $this->db->where('user_id', $this->session->userdata('user_id')); $this->db->where('key', xss_clean($key)); $this->db->delete('api'); } // Generate API Key function generate_key($rights) { - + // Expects either rw (Read, Write) or r (read only) // Generate Unique Key $data['key'] = uniqid("cl"); $data['rights'] = $rights; - + // Set API key to active $data['status'] = "active"; - $data['user_id'] = $this->session->userdata('user_id'); - - $this->db->insert('api', $data); + $this->db->insert('api', $data); } function access($key) { - + // No key = no access, mate if(!$key) { return $status = "No Key Found"; } // Check that the key is valid - $this->db->where('key', $key); + $this->db->where('key', $key); $query = $this->db->get('api'); if ($query->num_rows() > 0) @@ -339,7 +334,7 @@ class API_Model extends CI_Model { $s[12] = '/~([a-zA-Z0-9\-\_\*\(\)\=\~]+)/'; // *, which becomes '%' $s[13] = '/\*/'; - + $r[0] = ' AND '; $r[1] = ' OR '; $r[2] = ' < '; diff --git a/application/models/Bands.php b/application/models/Bands.php deleted file mode 100644 index a30c34b8..00000000 --- a/application/models/Bands.php +++ /dev/null @@ -1,140 +0,0 @@ -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 get_worked_bands() { - $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 in (" . $location_list . ") 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 in (" . $location_list . ") 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_worked_bands_distances() { - $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 - $sql = "SELECT distinct LOWER(COL_BAND) as COL_BAND FROM ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ")"; - - $data = $this->db->query($sql); - $worked_slots = array(); - foreach($data->result() as $row){ - array_push($worked_slots, $row->COL_BAND); - } - - // 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_worked_sats() { - $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 sats from database - $sql = "SELECT distinct col_sat_name FROM ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ") and coalesce(col_sat_name, '') <> '' ORDER BY col_sat_name"; - - $data = $this->db->query($sql); - - $worked_sats = array(); - foreach($data->result() as $row){ - array_push($worked_sats, $row->col_sat_name); - } - - return $worked_sats; - } - - function get_worked_bands_dok() { - $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 in (" . $location_list . ") AND COL_DARC_DOK IS NOT NULL AND COL_DARC_DOK != '' AND COL_DXCC = 230 " - ); - $worked_slots = array(); - foreach($data->result() as $row){ - array_push($worked_slots, $row->COL_BAND); - } - - - // 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; - } - -} - -?> \ No newline at end of file diff --git a/application/models/Cat.php b/application/models/Cat.php index bf68541d..2f92b788 100644 --- a/application/models/Cat.php +++ b/application/models/Cat.php @@ -2,12 +2,17 @@ class Cat extends CI_Model { - function update($result, $user_id) { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } - $this->db->where('radio', $result['radio']); - $this->db->where('user_id', $user_id); + function update($result) { + + $this->db->where('radio', $result['radio']); $query = $this->db->get('cat'); - + if ($query->num_rows() > 0) { if($result['radio'] == "SatPC32") { @@ -15,7 +20,7 @@ foreach ($query->result() as $row) { $radio_id = $row->id; - + $data = array( 'sat_name' => $result['sat_name'], 'downlink_freq' => $result['downlink_freq'], @@ -25,15 +30,14 @@ ); $this->db->where('id', $radio_id); - $this->db->where('user_id', $user_id); - $this->db->update('cat', $data); + $this->db->update('cat', $data); } } else { // Update the record foreach ($query->result() as $row) { $radio_id = $row->id; - + $data = array( 'frequency' => $result['frequency'], 'mode' => $result['mode'], @@ -41,13 +45,12 @@ ); $this->db->where('id', $radio_id); - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->update('cat', $data); + $this->db->update('cat', $data); } } } else { // Add a new record - + if($result['radio'] == "SatPC32") { $data = array( 'radio' => $result['radio'], @@ -58,7 +61,6 @@ 'uplink_freq' => $result['uplink_freq'], 'downlink_mode' => $result['downlink_mode'], 'uplink_mode' => $result['uplink_mode'], - 'user_id' => $user_id, ); } else { $data = array( @@ -66,25 +68,23 @@ 'frequency' => $result['frequency'], 'mode' => $result['mode'], 'timestamp' => $result['timestamp'], - 'user_id' => $user_id, ); } - $this->db->insert('cat', $data); + $this->db->insert('cat', $data); } } - + + function status() { - //$this->db->where('radio', $result['radio']); - $this->db->where('user_id', $this->session->userdata('user_id')); + //$this->db->where('radio', $result['radio']); $query = $this->db->get('cat'); - + return $query; } function recent_status() { - $this->db->where('user_id', $this->session->userdata('user_id')); $this->db->where("timestamp > date_sub(now(), interval 15 minute)", NULL, FALSE); $query = $this->db->get('cat'); @@ -94,23 +94,27 @@ /* Return list of radios */ function radios() { $this->db->select('id, radio'); - $this->db->where('user_id', $this->session->userdata('user_id')); $query = $this->db->get('cat'); - + return $query; } + function radio_status($id) { - $sql = 'SELECT *, CONVERT_TZ(`timestamp`, @@session.time_zone, \'+00:00\' ) as newtime FROM `cat` WHERE id = ' . $id . ' and user_id =' . $this->session->userdata('user_id'); - return $this->db->query($sql); + + return $this->db->query('SELECT *, CONVERT_TZ(`timestamp`, @@session.time_zone, \'+00:00\' ) as newtime FROM `cat` WHERE id = '.$id.' '); + } + function delete($id) { $this->db->where('id', $id); - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->delete('cat'); - + $this->db->delete('cat'); + return true; } + + + } ?> diff --git a/application/models/Clublog_model.php b/application/models/Clublog_model.php index f6c38688..acd2ee6c 100644 --- a/application/models/Clublog_model.php +++ b/application/models/Clublog_model.php @@ -2,6 +2,11 @@ class Clublog_model extends CI_Model { + function __construct() + { + parent::__construct(); + } + function get_clublog_auth_info($username) { $this->db->select('user_name, user_clublog_name, user_clublog_password'); $this->db->where('user_name', $username); diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php index 79918db1..2486b7bd 100644 --- a/application/models/Contesting_model.php +++ b/application/models/Contesting_model.php @@ -1,5 +1,11 @@ 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)."'"; + $station_id = $this->get_station_id(); $sql = "select count(distinct COL_CNTY) countycountworked, coalesce(x.countycountconfirmed, 0) countycountconfirmed, thcv.COL_STATE from " . $this->config->item('table_name') . " thcv left outer join ( select count(distinct COL_CNTY) countycountconfirmed, COL_STATE from " . $this->config->item('table_name') . - " where station_id in (" . $location_list . ")" . + " where station_id =" . $station_id . " and COL_DXCC in ('291', '6', '110') and coalesce(COL_CNTY, '') <> '' and COL_BAND != 'SAT' @@ -42,7 +43,7 @@ class Counties extends CI_Model group by COL_STATE order by COL_STATE ) x on thcv.COL_STATE = x.COL_STATE - where station_id in (" . $location_list . ")" . + where station_id =" . $station_id . " and COL_DXCC in ('291', '6', '110') and coalesce(COL_CNTY, '') <> '' and COL_BAND != 'SAT' @@ -53,6 +54,12 @@ class Counties extends CI_Model return $query->result_array(); } + function get_station_id() { + $CI =& get_instance(); + $CI->load->model('Stations'); + return $CI->Stations->find_active(); + } + /* * Makes a list of all counties in given state */ @@ -71,15 +78,11 @@ class Counties extends CI_Model } function get_counties($state, $confirmationtype) { - $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)."'"; + $station_id = $this->get_station_id(); $sql = "select distinct COL_CNTY, COL_STATE from " . $this->config->item('table_name') . " thcv - where station_id in (" . $location_list . ")" . + where station_id =" . $station_id . " and COL_DXCC in ('291', '6', '110') and coalesce(COL_CNTY, '') <> '' and COL_BAND != 'SAT'"; diff --git a/application/models/Cq.php b/application/models/Cq.php index 6ebdb2b8..c22735a0 100644 --- a/application/models/Cq.php +++ b/application/models/Cq.php @@ -2,6 +2,11 @@ class CQ extends CI_Model{ + function __construct(){ + // Call the Model constructor + parent::__construct(); + } + function get_zones(){ $CI =& get_instance(); $CI->load->model('Stations'); @@ -17,7 +22,59 @@ class CQ extends CI_Model{ return $data->result(); } - function get_cq_array($bands, $postdata, $location_list) { + public $bandslots = array("160m" => 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 get_worked_bands($station_id) + { + // 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_cq_array($bands, $postdata, $station_id) { $cqZ = array(); // Used for keeping track of which states that are not worked for ($i = 1; $i <= 40; $i++) { @@ -30,14 +87,14 @@ class CQ extends CI_Model{ } if ($postdata['worked'] != NULL) { - $cqBand = $this->getCQWorked($location_list, $band, $postdata); + $cqBand = $this->getCQWorked($station_id, $band, $postdata); foreach ($cqBand as $line) { $bandCq[$line->col_cqz][$band] = '

col_cqz) . '","' . $band . '","'. $postdata['mode'] . '","CQZone")\'>W
'; $cqZ[$line->col_cqz]['count']++; } } if ($postdata['confirmed'] != NULL) { - $cqBand = $this->getCQConfirmed($location_list, $band, $postdata); + $cqBand = $this->getCQConfirmed($station_id, $band, $postdata); foreach ($cqBand as $line) { $bandCq[$line->col_cqz][$band] = '
col_cqz) . '","' . $band . '","'. $postdata['mode'] . '","CQZone")\'>C
'; $cqZ[$line->col_cqz]['count']++; @@ -47,7 +104,7 @@ class CQ extends CI_Model{ // We want to remove the worked zones in the list, since we do not want to display them if ($postdata['worked'] == NULL) { - $cqBand = $this->getCQWorked($location_list, $postdata['band'], $postdata); + $cqBand = $this->getCQWorked($station_id, $postdata['band'], $postdata); foreach ($cqBand as $line) { unset($bandCq[$line->col_cqz]); } @@ -55,7 +112,7 @@ class CQ extends CI_Model{ // We want to remove the confirmed zones in the list, since we do not want to display them if ($postdata['confirmed'] == NULL) { - $cqBand = $this->getCQConfirmed($location_list, $postdata['band'], $postdata); + $cqBand = $this->getCQConfirmed($station_id, $postdata['band'], $postdata); foreach ($cqBand as $line) { unset($bandCq[$line->col_cqz]); } @@ -80,9 +137,9 @@ class CQ extends CI_Model{ * Function returns all worked, but not confirmed states * $postdata contains data from the form, in this case Lotw or QSL are used */ - function getCQWorked($location_list, $band, $postdata) { + function getCQWorked($station_id, $band, $postdata) { $sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv - where station_id in (" . $location_list . ") and col_cqz <> ''"; + where station_id = " . $station_id . " and col_cqz <> ''"; if ($postdata['mode'] != 'All') { $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; @@ -91,8 +148,8 @@ class CQ extends CI_Model{ $sql .= $this->addBandToQuery($band); $sql .= " and not exists (select 1 from " . $this->config->item('table_name') . - " where station_id in (" . $location_list . - ") and col_cqz = thcv.col_cqz and col_cqz <> '' "; + " where station_id = " . $station_id . + " and col_cqz = thcv.col_cqz and col_cqz <> '' "; if ($postdata['mode'] != 'All') { $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; @@ -113,9 +170,9 @@ class CQ extends CI_Model{ * Function returns all confirmed states on given band and on LoTW or QSL * $postdata contains data from the form, in this case Lotw or QSL are used */ - function getCQConfirmed($location_list, $band, $postdata) { + function getCQConfirmed($station_id, $band, $postdata) { $sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv - where station_id in (" . $location_list . ") and col_cqz <> ''"; + where station_id = " . $station_id . " and col_cqz <> ''"; if ($postdata['mode'] != 'All') { $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; @@ -162,16 +219,16 @@ class CQ extends CI_Model{ /* * Function gets worked and confirmed summary on each band on the active stationprofile */ - function get_cq_summary($bands, $location_list) { + function get_cq_summary($bands, $station_id) { foreach ($bands as $band) { - $worked = $this->getSummaryByBand($band, $location_list); - $confirmed = $this->getSummaryByBandConfirmed($band, $location_list); + $worked = $this->getSummaryByBand($band, $station_id); + $confirmed = $this->getSummaryByBandConfirmed($band, $station_id); $cqSummary['worked'][$band] = $worked[0]->count; $cqSummary['confirmed'][$band] = $confirmed[0]->count; } - $workedTotal = $this->getSummaryByBand('All', $location_list); - $confirmedTotal = $this->getSummaryByBandConfirmed('All', $location_list); + $workedTotal = $this->getSummaryByBand('All', $station_id); + $confirmedTotal = $this->getSummaryByBandConfirmed('All', $station_id); $cqSummary['worked']['Total'] = $workedTotal[0]->count; $cqSummary['confirmed']['Total'] = $confirmedTotal[0]->count; @@ -179,10 +236,10 @@ class CQ extends CI_Model{ return $cqSummary; } - function getSummaryByBand($band, $location_list) { + function getSummaryByBand($band, $station_id) { $sql = "SELECT count(distinct thcv.col_cqz) as count FROM " . $this->config->item('table_name') . " thcv"; - $sql .= " where station_id in (" . $location_list . ') and col_cqz > 0'; + $sql .= " where station_id = " . $station_id . ' and col_cqz > 0'; if ($band == 'SAT') { $sql .= " and thcv.col_prop_mode ='" . $band . "'"; @@ -198,10 +255,10 @@ class CQ extends CI_Model{ return $query->result(); } - function getSummaryByBandConfirmed($band, $location_list){ + function getSummaryByBandConfirmed($band, $station_id){ $sql = "SELECT count(distinct thcv.col_cqz) as count FROM " . $this->config->item('table_name') . " thcv"; - $sql .= " where station_id in (" . $location_list . ') and col_cqz > 0'; + $sql .= " where station_id = " . $station_id . ' and col_cqz > 0'; if ($band == 'SAT') { $sql .= " and thcv.col_prop_mode ='" . $band . "'"; diff --git a/application/models/Dayswithqso_model.php b/application/models/Dayswithqso_model.php index 75c2ac1e..1690a602 100644 --- a/application/models/Dayswithqso_model.php +++ b/application/models/Dayswithqso_model.php @@ -3,17 +3,21 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class Dayswithqso_model extends CI_Model { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + function getDaysWithQso() { - $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)."'"; + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $sql = "select year(COL_TIME_ON) Year, COUNT(DISTINCT TO_DAYS(COL_TIME_ON)) as Days from " .$this->config->item('table_name'). " thcv - where station_id in (" . $location_list . ") and COL_TIME_ON is not null group by year"; + where station_id = " . $station_id . " and COL_TIME_ON is not null group by year"; $query = $this->db->query($sql); @@ -146,19 +150,17 @@ class Dayswithqso_model extends CI_Model * Returns all distinct dates from db on active profile */ function getDates() { - $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)."'"; + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $sql = "select distinct cast(col_time_on as date) as date from " .$this->config->item('table_name'). " thcv - where station_id in (" . $location_list . ") order by date asc"; + where station_id = " . $station_id . " order by date asc"; $query = $this->db->query($sql); return $query->result(); } -} +} \ No newline at end of file diff --git a/application/models/Distances_model.php b/application/models/Distances_model.php index 1e73e538..2fc2ea25 100644 --- a/application/models/Distances_model.php +++ b/application/models/Distances_model.php @@ -3,96 +3,101 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class Distances_model extends CI_Model { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + + public $bandslots = array("160m"=>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); + + function get_worked_sats() { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + // get all worked sats from database + $sql = "SELECT distinct col_sat_name FROM ".$this->config->item('table_name')." WHERE station_id = ".$station_id . " and coalesce(col_sat_name, '') <> '' ORDER BY col_sat_name"; + + $data = $this->db->query($sql); + + $worked_sats = array(); + foreach($data->result() as $row){ + array_push($worked_sats, $row->col_sat_name); + } + + return $worked_sats; + } + + function get_worked_bands() { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + // get all worked slots from database + $sql = "SELECT distinct LOWER(COL_BAND) as COL_BAND FROM ".$this->config->item('table_name')." WHERE station_id = ".$station_id; + + $data = $this->db->query($sql); + $worked_slots = array(); + foreach($data->result() as $row){ + array_push($worked_slots, $row->COL_BAND); + } + + // 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_distances($postdata, $measurement_base) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $station_gridsquare = $CI->Stations->find_gridsquare(); + $gridsquare = explode(',', $station_gridsquare); // We need to convert to an array, since a user can enter several gridsquares - $result = array(); - - foreach ($logbooks_locations_array as $station_id) { - - $station_gridsquare = $this->find_gridsquare($station_id); - - if ($station_gridsquare != "") { - $gridsquare = explode(',', $station_gridsquare); // We need to convert to an array, since a user can enter several gridsquares - - $this->db->select('col_call callsign, col_gridsquare grid'); - $this->db->where('LENGTH(col_gridsquare) >', 0); - - if ($postdata['band'] == 'sat') { - $this->db->where('col_prop_mode', $postdata['band']); - if ($postdata['sat'] != 'All') { - $this->db->where('col_sat_name', $postdata['sat']); - } - } - else { - $this->db->where('col_band', $postdata['band']); - } - $this->db->where('station_id', $station_id); - $dataarrayata = $this->db->get($this->config->item('table_name')); - - $temp = $this->plot($dataarrayata->result_array(), $gridsquare, $measurement_base); - - $result = $this->mergeresult($result, $temp); - } - } - - if ($result) { - header('Content-Type: application/json'); - echo json_encode($result); - } - else { - header('Content-Type: application/json'); - echo json_encode(array('Error' => 'No QSOs found to plot.')); - } + $this->db->select('col_call callsign, col_gridsquare grid'); + $this->db->where('LENGTH(col_gridsquare) >', 0); + if ($postdata['band'] == 'sat') { + $this->db->where('col_prop_mode', $postdata['band']); + if ($postdata['sat'] != 'All') { + $this->db->where('col_sat_name', $postdata['sat']); + } + } + else { + $this->db->where('col_band', $postdata['band']); + } + $this->db->where('station_id', $station_id); + $dataarrayata = $this->db->get($this->config->item('table_name')); + $this->plot($dataarrayata->result_array(), $gridsquare, $measurement_base); } - /* - * We merge the result from several station_id's. They can have different gridsquares, so we need to use the correct gridsquare to calculate the correct distance. - */ - function mergeresult($result, $add) { - if (sizeof($result) > 0) { - if ($result['qrb']['Distance'] < $add['qrb']['Distance']) { - $result['qrb']['Distance'] = $add['qrb']['Distance']; - $result['qrb']['Grid'] = $add['qrb']['Grid']; - $result['qrb']['Callsign'] = $add['qrb']['Callsign']; - } - $result['qrb']['Qsos'] += $add['qrb']['Qsos']; - - for ($i = 0; $i <= 399; $i++) { - $result['qsodata'][$i]['count'] += $add['qsodata'][$i]['count']; - - if ($result['qsodata'][$i]['callcount'] < 5 && $add['qsodata'][$i]['callcount'] > 0) { - $calls = explode(',', $add['qsodata'][$i]['calls']); - foreach ($calls as $c) { - if ($result['qsodata'][$i]['callcount'] < 5) { - if ($result['qsodata'][$i]['callcount'] > 0) { - $result['qsodata'][$i]['calls'] .= ', '; - } - $result['qsodata'][$i]['calls'] .= $c; - $result['qsodata'][$i]['callcount']++; - } - } - } - } - return $result; - } - - return $add; - } - - /* - * Fetches the gridsquare from the station_id - */ - function find_gridsquare($station_id) { - $this->db->where('station_id', $station_id); - return $this->db->get('station_profile')->row()->station_gridsquare; - } - // This functions takes query result from the database and extracts grids from the qso, // then calculates distance between homelocator and locator given in qso. // It builds an array, which has 50km intervals, then inputs each length into the correct spot @@ -133,17 +138,17 @@ class Distances_model extends CI_Model $dataarray[$i]['callcount'] = 0; $j += 50; } - + $qrb = array ( // Used for storing the QSO with the longest QRB 'Callsign' => '', 'Grid' => '', 'Distance' => '', - 'Qsos' => '', + 'Qsoes' => '', 'Grids' => '' ); - + foreach ($qsoArray as $qso) { - $qrb['Qsos']++; // Counts up number of qsos + $qrb['Qsoes']++; // Counts up number of qsoes $bearingdistance = $this->bearing_dist($stationgrid, $qso['grid'], $measurement_base); // Calculates distance based on grids $arrayplacement = $bearingdistance / 50; // Resolution is 50, calculates where to put result in array if ($bearingdistance > $qrb['Distance']) { // Saves the longest QSO @@ -151,7 +156,7 @@ class Distances_model extends CI_Model $qrb['Callsign'] = $qso['callsign']; $qrb['Grid'] = $qso['grid']; } - $dataarray[$arrayplacement]['count']++; // Used for counting total qsos plotted + $dataarray[$arrayplacement]['count']++; // Used for counting total qsoes plotted if ($dataarray[$arrayplacement]['callcount'] < 5) { // Used for tooltip in graph, set limit to 5 calls shown if ($dataarray[$arrayplacement]['callcount'] > 0) { $dataarray[$arrayplacement]['calls'] .= ', '; @@ -160,13 +165,19 @@ class Distances_model extends CI_Model $dataarray[$arrayplacement]['callcount']++; } } - - $data['ok'] = 'OK'; - $data['qrb'] = $qrb; - $data['qsodata'] = $dataarray; - $data['unit'] = $unit; - - return $data; + + if (!$qrb['Qsoes'] == 0) { // We have a result :) + header('Content-Type: application/json'); + $data['ok'] = 'OK'; + $data['qrb'] = $qrb; + $data['qsodata'] = $dataarray; + $data['unit'] = $unit; + echo json_encode($data); + } + else { + header('Content-Type: application/json'); + echo json_encode(array('Error' => 'No QSOs found to plot.')); + } } } @@ -214,7 +225,7 @@ class Distances_model extends CI_Model function bearing_dist($loc1, $loc2, $measurement_base) { $loc1 = strtoupper($loc1); $loc2 = strtoupper($loc2); - + if (strlen($loc1) == 4) $loc1 .= 'MM'; if (strlen($loc2) == 4) $loc2 .= 'MM'; @@ -228,6 +239,8 @@ class Distances_model extends CI_Model $co = cos($l1[1] - $l2[1]) * cos($l1[0]) * cos($l2[0]) + sin($l1[0]) * sin($l2[0]); $ca = atan2(sqrt(1 - $co*$co), $co); + + switch ($measurement_base) { case 'M': return round(6371*$ca/1.609344); @@ -239,4 +252,4 @@ class Distances_model extends CI_Model return round(6371*$ca); } } -} +} \ No newline at end of file diff --git a/application/models/Dok.php b/application/models/Dok.php index 333e87c6..2a9653e5 100644 --- a/application/models/Dok.php +++ b/application/models/Dok.php @@ -2,18 +2,66 @@ class DOK extends CI_Model { - function show_stats() { + public $bandslots = array("160m"=>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); + + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + + function get_worked_bands() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $this->load->model('bands'); + // 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_DARC_DOK IS NOT NULL AND COL_DARC_DOK != '' AND COL_DXCC = 230 " + ); + $worked_slots = array(); + foreach($data->result() as $row){ + array_push($worked_slots, $row->COL_BAND); + } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + + // 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 show_stats(){ + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $data = $this->db->query( "select upper(COL_DARC_DOK) as COL_DARC_DOK, COL_MODE, lcase(COL_BAND) as COL_BAND, count(COL_DARC_DOK) as cnt - from ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ") AND COL_DARC_DOK IS NOT NULL AND COL_DARC_DOK != '' AND COL_DXCC = 230 + from ".$this->config->item('table_name')." WHERE station_id = ".$station_id." AND COL_DARC_DOK IS NOT NULL AND COL_DARC_DOK != '' AND COL_DXCC = 230 group by COL_DARC_DOK, COL_MODE, COL_BAND" ); @@ -22,20 +70,20 @@ class DOK extends CI_Model { foreach($data->result() as $row){ if ($last_dok != $row->COL_DARC_DOK){ // new row - $results[$row->COL_DARC_DOK] = $this->bands->bandslots; + $results[$row->COL_DARC_DOK] = $this->bandslots; $last_dok = $row->COL_DARC_DOK; } // update stats if (!isset($results[$row->COL_DARC_DOK])) - $results[$row->COL_DARC_DOK] = []; + $results[$row->COL_DARC_DOK] = []; if (!isset($results[$row->COL_DARC_DOK][$row->COL_BAND])) - $results[$row->COL_DARC_DOK][$row->COL_BAND] = 0; + $results[$row->COL_DARC_DOK][$row->COL_BAND] = 0; $results[$row->COL_DARC_DOK][$row->COL_BAND] += $row->cnt; } - + return $results; } diff --git a/application/models/Dxatlas_model.php b/application/models/Dxatlas_model.php deleted file mode 100644 index d6dea3d7..00000000 --- a/application/models/Dxatlas_model.php +++ /dev/null @@ -1,166 +0,0 @@ -fetchGrids($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate); - - if (isset($gridArray)) { - return $gridArray; - } else { - return 0; - } - } - - /* - * Builds the array for worked and confirmed gridsquares - */ - function fetchGrids($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate) { - - // Getting all the worked grids - $col_gridsquare_worked = $this->get_grids($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate, 'none', 'single'); - - $workedGridArray = array(); - foreach ($col_gridsquare_worked as $workedgrid) { - array_push($workedGridArray, $workedgrid['gridsquare']); - } - - $col_vucc_grids_worked = $this->get_grids($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate, 'none', 'multi'); - - foreach ($col_vucc_grids_worked as $gridSplit) { - $grids = explode(",", $gridSplit['col_vucc_grids']); - foreach($grids as $key) { - $grid_four = strtoupper(substr(trim($key),0,4)); - - if(!in_array($grid_four, $workedGridArray)){ - array_push($workedGridArray, $grid_four); - } - } - } - - // Getting all the confirmed grids - $col_gridsquare_confirmed = $this->get_grids($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate, 'both', 'single'); - - $confirmedGridArray = array(); - foreach ($col_gridsquare_confirmed as $confirmedgrid) { - array_push($confirmedGridArray, $confirmedgrid['gridsquare']); - if(in_array($confirmedgrid['gridsquare'], $workedGridArray)){ - $index = array_search($confirmedgrid['gridsquare'],$workedGridArray); - unset($workedGridArray[$index]); - } - } - - $col_vucc_grids_confirmed = $this->get_grids($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate, 'both', 'multi'); - - foreach ($col_vucc_grids_confirmed as $gridSplit) { - $grids = explode(",", $gridSplit['col_vucc_grids']); - foreach($grids as $key) { - $grid_four = strtoupper(substr(trim($key),0,4)); - - if(!in_array($grid_four, $confirmedGridArray)){ - array_push($confirmedGridArray, $grid_four); - } - if(in_array($grid_four, $workedGridArray)){ - $index = array_search($grid_four,$workedGridArray); - unset($workedGridArray[$index]); - } - } - } - - $vuccArray['worked'] = $workedGridArray; - $vuccArray['confirmed'] = $confirmedGridArray; - - return $vuccArray; - } - - /* - * Gets the grids from the datbase - * - * Filters: - * - * $band = filter on band - * $mode = filter on mode - * $dxcc = filter on dxx - * $cqz = filter on cq zone - * $propagation = Filter on propagation - * $fromdate = Date range from - * $todate = Date range to - * $column = Chooses if we fetch from col_gridsquare (only single grids) or col_vucc_grids (multisquares) - * $confirmationMethod - qsl, lotw or both, use anything else to skip confirmed - * - */ - function get_grids($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate, $confirmationMethod, $column) { - $sql = ""; - - if ($column == 'single') { - $sql .= "select distinct upper(substring(col_gridsquare, 1, 4)) gridsquare - from " . $this->config->item('table_name') . - " where col_gridsquare <> ''"; - } - else if ($column == 'multi') { - $sql .= "select col_vucc_grids - from " . $this->config->item('table_name') . - " where col_vucc_grids <> '' "; - } - - if ($station_id != "All") { - $sql .= ' and station_id = ' . $station_id; - } - - if ($confirmationMethod == 'both') { - $sql .= " and (col_qsl_rcvd='Y' or col_lotw_qsl_rcvd='Y')"; - } - else if ($confirmationMethod == 'qsl') { - $sql .= " and col_qsl_rcvd='Y'"; - } - else if ($confirmationMethod == 'lotw') { - $sql .= " and col_lotw_qsl_rcvd='Y'"; - } - - if ($band != 'All') { - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - } else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and col_band ='" . $band . "'"; - } - } - - if ($mode != 'All') { - $sql .= " and (COL_MODE = '" . $mode . "' or COL_SUBMODE = '" . $mode . "')"; - } - - if ($dxcc != 'All') { - $sql .= " and COL_DXCC ='" . $dxcc . "'"; - } - - if ($cqz != 'All') { - $sql .= " and COL_CQZ ='" . $cqz . "'"; - } - - if ($propagation != 'All') { - $sql .= " and COL_PROP_MODE ='" . $propagation . "'"; - } - - // If date is set, we format the date and add it to the where-statement - if ($fromdate != "") { - $from = DateTime::createFromFormat('d/m/Y', $fromdate); - $from = $from->format('Y-m-d'); - $sql .= " and date(COL_TIME_ON) >='" . $from . "'"; - } - if ($todate != "") { - $to = DateTime::createFromFormat('d/m/Y', $todate); - $to = $to->format('Y-m-d'); - $sql .= " and date(COL_TIME_ON) <='" . $to . "'"; - } - - $query = $this->db->query($sql); - - return $query->result_array(); - } -} -?> diff --git a/application/models/Dxcc.php b/application/models/Dxcc.php index 24cf79e6..54112070 100644 --- a/application/models/Dxcc.php +++ b/application/models/Dxcc.php @@ -2,6 +2,133 @@ class DXCC extends CI_Model { + public $bandslots = array("160m"=>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 show_stats(){ + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $data = $this->db->query( + "select COL_COUNTRY, COL_MODE, lcase(COL_BAND) as COL_BAND, count(COL_COUNTRY) as cnt + from ".$this->config->item('table_name')." + where station_id = ".$station_id." AND COL_PROP_MODE != \"SAT\" + group by COL_COUNTRY, COL_MODE, COL_BAND" + ); + + $results = array(); + $last_country = ""; + foreach($data->result() as $row){ + if ($last_country != $row->COL_COUNTRY){ + // new row + $results[$row->COL_COUNTRY] = $this->bandslots; + $last_country = $row->COL_COUNTRY; + } + + // update stats + if (!isset($results[$row->COL_COUNTRY])) + $results[$row->COL_COUNTRY] = []; + + if (!isset($results[$row->COL_COUNTRY][$row->COL_BAND])) + $results[$row->COL_COUNTRY][$row->COL_BAND] = 0; + + $results[$row->COL_COUNTRY][$row->COL_BAND] += $row->cnt; + } + + // Satellite DXCC + + $satellite_data = $this->db->query( + "select COL_COUNTRY, COL_PROP_MODE as COL_PROP_MODE, count(COL_COUNTRY) as cnt + from ".$this->config->item('table_name')." + where station_id = ".$station_id." AND COL_PROP_MODE = \"SAT\" + group by COL_COUNTRY" + ); + + foreach($satellite_data->result() as $row){ + if ($last_country != $row->COL_COUNTRY){ + // new row + $results[$row->COL_COUNTRY] = $this->bandslots; + $last_country = $row->COL_COUNTRY; + } + + // update stats + if (!isset($results[$row->COL_COUNTRY])) + $results[$row->COL_COUNTRY] = []; + + if (!isset($results[$row->COL_COUNTRY][$row->COL_PROP_MODE])) + $results[$row->COL_COUNTRY][$row->COL_PROP_MODE] = 0; + + $results[$row->COL_COUNTRY][$row->COL_PROP_MODE] += $row->cnt; + } + + // print_r($results); + // return; + + return $results; + } + /** * Function: mostactive * Information: Returns the most active band @@ -42,7 +169,7 @@ class DXCC extends CI_Model { } /* - * Fetches a list of all dxcc's, both current and deleted + * Fethes a list of all dxcc's, both current and deleted */ function list() { $this->db->order_by('name', 'ASC'); @@ -60,10 +187,8 @@ class DXCC extends CI_Model { function get_dxcc_array($dxccArray, $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')); - - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $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 ($dxccArray as $dxcc) { @@ -76,7 +201,7 @@ class DXCC extends CI_Model { // If worked is checked, we add worked entities to the array if ($postdata['worked'] != NULL) { - $workedDXCC = $this->getDxccBandWorked($location_list, $band, $postdata); + $workedDXCC = $this->getDxccBandWorked($station_id, $band, $postdata); foreach ($workedDXCC as $wdxcc) { //function displayContacts(searchphrase, band, mode, type) { $dxccMatrix[$wdxcc->dxcc][$band] = '
name).'","'. $band . '","'. $postdata['mode'] . '","DXCC")\'>W
'; @@ -85,7 +210,7 @@ class DXCC extends CI_Model { // If confirmed is checked, we add confirmed entities to the array if ($postdata['confirmed'] != NULL) { - $confirmedDXCC = $this->getDxccBandConfirmed($location_list, $band, $postdata); + $confirmedDXCC = $this->getDxccBandConfirmed($station_id, $band, $postdata); foreach ($confirmedDXCC as $cdxcc) { $dxccMatrix[$cdxcc->dxcc][$band] = '
name).'","'. $band . '","'. $postdata['mode'] . '","DXCC")\'>C
'; } @@ -94,7 +219,7 @@ class DXCC extends CI_Model { // We want to remove the worked dxcc's in the list, since we do not want to display them if ($postdata['worked'] == NULL) { - $workedDxcc = $this->getDxccWorked($location_list, $postdata); + $workedDxcc = $this->getDxccWorked($station_id, $postdata); foreach ($workedDxcc as $wdxcc) { if (array_key_exists($wdxcc->dxcc, $dxccMatrix)) { unset($dxccMatrix[$wdxcc->dxcc]); @@ -104,7 +229,7 @@ class DXCC extends CI_Model { // We want to remove the confirmed dxcc's in the list, since we do not want to display them if ($postdata['confirmed'] == NULL) { - $confirmedDxcc = $this->getDxccConfirmed($location_list, $postdata); + $confirmedDxcc = $this->getDxccConfirmed($station_id, $postdata); foreach ($confirmedDxcc as $cdxcc) { if (array_key_exists($cdxcc->dxcc, $dxccMatrix)) { unset($dxccMatrix[$cdxcc->dxcc]); @@ -120,12 +245,12 @@ class DXCC extends CI_Model { } } - function getDxccBandConfirmed($location_list, $band, $postdata) { + function getDxccBandConfirmed($station_id, $band, $postdata) { $sql = "select adif as dxcc, name from dxcc_entities join ( select col_dxcc from ".$this->config->item('table_name')." thcv - where station_id in (" . $location_list . - ") and col_dxcc > 0"; + where station_id = " . $station_id . + " and col_dxcc > 0"; if ($band == 'SAT') { $sql .= " and col_prop_mode ='" . $band . "'"; @@ -155,12 +280,12 @@ class DXCC extends CI_Model { return $query->result(); } - function getDxccBandWorked($location_list, $band, $postdata) { + function getDxccBandWorked($station_id, $band, $postdata) { $sql = "select adif as dxcc, name from dxcc_entities join ( select col_dxcc from ".$this->config->item('table_name')." thcv - where station_id in (" . $location_list . - ") and col_dxcc > 0"; + where station_id = " . $station_id . + " and col_dxcc > 0"; if ($band == 'SAT') { $sql .= " and col_prop_mode ='" . $band . "'"; @@ -190,16 +315,14 @@ class DXCC extends CI_Model { function fetchDxcc($postdata) { $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)."'"; + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $sql = "select adif, prefix, name, date(end) Enddate, date(start) Startdate from dxcc_entities"; if ($postdata['notworked'] == NULL) { - $sql .= " join (select col_dxcc from " . $this->config->item('table_name') . " where station_id in (" . $location_list . ") and col_dxcc > 0"; + $sql .= " join (select col_dxcc from " . $this->config->item('table_name') . " where station_id = " . $station_id . " and col_dxcc > 0"; if ($postdata['band'] != 'All') { if ($postdata['band'] == 'SAT') { @@ -232,13 +355,13 @@ class DXCC extends CI_Model { return $query->result(); } - function getDxccWorked($location_list, $postdata) { + function getDxccWorked($station_id, $postdata) { $sql = "SELECT adif as dxcc FROM dxcc_entities join ( select col_dxcc from ".$this->config->item('table_name')." thcv - where station_id in (" . $location_list . - ") and col_dxcc > 0"; + where station_id = " . $station_id . + " and col_dxcc > 0"; if ($postdata['band'] != 'All') { if ($postdata['band'] == 'SAT') { @@ -254,7 +377,7 @@ class DXCC extends CI_Model { $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; } - $sql .= " and not exists (select 1 from ".$this->config->item('table_name')." where station_id in (". $location_list .") and col_dxcc = thcv.col_dxcc and col_dxcc > 0"; + $sql .= " and not exists (select 1 from ".$this->config->item('table_name')." where station_id = $station_id and col_dxcc = thcv.col_dxcc and col_dxcc > 0"; if ($postdata['band'] != 'All') { if ($postdata['band'] == 'SAT') { @@ -289,13 +412,13 @@ class DXCC extends CI_Model { return $query->result(); } - function getDxccConfirmed($location_list, $postdata) { + function getDxccConfirmed($station_id, $postdata) { $sql = "SELECT adif as dxcc FROM dxcc_entities join ( select col_dxcc from ".$this->config->item('table_name')." thcv - where station_id in (". $location_list . - ") and col_dxcc > 0"; + where station_id = ". $station_id . + " and col_dxcc > 0"; if ($postdata['band'] != 'All') { if ($postdata['band'] == 'SAT') { @@ -384,20 +507,18 @@ class DXCC extends CI_Model { function get_dxcc_summary($bands) { $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)."'"; + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); foreach ($bands as $band) { - $worked = $this->getSummaryByBand($band, $location_list); - $confirmed = $this->getSummaryByBandConfirmed($band, $location_list); + $worked = $this->getSummaryByBand($band, $station_id); + $confirmed = $this->getSummaryByBandConfirmed($band, $station_id); $dxccSummary['worked'][$band] = $worked[0]->count; $dxccSummary['confirmed'][$band] = $confirmed[0]->count; } - $workedTotal = $this->getSummaryByBand('All', $location_list); - $confirmedTotal = $this->getSummaryByBandConfirmed('All', $location_list); + $workedTotal = $this->getSummaryByBand('All', $station_id); + $confirmedTotal = $this->getSummaryByBandConfirmed('All', $station_id); $dxccSummary['worked']['Total'] = $workedTotal[0]->count; $dxccSummary['confirmed']['Total'] = $confirmedTotal[0]->count; @@ -405,11 +526,11 @@ class DXCC extends CI_Model { return $dxccSummary; } - function getSummaryByBand($band, $location_list) + function getSummaryByBand($band, $station_id) { $sql = "SELECT count(distinct thcv.col_dxcc) as count FROM " . $this->config->item('table_name') . " thcv"; - $sql .= " where station_id in (" . $location_list . ") and col_dxcc > 0"; + $sql .= " where station_id = " . $station_id . " and col_dxcc > 0"; if ($band == 'SAT') { @@ -425,11 +546,11 @@ class DXCC extends CI_Model { return $query->result(); } - function getSummaryByBandConfirmed($band, $location_list) + function getSummaryByBandConfirmed($band, $station_id) { $sql = "SELECT count(distinct thcv.col_dxcc) as count FROM " . $this->config->item('table_name') . " thcv"; - $sql .= " where station_id in (" . $location_list . ")"; + $sql .= " where station_id = " . $station_id; if ($band == 'SAT') { $sql .= " and thcv.col_prop_mode ='" . $band . "'"; diff --git a/application/models/Dxcc_entities.php b/application/models/Dxcc_entities.php index f7bba0fa..c4e5d944 100644 --- a/application/models/Dxcc_entities.php +++ b/application/models/Dxcc_entities.php @@ -17,6 +17,11 @@ CREATE TABLE IF NOT EXISTS `dxcc_entities` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8; */ + function __construct(){ + parent::__construct(); + } + + function empty_table($table){ $this->db->empty_table($table); } diff --git a/application/models/Dxcc_exceptions.php b/application/models/Dxcc_exceptions.php index c22e7603..164426d6 100644 --- a/application/models/Dxcc_exceptions.php +++ b/application/models/Dxcc_exceptions.php @@ -18,7 +18,14 @@ CREATE TABLE IF NOT EXISTS `dxcc_exceptions` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8; */ + function __construct(){ + parent::__construct(); + } + + function empty_table($table){ $this->db->empty_table($table); } + + } \ No newline at end of file diff --git a/application/models/Dxcc_prefixes.php b/application/models/Dxcc_prefixes.php index 3b790e59..99a021b6 100644 --- a/application/models/Dxcc_prefixes.php +++ b/application/models/Dxcc_prefixes.php @@ -16,7 +16,14 @@ CREATE TABLE IF NOT EXISTS `dxcc_prefixes` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8; */ + function __construct(){ + parent::__construct(); + } + + function empty_table($table){ $this->db->empty_table($table); } -} \ No newline at end of file + + +} diff --git a/application/models/Eqsl_images.php b/application/models/Eqsl_images.php index 88137b01..0e4674cc 100644 --- a/application/models/Eqsl_images.php +++ b/application/models/Eqsl_images.php @@ -2,6 +2,11 @@ class Eqsl_images extends CI_Model { + function __construct() + { + parent::__construct(); + } + function get_image($qso_id) { $this->db->where('qso_id', $qso_id); $query = $this->db->get('eQSL_images'); diff --git a/application/models/Eqslmethods_model.php b/application/models/Eqslmethods_model.php index 9030d1f3..539be9e3 100644 --- a/application/models/Eqslmethods_model.php +++ b/application/models/Eqslmethods_model.php @@ -2,6 +2,11 @@ class Eqslmethods_model extends CI_Model { + function __construct() + { + parent::__construct(); + } + function mark_all_as_sent() { $data = array( 'COL_EQSL_QSL_SENT' => 'Y', diff --git a/application/models/Gridsquares_model.php b/application/models/Gridsquares_model.php index 42914aad..a173da5d 100644 --- a/application/models/Gridsquares_model.php +++ b/application/models/Gridsquares_model.php @@ -2,55 +2,46 @@ class Gridsquares_model extends CI_Model { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + function get_worked_sat_squares() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $this->db->select('distinct substring(COL_GRIDSQUARE,1,6) as SAT_SQUARE, COL_SAT_NAME', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_GRIDSQUARE !=', ''); - $this->db->where('COL_SAT_NAME !=', ''); + $this->db->where("station_id", $station_id); - return $this->db->get($this->config->item('table_name')); - } - - function get_confirmed_sat_squares() { - $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)."'"; - - $sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as SAT_SQUARE, COL_SAT_NAME FROM ' - . $this->config->item('table_name') - . ' WHERE station_id in (' . $location_list . ') AND COL_GRIDSQUARE != "" AND COL_SAT_NAME != "" AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'; - - return $this->db->query($sql); + return $this->db->query('SELECT distinct substring(COL_GRIDSQUARE,1,6) as SAT_SQUARE, COL_SAT_NAME FROM '.$this->config->item('table_name').' WHERE station_id = "'.$station_id.'" AND COL_GRIDSQUARE != "" AND COL_SAT_NAME != ""'); } - function get_confirmed_sat_vucc_squares() { - $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_confirmed_sat_squares() { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + return $this->db->query('SELECT distinct substring(COL_GRIDSQUARE,1,6) as SAT_SQUARE, COL_SAT_NAME FROM '.$this->config->item('table_name').' WHERE station_id = "'.$station_id.'" AND COL_GRIDSQUARE != "" AND COL_SAT_NAME != "" AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'); + } - $sql = 'SELECT COL_VUCC_GRIDS, COL_SAT_NAME FROM ' - . $this->config->item('table_name') - . ' WHERE station_id in (' . $location_list . ') AND COL_VUCC_GRIDS != "" AND COL_SAT_NAME != "" AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y") AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'; + function get_confirmed_sat_vucc_squares() { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - return $this->db->query($sql); - } + return $this->db->query('SELECT COL_VUCC_GRIDS, COL_SAT_NAME FROM '.$this->config->item('table_name').' WHERE station_id = "'.$station_id.'" AND COL_VUCC_GRIDS != "" AND COL_SAT_NAME != "" AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y") AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'); + } function get_worked_sat_vucc_squares() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $this->db->select('COL_PRIMARY_KEY, COL_VUCC_GRIDS, COL_SAT_NAME', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->select('COL_PRIMARY_KEY, COL_VUCC_GRIDS, COL_SAT_NAME'); + $this->db->where("station_id", $station_id); $this->db->where('COL_VUCC_GRIDS !=', ""); $this->db->where('COL_SAT_NAME !=', ""); return $this->db->get($this->config->item('table_name')); @@ -58,62 +49,59 @@ class Gridsquares_model extends CI_Model { function get_band($band) { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - - - $this->db->select('distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_GRIDSQUARE !=', ''); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + $sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND FROM ' + .$this->config->item('table_name') + .' WHERE station_id = "' + .$station_id.'" AND COL_GRIDSQUARE != ""'; if ($band != 'All') { - $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=', "SAT"); - $this->db->where('COL_PROP_MODE !=', "INTERNET"); - $this->db->where('COL_PROP_MODE !=', "ECH"); - $this->db->where('COL_PROP_MODE !=', "RPT"); - $this->db->where('COL_SAT_NAME =', ""); - } - - return $this->db->get($this->config->item('table_name')); - } - - function get_band_confirmed($band) { - $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)."'"; - - $sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND FROM ' - .$this->config->item('table_name') - .' WHERE station_id in (' - .$location_list.') AND COL_GRIDSQUARE != ""'; - if ($band != 'All') { - $sql .= ' AND COL_BAND = "' . $band - .'" + $sql .= ' AND COL_BAND = "' . $band + .'" AND COL_PROP_MODE != "SAT" AND COL_PROP_MODE != "INTERNET" AND COL_PROP_MODE != "ECH" AND COL_PROP_MODE != "RPT" AND COL_SAT_NAME = ""'; - } + } - $sql .= ' AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'; + return $this->db->query($sql); + } - return $this->db->query($sql); - } + function get_band_confirmed($band) { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND FROM ' + .$this->config->item('table_name') + .' WHERE station_id = "' + .$station_id.'" AND COL_GRIDSQUARE != ""'; + if ($band != 'All') { + $sql .= ' AND COL_BAND = "' . $band + .'" + AND COL_PROP_MODE != "SAT" + AND COL_PROP_MODE != "INTERNET" + AND COL_PROP_MODE != "ECH" + AND COL_PROP_MODE != "RPT" + AND COL_SAT_NAME = ""'; + } + + $sql .= ' AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")'; + + + return $this->db->query($sql); + } function search_band($band, $gridsquare) { $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)."'"; + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $sql = 'SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_GRIDSQUARE, COL_VUCC_GRIDS FROM ' .$this->config->item('table_name') - .' WHERE station_id IN (' . $location_list . ') ' + .' WHERE station_id = "' . $station_id . '" ' . ' AND (COL_GRIDSQUARE LIKE "%'.$gridsquare.'%" or COL_VUCC_GRIDS LIKE "%'.$gridsquare.'%")'; if ($band != 'All') { @@ -134,14 +122,12 @@ class Gridsquares_model extends CI_Model { function search_sat($gridsquare) { $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)."'"; + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $sql = 'SELECT COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_SAT_NAME, COL_GRIDSQUARE, COL_VUCC_GRIDS FROM ' . $this->config->item('table_name'). - ' WHERE station_id IN ('.$location_list. ')' . + ' WHERE station_id = "'.$station_id. '"' . ' AND (COL_GRIDSQUARE LIKE "%'.$gridsquare.'%" or COL_VUCC_GRIDS LIKE "%'.$gridsquare.'%")'. ' AND COL_PROP_MODE = "SAT"'; diff --git a/application/models/Iota.php b/application/models/Iota.php index 98b31fb4..d46c279d 100644 --- a/application/models/Iota.php +++ b/application/models/Iota.php @@ -2,12 +2,71 @@ class IOTA extends CI_Model { - function get_iota_array($iotaArray, $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')); + public $bandslots = array("160m"=>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, + ); - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + 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 iota to generate the array needed for display foreach ($iotaArray as $iota) { @@ -20,7 +79,7 @@ class IOTA extends CI_Model { // If worked is checked, we add worked iotas to the array if ($postdata['worked'] != NULL) { - $workedIota = $this->getIotaBandWorked($location_list, $band, $postdata); + $workedIota = $this->getIotaBandWorked($station_id, $band, $postdata); foreach ($workedIota as $wiota) { $iotaMatrix[$wiota->tag][$band] = '
tag.'","'. $band . '","'. $postdata['mode'] . '","IOTA")\'>W
'; } @@ -28,7 +87,7 @@ class IOTA extends CI_Model { // If confirmed is checked, we add confirmed iotas to the array if ($postdata['confirmed'] != NULL) { - $confirmedIota = $this->getIotaBandConfirmed($location_list, $band, $postdata); + $confirmedIota = $this->getIotaBandConfirmed($station_id, $band, $postdata); foreach ($confirmedIota as $ciota) { $iotaMatrix[$ciota->tag][$band] = '
tag.'","'. $band . '","'. $postdata['mode'] . '","IOTA")\'>C
'; } @@ -37,7 +96,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($location_list, $postdata); + $workedIota = $this->getIotaWorked($station_id, $postdata); foreach ($workedIota as $wiota) { if (array_key_exists($wiota->tag, $iotaMatrix)) { unset($iotaMatrix[$wiota->tag]); @@ -47,7 +106,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($location_list, $postdata); + $confirmedIOTA = $this->getIotaConfirmed($station_id, $postdata); foreach ($confirmedIOTA as $ciota) { if (array_key_exists($ciota->tag, $iotaMatrix)) { unset($iotaMatrix[$ciota->tag]); @@ -63,11 +122,11 @@ class IOTA extends CI_Model { } } - function getIotaBandConfirmed($location_list, $band, $postdata) { + 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 in (" . $location_list . - ") and thcv.col_iota is not null + where station_id = " . $station_id . + " and thcv.col_iota is not null and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')"; if ($postdata['mode'] != 'All') { @@ -93,11 +152,11 @@ class IOTA extends CI_Model { return $query->result(); } - function getIotaBandWorked($location_list, $band, $postdata) { + 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 in (' . $location_list . - ') and thcv.col_iota is not null'; + where station_id = ' . $station_id . + ' and thcv.col_iota is not null'; if ($postdata['mode'] != 'All') { $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; @@ -123,6 +182,10 @@ 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) { @@ -132,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 in (". $location_list . ") and col_iota = iota.tag"; + $sql .= " and exists (select 1 from " . $this->config->item('table_name') . " where station_id = ". $station_id . " and col_iota = iota.tag"; if ($postdata['mode'] != 'All') { $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; @@ -156,12 +219,12 @@ class IOTA extends CI_Model { return $query->result(); } - function getIotaWorked($location_list, $postdata) { + 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 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 . + 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['mode'] != 'All') { @@ -205,11 +268,11 @@ class IOTA extends CI_Model { return $query->result(); } - function getIotaConfirmed($location_list, $postdata) { + 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 in (" . $location_list . - ") and thcv.col_iota is not null + where station_id = " . $station_id . + " and thcv.col_iota is not null and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')"; if ($postdata['mode'] != 'All') { @@ -275,21 +338,19 @@ class IOTA extends CI_Model { */ function get_iota_summary($bands) { - $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)."'"; + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); foreach ($bands as $band) { - $worked = $this->getSummaryByBand($band, $location_list); - $confirmed = $this->getSummaryByBandConfirmed($band, $location_list); + $worked = $this->getSummaryByBand($band, $station_id); + $confirmed = $this->getSummaryByBandConfirmed($band, $station_id); $iotaSummary['worked'][$band] = $worked[0]->count; $iotaSummary['confirmed'][$band] = $confirmed[0]->count; } - $workedTotal = $this->getSummaryByBand('All', $location_list); - $confirmedTotal = $this->getSummaryByBandConfirmed('All', $location_list); + $workedTotal = $this->getSummaryByBand('All', $station_id); + $confirmedTotal = $this->getSummaryByBandConfirmed('All', $station_id); $iotaSummary['worked']['Total'] = $workedTotal[0]->count; $iotaSummary['confirmed']['Total'] = $confirmedTotal[0]->count; @@ -297,11 +358,11 @@ class IOTA extends CI_Model { return $iotaSummary; } - function getSummaryByBand($band, $location_list) + function getSummaryByBand($band, $station_id) { $sql = "SELECT count(distinct thcv.col_iota) as count FROM " . $this->config->item('table_name') . " thcv"; - $sql .= " where station_id in (" . $location_list . ")"; + $sql .= " where station_id = " . $station_id; if ($band == 'SAT') { $sql .= " and thcv.col_prop_mode ='" . $band . "'"; @@ -317,11 +378,11 @@ class IOTA extends CI_Model { return $query->result(); } - function getSummaryByBandConfirmed($band, $location_list) + function getSummaryByBandConfirmed($band, $station_id) { $sql = "SELECT count(distinct thcv.col_iota) as count FROM " . $this->config->item('table_name') . " thcv"; - $sql .= " where station_id in (" . $location_list . ")"; + $sql .= " where station_id = " . $station_id; if ($band == 'SAT') { $sql .= " and thcv.col_prop_mode ='" . $band . "'"; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 08701ebd..b52a7a79 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2,6 +2,12 @@ class Logbook_model extends CI_Model { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + /* Add QSO to Logbook */ function create_qso() { // Join date+time @@ -230,8 +236,8 @@ class Logbook_model extends CI_Model { */ public function qso_details($searchphrase, $band, $mode, $type){ $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); switch ($type) { case 'DXCC': @@ -262,7 +268,7 @@ class Logbook_model extends CI_Model { break; } - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('station_id', $station_id); if ($band != 'All') { if($band != "SAT") { @@ -281,14 +287,11 @@ class Logbook_model extends CI_Model { } public function vucc_qso_details($gridsquare, $band) { - $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)."'"; - + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $sql = "select * from " . $this->config->item('table_name') . - " where station_id in (" . $location_list . ")" . + " where station_id =" . $station_id . " and (col_gridsquare like '" . $gridsquare. "%' or col_vucc_grids like '%" . $gridsquare. "%')"; @@ -305,9 +308,9 @@ class Logbook_model extends CI_Model { } public function timeline_qso_details($querystring, $band, $mode, $type){ - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); if ($band != 'All') { if ($band == 'SAT') { @@ -322,7 +325,7 @@ class Logbook_model extends CI_Model { $this->db->where('col_mode', $mode); } - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('station_id', $station_id); switch($type) { case 'dxcc': $this->db->where('COL_DXCC', $querystring); break; @@ -459,16 +462,8 @@ class Logbook_model extends CI_Model { /* Edit QSO */ function edit() { $entity = $this->get_entity($this->input->post('dxcc_id')); - $stationId = $this->input->post('station_profile'); $country = $entity['name']; - // be sure that station belongs to user - $CI =& get_instance(); - $CI->load->model('Stations'); - if (!$CI->Stations->check_station_is_accessible($stationId)) { - return; - } - $mode = $this->get_main_mode_if_submode($this->input->post('mode')); if ($mode == null) { $mode = $this->input->post('mode'); @@ -543,11 +538,11 @@ class Logbook_model extends CI_Model { 'COL_FREQ_RX' => $this->parse_frequency($this->input->post('freq_display_rx')), 'COL_STX_STRING' => $this->input->post('stx_string'), 'COL_SRX_STRING' => $this->input->post('srx_string'), - 'COL_STX' => $stx_string, - 'COL_SRX' => $srx_string, - 'COL_CONTEST_ID' => $this->input->post('contest_name'), + 'COL_STX' => $stx_string, + 'COL_SRX' => $srx_string, + 'COL_CONTEST_ID' => $this->input->post('contest_name'), 'COL_QSL_VIA' => $this->input->post('qsl_via_callsign'), - 'station_id' => $stationId, + 'station_id' => $this->input->post('station_profile'), 'COL_OPERATOR' => $this->input->post('operator_callsign'), 'COL_STATE' =>$this->input->post('usa_state'), 'COL_CNTY' => $uscounty @@ -830,15 +825,10 @@ class Logbook_model extends CI_Model { } function get_qsos($num, $offset) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - //$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*'); $this->db->from($this->config->item('table_name')); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); - $this->db->where_in('station_profile.station_id', $logbooks_locations_array); $this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc"); $this->db->limit($num); @@ -907,21 +897,16 @@ class Logbook_model extends CI_Model { function get_last_qsos($num) { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - if ($logbooks_locations_array) { - //$this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_STX_STRING, COL_SRX_STRING, COL_IOTA, COL_STATE, COL_GRIDSQUARE'); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->order_by("COL_TIME_ON", "desc"); - $this->db->limit($num); - $query = $this->db->get($this->config->item('table_name')); - - return $query; - } else { - return null; - } + //$this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_STX_STRING, COL_SRX_STRING, COL_IOTA, COL_STATE, COL_GRIDSQUARE'); + $this->db->where("station_id", $station_id); + $this->db->order_by("COL_TIME_ON", "desc"); + $this->db->limit($num); + $query = $this->db->get($this->config->item('table_name')); + return $query; } /* Get all QSOs with a valid grid for use in the KML export */ @@ -994,80 +979,64 @@ class Logbook_model extends CI_Model { function totals_year() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - - - $this->db->select('DATE_FORMAT(COL_TIME_ON, \'%Y\') as \'year\',COUNT(COL_PRIMARY_KEY) as \'total\'', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->group_by('DATE_FORMAT(COL_TIME_ON, \'%Y\')'); - $this->db->order_by('year', 'ASC'); - - $query = $this->db->get($this->config->item('table_name')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + $query = $this->db->query(' + SELECT DATE_FORMAT(COL_TIME_ON, \'%Y\') as \'year\', + COUNT(COL_PRIMARY_KEY) as \'total\' + FROM '.$this->config->item('table_name').' + WHERE station_id = '.$station_id.' + GROUP BY DATE_FORMAT(COL_TIME_ON, \'%Y\') + '); return $query; } /* Return total number of qsos */ - function total_qsos() { + function total_qsos() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - if ($logbooks_locations_array) { - $this->db->select('COUNT( * ) as count', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $query = $this->db->get($this->config->item('table_name')); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.''); if ($query->num_rows() > 0) { - foreach ($query->result() as $row) - { - return $row->count; - } + foreach ($query->result() as $row) + { + return $row->count; + } } - } else { - return null; - } } /* Return number of QSOs had today */ function todays_qsos() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + - if ($logbooks_locations_array) { $morning = date('Y-m-d 00:00:00'); $night = date('Y-m-d 23:59:59'); - - $this->db->select('COUNT( * ) as count', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_TIME_ON >=', $morning); - $this->db->where('COL_TIME_ON <=', $night); - $query = $this->db->get($this->config->item('table_name')); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.' AND COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); if ($query->num_rows() > 0) { - foreach ($query->result() as $row) - { - return $row->count; - } + foreach ($query->result() as $row) + { + return $row->count; + } } - } else { - return null; - } - } /* Return QSOs over a period of days */ function map_week_qsos($start, $end) { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'"); - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where("station_id", $station_id); $this->db->order_by("COL_TIME_ON", "ASC"); $query = $this->db->get($this->config->item('table_name')); @@ -1076,12 +1045,13 @@ class Logbook_model extends CI_Model { /* used to return custom qsos requires start, end date plus a band */ function map_custom_qsos($start, $end, $band) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'"); - $this->db->where_in("station_id", $logbooks_locations_array); + $this->db->where("station_id", $station_id); + if($band != "All" && $band != "SAT") { $this->db->where("COL_BAND", $band); @@ -1100,14 +1070,14 @@ class Logbook_model extends CI_Model { /* Returns QSOs for the date sent eg 2011-09-30 */ function map_day($date) { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $start = $date." 00:00:00"; $end = $date." 23:59:59"; $this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'"); - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where("station_id", $station_id); $this->db->order_by("COL_TIME_ON", "ASC"); $query = $this->db->get($this->config->item('table_name')); @@ -1118,10 +1088,8 @@ class Logbook_model extends CI_Model { function month_qsos() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - - if ($logbooks_locations_array) { + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $morning = date('Y-m-01 00:00:00'); @@ -1130,11 +1098,7 @@ class Logbook_model extends CI_Model { $night = $date->format('Y-m-d')." 23:59:59"; - $this->db->select('COUNT( * ) as count', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_TIME_ON >=', $morning); - $this->db->where('COL_TIME_ON <=', $night); - $query = $this->db->get($this->config->item('table_name')); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.' AND COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); if ($query->num_rows() > 0) { @@ -1143,9 +1107,6 @@ class Logbook_model extends CI_Model { return $row->count; } } - } else { - return null; - } } /* Return QSOs for the year for the active profile */ @@ -1166,19 +1127,12 @@ class Logbook_model extends CI_Model { function year_qsos() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - - if ($logbooks_locations_array) { + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $morning = date('Y-01-01 00:00:00'); $night = date('Y-12-31 23:59:59'); - - $this->db->select('COUNT( * ) as count', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_TIME_ON >=', $morning); - $this->db->where('COL_TIME_ON <=', $night); - $query = $this->db->get($this->config->item('table_name')); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.' AND COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); if ($query->num_rows() > 0) { @@ -1187,25 +1141,16 @@ class Logbook_model extends CI_Model { return $row->count; } } - } else { - return null; - } } /* Return total amount of SSB QSOs logged */ function total_ssb() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $this->db->select('COUNT( * ) as count', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_MODE', 'SSB'); - $this->db->or_where('COL_MODE', 'LSB'); - $this->db->or_where('COL_MODE', 'USB'); - - $query = $this->db->get($this->config->item('table_name')); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.' AND COL_MODE = \'SSB\' OR COL_MODE = \'LSB\' OR COL_MODE = \'USB\''); if ($query->num_rows() > 0) { @@ -1219,15 +1164,11 @@ class Logbook_model extends CI_Model { /* Return total number of satellite QSOs */ function total_sat() { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $this->db->select('COL_SAT_NAME, COUNT( * ) as count', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_SAT_NAME !=', 'null'); - $this->db->group_by('COL_SAT_NAME'); - $query = $this->db->get($this->config->item('table_name')); + $query = $this->db->query('SELECT COL_SAT_NAME, COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.' AND COL_SAT_NAME != \'null\' GROUP BY COL_SAT_NAME'); return $query; } @@ -1236,13 +1177,10 @@ class Logbook_model extends CI_Model { function total_cw() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $this->db->select('COUNT( * ) as count', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_MODE', 'CW'); - $query = $this->db->get($this->config->item('table_name')); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.' AND COL_MODE = \'CW\' '); if ($query->num_rows() > 0) { @@ -1257,13 +1195,10 @@ class Logbook_model extends CI_Model { function total_fm() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $this->db->select('COUNT( * ) as count', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_MODE', 'FM'); - $query = $this->db->get($this->config->item('table_name')); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.' AND COL_MODE = \'FM\''); if ($query->num_rows() > 0) { @@ -1278,19 +1213,10 @@ class Logbook_model extends CI_Model { function total_digi() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $this->db->select('COUNT( * ) as count', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_MODE !=', 'SSB'); - $this->db->where('COL_MODE !=', 'LSB'); - $this->db->where('COL_MODE !=', 'USB'); - $this->db->where('COL_MODE !=', 'CW'); - $this->db->where('COL_MODE !=', 'FM'); - $this->db->where('COL_MODE !=', 'AM'); - - $query = $this->db->get($this->config->item('table_name')); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.' AND COL_MODE != \'SSB\' AND COL_MODE != \'LSB\' AND COL_MODE != \'USB\' AND COL_MODE != \'CW\' AND COL_MODE != \'FM\' AND COL_MODE != \'AM\''); if ($query->num_rows() > 0) { @@ -1309,18 +1235,14 @@ class Logbook_model extends CI_Model { /* Return total number of QSOs per band */ function total_bands() { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - $this->db->select('DISTINCT (COL_BAND) AS band, count( * ) AS count', FALSE); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->group_by('band'); - $this->db->order_by('count', 'DESC'); + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $query = $this->db->get($this->config->item('table_name')); + $query = $this->db->query('SELECT DISTINCT (COL_BAND) AS band, count( * ) AS count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.' GROUP BY band ORDER BY count DESC'); - return $query; + return $query; } /* Return total number of QSL Cards sent */ @@ -1508,49 +1430,28 @@ class Logbook_model extends CI_Model { } } - function lotw_update($datetime, $callsign, $band, $qsl_date, $qsl_status, $state, $qsl_gridsquare) { + function lotw_update($datetime, $callsign, $band, $qsl_date, $qsl_status, $state) { - $data = array( - 'COL_LOTW_QSLRDATE' => $qsl_date, - 'COL_LOTW_QSL_RCVD' => $qsl_status, - 'COL_LOTW_QSL_SENT' => 'Y' - ); - if($state != "") { - $data['COL_STATE'] = $state; - } + if($state != "") { + $data = array( + 'COL_LOTW_QSLRDATE' => $qsl_date, + 'COL_LOTW_QSL_RCVD' => $qsl_status, + 'COL_LOTW_QSL_SENT' => 'Y', + 'COL_STATE' => $state + ); + } else { + $data = array( + 'COL_LOTW_QSLRDATE' => $qsl_date, + 'COL_LOTW_QSL_RCVD' => $qsl_status, + 'COL_LOTW_QSL_SENT' => 'Y' + ); + } $this->db->where('date_format(COL_TIME_ON, \'%Y-%m-%d %H:%i\') = "'.$datetime.'"'); $this->db->where('COL_CALL', $callsign); $this->db->where('COL_BAND', $band); $this->db->update($this->config->item('table_name'), $data); - unset($data); - - if($qsl_gridsquare != "") { - $data = array( - 'COL_GRIDSQUARE' => $qsl_gridsquare - ); - $this->db->where('date_format(COL_TIME_ON, \'%Y-%m-%d %H:%i\') = "'.$datetime.'"'); - $this->db->where('COL_CALL', $callsign); - $this->db->where('COL_BAND', $band); - $this->db->group_start(); - $this->db->where('COL_VUCC_GRIDS'); - $this->db->or_where('COL_VUCC_GRIDS', ''); - $this->db->group_end(); - if(strlen($qsl_gridsquare) > 4) { - $this->db->group_start(); - $this->db->where('COL_GRIDSQUARE', ""); - $this->db->or_where('COL_GRIDSQUARE', substr($qsl_gridsquare, 0, 4)); - if(strlen($qsl_gridsquare) > 6) { - $this->db->or_where('COL_GRIDSQUARE', substr($qsl_gridsquare, 0, 6)); - } - $this->db->group_end(); - } else { - $this->db->where('COL_GRIDSQUARE', ""); - } - - $this->db->update($this->config->item('table_name'), $data); - } return "Updated"; } @@ -2251,8 +2152,8 @@ class Logbook_model extends CI_Model { $dxcc_exceptions = $this->db->select('`entity`, `adif`, `cqz`') ->where('call', $call) ->where('(start <= CURDATE()') - ->or_where('start is null)', NULL, false) - ->where('(end >= CURDATE()') + ->or_where('start is null', NULL, false) + ->where('end >= CURDATE()') ->or_where('end is null)', NULL, false) ->get('dxcc_exceptions'); @@ -2600,11 +2501,11 @@ class Logbook_model extends CI_Model { } function county_qso_details($state, $county) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('station_id', $station_id); $this->db->where('COL_STATE', $state); $this->db->where('COL_CNTY', $county); $this->db->where('COL_PROP_MODE !=', 'SAT'); diff --git a/application/models/Logbooks_model.php b/application/models/Logbooks_model.php deleted file mode 100644 index 42356667..00000000 --- a/application/models/Logbooks_model.php +++ /dev/null @@ -1,188 +0,0 @@ -db->where('user_id', $this->session->userdata('user_id')); - $this->db->order_by('logbook_name'); - return $this->db->get('station_logbooks'); - } - - function add() { - // Create data array with field values - $data = array( - 'user_id' => $this->session->userdata('user_id'), - 'logbook_name' => xss_clean($this->input->post('stationLogbook_Name', true)), - ); - - // Insert Records - $this->db->insert('station_logbooks', $data); - } - - function delete($id) { - // Clean ID - $clean_id = $this->security->xss_clean($id); - - // Delete QSOs - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('logbook_id', $id); - $this->db->delete('station_logbooks'); - } - - function edit() { - $data = array( - 'logbook_name' => xss_clean($this->input->post('station_logbook_name', true)), - ); - - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('logbook_id', xss_clean($this->input->post('logbook_id', true))); - $this->db->update('station_logbooks', $data); - } - - function set_logbook_active($id) { - // Clean input - $cleanId = xss_clean($id); - - // be sure that logbook belongs to user - if (!$this->check_logbook_is_accessible($cleanId)) { - return; - } - - $data = array( - 'active_station_logbook' => $cleanId, - ); - - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->update('users', $data); - } - - function logbook($id) { - // Clean ID - $clean_id = $this->security->xss_clean($id); - - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('logbook_id', $clean_id); - return $this->db->get('station_logbooks'); - } - - - // Creates relationship between a logbook and a station location - function create_logbook_location_link($logbook_id, $location_id) { - // Clean ID - $clean_logbook_id = $this->security->xss_clean($logbook_id); - $clean_location_id = $this->security->xss_clean($location_id); - - // be sure that logbook belongs to user - if (!$this->check_logbook_is_accessible($clean_logbook_id)) { - return; - } - - // be sure that station belongs to user - $CI =& get_instance(); - $CI->load->model('Stations'); - if (!$CI->Stations->check_station_is_accessible($clean_location_id)) { - return; - } - - // Create data array with field values - $data = array( - 'station_logbook_id' => $clean_logbook_id, - 'station_location_id' => $clean_location_id, - ); - - // Insert Record - $this->db->insert('station_logbooks_relationship', $data); - } - - function relationship_exists($logbook_id, $location_id) { - $this->db->where('station_logbook_id', $logbook_id); - $this->db->where('station_location_id', $location_id); - $query = $this->db->get('station_logbooks_relationship'); - - if ($query->num_rows() > 0){ - return true; - } - else{ - return false; - } - } - - function list_logbook_relationships($logbook_id) { - - $relationships_array = array(); - - $this->db->where('station_logbook_id', $logbook_id); - $query = $this->db->get('station_logbooks_relationship'); - - if ($query->num_rows() > 0){ - foreach ($query->result() as $row) - { - array_push($relationships_array, $row->station_location_id); - } - - return $relationships_array; - } - else{ - return false; - } - } - - function list_logbooks_linked($logbook_id) { - - $relationships_array = array(); - - $this->db->where('station_logbook_id', $logbook_id); - $query = $this->db->get('station_logbooks_relationship'); - - - if ($query->num_rows() > 0){ - foreach ($query->result() as $row) - { - array_push($relationships_array, $row->station_location_id); - } - - $this->db->where_in('station_id', $relationships_array); - $query = $this->db->get('station_profile'); - - return $query; - } - else{ - return false; - } - } - - function delete_relationship($logbook_id, $station_id) { - // Clean ID - $clean_logbook_id = $this->security->xss_clean($logbook_id); - $clean_station_id = $this->security->xss_clean($station_id); - - // be sure that logbook belongs to user - if (!$this->check_logbook_is_accessible($clean_logbook_id)) { - return; - } - - // be sure that station belongs to user - $CI =& get_instance(); - $CI->load->model('Stations'); - if (!$CI->Stations->check_station_is_accessible($clean_station_id)) { - return; - } - - // Delete relationship - $this->db->where('station_logbook_id', $clean_logbook_id); - $this->db->where('station_location_id', $clean_station_id); - $this->db->delete('station_logbooks_relationship'); - } - - public function check_logbook_is_accessible($id) { - // check if logbook belongs to user - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('logbook_id', $id); - $query = $this->db->get('station_logbooks'); - if ($query->num_rows() == 1) { - return true; - } - return false; - } -} -?> \ No newline at end of file diff --git a/application/models/Lookup_model.php b/application/models/Lookup_model.php index d87747a8..28d0e239 100644 --- a/application/models/Lookup_model.php +++ b/application/models/Lookup_model.php @@ -2,8 +2,13 @@ class Lookup_model extends CI_Model{ + function __construct(){ + // Call the Model constructor + parent::__construct(); + } + function getSearchResult($queryinfo){ - $modes = $this->get_worked_modes($queryinfo['location_list']); + $modes = $this->get_worked_modes($queryinfo['station_id']); return $this->getResultFromDatabase($queryinfo, $modes); } @@ -49,7 +54,7 @@ class Lookup_model extends CI_Model{ 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 '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; @@ -65,7 +70,7 @@ class Lookup_model extends CI_Model{ // 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 .= " where station_id in (" . $queryinfo['location_list'] . ")"; + $sql .= " where station_id = " . $queryinfo['station_id']; $sql .= " and coalesce(col_submode, '') = ''"; @@ -78,7 +83,7 @@ class Lookup_model extends CI_Model{ // 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 .= " where station_id in (" . $queryinfo['location_list'] . ")"; + $sql .= " where station_id = " . $queryinfo['station_id']; $sql .= " and coalesce(col_submode, '') <> ''"; @@ -91,7 +96,7 @@ class Lookup_model extends CI_Model{ // 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 .= " where station_id in (" . $queryinfo['location_list'] . ")"; + $sql .= " where station_id = " . $queryinfo['station_id']; $sql .= " and coalesce(col_submode, '') = ''"; @@ -104,7 +109,7 @@ class Lookup_model extends CI_Model{ // 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 .= " where station_id in (" . $queryinfo['location_list'] . ")"; + $sql .= " where station_id = " . $queryinfo['station_id']; $sql .= " and coalesce(col_submode, '') <> ''"; @@ -119,14 +124,69 @@ class Lookup_model extends CI_Model{ return $query->result(); } + public $bandslots = array("160m" => 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, + ); + + /* + * Get's the worked bands from the log + */ + function get_worked_bands($station_id) + { + // 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; + } + /* * Get's the worked modes from the log */ - function get_worked_modes($location_list) + function get_worked_modes($station_id) { // get all worked modes from database $data = $this->db->query( - "SELECT distinct LOWER(`COL_MODE`) as `COL_MODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id in (" . $location_list . ") order by COL_MODE ASC" + "SELECT distinct LOWER(`COL_MODE`) as `COL_MODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id = " . $station_id . " order by COL_MODE ASC" ); $results = array(); foreach ($data->result() as $row) { @@ -134,7 +194,7 @@ class Lookup_model extends CI_Model{ } $data = $this->db->query( - "SELECT distinct LOWER(`COL_SUBMODE`) as `COL_SUBMODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id in (" . $location_list . ") and coalesce(COL_SUBMODE, '') <> '' order by COL_SUBMODE ASC" + "SELECT distinct LOWER(`COL_SUBMODE`) as `COL_SUBMODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id = " . $station_id . " and coalesce(COL_SUBMODE, '') <> '' order by COL_SUBMODE ASC" ); foreach ($data->result() as $row) { if (!in_array($row, $results)) { diff --git a/application/models/LotwCert.php b/application/models/LotwCert.php index af2a6a95..c0c6c122 100644 --- a/application/models/LotwCert.php +++ b/application/models/LotwCert.php @@ -2,6 +2,12 @@ class LotwCert extends CI_Model { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + /* |-------------------------------------------------------------------------- | Function: lotw_certs diff --git a/application/models/Modes.php b/application/models/Modes.php index 66f40ac9..531c43ad 100644 --- a/application/models/Modes.php +++ b/application/models/Modes.php @@ -2,6 +2,12 @@ class Modes extends CI_Model { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + function all() { $this->db->order_by('mode', 'ASC'); $this->db->order_by('submode', 'ASC'); diff --git a/application/models/Note.php b/application/models/Note.php index 0390bd15..3ccdbefa 100644 --- a/application/models/Note.php +++ b/application/models/Note.php @@ -2,8 +2,13 @@ class Note extends CI_Model { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + function list_all() { - $this->db->where('user_id', $this->session->userdata('user_id')); return $this->db->get('notes'); } @@ -11,11 +16,10 @@ class Note extends CI_Model { $data = array( 'cat' => xss_clean($this->input->post('category')), 'title' => xss_clean($this->input->post('title')), - 'note' => xss_clean($this->input->post('content')), - 'user_id' => $this->session->userdata('user_id') + 'note' => xss_clean($this->input->post('content')) ); - $this->db->insert('notes', $data); + $this->db->insert('notes', $data); } function edit() { @@ -26,21 +30,19 @@ class Note extends CI_Model { ); $this->db->where('id', xss_clean($this->input->post('id'))); - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->update('notes', $data); + $this->db->update('notes', $data); } function delete($id) { - $this->db->delete('notes', array('id' => xss_clean($id), 'user_id' =>$this->session->userdata('user_id'))); + $this->db->delete('notes', array('id' => xss_clean($id))); } function view($id) { // Get Note - $this->db->where('id', xss_clean($id)); - $this->db->where('user_id', $this->session->userdata('user_id')); + $this->db->where('id', xss_clean($id)); return $this->db->get('notes'); } } -?> +?> \ No newline at end of file diff --git a/application/models/Options_model.php b/application/models/Options_model.php index 1fe5a488..56c847b7 100644 --- a/application/models/Options_model.php +++ b/application/models/Options_model.php @@ -8,6 +8,11 @@ class Options_model extends CI_Model { + function __construct() + { + parent::__construct(); + } + // Returns all options that are autoload yes function get_autoloads() { $this->db->where('autoload', "yes"); diff --git a/application/models/Qsl_model.php b/application/models/Qsl_model.php index 613c3e5e..0e07bd4b 100644 --- a/application/models/Qsl_model.php +++ b/application/models/Qsl_model.php @@ -1,5 +1,12 @@ load->model('Stations'); diff --git a/application/models/Qslprint_model.php b/application/models/Qslprint_model.php index 321eeb0c..23177eb3 100644 --- a/application/models/Qslprint_model.php +++ b/application/models/Qslprint_model.php @@ -2,6 +2,11 @@ class Qslprint_model extends CI_Model { + function __construct() + { + parent::__construct(); + } + function mark_qsos_printed($station_id2 = NULL) { $CI =& get_instance(); $CI->load->model('Stations'); diff --git a/application/models/Search.php b/application/models/Search.php index a3becd21..1889e725 100644 --- a/application/models/Search.php +++ b/application/models/Search.php @@ -2,6 +2,11 @@ class Search extends CI_Model { + function __construct() + { + parent::__construct(); + } + function callsign_iota($reference) { $this->db->where('COL_IOTA', $reference); $query = $this->db->get($this->config->item('table_name')); diff --git a/application/models/Search_filter.php b/application/models/Search_filter.php index 96fa8eef..d6d4c835 100644 --- a/application/models/Search_filter.php +++ b/application/models/Search_filter.php @@ -2,6 +2,11 @@ class Search_filter extends CI_Model { + function __construct() + { + parent::__construct(); + } + function get_table_columns() { $query = $this->db->query('DESCRIBE '.$this->config->item('table_name')); diff --git a/application/models/Sig.php b/application/models/Sig.php index 35f8f850..50fc7c7b 100644 --- a/application/models/Sig.php +++ b/application/models/Sig.php @@ -2,28 +2,31 @@ class Sig extends CI_Model { + function __construct() + { + parent::__construct(); + } + function get_all($type) { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $this->db->where_in("station_id", $logbooks_locations_array); + $this->db->where("station_id", $station_id); $this->db->order_by("COL_SIG_INFO", "ASC"); $this->db->where('COL_SIG =', $type); - + return $this->db->get($this->config->item('table_name')); } function get_all_sig_types() { - $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)."'"; + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $sql = "select col_sig, count(*) qsos, count(distinct col_sig_info) refs from " . $this->config->item('table_name') . " where col_sig <> ''" . - " and station_id in (" . $location_list . ")" . + " and station_id = " . $station_id . " group by col_sig"; $query = $this->db->query($sql); @@ -34,4 +37,4 @@ class Sig extends CI_Model { } -?> +?> \ No newline at end of file diff --git a/application/models/Sota.php b/application/models/Sota.php index 6f8a8927..9cb885de 100644 --- a/application/models/Sota.php +++ b/application/models/Sota.php @@ -2,17 +2,22 @@ class Sota extends CI_Model { + function __construct() + { + parent::__construct(); + } + function get_all() { $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); - $this->db->where_in("station_id", $logbooks_locations_array); - $this->db->order_by("COL_SOTA_REF", "ASC"); + $this->db->where("station_id", $station_id); + $this->db->order_by("COL_SOTA_REF", "ASC"); $this->db->where('COL_SOTA_REF !=', ''); - + return $this->db->get($this->config->item('table_name')); } } -?> +?> \ No newline at end of file diff --git a/application/models/Stations.php b/application/models/Stations.php index 21e20f73..d179bb00 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -2,29 +2,25 @@ class Stations extends CI_Model { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + function all_with_count() { $this->db->select('station_profile.*, count('.$this->config->item('table_name').'.station_id) as qso_total'); $this->db->from('station_profile'); $this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id','left'); $this->db->group_by('station_profile.station_id'); - $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); - $this->db->or_where('station_profile.user_id =', NULL); - $this->db->order_by('station_profile.station_profile_name'); return $this->db->get(); } - // Returns ALL station profiles regardless of user logged in - // This is also used by LoTW sync so must not be changed. function all() { return $this->db->get('station_profile'); } - function all_of_user() { - $this->db->where('user_id', $this->session->userdata('user_id')); - return $this->db->get('station_profile'); - } - function profile($id) { // Clean ID $clean_id = $this->security->xss_clean($id); @@ -96,7 +92,6 @@ class Stations extends CI_Model { 'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)), ); - $this->db->where('user_id', $this->session->userdata('user_id')); $this->db->where('station_id', xss_clean($this->input->post('station_id', true))); $this->db->update('station_profile', $data); } @@ -119,76 +114,55 @@ class Stations extends CI_Model { $this->db->delete($this->config->item('table_name')); } - function claim_user($id) { - $data = array( - 'user_id' => $this->session->userdata('user_id'), - ); - - $this->db->where('station_id', $id); - $this->db->update('station_profile', $data); - } - function set_active($current, $new) { + // Clean inputs + $clean_current = $this->security->xss_clean($current); $clean_new = $this->security->xss_clean($new); - // be sure that stations belong to user - if ($clean_current != 0) { - if (!$this->check_station_is_accessible($clean_current)) { - return; - } - } - if (!$this->check_station_is_accessible($clean_new)) { - return; - } - - // Deselect current default + // Deselect current default $current_default = array( - 'station_active' => null, + 'station_active' => null, ); - $this->db->where('user_id', $this->session->userdata('user_id')); $this->db->where('station_id', $clean_current); $this->db->update('station_profile', $current_default); - + // Deselect current default $newdefault = array( 'station_active' => 1, ); - $this->db->where('user_id', $this->session->userdata('user_id')); $this->db->where('station_id', $clean_new); $this->db->update('station_profile', $newdefault); - } + } - public function find_active() { - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('station_active', 1); - $query = $this->db->get('station_profile'); - - if($query->num_rows() >= 1) { - foreach ($query->result() as $row) + public function find_active() { + $this->db->where('station_active', 1); + $query = $this->db->get('station_profile'); + + if($query->num_rows() >= 1) { + foreach ($query->result() as $row) { return $row->station_id; } - } else { + } else { return "0"; } } public function find_gridsquare() { - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('station_active', 1); - $query = $this->db->get('station_profile'); - - if($query->num_rows() >= 1) { - foreach ($query->result() as $row) + $this->db->where('station_active', 1); + $query = $this->db->get('station_profile'); + + if($query->num_rows() >= 1) { + foreach ($query->result() as $row) { return $row->station_gridsquare; } - } else { + } else { return "0"; } - } + } public function reassign($id) { // Clean ID @@ -288,16 +262,6 @@ class Stations extends CI_Model { return $query->num_rows(); } - public function check_station_is_accessible($id) { - // check if station belongs to user - $this->db->where('user_id', $this->session->userdata('user_id')); - $this->db->where('station_id', $id); - $query = $this->db->get('station_profile'); - if ($query->num_rows() == 1) { - return true; - } - return false; - } } ?> \ No newline at end of file diff --git a/application/models/Stats.php b/application/models/Stats.php index f839876c..0e4b922e 100644 --- a/application/models/Stats.php +++ b/application/models/Stats.php @@ -2,6 +2,11 @@ class Stats extends CI_Model { + function __construct() + { + parent::__construct(); + } + function result() { $this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME'); diff --git a/application/models/Themes_model.php b/application/models/Themes_model.php deleted file mode 100644 index 5db6f37a..00000000 --- a/application/models/Themes_model.php +++ /dev/null @@ -1,50 +0,0 @@ -db->query('SELECT * FROM themes order by name'); - - return $result->result(); - } - - function delete($id) { - // Clean ID - $clean_id = $this->security->xss_clean($id); - - // Delete Theme - $this->db->delete('themes', array('id' => $clean_id)); - } - - function add() { - $data = array( - 'name' => xss_clean($this->input->post('name', true)), - 'foldername' => xss_clean($this->input->post('foldername', true)), - ); - - $this->db->insert('themes', $data); - } - - - function theme($id) { - // Clean ID - $clean_id = $this->security->xss_clean($id); - - $sql = "SELECT * FROM themes where id =" . $clean_id; - - $data = $this->db->query($sql); - - return ($data->row()); - } - - function edit($id) { - $data = array( - 'name' => xss_clean($this->input->post('name', true)), - 'foldername' => xss_clean($this->input->post('foldername', true)), - ); - - $this->db->where('id', $id); - $this->db->update('themes', $data); - } -} diff --git a/application/models/Timeline_model.php b/application/models/Timeline_model.php index 73deed44..446c741f 100644 --- a/application/models/Timeline_model.php +++ b/application/models/Timeline_model.php @@ -3,28 +3,32 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class Timeline_model extends CI_Model { - function get_timeline($band, $mode, $award) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + function __construct() + { + // Call the Model constructor + parent::__construct(); + } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + function get_timeline($band, $mode, $award) { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); switch ($award) { - case 'dxcc': $result = $this->get_timeline_dxcc($band, $mode, $location_list); break; - case 'was': $result = $this->get_timeline_was($band, $mode, $location_list); break; - case 'iota': $result = $this->get_timeline_iota($band, $mode, $location_list); break; - case 'waz': $result = $this->get_timeline_waz($band, $mode, $location_list); break; + case 'dxcc': $result = $this->get_timeline_dxcc($band, $mode, $station_id); break; + case 'was': $result = $this->get_timeline_was($band, $mode, $station_id); break; + case 'iota': $result = $this->get_timeline_iota($band, $mode, $station_id); break; + case 'waz': $result = $this->get_timeline_waz($band, $mode, $station_id); break; } return $result; } - public function get_timeline_dxcc($band, $mode, $location_list) { + public function get_timeline_dxcc($band, $mode, $station_id) { $sql = "select min(date(COL_TIME_ON)) date, prefix, col_country, end, adif from " .$this->config->item('table_name'). " thcv join dxcc_entities on thcv.col_dxcc = dxcc_entities.adif - where station_id in (" . $location_list . ")"; + where station_id = " . $station_id; if ($band != 'All') { if ($band == 'SAT') { @@ -48,10 +52,10 @@ class Timeline_model extends CI_Model return $query->result(); } - public function get_timeline_was($band, $mode, $location_list) { + public function get_timeline_was($band, $mode, $station_id) { $sql = "select min(date(COL_TIME_ON)) date, col_state from " .$this->config->item('table_name'). " thcv - where station_id in (" . $location_list . ")"; + where station_id = " . $station_id; if ($band != 'All') { if ($band == 'SAT') { @@ -78,11 +82,11 @@ class Timeline_model extends CI_Model return $query->result(); } - public function get_timeline_iota($band, $mode, $location_list) { + public function get_timeline_iota($band, $mode, $station_id) { $sql = "select min(date(COL_TIME_ON)) date, col_iota, name, prefix from " .$this->config->item('table_name'). " thcv join iota on thcv.col_iota = iota.tag - where station_id in (" . $location_list . ")"; + where station_id = " . $station_id; if ($band != 'All') { if ($band == 'SAT') { @@ -106,10 +110,10 @@ class Timeline_model extends CI_Model return $query->result(); } - public function get_timeline_waz($band, $mode, $location_list) { + public function get_timeline_waz($band, $mode, $station_id) { $sql = "select min(date(COL_TIME_ON)) date, col_cqz from " .$this->config->item('table_name'). " thcv - where station_id in (" . $location_list . ")"; + where station_id = " . $station_id; if ($band != 'All') { if ($band == 'SAT') { @@ -132,5 +136,61 @@ class Timeline_model extends CI_Model return $query->result(); } - + + public $bandslots = array("160m" => 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 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; + } + } diff --git a/application/models/Timeplotter_model.php b/application/models/Timeplotter_model.php index fb411cb4..ae3f4669 100644 --- a/application/models/Timeplotter_model.php +++ b/application/models/Timeplotter_model.php @@ -3,11 +3,70 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class Timeplotter_model extends CI_Model { + 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(); + + $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; + } + + public $bandslots = array("160m" => 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 getTimes($postdata) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $this->db->select('time(col_time_on) time, col_call as callsign'); @@ -28,7 +87,7 @@ class Timeplotter_model extends CI_Model $this->db->where('col_cqz', $postdata['cqzone']); } - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('station_id', $station_id); $datearray = $this->db->get($this->config->item('table_name')); $this->plot($datearray->result_array()); } @@ -89,4 +148,4 @@ class Timeplotter_model extends CI_Model } } -} +} \ No newline at end of file diff --git a/application/models/User_model.php b/application/models/User_model.php index 6c1073bf..9c0d9732 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -13,6 +13,12 @@ class User_Model extends CI_Model { + function __construct() + { + // Call the Model constructor + parent::__construct(); + } + // FUNCTION: object get($username) // Retrieve a user function get($username) { @@ -277,7 +283,6 @@ class User_Model extends CI_Model { 'user_column3' => isset($u->row()->user_column3) ? $u->row()->user_column3: 'RSTR', 'user_column4' => isset($u->row()->user_column4) ? $u->row()->user_column4: 'Band', 'user_column5' => isset($u->row()->user_column5) ? $u->row()->user_column5: 'Country', - 'active_station_logbook' => $u->row()->active_station_logbook, ); $this->session->set_userdata($userdata); @@ -365,14 +370,6 @@ class User_Model extends CI_Model { return $ts; } - // FUNCTION: array getThemes() - // Returns a list of themes - function getThemes() { - $result = $this->db->query('SELECT * FROM themes order by name'); - - return $result->result(); - } - // FUNCTION: bool _auth($password, $hash) // Checks a password against the stored hash private function _auth($password, $hash) { diff --git a/application/models/Vucc.php b/application/models/Vucc.php index 536c3731..9e37ff3c 100644 --- a/application/models/Vucc.php +++ b/application/models/Vucc.php @@ -2,6 +2,69 @@ class VUCC extends CI_Model { + + public $bandslots = array("160m" => 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; + } /* * Fetches worked and confirmed gridsquare on each band and total */ @@ -96,15 +159,11 @@ class VUCC extends CI_Model * $confirmationMethod - qsl, lotw or both, use anything else to skip confirmed */ function get_vucc_summary_col_vucc($band, $confirmationMethod) { - $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)."'"; + $station_id = $this->get_station_id(); $sql = "select col_vucc_grids from " . $this->config->item('table_name') . - " where station_id in (" . $location_list . ")" . + " where station_id =" . $station_id . " and col_vucc_grids <> '' "; if ($confirmationMethod == 'both') { @@ -136,15 +195,10 @@ class VUCC extends CI_Model * $confirmationMethod - qsl, lotw or both, use anything else to skip confirmed */ function get_vucc_summary($band, $confirmationMethod) { - $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)."'"; - + $station_id = $this->get_station_id(); $sql = "select distinct upper(substring(col_gridsquare, 1, 4)) gridsquare from " . $this->config->item('table_name') . - " where station_id in (" . $location_list . ")" . + " where station_id =" . $station_id . " and col_gridsquare <> ''"; if ($confirmationMethod == 'both') { @@ -317,5 +371,11 @@ class VUCC extends CI_Model return $workedGridArray; } + + function get_station_id() { + $CI =& get_instance(); + $CI->load->model('Stations'); + return $CI->Stations->find_active(); + } } -?> +?> \ No newline at end of file diff --git a/application/models/Was.php b/application/models/Was.php index 99371ec2..0d98cdd3 100644 --- a/application/models/Was.php +++ b/application/models/Was.php @@ -4,12 +4,71 @@ class was extends CI_Model { public $stateString = 'AK,AL,AR,AZ,CA,CO,CT,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VA,VT,WA,WI,WV,WY'; - function get_was_array($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')); + public $bandslots = array("160m"=>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, + ); - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + 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_was_array($bands, $postdata) { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); $stateArray = explode(',', $this->stateString); @@ -26,14 +85,14 @@ class was extends CI_Model { } if ($postdata['worked'] != NULL) { - $wasBand = $this->getWasWorked($location_list, $band, $postdata); + $wasBand = $this->getWasWorked($station_id, $band, $postdata); foreach ($wasBand as $line) { $bandWas[$line->col_state][$band] = '
col_state . '","' . $band . '","'. $postdata['mode'] . '","WAS")\'>W
'; $states[$line->col_state]['count']++; } } if ($postdata['confirmed'] != NULL) { - $wasBand = $this->getWasConfirmed($location_list, $band, $postdata); + $wasBand = $this->getWasConfirmed($station_id, $band, $postdata); foreach ($wasBand as $line) { $bandWas[$line->col_state][$band] = '
col_state . '","' . $band . '","'. $postdata['mode'] . '","WAS")\'>C
'; $states[$line->col_state]['count']++; @@ -43,7 +102,7 @@ class was extends CI_Model { // We want to remove the worked states in the list, since we do not want to display them if ($postdata['worked'] == NULL) { - $wasBand = $this->getWasWorked($location_list, $postdata['band'], $postdata); + $wasBand = $this->getWasWorked($station_id, $postdata['band'], $postdata); foreach ($wasBand as $line) { unset($bandWas[$line->col_state]); } @@ -51,7 +110,7 @@ class was extends CI_Model { // We want to remove the confirmed states in the list, since we do not want to display them if ($postdata['confirmed'] == NULL) { - $wasBand = $this->getWasConfirmed($location_list, $postdata['band'], $postdata); + $wasBand = $this->getWasConfirmed($station_id, $postdata['band'], $postdata); foreach ($wasBand as $line) { unset($bandWas[$line->col_state]); } @@ -78,21 +137,19 @@ class was extends CI_Model { */ function get_was_summary($bands) { - $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)."'"; + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); foreach ($bands as $band) { - $worked = $this->getSummaryByBand($band, $location_list); - $confirmed = $this->getSummaryByBandConfirmed($band, $location_list); + $worked = $this->getSummaryByBand($band, $station_id); + $confirmed = $this->getSummaryByBandConfirmed($band, $station_id); $wasSummary['worked'][$band] = $worked[0]->count; $wasSummary['confirmed'][$band] = $confirmed[0]->count; } - $workedTotal = $this->getSummaryByBand('All', $location_list); - $confirmedTotal = $this->getSummaryByBandConfirmed('All', $location_list); + $workedTotal = $this->getSummaryByBand('All', $station_id); + $confirmedTotal = $this->getSummaryByBandConfirmed('All', $station_id); $wasSummary['worked']['Total'] = $workedTotal[0]->count; $wasSummary['confirmed']['Total'] = $confirmedTotal[0]->count; @@ -100,11 +157,11 @@ class was extends CI_Model { return $wasSummary; } - function getSummaryByBand($band, $location_list) + function getSummaryByBand($band, $station_id) { $sql = "SELECT count(distinct thcv.col_state) as count FROM " . $this->config->item('table_name') . " thcv"; - $sql .= " where station_id in (" . $location_list . ")"; + $sql .= " where station_id = " . $station_id; if ($band == 'SAT') { $sql .= " and thcv.col_prop_mode ='" . $band . "'"; @@ -122,11 +179,11 @@ class was extends CI_Model { return $query->result(); } - function getSummaryByBandConfirmed($band, $location_list) + function getSummaryByBandConfirmed($band, $station_id) { $sql = "SELECT count(distinct thcv.col_state) as count FROM " . $this->config->item('table_name') . " thcv"; - $sql .= " where station_id in (" . $location_list . ")"; + $sql .= " where station_id = " . $station_id; if ($band == 'SAT') { $sql .= " and thcv.col_prop_mode ='" . $band . "'"; @@ -150,9 +207,9 @@ class was extends CI_Model { * Function returns all worked, but not confirmed states * $postdata contains data from the form, in this case Lotw or QSL are used */ - function getWasWorked($location_list, $band, $postdata) { + function getWasWorked($station_id, $band, $postdata) { $sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv - where station_id in (" . $location_list . ")"; + where station_id = " . $station_id; if ($postdata['mode'] != 'All') { $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; @@ -163,7 +220,7 @@ class was extends CI_Model { $sql .= $this->addBandToQuery($band); $sql .= " and not exists (select 1 from ". $this->config->item('table_name') . - " where station_id in (". $location_list . ")" . + " where station_id = ". $station_id . " and col_state = thcv.col_state"; if ($postdata['mode'] != 'All') { @@ -187,9 +244,9 @@ class was extends CI_Model { * Function returns all confirmed states on given band and on LoTW or QSL * $postdata contains data from the form, in this case Lotw or QSL are used */ - function getWasConfirmed($location_list, $band, $postdata) { + function getWasConfirmed($station_id, $band, $postdata) { $sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv - where station_id in (" . $location_list . ")"; + where station_id = " . $station_id; if ($postdata['mode'] != 'All') { $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; diff --git a/application/views/dxatlas/index.php b/application/views/dxatlas/index.php deleted file mode 100644 index 7d7cad24..00000000 --- a/application/views/dxatlas/index.php +++ /dev/null @@ -1,137 +0,0 @@ -
-
-

- -
-
- Export your logbook for use in DX Atlas to display worked / confirmed gridsquares. -
- - - -
- -
-
-
- - -
-
- -
-
- - -
-
- - -
- -
- - -
- -
- - - -
-
- - -
- -
- - -
-
-
-
- -
- -
-
-
-
-
- -
- -
- -
-
-
-
-
-
-
- -
-
-
-
diff --git a/application/views/gridsquares/index.php b/application/views/gridsquares/index.php index 3b71cf5e..eec7fe51 100644 --- a/application/views/gridsquares/index.php +++ b/application/views/gridsquares/index.php @@ -26,13 +26,15 @@ uri->segment(2) == "satellites") { ?> uri->segment(2) == "band") { ?> diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 592930c0..cce1859f 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -404,8 +404,9 @@ $('[data-fancybox]').fancybox({ } }); -// Here we capture ALT-L to invoke the Quick lookup +// Here we capture ALT-L to invoice the Quick lookup document.onkeyup = function(e) { + // ALT-W wipe if (e.altKey && e.which == 76) { spawnLookupModal(); } @@ -2126,90 +2127,6 @@ function deleteQsl(id) { -uri->segment(1) == "themes") { ?> - - - -uri->segment(1) == "dxatlas") { ?> - - - - - uri->segment(1) == "qslprint") { ?> -
+