kopia lustrzana https://github.com/magicbug/Cloudlog
[Maps] Added a view to show all logged QSOs of an active profile on a map /map
rodzic
85a1783eb7
commit
9d4ab310d2
|
@ -0,0 +1,88 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
class Map extends CI_Controller {
|
||||
|
||||
function index()
|
||||
{
|
||||
|
||||
// Calculate Lat/Lng from Locator to use on Maps
|
||||
if($this->session->userdata('user_locator')) {
|
||||
$this->load->library('qra');
|
||||
|
||||
$qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator'));
|
||||
$data['qra'] = "set";
|
||||
$data['qra_lat'] = $qra_position[0];
|
||||
$data['qra_lng'] = $qra_position[1];
|
||||
} else {
|
||||
$data['qra'] = "none";
|
||||
}
|
||||
|
||||
$this->load->model('Stations');
|
||||
$station_id = $this->Stations->find_active();
|
||||
$station_data = $this->Stations->profile_clean($station_id);
|
||||
|
||||
// load the view
|
||||
$data['station_profile'] = $station_data;
|
||||
$data['page_title'] = "Map QSOs";
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('map/qsos');
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
||||
function map_data() {
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$this->load->library('qra');
|
||||
|
||||
//echo date('Y-m-d')
|
||||
$raw = strtotime('Monday last week');
|
||||
|
||||
$mon = date('Y-m-d', $raw);
|
||||
$sun = date('Y-m-d', strtotime('Monday next week'));
|
||||
|
||||
$qsos = $this->logbook_model->map_all_qsos_for_active_station_profile();
|
||||
|
||||
echo "{\"markers\": [";
|
||||
$count = 1;
|
||||
foreach ($qsos->result() as $row) {
|
||||
//print_r($row);
|
||||
if($row->COL_GRIDSQUARE != null) {
|
||||
$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
|
||||
if($count != 1) {
|
||||
echo ",";
|
||||
}
|
||||
|
||||
if($row->COL_SAT_NAME != null) {
|
||||
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
|
||||
} else {
|
||||
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_entities
|
||||
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 "}";
|
||||
|
||||
}
|
||||
}
|
|
@ -986,6 +986,20 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
}
|
||||
|
||||
/* Return QSOs for the year for the active profile */
|
||||
function map_all_qsos_for_active_station_profile() {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
|
||||
$this->db->where("station_id", $station_id);
|
||||
$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 Year */
|
||||
function year_qsos() {
|
||||
|
||||
|
|
|
@ -24,10 +24,21 @@ class Stations extends CI_Model {
|
|||
function profile($id) {
|
||||
// Clean ID
|
||||
$clean_id = $this->security->xss_clean($id);
|
||||
$this->db->where('station_id', $clean_id);
|
||||
return $this->db->get('station_profile');
|
||||
}
|
||||
|
||||
function profile_clean($id) {
|
||||
// Clean ID
|
||||
$clean_id = $this->security->xss_clean($id);
|
||||
|
||||
|
||||
$this->db->where('station_id', $clean_id);
|
||||
return $this->db->get('station_profile');
|
||||
$query = $this->db->get('station_profile');
|
||||
|
||||
$row = $query->row();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -142,6 +142,37 @@ $('[data-fancybox]').fancybox({
|
|||
|
||||
</script>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "map") { ?>
|
||||
<script type="text/javascript" src="<?php echo base_url();?>assets/js/leaflet/L.Maidenhead.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url();?>assets/js/leaflet/leafembed.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
});
|
||||
|
||||
<?php if($qra == "set") { ?>
|
||||
var q_lat = <?php echo $qra_lat; ?>;
|
||||
var q_lng = <?php echo $qra_lng; ?>;
|
||||
<?php } else { ?>
|
||||
var q_lat = 40.313043;
|
||||
var q_lng = -32.695312;
|
||||
<?php } ?>
|
||||
|
||||
var qso_loc = '<?php echo site_url('map/map_data');?>';
|
||||
var q_zoom = 2;
|
||||
|
||||
$(document).ready(function(){
|
||||
<?php if ($this->config->item('map_gridsquares') != FALSE) { ?>
|
||||
var grid = "Yes";
|
||||
<?php } else { ?>
|
||||
var grid = "No";
|
||||
<?php } ?>
|
||||
initmap(grid);
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "" || $this->uri->segment(1) == "dashboard" ) { ?>
|
||||
<script type="text/javascript" src="<?php echo base_url();?>assets/js/leaflet/L.Maidenhead.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url();?>assets/js/leaflet/leafembed.js"></script>
|
||||
|
|
|
@ -94,6 +94,8 @@
|
|||
<a class="dropdown-item" href="<?php echo site_url('accumulated');?>" title="Accumulated statistics">Accumulated statistics</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="<?php echo site_url('timeplotter');?>" title="View time when worked">Timeplotter</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="<?php echo site_url('map');?>" title="Maps of QSOs">Maps</a>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<div class="container map-QSOs">
|
||||
|
||||
<h2><?php echo $station_profile->station_profile_name; ?> Station Profile QSOs (All)</h2>
|
||||
|
||||
<?php if($this->session->flashdata('notice')) { ?>
|
||||
<div class="alert alert-info" role="alert">
|
||||
<?php echo $this->session->flashdata('notice'); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<!-- Map -->
|
||||
<div id="map" style="width: 100%; height: 700px;"></div>
|
||||
|
||||
<div class="alert alert-success" role="alert">Showing All QSOs for Active Station Profile - <?php echo $station_profile->station_profile_name; ?> </div>
|
Ładowanie…
Reference in New Issue