diff --git a/application/controllers/statistics.php b/application/controllers/statistics.php index f58a0386..a9d633d4 100644 --- a/application/controllers/statistics.php +++ b/application/controllers/statistics.php @@ -62,6 +62,9 @@ class Statistics extends CI_Controller { $this->load->library('form_validation'); + $this->form_validation->set_rules('start_date', 'Start Date', 'required'); + $this->form_validation->set_rules('end_date', 'End Date', 'required'); + if ($this->form_validation->run() == FALSE) { $this->load->view('layout/header', $data); @@ -70,7 +73,16 @@ class Statistics extends CI_Controller { } else { - $this->load->view('formsuccess'); + + $this->load->model('stats'); + + $data['result'] = $this->stats->result(); + + + $this->load->view('layout/header', $data); + $this->load->view('statistics/custom_result'); + $this->load->view('layout/footer'); + } } diff --git a/application/models/logbook_model.php b/application/models/logbook_model.php index aef279e4..346a90bf 100644 --- a/application/models/logbook_model.php +++ b/application/models/logbook_model.php @@ -373,7 +373,7 @@ class Logbook_model extends CI_Model { /* Return total number of Digital QSOs */ function total_digi() { - $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_MODE != \'SSB\' AND COL_MODE != \'LSB\' AND COL_MODE != \'USB\' AND COL_MODE != \'CW\' AND COL_MODE != \'FM\''); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_MODE != \'SSB\' AND COL_MODE != \'LSB\' AND COL_MODE != \'USB\' AND COL_MODE != \'CW\' AND COL_MODE != \'FM\' AND COL_MODE != \'AM\''); if ($query->num_rows() > 0) { diff --git a/application/models/stats.php b/application/models/stats.php new file mode 100644 index 00000000..0e4b922e --- /dev/null +++ b/application/models/stats.php @@ -0,0 +1,80 @@ +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'); + + $this->db->where('COL_TIME_ON >=', $this->input->post('start_date')); + $this->db->where('COL_TIME_OFF <=', $this->input->post('end_date')); + + if($this->input->post('band_6m') == "6m") { + $this->db->where('COL_BAND', $this->input->post('band_6m')); + } + + if($this->input->post('band_2m') == "2m") { + $this->db->where('COL_BAND', $this->input->post('band_2m')); + } + + if($this->input->post('band_70cm') == "70cm") { + $this->db->where('COL_BAND', $this->input->post('band_70cm')); + } + + if($this->input->post('band_23cm') == "23cm") { + $this->db->where('COL_BAND', $this->input->post('band_23cm')); + } + + if($this->input->post('band_3cm') == "3cm") { + $this->db->where('COL_BAND', $this->input->post('band_3cm')); + } + + // Select Voice QSOs + if($this->input->post('mode_data') == "data") { + if($this->input->post('mode_ssb') != "ssb") { + $this->db->where('COL_MODE !=', 'SSB'); + $this->db->where('COL_MODE !=', 'LSB'); + $this->db->where('COL_MODE !=', 'USB'); + } + if($this->input->post('mode_cw') != "cw") { + $this->db->where('COL_MODE !=', 'CW'); + } + if($this->input->post('mode_fm') != "fm") { + $this->db->where('COL_MODE !=', 'FM'); + } + if($this->input->post('mode_am') != "am") { + $this->db->where('COL_MODE !=', 'AM'); + } + } + + // Select Voice QSOs + if($this->input->post('mode_ssb') == "ssb") { + $this->db->where('COL_MODE', $this->input->post('mode_ssb')); + $this->db->or_where('COL_MODE', 'USB'); + $this->db->or_where('COL_MODE', 'LSB'); + } + + // Select CW QSOs + if($this->input->post('mode_cw') == "cw") { + $this->db->where('COL_MODE', $this->input->post('mode_ssb')); + } + + // Select FM QSOs + if($this->input->post('mode_fm') == "fm") { + $this->db->where('COL_MODE', $this->input->post('mode_ssb')); + } + + // Select AM QSOs + if($this->input->post('mode_am') == "am") { + $this->db->where('COL_MODE', $this->input->post('mode_am')); + } + + return $this->db->get($this->config->item('table_name')); + } +} + +?> \ No newline at end of file diff --git a/application/views/statistics/custom.php b/application/views/statistics/custom.php index f0eaffe9..233ecc13 100644 --- a/application/views/statistics/custom.php +++ b/application/views/statistics/custom.php @@ -1,7 +1,7 @@ @@ -24,10 +24,6 @@ - -
- -

Date

@@ -46,50 +42,18 @@

Band

- + 6m + 2m + 70cm + 23cm + 3cm

Mode

- + SSB + CW + Data + FM + AM
@@ -100,7 +64,7 @@
-
diff --git a/application/views/statistics/custom_result.php b/application/views/statistics/custom_result.php new file mode 100644 index 00000000..76853505 --- /dev/null +++ b/application/views/statistics/custom_result.php @@ -0,0 +1,104 @@ + + +
+ +

+ + + +

This is a work in-progress

+ +
+ +

Options

+ + + + + +
+

Date

+ + + + + + + + + + +
Start
End
+
+ +
+

Band

+ 6m + 2m + 70cm + 23cm + 3cm + +

Mode

+ SSB + CW + Data + FM + AM +
+ +
+

Finished your selection? time to search!

+ +
+ +
+ + + +
+ + +
+ + + + + + + + + + + + + result() as $row) { ?> + '; ?> + + + + + + + COL_SAT_NAME != null) { ?> + + + + + + + + +
DateTimeCallModeSentRecvBandCountry
COL_TIME_ON); echo date('d/m/y', $timestamp); ?>COL_TIME_ON); echo date('H:i', $timestamp); ?>COL_PRIMARY_KEY; ?>">COL_CALL); ?>COL_MODE; ?>COL_RST_SENT; ?>COL_RST_RCVD; ?>COL_SAT_NAME; ?>COL_BAND; ?>COL_COUNTRY; ?>
+
+ +