diff --git a/application/config/config.sample.php b/application/config/config.sample.php
index 1f596a03a..fd619c4ba 100644
--- a/application/config/config.sample.php
+++ b/application/config/config.sample.php
@@ -19,6 +19,8 @@ $config['directory'] = "logbook";
$config['callbook'] = "hamqth"; // Options are hamqth or qrz
+$config['datadir'] = null; // default to install directory
+
/*
|--------------------------------------------------------------------------
| Logbook Options
@@ -72,12 +74,9 @@ $config['hamqth_password'] = "";
$config['use_auth'] = true;
$config['auth_table'] = "users";
-$config['auth_mode'] = "0";
+$config['auth_mode'] = "3";
-$config['auth_level'][0] = "Anonymous";
-$config['auth_level'][1] = "Viewer";
-$config['auth_level'][2] = "Editor";
-$config['auth_level'][3] = "API User";
+$config['auth_level'][3] = "Operator";
$config['auth_level'][99] = "Administrator";
/*
diff --git a/application/config/migration.php b/application/config/migration.php
index 227bc690e..a875a2db3 100644
--- a/application/config/migration.php
+++ b/application/config/migration.php
@@ -21,7 +21,8 @@ $config['migration_enabled'] = TRUE;
| be upgraded / downgraded to.
|
*/
-$config['migration_version'] = 71;
+
+$config['migration_version'] = 79;
/*
|--------------------------------------------------------------------------
diff --git a/application/controllers/Accumulated.php b/application/controllers/Accumulated.php
index c299d4bf2..152d5abff 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('Accumulate_model');
+ $this->load->model('bands');
- $data['worked_bands'] = $this->Accumulate_model->get_worked_bands();
+ $data['worked_bands'] = $this->bands->get_worked_bands(); // Used in the view for band select
$this->load->model('modes');
diff --git a/application/controllers/Api.php b/application/controllers/Api.php
index 9e88e859d..022e10a9b 100644
--- a/application/controllers/Api.php
+++ b/application/controllers/Api.php
@@ -7,7 +7,6 @@ class API extends CI_Controller {
{
}
-
/*
TODOs
- Search Callsign (Return Json)
@@ -476,8 +475,10 @@ class API extends CI_Controller {
die();
}
+ $user_id = $this->api_model->key_userid($obj['key']);
+
// Store Result to Database
- $this->cat->update($obj);
+ $this->cat->update($obj, $user_id);
// Return Message
diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php
index 4fa7d2ecf..625a9ca65 100644
--- a/application/controllers/Awards.php
+++ b/application/controllers/Awards.php
@@ -27,10 +27,12 @@ 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->dok->get_worked_bands();
+
+ $data['worked_bands'] = $this->bands->get_worked_bands_dok(); // Used in the view for band select
// Render Page
$data['page_title'] = "Awards - DOK";
@@ -76,8 +78,9 @@ class Awards extends CI_Controller {
public function dxcc () {
$this->load->model('dxcc');
$this->load->model('modes');
+ $this->load->model('bands');
- $data['worked_bands'] = $this->dxcc->get_worked_bands(); // Used in the view for band 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
if ($this->input->post('band') != NULL) { // Band is not set when page first loads.
@@ -142,7 +145,8 @@ class Awards extends CI_Controller {
public function vucc() {
$this->load->model('vucc');
- $data['worked_bands'] = $this->vucc->get_worked_bands();
+ $this->load->model('bands');
+ $data['worked_bands'] = $this->bands->get_worked_bands();
$data['vucc_array'] = $this->vucc->get_vucc_array($data);
@@ -226,15 +230,18 @@ class Awards extends CI_Controller {
$this->load->view('interface_assets/footer');
}
- public function cq(){
+ public function cq() {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $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)."'";
$this->load->model('cq');
$this->load->model('modes');
+ $this->load->model('bands');
- $data['worked_bands'] = $this->cq->get_worked_bands($station_id);
+ $data['worked_bands'] = $this->bands->get_worked_bands($location_list);
$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.
@@ -270,8 +277,8 @@ class Awards extends CI_Controller {
$postdata['mode'] = 'All';
}
- $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);
+ $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);
// Render page
$data['page_title'] = "Awards - CQ Magazine";
@@ -283,8 +290,9 @@ class Awards extends CI_Controller {
public function was() {
$this->load->model('was');
$this->load->model('modes');
+ $this->load->model('bands');
- $data['worked_bands'] = $this->was->get_worked_bands();
+ $data['worked_bands'] = $this->bands->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.
@@ -333,8 +341,9 @@ class Awards extends CI_Controller {
public function iota () {
$this->load->model('iota');
$this->load->model('modes');
+ $this->load->model('bands');
- $data['worked_bands'] = $this->iota->get_worked_bands(); // Used in the view for band select
+ $data['worked_bands'] = $this->bands->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
@@ -475,7 +484,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 f539f572b..ce8238fe9 100644
--- a/application/controllers/Dashboard.php
+++ b/application/controllers/Dashboard.php
@@ -4,13 +4,24 @@ 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 8c1865f2f..812d548c5 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('Distances_model');
- $data['bands_available'] = $this->Distances_model->get_worked_bands();
- $data['sats_available'] = $this->Distances_model->get_worked_sats();
+ $this->load->model('bands');
+ $data['bands_available'] = $this->bands->get_worked_bands_distances();
+ $data['sats_available'] = $this->bands->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
new file mode 100644
index 000000000..cf290bd21
--- /dev/null
+++ b/application/controllers/Dxatlas.php
@@ -0,0 +1,122 @@
+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 9d0f27edf..b3126fe5b 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->dxcc->get_worked_bands(); // Used in the view for band 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
diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php
index fd3e96c66..cb051dc9c 100755
--- a/application/controllers/Logbook.php
+++ b/application/controllers/Logbook.php
@@ -17,19 +17,19 @@ class Logbook extends CI_Controller {
function index()
{
- $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');
- }
- }
+
+ // 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->library('pagination');
$config['base_url'] = base_url().'index.php/logbook/index/';
- $config['total_rows'] = $this->db->count_all($this->config->item('table_name'));
+ $config['total_rows'] = $this->logbook_model->total_qsos();
$config['per_page'] = '25';
$config['num_links'] = 6;
$config['full_tag_open'] = '';
@@ -40,7 +40,6 @@ 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
@@ -196,9 +195,8 @@ class Logbook extends CI_Controller {
return false;
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
-
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
@@ -208,7 +206,7 @@ class Logbook extends CI_Controller {
$this->db->where('COL_PROP_MODE !=','SAT');
}
- $this->db->where('station_id', $station_id);
+ $this->db->where_in('station_id', $logbooks_locations_array);
$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);
@@ -237,8 +235,8 @@ class Logbook extends CI_Controller {
];
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
@@ -249,7 +247,7 @@ class Logbook extends CI_Controller {
}
- $this->db->where('station_id', $station_id);
+ $this->db->where_in('station_id', $logbooks_locations_array);
$this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4));
$query = $this->db->get($this->config->item('table_name'), 1, 0);
@@ -271,8 +269,8 @@ class Logbook extends CI_Controller {
];
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
@@ -283,7 +281,7 @@ class Logbook extends CI_Controller {
}
- $this->db->where('station_id', $station_id);
+ $this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_COUNTRY', urldecode($country));
$query = $this->db->get($this->config->item('table_name'), 1, 0);
@@ -308,8 +306,8 @@ class Logbook extends CI_Controller {
];
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
@@ -320,7 +318,7 @@ class Logbook extends CI_Controller {
}
- $this->db->where('station_id', $station_id);
+ $this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_CALL', strtoupper($callsign));
$query = $this->db->get($this->config->item('table_name'), 1, 0);
@@ -704,5 +702,4 @@ class Logbook extends CI_Controller {
return $this->db->get();
}
-
}
diff --git a/application/controllers/Logbooks.php b/application/controllers/Logbooks.php
new file mode 100644
index 000000000..7b2c92504
--- /dev/null
+++ b/application/controllers/Logbooks.php
@@ -0,0 +1,119 @@
+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 587fb7da0..f935cb6db 100644
--- a/application/controllers/Lookup.php
+++ b/application/controllers/Lookup.php
@@ -28,12 +28,15 @@ class Lookup extends CI_Controller {
public function search() {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $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)."'";
$this->load->model('lookup_model');
+ $this->load->model('bands');
- $data['bands'] = $this->lookup_model->get_Worked_Bands($station_id);
+ $data['bands'] = $this->bands->get_worked_bands();
$data['type'] = xss_clean($this->input->post('type'));
$data['dxcc'] = xss_clean($this->input->post('dxcc'));
@@ -43,7 +46,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['station_id'] = $station_id;
+ $data['location_list'] = $location_list;
$data['result'] = $this->lookup_model->getSearchResult($data);
diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php
index 300870e9d..5dc2328f0 100644
--- a/application/controllers/Lotw.php
+++ b/application/controllers/Lotw.php
@@ -466,6 +466,7 @@ class Lotw extends CI_Controller {
$tableheaders .= "
LoTW QSL Received | ";
$tableheaders .= "Date LoTW Confirmed | ";
$tableheaders .= "State | ";
+ $tableheaders .= "Gridsquare | ";
$tableheaders .= "Log Status | ";
$tableheaders .= "LoTW Status | ";
$tableheaders .= "";
@@ -512,8 +513,15 @@ 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);
+
+ $lotw_status = $this->logbook_model->lotw_update($time_on, $record['call'], $record['band'], $qsl_date, $record['qsl_rcvd'], $state, $qsl_gridsquare);
}
@@ -525,6 +533,7 @@ 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 4abd750c9..bfb477678 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('dxcc');
- $this->load->model('modes');
+ $this->load->model('bands');
+ //$this->load->model('modes');
- $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['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
- 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";
}
- $this->load->model('Stations');
- $station_id = $this->Stations->find_active();
- $station_data = $this->Stations->profile_clean($station_id);
+ $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;
// load the view
- $data['station_profile'] = $station_data;
+ $data['logbook_name'] = $logbook_name;
$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,7 +93,6 @@ 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);
@@ -105,7 +104,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);
@@ -120,7 +119,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."\"}";
@@ -134,7 +133,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) {
@@ -154,12 +153,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'));
@@ -175,7 +174,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."\"}";
@@ -189,7 +188,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) {
@@ -206,4 +205,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 45c7478a6..be8b83ef2 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,6 +41,10 @@ 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');
@@ -101,10 +105,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 245fc1a9a..c852bd14a 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();
+ $data['stations'] = $this->stations->all_of_user();
$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 d8c958382..2a2a5709b 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'] = "Radio Interface";
+ $data['page_title'] = "Hardware Interfaces";
$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 e59b44dd1..35ce839a8 100644
--- a/application/controllers/Station.php
+++ b/application/controllers/Station.php
@@ -97,6 +97,17 @@ 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
new file mode 100644
index 000000000..2420e6896
--- /dev/null
+++ b/application/controllers/Themes.php
@@ -0,0 +1,89 @@
+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 879df97b9..873215564 100644
--- a/application/controllers/Timeline.php
+++ b/application/controllers/Timeline.php
@@ -40,11 +40,12 @@ 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->Timeline_model->get_worked_bands();
+ $data['worked_bands'] = $this->bands->get_worked_bands();
$data['bandselect'] = $band;
$data['modeselect'] = $mode;
diff --git a/application/controllers/Timeplotter.php b/application/controllers/Timeplotter.php
index 0857e5123..42d3aa841 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('Timeplotter_model');
+ $this->load->model('bands');
- $data['worked_bands'] = $this->Timeplotter_model->get_worked_bands();
+ $data['worked_bands'] = $this->bands->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 f77f22d84..06ba2aae4 100644
--- a/application/controllers/Update.php
+++ b/application/controllers/Update.php
@@ -17,6 +17,19 @@ 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
*/
@@ -25,7 +38,7 @@ class Update extends CI_Controller {
$this->load->model('dxcc_entities');
// Load the cty file
- $xml_data = simplexml_load_file("updates/cty.xml");
+ $xml_data = simplexml_load_file($this->make_update_path("cty.xml"));
//$xml_data->entities->entity->count();
@@ -74,7 +87,7 @@ class Update extends CI_Controller {
// Load Database connectors
$this->load->model('dxcc_exceptions');
// Load the cty file
- $xml_data = simplexml_load_file("updates/cty.xml");
+ $xml_data = simplexml_load_file($this->make_update_path("cty.xml"));
$count = 0;
foreach ($xml_data->exceptions->exception as $record) {
@@ -114,7 +127,7 @@ class Update extends CI_Controller {
// Load Database connectors
$this->load->model('dxcc_prefixes');
// Load the cty file
- $xml_data = simplexml_load_file("updates/cty.xml");
+ $xml_data = simplexml_load_file($this->make_update_path("cty.xml"));
$count = 0;
foreach ($xml_data->prefixes->prefix as $record) {
@@ -169,8 +182,8 @@ class Update extends CI_Controller {
$data .= gzgetc($gz);
}
gzclose($gz);
-
- file_put_contents('./updates/cty.xml', $data);
+
+ file_put_contents($this->make_update_path("cty.xml"), $data);
// Clear the tables, ready for new data
$this->db->empty_table("dxcc_entities");
@@ -203,7 +216,7 @@ class Update extends CI_Controller {
$html = $done."....
";
}
- file_put_contents('./updates/status.html', $html);
+ file_put_contents($this->make_update_path("status.html"), $html);
}
@@ -231,7 +244,7 @@ class Update extends CI_Controller {
}
public function update_clublog_scp() {
- $strFile = "./updates/clublog_scp.txt";
+ $strFile = $this->make_update_path("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 976ea38e9..7652f6c11 100644
--- a/application/controllers/User.php
+++ b/application/controllers/User.php
@@ -42,6 +42,9 @@ 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();
@@ -158,6 +161,9 @@ 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();
@@ -453,7 +459,7 @@ class User extends CI_Controller {
if ($this->form_validation->run() == FALSE)
{
$data['page_title'] = "Login";
- $this->load->view('interface_assets/header', $data);
+ $this->load->view('interface_assets/mini_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 a1f90889b..7b439c836 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
new file mode 100644
index 000000000..452ec50b8
--- /dev/null
+++ b/application/migrations/072_create_station_logbook_table.php
@@ -0,0 +1,54 @@
+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
new file mode 100644
index 000000000..8f487af03
--- /dev/null
+++ b/application/migrations/073_create_station_logbook_relationship_table.php
@@ -0,0 +1,56 @@
+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
new file mode 100644
index 000000000..7a2c51610
--- /dev/null
+++ b/application/migrations/074_add_userid_to_station_profiles.php
@@ -0,0 +1,22 @@
+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
new file mode 100644
index 000000000..89967405b
--- /dev/null
+++ b/application/migrations/075_add_active_station_logbook_to_user_table.php
@@ -0,0 +1,27 @@
+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
new file mode 100644
index 000000000..15ae9047b
--- /dev/null
+++ b/application/migrations/076_theme_table.php
@@ -0,0 +1,22 @@
+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
new file mode 100644
index 000000000..e15f30439
--- /dev/null
+++ b/application/migrations/077_add_userid_to_notes.php
@@ -0,0 +1,21 @@
+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
new file mode 100644
index 000000000..9edb4fd42
--- /dev/null
+++ b/application/migrations/078_add_userid_to_hardware.php
@@ -0,0 +1,22 @@
+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
new file mode 100644
index 000000000..0947b9214
--- /dev/null
+++ b/application/migrations/079_add_userid_to_api.php
@@ -0,0 +1,21 @@
+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 72c1b1329..bf959cf60 100644
--- a/application/models/Accumulate_model.php
+++ b/application/models/Accumulate_model.php
@@ -3,39 +3,35 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
class Accumulate_model extends CI_Model
{
- function __construct()
- {
- // Call the Model constructor
- parent::__construct();
- }
-
function get_accumulated_data($band, $award, $mode, $period) {
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
switch ($award) {
- 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;
+ 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;
}
return $result;
}
- function get_accumulated_dxcc($band, $mode, $period, $station_id) {
+ function get_accumulated_dxcc($band, $mode, $period, $location_list) {
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 = ". $station_id;
+ " as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")";
}
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 = ". $station_id;
+ " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")";
}
if ($band != 'All') {
@@ -48,11 +44,11 @@ class Accumulate_model extends CI_Model
}
if ($mode != 'All') {
- $sql .= " and col_mode ='" . $mode . "'";
+ $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
}
- $sql .=") total from " . $this->config->item('table_name') . " as a
- where a.station_id = ". $station_id;
+ $sql .=" and b.col_dxcc > 0) total from " . $this->config->item('table_name') . " as a
+ where a.station_id in (". $location_list . ")";
if ($band != 'All') {
if ($band == 'SAT') {
@@ -64,15 +60,17 @@ class Accumulate_model extends CI_Model
}
if ($mode != 'All') {
- $sql .= " and col_mode ='" . $mode . "'";
+ $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $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')";
}
@@ -81,18 +79,18 @@ class Accumulate_model extends CI_Model
return $query->result();
}
- function get_accumulated_was($band, $mode, $period, $station_id) {
+ function get_accumulated_was($band, $mode, $period, $location_list) {
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 = ". $station_id;
+ " as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")";
}
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 = ". $station_id;
+ " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")";
}
if ($band != 'All') {
@@ -105,14 +103,14 @@ class Accumulate_model extends CI_Model
}
if ($mode != 'All') {
- $sql .= " and col_mode ='" . $mode . "'";
+ $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $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 = ". $station_id;
+ where a.station_id in (". $location_list . ")";
if ($band != 'All') {
if ($band == 'SAT') {
@@ -124,18 +122,18 @@ class Accumulate_model extends CI_Model
}
if ($mode != 'All') {
- $sql .= " and col_mode ='" . $mode . "'";
+ $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $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')";
}
@@ -144,18 +142,18 @@ class Accumulate_model extends CI_Model
return $query->result();
}
- function get_accumulated_iota($band, $mode, $period, $station_id) {
+ function get_accumulated_iota($band, $mode, $period, $location_list) {
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 = ". $station_id;
+ " as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")";
}
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 = ". $station_id;
+ " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")";
}
if ($band != 'All') {
@@ -168,11 +166,11 @@ class Accumulate_model extends CI_Model
}
if ($mode != 'All') {
- $sql .= " and col_mode ='" . $mode . "'";
+ $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
}
$sql .=") total from " . $this->config->item('table_name') . " as a
- where a.station_id = ". $station_id;
+ where a.station_id in (". $location_list . ")";
if ($band != 'All') {
if ($band == 'SAT') {
@@ -184,15 +182,15 @@ class Accumulate_model extends CI_Model
}
if ($mode != 'All') {
- $sql .= " and col_mode ='" . $mode . "'";
+ $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $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')";
}
@@ -201,18 +199,18 @@ class Accumulate_model extends CI_Model
return $query->result();
}
- function get_accumulated_waz($band, $mode, $period, $station_id) {
+ function get_accumulated_waz($band, $mode, $period, $location_list) {
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 = ". $station_id;
+ " as b where year(col_time_on) <= year and b.station_id in (". $location_list . ")";
}
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 = ". $station_id;
+ " as b where date_format(col_time_on, '%Y%m') <= year and b.station_id in (". $location_list . ")";
}
if ($band != 'All') {
@@ -225,11 +223,11 @@ class Accumulate_model extends CI_Model
}
if ($mode != 'All') {
- $sql .= " and col_mode ='" . $mode . "'";
+ $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
}
$sql .=") total from " . $this->config->item('table_name') . " as a
- where a.station_id = ". $station_id;
+ where a.station_id in (". $location_list . ")";
if ($band != 'All') {
if ($band == 'SAT') {
@@ -241,15 +239,15 @@ class Accumulate_model extends CI_Model
}
if ($mode != 'All') {
- $sql .= " and col_mode ='" . $mode . "'";
+ $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $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')";
}
@@ -257,58 +255,4 @@ 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 deaa9ea4b..40bfacef1 100644
--- a/application/models/Adif_data.php
+++ b/application/models/Adif_data.php
@@ -2,12 +2,6 @@
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();
@@ -128,12 +122,13 @@ class adif_data extends CI_Model {
}
function sig_all($type) {
- $this->load->model('stations');
- $active_station_id = $this->stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$this->db->select(''.$this->config->item('table_name').'.*, station_profile.*');
$this->db->from($this->config->item('table_name'));
- $this->db->where($this->config->item('table_name').'.station_id', $active_station_id);
+ $this->db->where_in($this->config->item('table_name').'.station_id', $logbooks_locations_array);
$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 f5c9e417e..747e1d470 100644
--- a/application/models/Api_model.php
+++ b/application/models/Api_model.php
@@ -8,37 +8,39 @@
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('key', $key);
+ $this->db->where('user_id', $this->session->userdata('user_id'));
+ $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") {
@@ -93,35 +95,38 @@ 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";
- $this->db->insert('api', $data);
+ $data['user_id'] = $this->session->userdata('user_id');
+
+ $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)
@@ -334,7 +339,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
new file mode 100644
index 000000000..15abef552
--- /dev/null
+++ b/application/models/Bands.php
@@ -0,0 +1,145 @@
+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('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 2f92b788c..bf68541db 100644
--- a/application/models/Cat.php
+++ b/application/models/Cat.php
@@ -2,17 +2,12 @@
class Cat extends CI_Model {
- function __construct()
- {
- // Call the Model constructor
- parent::__construct();
- }
+ function update($result, $user_id) {
- function update($result) {
-
- $this->db->where('radio', $result['radio']);
+ $this->db->where('radio', $result['radio']);
+ $this->db->where('user_id', $user_id);
$query = $this->db->get('cat');
-
+
if ($query->num_rows() > 0)
{
if($result['radio'] == "SatPC32") {
@@ -20,7 +15,7 @@
foreach ($query->result() as $row)
{
$radio_id = $row->id;
-
+
$data = array(
'sat_name' => $result['sat_name'],
'downlink_freq' => $result['downlink_freq'],
@@ -30,14 +25,15 @@
);
$this->db->where('id', $radio_id);
- $this->db->update('cat', $data);
+ $this->db->where('user_id', $user_id);
+ $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'],
@@ -45,12 +41,13 @@
);
$this->db->where('id', $radio_id);
- $this->db->update('cat', $data);
+ $this->db->where('user_id', $this->session->userdata('user_id'));
+ $this->db->update('cat', $data);
}
}
} else {
// Add a new record
-
+
if($result['radio'] == "SatPC32") {
$data = array(
'radio' => $result['radio'],
@@ -61,6 +58,7 @@
'uplink_freq' => $result['uplink_freq'],
'downlink_mode' => $result['downlink_mode'],
'uplink_mode' => $result['uplink_mode'],
+ 'user_id' => $user_id,
);
} else {
$data = array(
@@ -68,23 +66,25 @@
'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('radio', $result['radio']);
+ $this->db->where('user_id', $this->session->userdata('user_id'));
$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,27 +94,23 @@
/* 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) {
-
- return $this->db->query('SELECT *, CONVERT_TZ(`timestamp`, @@session.time_zone, \'+00:00\' ) as newtime FROM `cat` WHERE id = '.$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);
}
-
function delete($id) {
$this->db->where('id', $id);
- $this->db->delete('cat');
-
+ $this->db->where('user_id', $this->session->userdata('user_id'));
+ $this->db->delete('cat');
+
return true;
}
-
-
-
}
?>
diff --git a/application/models/Clublog_model.php b/application/models/Clublog_model.php
index acd2ee6ca..f6c386886 100644
--- a/application/models/Clublog_model.php
+++ b/application/models/Clublog_model.php
@@ -2,11 +2,6 @@
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 2486b7bdd..79918db1d 100644
--- a/application/models/Contesting_model.php
+++ b/application/models/Contesting_model.php
@@ -1,11 +1,5 @@
get_station_id();
+ $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 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 =" . $station_id .
+ " where station_id in (" . $location_list . ")" .
" and COL_DXCC in ('291', '6', '110')
and coalesce(COL_CNTY, '') <> ''
and COL_BAND != 'SAT'
@@ -43,7 +42,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 =" . $station_id .
+ where station_id in (" . $location_list . ")" .
" and COL_DXCC in ('291', '6', '110')
and coalesce(COL_CNTY, '') <> ''
and COL_BAND != 'SAT'
@@ -54,12 +53,6 @@ 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
*/
@@ -78,11 +71,15 @@ class Counties extends CI_Model
}
function get_counties($state, $confirmationtype) {
- $station_id = $this->get_station_id();
+ $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 COL_CNTY, COL_STATE
from " . $this->config->item('table_name') . " thcv
- where station_id =" . $station_id .
+ where station_id in (" . $location_list . ")" .
" 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 c22735a08..6ebdb2b80 100644
--- a/application/models/Cq.php
+++ b/application/models/Cq.php
@@ -2,11 +2,6 @@
class CQ extends CI_Model{
- function __construct(){
- // Call the Model constructor
- parent::__construct();
- }
-
function get_zones(){
$CI =& get_instance();
$CI->load->model('Stations');
@@ -22,59 +17,7 @@ class CQ extends CI_Model{
return $data->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($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) {
+ function get_cq_array($bands, $postdata, $location_list) {
$cqZ = array(); // Used for keeping track of which states that are not worked
for ($i = 1; $i <= 40; $i++) {
@@ -87,14 +30,14 @@ class CQ extends CI_Model{
}
if ($postdata['worked'] != NULL) {
- $cqBand = $this->getCQWorked($station_id, $band, $postdata);
+ $cqBand = $this->getCQWorked($location_list, $band, $postdata);
foreach ($cqBand as $line) {
$bandCq[$line->col_cqz][$band] = '';
$cqZ[$line->col_cqz]['count']++;
}
}
if ($postdata['confirmed'] != NULL) {
- $cqBand = $this->getCQConfirmed($station_id, $band, $postdata);
+ $cqBand = $this->getCQConfirmed($location_list, $band, $postdata);
foreach ($cqBand as $line) {
$bandCq[$line->col_cqz][$band] = '';
$cqZ[$line->col_cqz]['count']++;
@@ -104,7 +47,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($station_id, $postdata['band'], $postdata);
+ $cqBand = $this->getCQWorked($location_list, $postdata['band'], $postdata);
foreach ($cqBand as $line) {
unset($bandCq[$line->col_cqz]);
}
@@ -112,7 +55,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($station_id, $postdata['band'], $postdata);
+ $cqBand = $this->getCQConfirmed($location_list, $postdata['band'], $postdata);
foreach ($cqBand as $line) {
unset($bandCq[$line->col_cqz]);
}
@@ -137,9 +80,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($station_id, $band, $postdata) {
+ function getCQWorked($location_list, $band, $postdata) {
$sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv
- where station_id = " . $station_id . " and col_cqz <> ''";
+ where station_id in (" . $location_list . ") and col_cqz <> ''";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
@@ -148,8 +91,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 = " . $station_id .
- " and col_cqz = thcv.col_cqz and col_cqz <> '' ";
+ " where station_id in (" . $location_list .
+ ") and col_cqz = thcv.col_cqz and col_cqz <> '' ";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
@@ -170,9 +113,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($station_id, $band, $postdata) {
+ function getCQConfirmed($location_list, $band, $postdata) {
$sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv
- where station_id = " . $station_id . " and col_cqz <> ''";
+ where station_id in (" . $location_list . ") and col_cqz <> ''";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
@@ -219,16 +162,16 @@ class CQ extends CI_Model{
/*
* Function gets worked and confirmed summary on each band on the active stationprofile
*/
- function get_cq_summary($bands, $station_id) {
+ function get_cq_summary($bands, $location_list) {
foreach ($bands as $band) {
- $worked = $this->getSummaryByBand($band, $station_id);
- $confirmed = $this->getSummaryByBandConfirmed($band, $station_id);
+ $worked = $this->getSummaryByBand($band, $location_list);
+ $confirmed = $this->getSummaryByBandConfirmed($band, $location_list);
$cqSummary['worked'][$band] = $worked[0]->count;
$cqSummary['confirmed'][$band] = $confirmed[0]->count;
}
- $workedTotal = $this->getSummaryByBand('All', $station_id);
- $confirmedTotal = $this->getSummaryByBandConfirmed('All', $station_id);
+ $workedTotal = $this->getSummaryByBand('All', $location_list);
+ $confirmedTotal = $this->getSummaryByBandConfirmed('All', $location_list);
$cqSummary['worked']['Total'] = $workedTotal[0]->count;
$cqSummary['confirmed']['Total'] = $confirmedTotal[0]->count;
@@ -236,10 +179,10 @@ class CQ extends CI_Model{
return $cqSummary;
}
- function getSummaryByBand($band, $station_id) {
+ function getSummaryByBand($band, $location_list) {
$sql = "SELECT count(distinct thcv.col_cqz) as count FROM " . $this->config->item('table_name') . " thcv";
- $sql .= " where station_id = " . $station_id . ' and col_cqz > 0';
+ $sql .= " where station_id in (" . $location_list . ') and col_cqz > 0';
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
@@ -255,10 +198,10 @@ class CQ extends CI_Model{
return $query->result();
}
- function getSummaryByBandConfirmed($band, $station_id){
+ function getSummaryByBandConfirmed($band, $location_list){
$sql = "SELECT count(distinct thcv.col_cqz) as count FROM " . $this->config->item('table_name') . " thcv";
- $sql .= " where station_id = " . $station_id . ' and col_cqz > 0';
+ $sql .= " where station_id in (" . $location_list . ') 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 1690a602d..75c2ac1ec 100644
--- a/application/models/Dayswithqso_model.php
+++ b/application/models/Dayswithqso_model.php
@@ -3,21 +3,17 @@ 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('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
$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 = " . $station_id . " and COL_TIME_ON is not null group by year";
+ where station_id in (" . $location_list . ") and COL_TIME_ON is not null group by year";
$query = $this->db->query($sql);
@@ -150,17 +146,19 @@ class Dayswithqso_model extends CI_Model
* Returns all distinct dates from db on active profile
*/
function getDates() {
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = "select distinct cast(col_time_on as date) as date from "
.$this->config->item('table_name'). " thcv
- where station_id = " . $station_id . " order by date asc";
+ where station_id in (" . $location_list . ") 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 2fc2ea25b..1e73e538a 100644
--- a/application/models/Distances_model.php
+++ b/application/models/Distances_model.php
@@ -3,101 +3,96 @@ 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('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
+ $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('col_call callsign, col_gridsquare grid');
- $this->db->where('LENGTH(col_gridsquare) >', 0);
+ $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.'));
+ }
- 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
@@ -138,17 +133,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' => '',
- 'Qsoes' => '',
+ 'Qsos' => '',
'Grids' => ''
);
-
+
foreach ($qsoArray as $qso) {
- $qrb['Qsoes']++; // Counts up number of qsoes
+ $qrb['Qsos']++; // Counts up number of qsos
$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
@@ -156,7 +151,7 @@ class Distances_model extends CI_Model
$qrb['Callsign'] = $qso['callsign'];
$qrb['Grid'] = $qso['grid'];
}
- $dataarray[$arrayplacement]['count']++; // Used for counting total qsoes plotted
+ $dataarray[$arrayplacement]['count']++; // Used for counting total qsos 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'] .= ', ';
@@ -165,19 +160,13 @@ class Distances_model extends CI_Model
$dataarray[$arrayplacement]['callcount']++;
}
}
-
- 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.'));
- }
+
+ $data['ok'] = 'OK';
+ $data['qrb'] = $qrb;
+ $data['qsodata'] = $dataarray;
+ $data['unit'] = $unit;
+
+ return $data;
}
}
@@ -225,7 +214,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';
@@ -239,8 +228,6 @@ 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);
@@ -252,4 +239,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 2a9653e58..333e87c68 100644
--- a/application/models/Dok.php
+++ b/application/models/Dok.php
@@ -2,66 +2,18 @@
class DOK 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);
-
- function __construct()
- {
- // Call the Model constructor
- parent::__construct();
- }
-
- function get_worked_bands() {
+ function show_stats() {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- // 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);
- }
+ $this->load->model('bands');
-
- // 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();
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
$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 = ".$station_id." AND COL_DARC_DOK IS NOT NULL AND COL_DARC_DOK != '' AND COL_DXCC = 230
+ 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
group by COL_DARC_DOK, COL_MODE, COL_BAND"
);
@@ -70,20 +22,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->bandslots;
+ $results[$row->COL_DARC_DOK] = $this->bands->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
new file mode 100644
index 000000000..d6dea3d7a
--- /dev/null
+++ b/application/models/Dxatlas_model.php
@@ -0,0 +1,166 @@
+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 54112070d..24cf79e6d 100644
--- a/application/models/Dxcc.php
+++ b/application/models/Dxcc.php
@@ -2,133 +2,6 @@
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
@@ -169,7 +42,7 @@ class DXCC extends CI_Model {
}
/*
- * Fethes a list of all dxcc's, both current and deleted
+ * Fetches a list of all dxcc's, both current and deleted
*/
function list() {
$this->db->order_by('name', 'ASC');
@@ -187,8 +60,10 @@ class DXCC extends CI_Model {
function get_dxcc_array($dxccArray, $bands, $postdata) {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
foreach ($bands as $band) { // Looping through bands and entities to generate the array needed for display
foreach ($dxccArray as $dxcc) {
@@ -201,7 +76,7 @@ class DXCC extends CI_Model {
// If worked is checked, we add worked entities to the array
if ($postdata['worked'] != NULL) {
- $workedDXCC = $this->getDxccBandWorked($station_id, $band, $postdata);
+ $workedDXCC = $this->getDxccBandWorked($location_list, $band, $postdata);
foreach ($workedDXCC as $wdxcc) {
//function displayContacts(searchphrase, band, mode, type) {
$dxccMatrix[$wdxcc->dxcc][$band] = '';
@@ -210,7 +85,7 @@ class DXCC extends CI_Model {
// If confirmed is checked, we add confirmed entities to the array
if ($postdata['confirmed'] != NULL) {
- $confirmedDXCC = $this->getDxccBandConfirmed($station_id, $band, $postdata);
+ $confirmedDXCC = $this->getDxccBandConfirmed($location_list, $band, $postdata);
foreach ($confirmedDXCC as $cdxcc) {
$dxccMatrix[$cdxcc->dxcc][$band] = '';
}
@@ -219,7 +94,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($station_id, $postdata);
+ $workedDxcc = $this->getDxccWorked($location_list, $postdata);
foreach ($workedDxcc as $wdxcc) {
if (array_key_exists($wdxcc->dxcc, $dxccMatrix)) {
unset($dxccMatrix[$wdxcc->dxcc]);
@@ -229,7 +104,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($station_id, $postdata);
+ $confirmedDxcc = $this->getDxccConfirmed($location_list, $postdata);
foreach ($confirmedDxcc as $cdxcc) {
if (array_key_exists($cdxcc->dxcc, $dxccMatrix)) {
unset($dxccMatrix[$cdxcc->dxcc]);
@@ -245,12 +120,12 @@ class DXCC extends CI_Model {
}
}
- function getDxccBandConfirmed($station_id, $band, $postdata) {
+ function getDxccBandConfirmed($location_list, $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 = " . $station_id .
- " and col_dxcc > 0";
+ where station_id in (" . $location_list .
+ ") and col_dxcc > 0";
if ($band == 'SAT') {
$sql .= " and col_prop_mode ='" . $band . "'";
@@ -280,12 +155,12 @@ class DXCC extends CI_Model {
return $query->result();
}
- function getDxccBandWorked($station_id, $band, $postdata) {
+ function getDxccBandWorked($location_list, $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 = " . $station_id .
- " and col_dxcc > 0";
+ where station_id in (" . $location_list .
+ ") and col_dxcc > 0";
if ($band == 'SAT') {
$sql .= " and col_prop_mode ='" . $band . "'";
@@ -315,14 +190,16 @@ class DXCC extends CI_Model {
function fetchDxcc($postdata) {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $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 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 = " . $station_id . " and col_dxcc > 0";
+ $sql .= " join (select col_dxcc from " . $this->config->item('table_name') . " where station_id in (" . $location_list . ") and col_dxcc > 0";
if ($postdata['band'] != 'All') {
if ($postdata['band'] == 'SAT') {
@@ -355,13 +232,13 @@ class DXCC extends CI_Model {
return $query->result();
}
- function getDxccWorked($station_id, $postdata) {
+ function getDxccWorked($location_list, $postdata) {
$sql = "SELECT adif as dxcc FROM dxcc_entities
join (
select col_dxcc
from ".$this->config->item('table_name')." thcv
- where station_id = " . $station_id .
- " and col_dxcc > 0";
+ where station_id in (" . $location_list .
+ ") and col_dxcc > 0";
if ($postdata['band'] != 'All') {
if ($postdata['band'] == 'SAT') {
@@ -377,7 +254,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 = $station_id 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 in (". $location_list .") and col_dxcc = thcv.col_dxcc and col_dxcc > 0";
if ($postdata['band'] != 'All') {
if ($postdata['band'] == 'SAT') {
@@ -412,13 +289,13 @@ class DXCC extends CI_Model {
return $query->result();
}
- function getDxccConfirmed($station_id, $postdata) {
+ function getDxccConfirmed($location_list, $postdata) {
$sql = "SELECT adif as dxcc FROM dxcc_entities
join (
select col_dxcc
from ".$this->config->item('table_name')." thcv
- where station_id = ". $station_id .
- " and col_dxcc > 0";
+ where station_id in (". $location_list .
+ ") and col_dxcc > 0";
if ($postdata['band'] != 'All') {
if ($postdata['band'] == 'SAT') {
@@ -507,18 +384,20 @@ class DXCC extends CI_Model {
function get_dxcc_summary($bands)
{
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
foreach ($bands as $band) {
- $worked = $this->getSummaryByBand($band, $station_id);
- $confirmed = $this->getSummaryByBandConfirmed($band, $station_id);
+ $worked = $this->getSummaryByBand($band, $location_list);
+ $confirmed = $this->getSummaryByBandConfirmed($band, $location_list);
$dxccSummary['worked'][$band] = $worked[0]->count;
$dxccSummary['confirmed'][$band] = $confirmed[0]->count;
}
- $workedTotal = $this->getSummaryByBand('All', $station_id);
- $confirmedTotal = $this->getSummaryByBandConfirmed('All', $station_id);
+ $workedTotal = $this->getSummaryByBand('All', $location_list);
+ $confirmedTotal = $this->getSummaryByBandConfirmed('All', $location_list);
$dxccSummary['worked']['Total'] = $workedTotal[0]->count;
$dxccSummary['confirmed']['Total'] = $confirmedTotal[0]->count;
@@ -526,11 +405,11 @@ class DXCC extends CI_Model {
return $dxccSummary;
}
- function getSummaryByBand($band, $station_id)
+ function getSummaryByBand($band, $location_list)
{
$sql = "SELECT count(distinct thcv.col_dxcc) as count FROM " . $this->config->item('table_name') . " thcv";
- $sql .= " where station_id = " . $station_id . " and col_dxcc > 0";
+ $sql .= " where station_id in (" . $location_list . ") and col_dxcc > 0";
if ($band == 'SAT') {
@@ -546,11 +425,11 @@ class DXCC extends CI_Model {
return $query->result();
}
- function getSummaryByBandConfirmed($band, $station_id)
+ function getSummaryByBandConfirmed($band, $location_list)
{
$sql = "SELECT count(distinct thcv.col_dxcc) as count FROM " . $this->config->item('table_name') . " thcv";
- $sql .= " where station_id = " . $station_id;
+ $sql .= " where station_id in (" . $location_list . ")";
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
diff --git a/application/models/Dxcc_entities.php b/application/models/Dxcc_entities.php
index c4e5d944c..f7bba0fa3 100644
--- a/application/models/Dxcc_entities.php
+++ b/application/models/Dxcc_entities.php
@@ -17,11 +17,6 @@ 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 164426d67..c22e7603b 100644
--- a/application/models/Dxcc_exceptions.php
+++ b/application/models/Dxcc_exceptions.php
@@ -18,14 +18,7 @@ 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 99a021b63..3b790e590 100644
--- a/application/models/Dxcc_prefixes.php
+++ b/application/models/Dxcc_prefixes.php
@@ -16,14 +16,7 @@ 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 0e4674ccd..88137b01b 100644
--- a/application/models/Eqsl_images.php
+++ b/application/models/Eqsl_images.php
@@ -2,11 +2,6 @@
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 539be9e37..9030d1f36 100644
--- a/application/models/Eqslmethods_model.php
+++ b/application/models/Eqslmethods_model.php
@@ -2,11 +2,6 @@
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 a173da5dc..42914aad8 100644
--- a/application/models/Gridsquares_model.php
+++ b/application/models/Gridsquares_model.php
@@ -2,46 +2,55 @@
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('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- $this->db->where("station_id", $station_id);
+ $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 !=', '');
- 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 != ""');
+ 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);
}
- function get_confirmed_sat_squares() {
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ 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'));
- 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")');
- }
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
- function get_confirmed_sat_vucc_squares() {
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $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")';
- 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")');
- }
+ return $this->db->query($sql);
+ }
function get_worked_sat_vucc_squares() {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- $this->db->select('COL_PRIMARY_KEY, COL_VUCC_GRIDS, COL_SAT_NAME');
- $this->db->where("station_id", $station_id);
+ $this->db->select('COL_PRIMARY_KEY, COL_VUCC_GRIDS, COL_SAT_NAME', FALSE);
+ $this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_VUCC_GRIDS !=', "");
$this->db->where('COL_SAT_NAME !=', "");
return $this->db->get($this->config->item('table_name'));
@@ -49,59 +58,62 @@ class Gridsquares_model extends CI_Model {
function get_band($band) {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $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 !=', '');
- $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
- .'"
+ $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
+ .'"
AND COL_PROP_MODE != "SAT"
AND COL_PROP_MODE != "INTERNET"
AND COL_PROP_MODE != "ECH"
AND COL_PROP_MODE != "RPT"
AND COL_SAT_NAME = ""';
- }
+ }
- return $this->db->query($sql);
- }
+ $sql .= ' AND (COL_LOTW_QSL_RCVD = "Y" OR COL_QSL_RCVD = "Y")';
- 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);
- }
+ return $this->db->query($sql);
+ }
function search_band($band, $gridsquare) {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $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 COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_GRIDSQUARE, COL_VUCC_GRIDS FROM '
.$this->config->item('table_name')
- .' WHERE station_id = "' . $station_id . '" '
+ .' WHERE station_id IN (' . $location_list . ') '
. ' AND (COL_GRIDSQUARE LIKE "%'.$gridsquare.'%" or COL_VUCC_GRIDS LIKE "%'.$gridsquare.'%")';
if ($band != 'All') {
@@ -122,12 +134,14 @@ class Gridsquares_model extends CI_Model {
function search_sat($gridsquare) {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $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 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 = "'.$station_id. '"' .
+ ' WHERE station_id IN ('.$location_list. ')' .
' 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 d46c279d9..98b31fb43 100644
--- a/application/models/Iota.php
+++ b/application/models/Iota.php
@@ -2,71 +2,12 @@
class IOTA 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 get_iota_array($iotaArray, $bands, $postdata) {
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
foreach ($bands as $band) { // Looping through bands and iota to generate the array needed for display
foreach ($iotaArray as $iota) {
@@ -79,7 +20,7 @@ class IOTA extends CI_Model {
// If worked is checked, we add worked iotas to the array
if ($postdata['worked'] != NULL) {
- $workedIota = $this->getIotaBandWorked($station_id, $band, $postdata);
+ $workedIota = $this->getIotaBandWorked($location_list, $band, $postdata);
foreach ($workedIota as $wiota) {
$iotaMatrix[$wiota->tag][$band] = '';
}
@@ -87,7 +28,7 @@ class IOTA extends CI_Model {
// If confirmed is checked, we add confirmed iotas to the array
if ($postdata['confirmed'] != NULL) {
- $confirmedIota = $this->getIotaBandConfirmed($station_id, $band, $postdata);
+ $confirmedIota = $this->getIotaBandConfirmed($location_list, $band, $postdata);
foreach ($confirmedIota as $ciota) {
$iotaMatrix[$ciota->tag][$band] = '';
}
@@ -96,7 +37,7 @@ class IOTA extends CI_Model {
// We want to remove the worked iotas in the list, since we do not want to display them
if ($postdata['worked'] == NULL) {
- $workedIota = $this->getIotaWorked($station_id, $postdata);
+ $workedIota = $this->getIotaWorked($location_list, $postdata);
foreach ($workedIota as $wiota) {
if (array_key_exists($wiota->tag, $iotaMatrix)) {
unset($iotaMatrix[$wiota->tag]);
@@ -106,7 +47,7 @@ class IOTA extends CI_Model {
// We want to remove the confirmed iotas in the list, since we do not want to display them
if ($postdata['confirmed'] == NULL) {
- $confirmedIOTA = $this->getIotaConfirmed($station_id, $postdata);
+ $confirmedIOTA = $this->getIotaConfirmed($location_list, $postdata);
foreach ($confirmedIOTA as $ciota) {
if (array_key_exists($ciota->tag, $iotaMatrix)) {
unset($iotaMatrix[$ciota->tag]);
@@ -122,11 +63,11 @@ class IOTA extends CI_Model {
}
}
- function getIotaBandConfirmed($station_id, $band, $postdata) {
+ function getIotaBandConfirmed($location_list, $band, $postdata) {
$sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv
join iota on thcv.col_iota = iota.tag
- where station_id = " . $station_id .
- " and thcv.col_iota is not null
+ where station_id in (" . $location_list .
+ ") and thcv.col_iota is not null
and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
if ($postdata['mode'] != 'All') {
@@ -152,11 +93,11 @@ class IOTA extends CI_Model {
return $query->result();
}
- function getIotaBandWorked($station_id, $band, $postdata) {
+ function getIotaBandWorked($location_list, $band, $postdata) {
$sql = 'SELECT distinct col_iota as tag FROM ' . $this->config->item('table_name'). ' thcv
join iota on thcv.col_iota = iota.tag
- where station_id = ' . $station_id .
- ' and thcv.col_iota is not null';
+ where station_id in (' . $location_list .
+ ') and thcv.col_iota is not null';
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
@@ -182,10 +123,6 @@ class IOTA extends CI_Model {
}
function fetchIota($postdata) {
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
-
$sql = "select tag, name, prefix, dxccid, status from iota where 1=1";
if ($postdata['includedeleted'] == NULL) {
@@ -195,7 +132,7 @@ class IOTA extends CI_Model {
$sql .= $this->addContinentsToQuery($postdata);
if ($postdata['notworked'] == NULL) {
- $sql .= " and exists (select 1 from " . $this->config->item('table_name') . " where station_id = ". $station_id . " and col_iota = iota.tag";
+ $sql .= " and exists (select 1 from " . $this->config->item('table_name') . " where station_id in (". $location_list . ") and col_iota = iota.tag";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
@@ -219,12 +156,12 @@ class IOTA extends CI_Model {
return $query->result();
}
- function getIotaWorked($station_id, $postdata) {
+ function getIotaWorked($location_list, $postdata) {
$sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv
join iota on thcv.col_iota = iota.tag
- where station_id = " . $station_id .
- " and thcv.col_iota is not null
- and not exists (select 1 from ". $this->config->item('table_name') . " where station_id = ". $station_id .
+ where station_id in (" . $location_list .
+ ") and thcv.col_iota is not null
+ and not exists (select 1 from ". $this->config->item('table_name') . " where station_id = ". $location_list .
" and col_iota = thcv.col_iota";
if ($postdata['mode'] != 'All') {
@@ -268,11 +205,11 @@ class IOTA extends CI_Model {
return $query->result();
}
- function getIotaConfirmed($station_id, $postdata) {
+ function getIotaConfirmed($location_list, $postdata) {
$sql = "SELECT distinct col_iota as tag FROM " . $this->config->item('table_name') . " thcv
join iota on thcv.col_iota = iota.tag
- where station_id = " . $station_id .
- " and thcv.col_iota is not null
+ where station_id in (" . $location_list .
+ ") and thcv.col_iota is not null
and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
if ($postdata['mode'] != 'All') {
@@ -338,19 +275,21 @@ class IOTA extends CI_Model {
*/
function get_iota_summary($bands)
{
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
foreach ($bands as $band) {
- $worked = $this->getSummaryByBand($band, $station_id);
- $confirmed = $this->getSummaryByBandConfirmed($band, $station_id);
+ $worked = $this->getSummaryByBand($band, $location_list);
+ $confirmed = $this->getSummaryByBandConfirmed($band, $location_list);
$iotaSummary['worked'][$band] = $worked[0]->count;
$iotaSummary['confirmed'][$band] = $confirmed[0]->count;
}
- $workedTotal = $this->getSummaryByBand('All', $station_id);
- $confirmedTotal = $this->getSummaryByBandConfirmed('All', $station_id);
+ $workedTotal = $this->getSummaryByBand('All', $location_list);
+ $confirmedTotal = $this->getSummaryByBandConfirmed('All', $location_list);
$iotaSummary['worked']['Total'] = $workedTotal[0]->count;
$iotaSummary['confirmed']['Total'] = $confirmedTotal[0]->count;
@@ -358,11 +297,11 @@ class IOTA extends CI_Model {
return $iotaSummary;
}
- function getSummaryByBand($band, $station_id)
+ function getSummaryByBand($band, $location_list)
{
$sql = "SELECT count(distinct thcv.col_iota) as count FROM " . $this->config->item('table_name') . " thcv";
- $sql .= " where station_id = " . $station_id;
+ $sql .= " where station_id in (" . $location_list . ")";
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
@@ -378,11 +317,11 @@ class IOTA extends CI_Model {
return $query->result();
}
- function getSummaryByBandConfirmed($band, $station_id)
+ function getSummaryByBandConfirmed($band, $location_list)
{
$sql = "SELECT count(distinct thcv.col_iota) as count FROM " . $this->config->item('table_name') . " thcv";
- $sql .= " where station_id = " . $station_id;
+ $sql .= " where station_id in (" . $location_list . ")";
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php
index b52a7a791..08701ebd7 100755
--- a/application/models/Logbook_model.php
+++ b/application/models/Logbook_model.php
@@ -2,12 +2,6 @@
class Logbook_model extends CI_Model {
- function __construct()
- {
- // Call the Model constructor
- parent::__construct();
- }
-
/* Add QSO to Logbook */
function create_qso() {
// Join date+time
@@ -236,8 +230,8 @@ class Logbook_model extends CI_Model {
*/
public function qso_details($searchphrase, $band, $mode, $type){
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
switch ($type) {
case 'DXCC':
@@ -268,7 +262,7 @@ class Logbook_model extends CI_Model {
break;
}
- $this->db->where('station_id', $station_id);
+ $this->db->where_in('station_id', $logbooks_locations_array);
if ($band != 'All') {
if($band != "SAT") {
@@ -287,11 +281,14 @@ class Logbook_model extends CI_Model {
}
public function vucc_qso_details($gridsquare, $band) {
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
+
$sql = "select * from " . $this->config->item('table_name') .
- " where station_id =" . $station_id .
+ " where station_id in (" . $location_list . ")" .
" and (col_gridsquare like '" . $gridsquare. "%'
or col_vucc_grids like '%" . $gridsquare. "%')";
@@ -308,9 +305,9 @@ class Logbook_model extends CI_Model {
}
public function timeline_qso_details($querystring, $band, $mode, $type){
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if ($band != 'All') {
if ($band == 'SAT') {
@@ -325,7 +322,7 @@ class Logbook_model extends CI_Model {
$this->db->where('col_mode', $mode);
}
- $this->db->where('station_id', $station_id);
+ $this->db->where_in('station_id', $logbooks_locations_array);
switch($type) {
case 'dxcc': $this->db->where('COL_DXCC', $querystring); break;
@@ -462,8 +459,16 @@ 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');
@@ -538,11 +543,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' => $this->input->post('station_profile'),
+ 'station_id' => $stationId,
'COL_OPERATOR' => $this->input->post('operator_callsign'),
'COL_STATE' =>$this->input->post('usa_state'),
'COL_CNTY' => $uscounty
@@ -825,10 +830,15 @@ 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);
@@ -897,16 +907,21 @@ class Logbook_model extends CI_Model {
function get_last_qsos($num) {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- //$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'));
+ 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;
+ }
- return $query;
}
/* Get all QSOs with a valid grid for use in the KML export */
@@ -979,64 +994,80 @@ class Logbook_model extends CI_Model {
function totals_year() {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $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'));
- $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('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.'');
+ 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'));
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('Stations');
- $station_id = $CI->Stations->find_active();
-
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+ if ($logbooks_locations_array) {
$morning = date('Y-m-d 00:00:00');
$night = date('Y-m-d 23:59:59');
- $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.'\'');
+
+ $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'));
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('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'");
- $this->db->where("station_id", $station_id);
+ $this->db->where_in('station_id', $logbooks_locations_array);
$this->db->order_by("COL_TIME_ON", "ASC");
$query = $this->db->get($this->config->item('table_name'));
@@ -1045,13 +1076,12 @@ 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('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'");
- $this->db->where("station_id", $station_id);
-
+ $this->db->where_in("station_id", $logbooks_locations_array);
if($band != "All" && $band != "SAT") {
$this->db->where("COL_BAND", $band);
@@ -1070,14 +1100,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('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$start = $date." 00:00:00";
$end = $date." 23:59:59";
$this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'");
- $this->db->where("station_id", $station_id);
+ $this->db->where_in('station_id', $logbooks_locations_array);
$this->db->order_by("COL_TIME_ON", "ASC");
$query = $this->db->get($this->config->item('table_name'));
@@ -1088,8 +1118,10 @@ class Logbook_model extends CI_Model {
function month_qsos() {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ if ($logbooks_locations_array) {
$morning = date('Y-m-01 00:00:00');
@@ -1098,7 +1130,11 @@ class Logbook_model extends CI_Model {
$night = $date->format('Y-m-d')." 23:59:59";
- $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.'\'');
+ $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'));
if ($query->num_rows() > 0)
{
@@ -1107,6 +1143,9 @@ class Logbook_model extends CI_Model {
return $row->count;
}
}
+ } else {
+ return null;
+ }
}
/* Return QSOs for the year for the active profile */
@@ -1127,12 +1166,19 @@ class Logbook_model extends CI_Model {
function year_qsos() {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ if ($logbooks_locations_array) {
$morning = date('Y-01-01 00:00:00');
$night = date('Y-12-31 23:59:59');
- $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.'\'');
+
+ $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'));
if ($query->num_rows() > 0)
{
@@ -1141,16 +1187,25 @@ 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('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- $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\'');
+ $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'));
if ($query->num_rows() > 0)
{
@@ -1164,11 +1219,15 @@ class Logbook_model extends CI_Model {
/* Return total number of satellite QSOs */
function total_sat() {
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- $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');
+ $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'));
return $query;
}
@@ -1177,10 +1236,13 @@ class Logbook_model extends CI_Model {
function total_cw() {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.' AND COL_MODE = \'CW\' ');
+ $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'));
if ($query->num_rows() > 0)
{
@@ -1195,10 +1257,13 @@ class Logbook_model extends CI_Model {
function total_fm() {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE station_id = '.$station_id.' AND COL_MODE = \'FM\'');
+ $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'));
if ($query->num_rows() > 0)
{
@@ -1213,10 +1278,19 @@ class Logbook_model extends CI_Model {
function total_digi() {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- $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\'');
+ $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'));
if ($query->num_rows() > 0)
{
@@ -1235,14 +1309,18 @@ 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'));
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $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');
- $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');
+ $query = $this->db->get($this->config->item('table_name'));
- return $query;
+ return $query;
}
/* Return total number of QSL Cards sent */
@@ -1430,28 +1508,49 @@ class Logbook_model extends CI_Model {
}
}
- function lotw_update($datetime, $callsign, $band, $qsl_date, $qsl_status, $state) {
+ function lotw_update($datetime, $callsign, $band, $qsl_date, $qsl_status, $state, $qsl_gridsquare) {
- 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'
- );
- }
+ $data = array(
+ 'COL_LOTW_QSLRDATE' => $qsl_date,
+ 'COL_LOTW_QSL_RCVD' => $qsl_status,
+ 'COL_LOTW_QSL_SENT' => 'Y'
+ );
+ if($state != "") {
+ $data['COL_STATE'] = $state;
+ }
$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";
}
@@ -2152,8 +2251,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');
@@ -2501,11 +2600,11 @@ class Logbook_model extends CI_Model {
}
function county_qso_details($state, $county) {
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- $this->db->where('station_id', $station_id);
+ $this->db->where_in('station_id', $logbooks_locations_array);
$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
new file mode 100644
index 000000000..423566676
--- /dev/null
+++ b/application/models/Logbooks_model.php
@@ -0,0 +1,188 @@
+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 28d0e2399..d87747a88 100644
--- a/application/models/Lookup_model.php
+++ b/application/models/Lookup_model.php
@@ -2,13 +2,8 @@
class Lookup_model extends CI_Model{
- function __construct(){
- // Call the Model constructor
- parent::__construct();
- }
-
function getSearchResult($queryinfo){
- $modes = $this->get_worked_modes($queryinfo['station_id']);
+ $modes = $this->get_worked_modes($queryinfo['location_list']);
return $this->getResultFromDatabase($queryinfo, $modes);
}
@@ -54,7 +49,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;
@@ -70,7 +65,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 = " . $queryinfo['station_id'];
+ $sql .= " where station_id in (" . $queryinfo['location_list'] . ")";
$sql .= " and coalesce(col_submode, '') = ''";
@@ -83,7 +78,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 = " . $queryinfo['station_id'];
+ $sql .= " where station_id in (" . $queryinfo['location_list'] . ")";
$sql .= " and coalesce(col_submode, '') <> ''";
@@ -96,7 +91,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 = " . $queryinfo['station_id'];
+ $sql .= " where station_id in (" . $queryinfo['location_list'] . ")";
$sql .= " and coalesce(col_submode, '') = ''";
@@ -109,7 +104,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 = " . $queryinfo['station_id'];
+ $sql .= " where station_id in (" . $queryinfo['location_list'] . ")";
$sql .= " and coalesce(col_submode, '') <> ''";
@@ -124,69 +119,14 @@ 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($station_id)
+ function get_worked_modes($location_list)
{
// 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 = " . $station_id . " order by COL_MODE ASC"
+ "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"
);
$results = array();
foreach ($data->result() as $row) {
@@ -194,7 +134,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 = " . $station_id . " 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 in (" . $location_list . ") 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 c0c6c1229..af2a6a953 100644
--- a/application/models/LotwCert.php
+++ b/application/models/LotwCert.php
@@ -2,12 +2,6 @@
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 531c43ad7..66f40ac9b 100644
--- a/application/models/Modes.php
+++ b/application/models/Modes.php
@@ -2,12 +2,6 @@
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 3ccdbefa6..0390bd156 100644
--- a/application/models/Note.php
+++ b/application/models/Note.php
@@ -2,13 +2,8 @@
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');
}
@@ -16,10 +11,11 @@ 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'))
+ 'note' => xss_clean($this->input->post('content')),
+ 'user_id' => $this->session->userdata('user_id')
);
- $this->db->insert('notes', $data);
+ $this->db->insert('notes', $data);
}
function edit() {
@@ -30,19 +26,21 @@ class Note extends CI_Model {
);
$this->db->where('id', xss_clean($this->input->post('id')));
- $this->db->update('notes', $data);
+ $this->db->where('user_id', $this->session->userdata('user_id'));
+ $this->db->update('notes', $data);
}
function delete($id) {
- $this->db->delete('notes', array('id' => xss_clean($id)));
+ $this->db->delete('notes', array('id' => xss_clean($id), 'user_id' =>$this->session->userdata('user_id')));
}
function view($id) {
// Get Note
- $this->db->where('id', xss_clean($id));
+ $this->db->where('id', xss_clean($id));
+ $this->db->where('user_id', $this->session->userdata('user_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 56c847b7d..1fe5a488e 100644
--- a/application/models/Options_model.php
+++ b/application/models/Options_model.php
@@ -8,11 +8,6 @@
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 0e07bd4bf..613c3e5e1 100644
--- a/application/models/Qsl_model.php
+++ b/application/models/Qsl_model.php
@@ -1,12 +1,5 @@
load->model('Stations');
diff --git a/application/models/Qslprint_model.php b/application/models/Qslprint_model.php
index 23177eb3b..321eeb0c0 100644
--- a/application/models/Qslprint_model.php
+++ b/application/models/Qslprint_model.php
@@ -2,11 +2,6 @@
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 1889e7259..a3becd210 100644
--- a/application/models/Search.php
+++ b/application/models/Search.php
@@ -2,11 +2,6 @@
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 d6d4c835d..96fa8eef2 100644
--- a/application/models/Search_filter.php
+++ b/application/models/Search_filter.php
@@ -2,11 +2,6 @@
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 50fc7c7bd..35f8f850d 100644
--- a/application/models/Sig.php
+++ b/application/models/Sig.php
@@ -2,31 +2,28 @@
class Sig extends CI_Model {
- function __construct()
- {
- parent::__construct();
- }
-
function get_all($type) {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- $this->db->where("station_id", $station_id);
+ $this->db->where_in("station_id", $logbooks_locations_array);
$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('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = "select col_sig, count(*) qsos, count(distinct col_sig_info) refs from " . $this->config->item('table_name') .
" where col_sig <> ''" .
- " and station_id = " . $station_id .
+ " and station_id in (" . $location_list . ")" .
" group by col_sig";
$query = $this->db->query($sql);
@@ -37,4 +34,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 9cb885de5..6f8a8927c 100644
--- a/application/models/Sota.php
+++ b/application/models/Sota.php
@@ -2,22 +2,17 @@
class Sota extends CI_Model {
- function __construct()
- {
- parent::__construct();
- }
-
function get_all() {
$CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
- $this->db->where("station_id", $station_id);
- $this->db->order_by("COL_SOTA_REF", "ASC");
+ $this->db->where_in("station_id", $logbooks_locations_array);
+ $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 d179bb00b..21e20f73f 100644
--- a/application/models/Stations.php
+++ b/application/models/Stations.php
@@ -2,25 +2,29 @@
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);
@@ -92,6 +96,7 @@ 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);
}
@@ -114,55 +119,76 @@ 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);
- // Deselect current default
+ // 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
$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('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('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)
{
return $row->station_id;
}
- } else {
+ } else {
return "0";
}
}
public function find_gridsquare() {
- $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('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)
{
return $row->station_gridsquare;
}
- } else {
+ } else {
return "0";
}
- }
+ }
public function reassign($id) {
// Clean ID
@@ -262,6 +288,16 @@ 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 0e4b922e2..f839876cb 100644
--- a/application/models/Stats.php
+++ b/application/models/Stats.php
@@ -2,11 +2,6 @@
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
new file mode 100644
index 000000000..5db6f37a6
--- /dev/null
+++ b/application/models/Themes_model.php
@@ -0,0 +1,50 @@
+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 446c741f0..73deed449 100644
--- a/application/models/Timeline_model.php
+++ b/application/models/Timeline_model.php
@@ -3,32 +3,28 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
class Timeline_model extends CI_Model
{
- function __construct()
- {
- // Call the Model constructor
- parent::__construct();
- }
-
function get_timeline($band, $mode, $award) {
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
switch ($award) {
- 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;
+ 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;
}
return $result;
}
- public function get_timeline_dxcc($band, $mode, $station_id) {
+ public function get_timeline_dxcc($band, $mode, $location_list) {
$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 = " . $station_id;
+ where station_id in (" . $location_list . ")";
if ($band != 'All') {
if ($band == 'SAT') {
@@ -52,10 +48,10 @@ class Timeline_model extends CI_Model
return $query->result();
}
- public function get_timeline_was($band, $mode, $station_id) {
+ public function get_timeline_was($band, $mode, $location_list) {
$sql = "select min(date(COL_TIME_ON)) date, col_state from "
.$this->config->item('table_name'). " thcv
- where station_id = " . $station_id;
+ where station_id in (" . $location_list . ")";
if ($band != 'All') {
if ($band == 'SAT') {
@@ -82,11 +78,11 @@ class Timeline_model extends CI_Model
return $query->result();
}
- public function get_timeline_iota($band, $mode, $station_id) {
+ public function get_timeline_iota($band, $mode, $location_list) {
$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 = " . $station_id;
+ where station_id in (" . $location_list . ")";
if ($band != 'All') {
if ($band == 'SAT') {
@@ -110,10 +106,10 @@ class Timeline_model extends CI_Model
return $query->result();
}
- public function get_timeline_waz($band, $mode, $station_id) {
+ public function get_timeline_waz($band, $mode, $location_list) {
$sql = "select min(date(COL_TIME_ON)) date, col_cqz from "
.$this->config->item('table_name'). " thcv
- where station_id = " . $station_id;
+ where station_id in (" . $location_list . ")";
if ($band != 'All') {
if ($band == 'SAT') {
@@ -136,61 +132,5 @@ 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 ae3f46698..fb411cb43 100644
--- a/application/models/Timeplotter_model.php
+++ b/application/models/Timeplotter_model.php
@@ -3,70 +3,11 @@ 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('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$this->db->select('time(col_time_on) time, col_call as callsign');
@@ -87,7 +28,7 @@ class Timeplotter_model extends CI_Model
$this->db->where('col_cqz', $postdata['cqzone']);
}
- $this->db->where('station_id', $station_id);
+ $this->db->where_in('station_id', $logbooks_locations_array);
$datearray = $this->db->get($this->config->item('table_name'));
$this->plot($datearray->result_array());
}
@@ -148,4 +89,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 9c0d9732d..6c1073bf6 100644
--- a/application/models/User_model.php
+++ b/application/models/User_model.php
@@ -13,12 +13,6 @@
class User_Model extends CI_Model {
- function __construct()
- {
- // Call the Model constructor
- parent::__construct();
- }
-
// FUNCTION: object get($username)
// Retrieve a user
function get($username) {
@@ -283,6 +277,7 @@ 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);
@@ -370,6 +365,14 @@ 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 9e37ff3cb..536c3731f 100644
--- a/application/models/Vucc.php
+++ b/application/models/Vucc.php
@@ -2,69 +2,6 @@
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
*/
@@ -159,11 +96,15 @@ class VUCC extends CI_Model
* $confirmationMethod - qsl, lotw or both, use anything else to skip confirmed
*/
function get_vucc_summary_col_vucc($band, $confirmationMethod) {
- $station_id = $this->get_station_id();
+ $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 col_vucc_grids
from " . $this->config->item('table_name') .
- " where station_id =" . $station_id .
+ " where station_id in (" . $location_list . ")" .
" and col_vucc_grids <> '' ";
if ($confirmationMethod == 'both') {
@@ -195,10 +136,15 @@ class VUCC extends CI_Model
* $confirmationMethod - qsl, lotw or both, use anything else to skip confirmed
*/
function get_vucc_summary($band, $confirmationMethod) {
- $station_id = $this->get_station_id();
+ $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 upper(substring(col_gridsquare, 1, 4)) gridsquare
from " . $this->config->item('table_name') .
- " where station_id =" . $station_id .
+ " where station_id in (" . $location_list . ")" .
" and col_gridsquare <> ''";
if ($confirmationMethod == 'both') {
@@ -371,11 +317,5 @@ 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 0d98cdd39..99371ec24 100644
--- a/application/models/Was.php
+++ b/application/models/Was.php
@@ -4,71 +4,12 @@ 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';
- 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 get_was_array($bands, $postdata) {
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
$stateArray = explode(',', $this->stateString);
@@ -85,14 +26,14 @@ class was extends CI_Model {
}
if ($postdata['worked'] != NULL) {
- $wasBand = $this->getWasWorked($station_id, $band, $postdata);
+ $wasBand = $this->getWasWorked($location_list, $band, $postdata);
foreach ($wasBand as $line) {
$bandWas[$line->col_state][$band] = '';
$states[$line->col_state]['count']++;
}
}
if ($postdata['confirmed'] != NULL) {
- $wasBand = $this->getWasConfirmed($station_id, $band, $postdata);
+ $wasBand = $this->getWasConfirmed($location_list, $band, $postdata);
foreach ($wasBand as $line) {
$bandWas[$line->col_state][$band] = '';
$states[$line->col_state]['count']++;
@@ -102,7 +43,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($station_id, $postdata['band'], $postdata);
+ $wasBand = $this->getWasWorked($location_list, $postdata['band'], $postdata);
foreach ($wasBand as $line) {
unset($bandWas[$line->col_state]);
}
@@ -110,7 +51,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($station_id, $postdata['band'], $postdata);
+ $wasBand = $this->getWasConfirmed($location_list, $postdata['band'], $postdata);
foreach ($wasBand as $line) {
unset($bandWas[$line->col_state]);
}
@@ -137,19 +78,21 @@ class was extends CI_Model {
*/
function get_was_summary($bands)
{
- $CI =& get_instance();
- $CI->load->model('Stations');
- $station_id = $CI->Stations->find_active();
+ $CI =& get_instance();
+ $CI->load->model('logbooks_model');
+ $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
foreach ($bands as $band) {
- $worked = $this->getSummaryByBand($band, $station_id);
- $confirmed = $this->getSummaryByBandConfirmed($band, $station_id);
+ $worked = $this->getSummaryByBand($band, $location_list);
+ $confirmed = $this->getSummaryByBandConfirmed($band, $location_list);
$wasSummary['worked'][$band] = $worked[0]->count;
$wasSummary['confirmed'][$band] = $confirmed[0]->count;
}
- $workedTotal = $this->getSummaryByBand('All', $station_id);
- $confirmedTotal = $this->getSummaryByBandConfirmed('All', $station_id);
+ $workedTotal = $this->getSummaryByBand('All', $location_list);
+ $confirmedTotal = $this->getSummaryByBandConfirmed('All', $location_list);
$wasSummary['worked']['Total'] = $workedTotal[0]->count;
$wasSummary['confirmed']['Total'] = $confirmedTotal[0]->count;
@@ -157,11 +100,11 @@ class was extends CI_Model {
return $wasSummary;
}
- function getSummaryByBand($band, $station_id)
+ function getSummaryByBand($band, $location_list)
{
$sql = "SELECT count(distinct thcv.col_state) as count FROM " . $this->config->item('table_name') . " thcv";
- $sql .= " where station_id = " . $station_id;
+ $sql .= " where station_id in (" . $location_list . ")";
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
@@ -179,11 +122,11 @@ class was extends CI_Model {
return $query->result();
}
- function getSummaryByBandConfirmed($band, $station_id)
+ function getSummaryByBandConfirmed($band, $location_list)
{
$sql = "SELECT count(distinct thcv.col_state) as count FROM " . $this->config->item('table_name') . " thcv";
- $sql .= " where station_id = " . $station_id;
+ $sql .= " where station_id in (" . $location_list . ")";
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
@@ -207,9 +150,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($station_id, $band, $postdata) {
+ function getWasWorked($location_list, $band, $postdata) {
$sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv
- where station_id = " . $station_id;
+ where station_id in (" . $location_list . ")";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
@@ -220,7 +163,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 = ". $station_id .
+ " where station_id in (". $location_list . ")" .
" and col_state = thcv.col_state";
if ($postdata['mode'] != 'All') {
@@ -244,9 +187,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($station_id, $band, $postdata) {
+ function getWasConfirmed($location_list, $band, $postdata) {
$sql = "SELECT distinct col_state FROM " . $this->config->item('table_name') . " thcv
- where station_id = " . $station_id;
+ where station_id in (" . $location_list . ")";
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
new file mode 100644
index 000000000..7d7cad24f
--- /dev/null
+++ b/application/views/dxatlas/index.php
@@ -0,0 +1,137 @@
+
+
+
+
+
+
+
+
+ Only QSOs with a gridsquare defined will be exported!
+
+
+
+
+
diff --git a/application/views/gridsquares/index.php b/application/views/gridsquares/index.php
index eec7fe519..3b71cf5e2 100644
--- a/application/views/gridsquares/index.php
+++ b/application/views/gridsquares/index.php
@@ -26,15 +26,13 @@
uri->segment(2) == "satellites") { ?>
Confirmed is Green | Worked but not confirmed is Red
- [This grid square map is publically viewable for sharing]
uri->segment(2) == "band") { ?>
Confirmed is Green | Worked but not confirmed is Red
- [This map does not include satellite, internet or repeater QSOs]
- [This grid square map is publically viewable for sharing]
+ [This map does not include satellite, internet or repeater QSOs]
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php
index cce1859f6..592930c09 100644
--- a/application/views/interface_assets/footer.php
+++ b/application/views/interface_assets/footer.php
@@ -404,9 +404,8 @@ $('[data-fancybox]').fancybox({
}
});
-// Here we capture ALT-L to invoice the Quick lookup
+// Here we capture ALT-L to invoke the Quick lookup
document.onkeyup = function(e) {
- // ALT-W wipe
if (e.altKey && e.which == 76) {
spawnLookupModal();
}
@@ -2127,6 +2126,90 @@ function deleteQsl(id) {
+uri->segment(1) == "themes") { ?>
+
+
+
+uri->segment(1) == "dxatlas") { ?>
+
+
+
+
+
uri->segment(1) == "qslprint") { ?>