kopia lustrzana https://github.com/magicbug/Cloudlog
Started Social stuff /social/map/*date*, displays qsos for that day on a table and map
rodzic
5523f2e2c2
commit
0fe30402bf
|
@ -0,0 +1,66 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Social extends CI_Controller {
|
||||
|
||||
|
||||
public function map($day)
|
||||
{
|
||||
|
||||
$this->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."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />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."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
echo "]";
|
||||
echo "}";
|
||||
|
||||
}
|
||||
}
|
|
@ -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'));
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
<script type="text/javascript" src="<?php echo base_url() ;?>/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
|
||||
|
||||
<script type="text/javascript" src="<?php echo base_url() ;?>/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ;?>/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
$(".qsobox").fancybox({
|
||||
'autoDimensions' : false,
|
||||
'width' : 700,
|
||||
'height' : 300,
|
||||
'transitionIn' : 'fade',
|
||||
'transitionOut' : 'fade',
|
||||
'type' : 'iframe'
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function create_map() {
|
||||
var latlng = new google.maps.LatLng(40.313043, -32.695312);
|
||||
var myOptions = {
|
||||
zoom: 2,
|
||||
center: latlng,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
};
|
||||
var infowindow = new google.maps.InfoWindow();
|
||||
|
||||
var marker, i;
|
||||
|
||||
/* Get QSO points via json*/
|
||||
$.getJSON("/logbook/index.php/social/json_map/<?php echo $date; ?>", function(data) {
|
||||
|
||||
$.each(data.markers, function(i, val) {
|
||||
/* Create Markers */
|
||||
marker = new google.maps.Marker({
|
||||
position: new google.maps.LatLng(this.lat, this.lng),
|
||||
map: map
|
||||
});
|
||||
|
||||
/* Store Popup Text */
|
||||
var content = this.html;
|
||||
|
||||
/* Create Popups */
|
||||
google.maps.event.addListener(marker, 'click', (function(marker, i) {
|
||||
return function() {
|
||||
infowindow.setContent(content);
|
||||
infowindow.open(map, marker);
|
||||
}
|
||||
})(marker, i));
|
||||
});
|
||||
});
|
||||
|
||||
var map = new google.maps.Map(document.getElementById("map"),
|
||||
myOptions);
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
create_map();
|
||||
});
|
||||
</script>
|
||||
|
||||
<h2>Social Media Map - <?php echo $formated_date; ?></h2>
|
||||
<div class="wrap_content dashboard">
|
||||
|
||||
<div id="map" style="width: 100%; height: 300px"></div>
|
||||
|
||||
|
||||
<div id="dashboard_container">
|
||||
|
||||
<div class="dashboard_top">
|
||||
|
||||
<div class="dashboard_log">
|
||||
<table class="logbook" width="100%">
|
||||
<tr class="log_title titles">
|
||||
<td>Date</td>
|
||||
<td>Time</td>
|
||||
<td>Call</td>
|
||||
<td>Mode</td>
|
||||
<td>Sent</td>
|
||||
<td>Recv</td>
|
||||
<td>Band</td>
|
||||
</tr>
|
||||
|
||||
<?php $i = 0;
|
||||
foreach ($qsos->result() as $row) { ?>
|
||||
<?php echo '<tr class="tr'.($i & 1).'">'; ?>
|
||||
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('d/m/y', $timestamp); ?></td>
|
||||
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
|
||||
<td><a class="qsobox" href="<?php echo site_url('logbook/view')."/".$row->COL_PRIMARY_KEY; ?>"><?php echo strtoupper($row->COL_CALL); ?></a></td>
|
||||
<td><?php echo $row->COL_MODE; ?></td>
|
||||
<td><?php echo $row->COL_RST_SENT; ?></td>
|
||||
<td><?php echo $row->COL_RST_RCVD; ?></td>
|
||||
<?php if($row->COL_SAT_NAME != null) { ?>
|
||||
<td>SAT</td>
|
||||
<?php } else { ?>
|
||||
<td><?php echo $row->COL_BAND; ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php $i++; } ?>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="dashboard_bottom">
|
||||
<div class="chart" id="modechart_div"></div>
|
||||
<div class="chart" id="bandchart_div"></div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
|
@ -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
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue