From 0fe30402bf5482a619e8f4a51708647cc278b21a Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Fri, 30 Sep 2011 14:45:04 +0100 Subject: [PATCH] Started Social stuff /social/map/*date*, displays qsos for that day on a table and map --- application/controllers/social.php | 66 ++++++++++++++ application/models/logbook_model.php | 45 +++++++++- application/views/social/map.php | 124 +++++++++++++++++++++++++++ cloudlog.sublime-workspace | 7 +- 4 files changed, 237 insertions(+), 5 deletions(-) create mode 100644 application/controllers/social.php create mode 100644 application/views/social/map.php diff --git a/application/controllers/social.php b/application/controllers/social.php new file mode 100644 index 00000000..5dd76d34 --- /dev/null +++ b/application/controllers/social.php @@ -0,0 +1,66 @@ +load->model('logbook_model'); + + $map_date = date('Y-m-d', strtotime($day)); + $formated_date = date('d-m-Y', strtotime($day)); + + $data['qsos'] = $this->logbook_model->get_date_qsos($map_date); + + $data['date'] = $map_date; + $data['formated_date'] = $formated_date; + + $this->load->view('layout/header'); + $this->load->view('social/map', $data); + $this->load->view('layout/footer'); + } + + function json_map($date) { + $this->load->model('logbook_model'); + + $qsos = $this->logbook_model->map_day($date); + + echo "{\"markers\": ["; + $count = 1; + foreach ($qsos->result() as $row) { + //print_r($row); + if($row->COL_GRIDSQUARE != null) { + $stn_loc = qra2latlong($row->COL_GRIDSQUARE); + if($count != 1) { + echo ","; + } + + 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."\"}"; + + $count++; + + } else { + $query = $this->db->query(' + SELECT * + FROM dxcc + WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) ) + ORDER BY LENGTH( prefix ) DESC + LIMIT 1 + '); + + foreach ($query->result() as $dxcc) { + if($count != 1) { + echo ","; + } + echo "{\"lat\":\"".$dxcc->lat."\",\"lng\":\"".$dxcc->long."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; + $count++; + } + } + + } + echo "]"; + echo "}"; + + } +} \ No newline at end of file diff --git a/application/models/logbook_model.php b/application/models/logbook_model.php index 1c8cdbff..3fe9cc5d 100644 --- a/application/models/logbook_model.php +++ b/application/models/logbook_model.php @@ -170,6 +170,18 @@ class Logbook_model extends CI_Model { return $query; } + + function get_date_qsos($date) { + $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'); + $this->db->order_by("COL_TIME_ON", "desc"); + $start = $date." 00:00:00"; + $end = $date." 23:59:59"; + + $this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'"); + $query = $this->db->get($this->config->item('table_name')); + + return $query; + } function get_todays_qsos() { @@ -180,6 +192,7 @@ class Logbook_model extends CI_Model { return $query; } + /* Return total number of qsos */ function total_qsos() { $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').''); @@ -192,7 +205,7 @@ class Logbook_model extends CI_Model { } } - + /* Return number of QSOs had today */ function todays_qsos() { $morning = date('Y-m-d 00:00:00'); @@ -208,6 +221,7 @@ class Logbook_model extends CI_Model { } } + /* Return QSOs over a period of days */ function map_week_qsos($start, $end) { $this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'"); @@ -216,8 +230,21 @@ class Logbook_model extends CI_Model { return $query; } + + /* Returns QSOs for the date sent eg 2011-09-30 */ + function map_day($date) { + $start = $date." 00:00:00"; + $end = $date." 23:59:59"; + + $this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'"); + $this->db->order_by("COL_TIME_ON", "ASC"); + $query = $this->db->get($this->config->item('table_name')); + + return $query; + } + // Return QSOs made during the current month function month_qsos() { $morning = date('Y-m-01 00:00:00'); @@ -233,6 +260,7 @@ class Logbook_model extends CI_Model { } } + /* Return QSOs made during the current Year */ function year_qsos() { $morning = date('Y-01-01 00:00:00'); @@ -248,7 +276,7 @@ class Logbook_model extends CI_Model { } } - + /* Return total amount of SSB QSOs logged */ function total_ssb() { $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_MODE = \'SSB\' OR COL_MODE = \'LSB\' OR COL_MODE = \'USB\''); @@ -260,14 +288,15 @@ class Logbook_model extends CI_Model { } } } - + + /* Return total number of satellite QSOs */ 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; } - + /* Return total number of CW QSOs */ function total_cw() { $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_MODE = \'CW\' '); @@ -280,6 +309,7 @@ class Logbook_model extends CI_Model { } } + /* Return total number of FM QSOs */ function total_fm() { $query = $this->db->query('SELECT COUNT( * ) as count FROM '.$this->config->item('table_name').' WHERE COL_MODE = \'FM\''); @@ -292,6 +322,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\' or COL_MODE != \'USB\' or COL_MODE != \'CW\' or COL_MODE != \'FM\')'); @@ -304,12 +335,14 @@ class Logbook_model extends CI_Model { } } + /* Return total number of QSOs per band */ function total_bands() { $query = $this->db->query('SELECT DISTINCT (COL_BAND) AS band, count( * ) AS count FROM '.$this->config->item('table_name').' GROUP BY band ORDER BY count DESC'); return $query; } + /* Return total number of QSL Cards sent */ function total_qsl_sent() { $query = $this->db->query('SELECT DISTINCT (COL_QSL_SENT) AS band, count(COL_QSL_SENT) AS count FROM '.$this->config->item('table_name').' WHERE COL_QSL_SENT = "Y" GROUP BY band'); @@ -322,6 +355,7 @@ class Logbook_model extends CI_Model { } } + /* Return total number of QSL Cards requested */ function total_qsl_requested() { $query = $this->db->query('SELECT DISTINCT (COL_QSL_SENT) AS band, count(COL_QSL_SENT) AS count FROM '.$this->config->item('table_name').' WHERE COL_QSL_SENT = "R" GROUP BY band'); @@ -334,6 +368,7 @@ class Logbook_model extends CI_Model { } } + /* Return total number of QSL Cards received */ function total_qsl_recv() { $query = $this->db->query('SELECT DISTINCT (COL_QSL_RCVD) AS band, count(COL_QSL_RCVD) AS count FROM '.$this->config->item('table_name').' WHERE COL_QSL_RCVD = "Y" GROUP BY band'); @@ -346,6 +381,7 @@ class Logbook_model extends CI_Model { } } + /* Return total number of countrys worked */ function total_countrys() { $query = $this->db->query('SELECT DISTINCT (COL_COUNTRY) FROM '.$this->config->item('table_name').''); @@ -361,6 +397,7 @@ class Logbook_model extends CI_Model { return array('query' => $query, 'results' => $results, 'time' => $time); } + /* Delete QSO based on the QSO ID */ function delete($id) { $this->db->where('COL_PRIMARY_KEY', $id); $this->db->delete($this->config->item('table_name')); diff --git a/application/views/social/map.php b/application/views/social/map.php new file mode 100644 index 00000000..68c3f876 --- /dev/null +++ b/application/views/social/map.php @@ -0,0 +1,124 @@ + + + + + + + + + + + + +

Social Media Map -

+
+ +
+ + +
+ +
+ +
+ + + + + + + + + + + + result() as $row) { ?> + '; ?> + + + + + + + COL_SAT_NAME != null) { ?> + + + + + + + +
DateTimeCallModeSentRecvBand
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; ?>SATCOL_BAND; ?>
+ +
+ +
+
+ + + +
+ +
+
\ No newline at end of file diff --git a/cloudlog.sublime-workspace b/cloudlog.sublime-workspace index 50cfee1b..00beda65 100644 --- a/cloudlog.sublime-workspace +++ b/cloudlog.sublime-workspace @@ -36,6 +36,11 @@ }, "file_history": [ + "/C/Users/Peter/git/HRD-Web-Frontend/application/controllers/dashboard.php", + "/C/Users/Peter/git/HRD-Web-Frontend/application/views/dashboard/index.php", + "/C/wamp/www/m3php/data.html", + "/C/Users/Peter/git/HRD-Web-Frontend/application/views/layout/header.php", + "/C/Users/Peter/git/HRD-Web-Frontend/application/config/config.php", "/C/Users/Peter/git/HRD-Web-Frontend/index.php", "/C/Users/Peter/AppData/Roaming/Sublime Text 2/Packages/Default/Base File.sublime-settings", "/C/Users/Peter/AppData/Roaming/Sublime Text 2/Packages/User/Base File.sublime-settings" @@ -137,6 +142,6 @@ "show_open_files": false, "show_tabs": true, "side_bar_visible": true, - "side_bar_width": 150.0, + "side_bar_width": 211.0, "status_bar_visible": true }