diff --git a/application/controllers/Accumulated.php b/application/controllers/Accumulated.php index f8616fb4b..97be191a8 100644 --- a/application/controllers/Accumulated.php +++ b/application/controllers/Accumulated.php @@ -4,8 +4,7 @@ defined('BASEPATH') or exit('No direct script access allowed'); class Accumulated extends CI_Controller { - function __construct() - { + function __construct() { parent::__construct(); $this->load->model('user_model'); @@ -15,39 +14,59 @@ class Accumulated extends CI_Controller } } - public function index() - { - // Render Page - $data['page_title'] = __("Accumulated Statistics"); + public function index() { + // Render Page + $data['page_title'] = __("Accumulated Statistics"); - $this->load->model('bands'); + $this->load->model('bands'); - $data['worked_bands'] = $this->bands->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 - $this->load->model('modes'); + $this->load->model('modes'); - $data['modes'] = $this->modes->active(); + if (($this->input->post('Propmode') != NULL) && ($this->input->post('Propmode') != '0')) { // Set, but not "All" + $data['propmode'] = $this->security->xss_clean($this->input->post('Propmode')); + } else { + if (($this->session->userdata('user_default_band') == 'SAT') && ($this->input->post('propmode') == NULL)){ // Not set, and empty and default is SAT? + $data['propmode']='SAT'; + } else { // Not set and empty and no SAT as default? + $data['propmode'] = 'All'; + } + } - $this->load->view('interface_assets/header', $data); - $this->load->view('accumulate/index'); - $this->load->view('interface_assets/footer'); + + $data['modes'] = $this->modes->active(); + + $this->load->view('interface_assets/header', $data); + $this->load->view('accumulate/index'); + $this->load->view('interface_assets/footer'); } /* * Used for ajax-call in javascript to fetch the data and insert into table and chart */ - public function get_accumulated_data() - { - //load model - $this->load->model('accumulate_model'); - $band = xss_clean($this->input->post('Band')); - $award = xss_clean($this->input->post('Award')); - $mode = xss_clean($this->input->post('Mode')); - $period = xss_clean($this->input->post('Period')); + public function get_accumulated_data() { - // get data - $data = $this->accumulate_model->get_accumulated_data($band, $award, $mode, $period); - header('Content-Type: application/json'); - echo json_encode($data); + if (($this->input->post('Propmode') != NULL) && ($this->input->post('Propmode') != '0')) { // Set, but not "All" + $propmode = $this->security->xss_clean($this->input->post('Propmode')); + } else { + if (($this->session->userdata('user_default_band') == 'SAT') && ($this->input->post('Propmode') == NULL)){ // Not set, and empty and default is SAT? + $propmode='SAT'; + } else { // Not set and empty and no SAT as default? + $propmode = 'All'; + } + } + + //load model + $this->load->model('accumulate_model'); + $band = xss_clean($this->input->post('Band')); + $award = xss_clean($this->input->post('Award')); + $mode = xss_clean($this->input->post('Mode')); + $period = xss_clean($this->input->post('Period')); + + // get data + $data = $this->accumulate_model->get_accumulated_data($band, $award, $mode, $propmode, $period); + header('Content-Type: application/json'); + echo json_encode($data); } } diff --git a/application/models/Accumulate_model.php b/application/models/Accumulate_model.php index 3092ac39c..139d6929f 100644 --- a/application/models/Accumulate_model.php +++ b/application/models/Accumulate_model.php @@ -3,8 +3,7 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class Accumulate_model extends CI_Model { - function get_accumulated_data($band, $award, $mode, $period) - { + function get_accumulated_data($band, $award, $mode, $propmode, $period) { $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); diff --git a/application/views/accumulate/index.php b/application/views/accumulate/index.php index 92912a6c0..835a98e53 100644 --- a/application/views/accumulate/index.php +++ b/application/views/accumulate/index.php @@ -76,6 +76,35 @@ +