diff --git a/application/controllers/Dxatlas.php b/application/controllers/Dxatlas.php index 4e4f11e1..313f6f22 100644 --- a/application/controllers/Dxatlas.php +++ b/application/controllers/Dxatlas.php @@ -2,15 +2,17 @@ class Dxatlas extends CI_Controller { - public function index() - { + public function index() { $this->load->model('user_model'); - $this->load->model('modes'); - $this->load->model('dxcc'); - $this->load->model('logbook_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('dxcc'); + $this->load->model('logbook_model'); + $this->load->model('stations'); + + $data['station_profile'] = $this->stations->all(); // Used in the view for station location select $data['worked_bands'] = $this->dxcc->get_worked_bands(); // Used in the view for band select $data['modes'] = $this->modes->active(); // Used in the view for mode select $data['dxcc'] = $this->logbook_model->fetchDxcc(); // Used in the view for dxcc select @@ -23,21 +25,21 @@ class Dxatlas extends CI_Controller { } - public function export() - { + public function export() { $this->load->model('dxatlas_model'); // Parameters - $band = $this->input->post('band'); - $mode = $this->input->post('mode'); - $dxcc = $this->input->post('dxcc_id'); - $cqz = $this->input->post('cqz'); - $propagation = $this->input->post('prop_mode'); - $fromdate = $this->input->post('fromdate'); - $todate = $this->input->post('todate'); + $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($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate); + $grids = $this->dxatlas_model->get_gridsquares($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate); $this->generateFiles($grids['worked'], $grids['confirmed'], $band); } diff --git a/application/models/Dxatlas_model.php b/application/models/Dxatlas_model.php index 3f53a93a..154537d4 100644 --- a/application/models/Dxatlas_model.php +++ b/application/models/Dxatlas_model.php @@ -12,8 +12,8 @@ class Dxatlas_model extends CI_Model /* * Fetches worked and confirmed gridsquare from the logbook */ - function get_gridsquares($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate) { - $gridArray = $this->fetchGrids($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate); + function get_gridsquares($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate) { + $gridArray = $this->fetchGrids($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate); if (isset($gridArray)) { return $gridArray; @@ -25,17 +25,17 @@ class Dxatlas_model extends CI_Model /* * Builds the array for worked and confirmed gridsquares */ - function fetchGrids($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate) { + function fetchGrids($station_id, $band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate) { // Getting all the worked grids - $col_gridsquare_worked = $this->get_grids($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate, 'none', 'single'); + $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($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate, 'none', 'multi'); + $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']); @@ -49,7 +49,7 @@ class Dxatlas_model extends CI_Model } // Getting all the confirmed grids - $col_gridsquare_confirmed = $this->get_grids($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate, 'both', 'single'); + $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) { @@ -60,7 +60,7 @@ class Dxatlas_model extends CI_Model } } - $col_vucc_grids_confirmed = $this->get_grids($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate, 'both', 'multi'); + $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']); @@ -99,22 +99,22 @@ class Dxatlas_model extends CI_Model * $confirmationMethod - qsl, lotw or both, use anything else to skip confirmed * */ - function get_grids($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate, $confirmationMethod, $column) { - $station_id = $this->get_station_id(); - + 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 station_id =" . $station_id . - " and col_gridsquare <> ''"; + " where col_gridsquare <> ''"; } else if ($column == 'multi') { $sql .= "select col_vucc_grids from " . $this->config->item('table_name') . - " where station_id =" . $station_id . - " and col_vucc_grids <> '' "; + " where col_vucc_grids <> '' "; + } + + if ($station_id != "All") { + $sql .= ' and station_id = ' . $station_id; } if ($confirmationMethod == 'both') { @@ -168,11 +168,5 @@ class Dxatlas_model extends CI_Model return $query->result_array(); } - - function get_station_id() { - $CI =& get_instance(); - $CI->load->model('Stations'); - return $CI->Stations->find_active(); - } } ?> diff --git a/application/views/dxatlas/index.php b/application/views/dxatlas/index.php index 16a91189..7d7cad24 100644 --- a/application/views/dxatlas/index.php +++ b/application/views/dxatlas/index.php @@ -14,6 +14,18 @@
+
+
+ + +
+
+