From 925034e3e580565d680d64fff9eece1264a51a74 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sun, 24 Jul 2011 23:33:08 +0100 Subject: [PATCH] Added Name Field, QRA Lookup, Stats Tab --- application/controllers/qso.php | 3 +- application/controllers/statistics.php | 35 ++++++++++ application/controllers/welcome.php | 16 +---- application/models/logbook_model.php | 58 +++++++++++++++- application/views/dashboard/index.php | 25 ++++++- application/views/layout/header.php | 7 +- application/views/notes/main.php | 4 +- application/views/notes/view.php | 6 +- application/views/qso/index.php | 17 ++++- application/views/statistics/index.php | 94 ++++++++++++++++++++++++++ application/views/view_log/qso.php | 7 ++ 11 files changed, 242 insertions(+), 30 deletions(-) create mode 100644 application/controllers/statistics.php create mode 100644 application/views/statistics/index.php diff --git a/application/controllers/qso.php b/application/controllers/qso.php index 0c658224..63ee266e 100644 --- a/application/controllers/qso.php +++ b/application/controllers/qso.php @@ -32,10 +32,9 @@ class QSO extends CI_Controller { } else { - // Add QSO $this->logbook_model->add(); - + // Store Basic QSO Info for reuse $this->session->set_userdata('band', $this->input->post('band')); $this->session->set_userdata('freq', $this->input->post('freq')); diff --git a/application/controllers/statistics.php b/application/controllers/statistics.php new file mode 100644 index 00000000..1d955ca5 --- /dev/null +++ b/application/controllers/statistics.php @@ -0,0 +1,35 @@ +load->model('logbook_model'); + + // Store info + $data['todays_qsos'] = $this->logbook_model->todays_qsos(); + $data['total_qsos'] = $this->logbook_model->total_qsos(); + $data['month_qsos'] = $this->logbook_model->month_qsos(); + $data['year_qsos'] = $this->logbook_model->year_qsos(); + + $data['total_ssb'] = $this->logbook_model->total_ssb(); + $data['total_cw'] = $this->logbook_model->total_cw(); + $data['total_fm'] = $this->logbook_model->total_fm(); + $data['total_digi'] = $this->logbook_model->total_digi(); + + $data['total_bands'] = $this->logbook_model->total_bands(); + + $data['total_sat'] = $this->logbook_model->total_sat(); + + $data['page_title'] = "Statistics"; + + $data['total_digi'] = $this->logbook_model->total_digi(); + + $this->load->view('layout/header'); + $this->load->view('statistics/index', $data); + $this->load->view('layout/footer'); + } +} \ No newline at end of file diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php index 21bef43d..3cb3eb0b 100644 --- a/application/controllers/welcome.php +++ b/application/controllers/welcome.php @@ -2,21 +2,7 @@ class Welcome extends CI_Controller { - /** - * Index Page for this controller. - * - * Maps to the following URL - * http://example.com/index.php/welcome - * - or - - * http://example.com/index.php/welcome/index - * - or - - * Since this controller is set as the default controller in - * config/routes.php, it's displayed at http://example.com/ - * - * So any other public methods not prefixed with an underscore will - * map to /index.php/welcome/ - * @see http://codeigniter.com/user_guide/general/urls.html - */ + public function index() { $this->load->view('welcome_message'); diff --git a/application/models/logbook_model.php b/application/models/logbook_model.php index 67560e8c..836a3a86 100644 --- a/application/models/logbook_model.php +++ b/application/models/logbook_model.php @@ -23,6 +23,7 @@ class Logbook_model extends CI_Model { 'COL_MODE' => $this->input->post('mode'), 'COL_RST_RCVD' => $this->input->post('rst_recv'), 'COL_RST_SENT' => $this->input->post('rst_sent'), + 'COL_NAME' => $this->input->post('name'), 'COL_COMMENT' => $this->input->post('comment'), 'COL_SAT_NAME' => $this->input->post('sat_name'), 'COL_SAT_MODE' => $this->input->post('sat_mode'), @@ -67,6 +68,54 @@ class Logbook_model extends CI_Model { return $this->db->get($this->config->item('table_name')); } + /* Callsign QRA */ + + function call_qra($callsign) { + $this->db->select('COL_CALL, COL_GRIDSQUARE, COL_TIME_ON'); + $this->db->where('COL_CALL', $callsign); + $where = "COL_GRIDSQUARE != \"\""; + + $this->db->where($where); + + $this->db->order_by("COL_TIME_ON", "desc"); + $this->db->limit(1); + $query = $this->db->get($this->config->item('table_name')); + $callsign = ""; + if ($query->num_rows() > 0) + { + $data = $query->row(); + $callsign = strtoupper($data->COL_GRIDSQUARE); + } + + return $callsign; + } + + function call_name($callsign) { + $this->db->select('COL_CALL, COL_NAME, COL_TIME_ON'); + $this->db->where('COL_CALL', $callsign); + $where = "COL_NAME != \"\""; + + $this->db->where($where); + + $this->db->order_by("COL_TIME_ON", "desc"); + $this->db->limit(1); + $query = $this->db->get($this->config->item('table_name')); + $name = ""; + if ($query->num_rows() > 0) + { + $data = $query->row(); + $name = $data->COL_NAME; + } else { + //$json = file_get_contents("http://callbytxt.org/db/".$callsign.".json"); + + //$obj = json_decode($json); + //$uppercase_name = strtolower($obj->{'calls'}->{'first_name'}); + // $name = ucwords($uppercase_name); + } + + return $name; + } + /* Return QSO Info */ function qso_info($id) { $this->db->where('COL_PRIMARY_KEY', $id); @@ -170,9 +219,16 @@ class Logbook_model extends CI_Model { } } } + + function total_sat() { + $query = $this->db->query('SELECT COL_SAT_NAME, COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_SAT_NAME != \'null\' GROUP BY COL_SAT_NAME'); + + return $query; + } + function total_cw() { - $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_MODE = \'CW\''); + $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_MODE = \'CW\' '); if ($query->num_rows() > 0) { diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index 70c1d00b..a2e30df2 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -1,3 +1,26 @@ + + + + + + + + + + + + +

+ +
+ +

Statistics built using information from the logbook.

+ +
+ +
+
+
+
+
\ No newline at end of file diff --git a/application/views/view_log/qso.php b/application/views/view_log/qso.php index 728d065c..33e8c220 100644 --- a/application/views/view_log/qso.php +++ b/application/views/view_log/qso.php @@ -86,6 +86,13 @@ + COL_NAME != null) { ?> + + Name + COL_NAME; ?> + + + COL_COMMENT != null) { ?> Comment